diff options
author | Martin Holst Swende <martin@swende.se> | 2019-05-26 06:07:10 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-05-26 06:07:10 +0800 |
commit | fec3b56f7f440b635787f740b527f15b818c0e1b (patch) | |
tree | 034c22ce8ce77ce32c77169b44e5e3bf1fa0e036 /rpc | |
parent | 9efc1a847e53b63847f6f95e0857b1a6300786eb (diff) | |
download | go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar.gz go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar.bz2 go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar.lz go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar.xz go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.tar.zst go-tangerine-fec3b56f7f440b635787f740b527f15b818c0e1b.zip |
accounts, p2p, rpc: make CGO_ENABLED=0 build again (#19593)
* p2p: remove direct import of cgo-library
* accounts, rpc: more nocgo alternatives
* rpc: move unix path constant into separate file
* accounts/scwallet: address review concerns, remove copy-pasta
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/constants_unix.go | 33 | ||||
-rw-r--r-- | rpc/constants_unix_nocgo.go | 25 | ||||
-rw-r--r-- | rpc/ipc_unix.go | 16 |
3 files changed, 61 insertions, 13 deletions
diff --git a/rpc/constants_unix.go b/rpc/constants_unix.go new file mode 100644 index 000000000..2f98d6499 --- /dev/null +++ b/rpc/constants_unix.go @@ -0,0 +1,33 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. + +// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris + +package rpc + +/* +#include <sys/un.h> + +int max_socket_path_size() { +struct sockaddr_un s; +return sizeof(s.sun_path); +} +*/ +import "C" + +var ( + max_path_size = C.max_socket_path_size() +) diff --git a/rpc/constants_unix_nocgo.go b/rpc/constants_unix_nocgo.go new file mode 100644 index 000000000..ecb231f92 --- /dev/null +++ b/rpc/constants_unix_nocgo.go @@ -0,0 +1,25 @@ +// Copyright 2019 The go-ethereum Authors +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. + +// +build !cgo,!windows + +package rpc + +var ( + // On Linux, sun_path is 108 bytes in size + // see http://man7.org/linux/man-pages/man7/unix.7.html + max_path_size = 108 +) diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index 707b47fd7..da6ce294d 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -1,4 +1,4 @@ -// Copyright 2015 The go-ethereum Authors +// Copyright 2019 The go-ethereum Authors // This file is part of the go-ethereum library. // // The go-ethereum library is free software: you can redistribute it and/or modify @@ -28,20 +28,10 @@ import ( "github.com/ethereum/go-ethereum/log" ) -/* -#include <sys/un.h> - -int max_socket_path_size() { -struct sockaddr_un s; -return sizeof(s.sun_path); -} -*/ -import "C" - // ipcListen will create a Unix socket on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { - if len(endpoint) > int(C.max_socket_path_size()) { - log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", C.max_socket_path_size()), + if len(endpoint) > int(max_path_size) { + log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size), "endpoint", endpoint) } |