diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-01 04:07:46 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-01 04:07:46 +0800 |
commit | cdb77f0ecd239fe7a5494891c6a42645904a432b (patch) | |
tree | 27b9a42b43b0bbb7c54a78885cb48d8a40abb3d3 | |
parent | 43b5777709d9b867d1e2331d5586b914207f354f (diff) | |
parent | ea0517b5396efc7bd47f820ec0263f68f76f29a4 (diff) | |
download | dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar.gz dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar.bz2 dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar.lz dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar.xz dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.tar.zst dexon-cdb77f0ecd239fe7a5494891c6a42645904a432b.zip |
Merge pull request #402 from tgerring/rpcupdates
Set RPC listening address via param
-rw-r--r-- | cmd/ethereum/flags.go | 70 | ||||
-rw-r--r-- | cmd/ethereum/main.go | 2 | ||||
-rw-r--r-- | cmd/mist/flags.go | 52 | ||||
-rw-r--r-- | cmd/mist/main.go | 2 | ||||
-rw-r--r-- | cmd/utils/cmd.go | 4 | ||||
-rw-r--r-- | rpc/http/server.go | 8 |
6 files changed, 72 insertions, 66 deletions
diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index c42083160..1a0c13c82 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -36,40 +36,41 @@ import ( ) var ( - Identifier string - KeyRing string - DiffTool bool - DiffType string - KeyStore string - StartRpc bool - StartWebSockets bool - RpcPort int - WsPort int - OutboundPort string - ShowGenesis bool - AddPeer string - MaxPeer int - GenAddr bool - BootNodes string - NodeKey *ecdsa.PrivateKey - NAT nat.Interface - SecretFile string - ExportDir string - NonInteractive bool - Datadir string - LogFile string - ConfigFile string - DebugFile string - LogLevel int - LogFormat string - Dump bool - DumpHash string - DumpNumber int - VmType int - ImportChain string - SHH bool - Dial bool - PrintVersion bool + Identifier string + KeyRing string + DiffTool bool + DiffType string + KeyStore string + StartRpc bool + StartWebSockets bool + RpcListenAddress string + RpcPort int + WsPort int + OutboundPort string + ShowGenesis bool + AddPeer string + MaxPeer int + GenAddr bool + BootNodes string + NodeKey *ecdsa.PrivateKey + NAT nat.Interface + SecretFile string + ExportDir string + NonInteractive bool + Datadir string + LogFile string + ConfigFile string + DebugFile string + LogLevel int + LogFormat string + Dump bool + DumpHash string + DumpNumber int + VmType int + ImportChain string + SHH bool + Dial bool + PrintVersion bool ) // flags specific to cli client @@ -93,6 +94,7 @@ func Init() { flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", false, "start rpc server") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index f72b11e14..07ef0d5dd 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -128,7 +128,7 @@ func main() { } if StartRpc { - utils.StartRpc(ethereum, RpcPort) + utils.StartRpc(ethereum, RpcListenAddress, RpcPort) } if StartWebSockets { diff --git a/cmd/mist/flags.go b/cmd/mist/flags.go index 0010df826..1ffeb1915 100644 --- a/cmd/mist/flags.go +++ b/cmd/mist/flags.go @@ -37,31 +37,32 @@ import ( ) var ( - Identifier string - KeyRing string - KeyStore string - StartRpc bool - StartWebSockets bool - RpcPort int - WsPort int - OutboundPort string - ShowGenesis bool - AddPeer string - MaxPeer int - GenAddr bool - BootNodes string - NodeKey *ecdsa.PrivateKey - NAT nat.Interface - SecretFile string - ExportDir string - NonInteractive bool - Datadir string - LogFile string - ConfigFile string - DebugFile string - LogLevel int - VmType int - MinerThreads int + Identifier string + KeyRing string + KeyStore string + StartRpc bool + StartWebSockets bool + RpcListenAddress string + RpcPort int + WsPort int + OutboundPort string + ShowGenesis bool + AddPeer string + MaxPeer int + GenAddr bool + BootNodes string + NodeKey *ecdsa.PrivateKey + NAT nat.Interface + SecretFile string + ExportDir string + NonInteractive bool + Datadir string + LogFile string + ConfigFile string + DebugFile string + LogLevel int + VmType int + MinerThreads int ) // flags specific to gui client @@ -79,6 +80,7 @@ func Init() { flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") + flag.StringVar(&RpcListenAddress, "rpcaddr", "127.0.0.1", "address for json-rpc server to listen on") flag.IntVar(&RpcPort, "rpcport", 8545, "port to start json-rpc server on") flag.IntVar(&WsPort, "wsport", 40404, "port to start websocket rpc server on") flag.BoolVar(&StartRpc, "rpc", true, "start rpc server") diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 3abe16767..c9a07bfde 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -73,7 +73,7 @@ func run() error { utils.KeyTasks(ethereum.KeyManager(), KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive) if StartRpc { - utils.StartRpc(ethereum, RpcPort) + utils.StartRpc(ethereum, RpcListenAddress, RpcPort) } if StartWebSockets { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a36c10e3b..5c7ec3221 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -160,9 +160,9 @@ func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, Secre clilogger.Infof("Main address %x\n", keyManager.Address()) } -func StartRpc(ethereum *eth.Ethereum, RpcPort int) { +func StartRpc(ethereum *eth.Ethereum, RpcListenAddress string, RpcPort int) { var err error - ethereum.RpcServer, err = rpchttp.NewRpcHttpServer(xeth.New(ethereum), RpcPort) + ethereum.RpcServer, err = rpchttp.NewRpcHttpServer(xeth.New(ethereum), RpcListenAddress, RpcPort) if err != nil { clilogger.Errorf("Could not start RPC interface (port %v): %v", RpcPort, err) } else { diff --git a/rpc/http/server.go b/rpc/http/server.go index fa66eed48..452b7c9af 100644 --- a/rpc/http/server.go +++ b/rpc/http/server.go @@ -29,8 +29,8 @@ import ( var rpchttplogger = logger.NewLogger("RPC-HTTP") var JSON rpc.JsonWrapper -func NewRpcHttpServer(pipe *xeth.XEth, port int) (*RpcHttpServer, error) { - sport := fmt.Sprintf("127.0.0.1:%d", port) +func NewRpcHttpServer(pipe *xeth.XEth, address string, port int) (*RpcHttpServer, error) { + sport := fmt.Sprintf("%s:%d", address, port) l, err := net.Listen("tcp", sport) if err != nil { return nil, err @@ -41,6 +41,7 @@ func NewRpcHttpServer(pipe *xeth.XEth, port int) (*RpcHttpServer, error) { quit: make(chan bool), pipe: pipe, port: port, + addr: address, }, nil } @@ -49,6 +50,7 @@ type RpcHttpServer struct { listener net.Listener pipe *xeth.XEth port int + addr string } func (s *RpcHttpServer) exitHandler() { @@ -69,7 +71,7 @@ func (s *RpcHttpServer) Stop() { } func (s *RpcHttpServer) Start() { - rpchttplogger.Infof("Starting RPC-HTTP server on port %d", s.port) + rpchttplogger.Infof("Starting RPC-HTTP server on %s:%d", s.addr, s.port) go s.exitHandler() api := rpc.NewEthereumApi(s.pipe) |