diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-04-12 20:03:21 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-04-12 20:03:21 +0800 |
commit | 8627680e24a29abd5f2aaaeaa2c1c852d8fb693b (patch) | |
tree | 1ad39e8b43d04e5a17c17c0b7314eece80620dd5 /node/node.go | |
parent | 934f587bd5c38a36e8b8c8647a9e600d1751ff2f (diff) | |
parent | aa9fff3e68b1def0a9a22009c233150bf9ba481f (diff) | |
download | go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar.gz go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar.bz2 go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar.lz go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar.xz go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.tar.zst go-tangerine-8627680e24a29abd5f2aaaeaa2c1c852d8fb693b.zip |
Merge pull request #2359 from bas-vk/rpc-optional-args
rpc: several fixes and support for optional arguments
Diffstat (limited to 'node/node.go')
-rw-r--r-- | node/node.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/node/node.go b/node/node.go index 62cc3895b..18c3f91d8 100644 --- a/node/node.go +++ b/node/node.go @@ -62,15 +62,19 @@ type Node struct { ipcListener net.Listener // IPC RPC listener socket to serve API requests ipcHandler *rpc.Server // IPC RPC request handler to process the API requests + httpHost string // HTTP hostname + httpPort int // HTTP post httpEndpoint string // HTTP endpoint (interface + port) to listen at (empty = HTTP disabled) httpWhitelist []string // HTTP RPC modules to allow through this endpoint httpCors string // HTTP RPC Cross-Origin Resource Sharing header httpListener net.Listener // HTTP RPC listener socket to server API requests httpHandler *rpc.Server // HTTP RPC request handler to process the API requests + wsHost string // Websocket host + wsPort int // Websocket post wsEndpoint string // Websocket endpoint (interface + port) to listen at (empty = websocket disabled) wsWhitelist []string // Websocket RPC modules to allow through this endpoint - wsDomains string // Websocket RPC allowed origin domains + wsOrigins string // Websocket RPC allowed origin domains wsListener net.Listener // Websocket RPC listener socket to server API requests wsHandler *rpc.Server // Websocket RPC request handler to process the API requests @@ -110,12 +114,16 @@ func New(conf *Config) (*Node, error) { }, serviceFuncs: []ServiceConstructor{}, ipcEndpoint: conf.IPCEndpoint(), + httpHost: conf.HTTPHost, + httpPort: conf.HTTPPort, httpEndpoint: conf.HTTPEndpoint(), httpWhitelist: conf.HTTPModules, httpCors: conf.HTTPCors, + wsHost: conf.WSHost, + wsPort: conf.WSPort, wsEndpoint: conf.WSEndpoint(), wsWhitelist: conf.WSModules, - wsDomains: conf.WSDomains, + wsOrigins: conf.WSOrigins, eventmux: new(event.TypeMux), }, nil } @@ -231,7 +239,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error { n.stopInProc() return err } - if err := n.startWS(n.wsEndpoint, apis, n.wsWhitelist, n.wsDomains); err != nil { + if err := n.startWS(n.wsEndpoint, apis, n.wsWhitelist, n.wsOrigins); err != nil { n.stopHTTP() n.stopIPC() n.stopInProc() @@ -383,7 +391,7 @@ func (n *Node) stopHTTP() { } // startWS initializes and starts the websocket RPC endpoint. -func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, cors string) error { +func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrigins string) error { // Short circuit if the WS endpoint isn't being exposed if endpoint == "" { return nil @@ -411,14 +419,14 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, cors s if listener, err = net.Listen("tcp", endpoint); err != nil { return err } - go rpc.NewWSServer(cors, handler).Serve(listener) + go rpc.NewWSServer(wsOrigins, handler).Serve(listener) glog.V(logger.Info).Infof("WebSocket endpoint opened: ws://%s", endpoint) // All listeners booted successfully n.wsEndpoint = endpoint n.wsListener = listener n.wsHandler = handler - n.wsDomains = cors + n.wsOrigins = wsOrigins return nil } |