From 9b4fd775d5f7caae3e7e2e85cfee810a6a0d6100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 4 Apr 2016 15:00:45 +0300 Subject: [PATCH] cmd/geth, cmd/utils, node: rename ws domains to origins --- cmd/geth/main.go | 2 +- cmd/geth/usage.go | 2 +- cmd/utils/flags.go | 8 ++++---- node/config.go | 4 ++-- node/node.go | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 645743c13a..37cf3451a1 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -326,7 +326,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.WSListenAddrFlag, utils.WSPortFlag, utils.WSApiFlag, - utils.WSAllowedDomainsFlag, + utils.WSAllowedOriginsFlag, utils.IPCDisabledFlag, utils.IPCApiFlag, utils.IPCPathFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index e2adf73057..b7ee50b796 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -94,7 +94,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.WSListenAddrFlag, utils.WSPortFlag, utils.WSApiFlag, - utils.WSAllowedDomainsFlag, + utils.WSAllowedOriginsFlag, utils.IPCDisabledFlag, utils.IPCApiFlag, utils.IPCPathFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2f10938e31..c4ea78422a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -287,9 +287,9 @@ var ( Usage: "API's offered over the WS-RPC interface", Value: rpc.DefaultHTTPApis, } - WSAllowedDomainsFlag = cli.StringFlag{ - Name: "wsdomains", - Usage: "Domains from which to accept websockets requests (can be spoofed)", + WSAllowedOriginsFlag = cli.StringFlag{ + Name: "wsorigins", + Usage: "Origins from which to accept websockets requests (can be spoofed)", Value: "", } ExecFlag = cli.StringFlag{ @@ -655,7 +655,7 @@ func MakeSystemNode(name, version string, extra []byte, ctx *cli.Context) *node. HTTPModules: strings.Split(ctx.GlobalString(RPCApiFlag.Name), ","), WSHost: MakeWSRpcHost(ctx), WSPort: ctx.GlobalInt(WSPortFlag.Name), - WSDomains: ctx.GlobalString(WSAllowedDomainsFlag.Name), + WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name), WSModules: strings.Split(ctx.GlobalString(WSApiFlag.Name), ","), } // Configure the Ethereum service diff --git a/node/config.go b/node/config.go index 301ec636ee..c8ad1aaf3e 100644 --- a/node/config.go +++ b/node/config.go @@ -127,10 +127,10 @@ type Config struct { // ephemeral nodes). WSPort int - // WSDomains is the list of domain to accept websocket requests from. Please be + // WSOrigins is the list of origins to accept websocket requests from. Please be // aware that the server can only act upon the HTTP request the client sends and // cannot verify the validity of the request header. - WSDomains string + WSOrigins string // WSModules is a list of API modules to expose via the websocket RPC interface. // If the module list is empty, all RPC API endpoints designated public will be diff --git a/node/node.go b/node/node.go index 7d3a10874c..02047fb137 100644 --- a/node/node.go +++ b/node/node.go @@ -70,7 +70,7 @@ type Node struct { 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 @@ -115,7 +115,7 @@ func New(conf *Config) (*Node, error) { httpCors: conf.HTTPCors, wsEndpoint: conf.WSEndpoint(), wsWhitelist: conf.WSModules, - wsDomains: conf.WSDomains, + wsOrigins: conf.WSOrigins, eventmux: new(event.TypeMux), }, nil } @@ -231,7 +231,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 +383,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, origins string) error { // Short circuit if the WS endpoint isn't being exposed if endpoint == "" { return nil @@ -411,14 +411,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(origins, 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 = origins return nil }