mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
cmd/geth, cmd/utils, node: rename ws domains to origins
This commit is contained in:
parent
3a2da31c3e
commit
9b4fd775d5
5 changed files with 14 additions and 14 deletions
|
|
@ -326,7 +326,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
|
||||||
utils.WSListenAddrFlag,
|
utils.WSListenAddrFlag,
|
||||||
utils.WSPortFlag,
|
utils.WSPortFlag,
|
||||||
utils.WSApiFlag,
|
utils.WSApiFlag,
|
||||||
utils.WSAllowedDomainsFlag,
|
utils.WSAllowedOriginsFlag,
|
||||||
utils.IPCDisabledFlag,
|
utils.IPCDisabledFlag,
|
||||||
utils.IPCApiFlag,
|
utils.IPCApiFlag,
|
||||||
utils.IPCPathFlag,
|
utils.IPCPathFlag,
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||||
utils.WSListenAddrFlag,
|
utils.WSListenAddrFlag,
|
||||||
utils.WSPortFlag,
|
utils.WSPortFlag,
|
||||||
utils.WSApiFlag,
|
utils.WSApiFlag,
|
||||||
utils.WSAllowedDomainsFlag,
|
utils.WSAllowedOriginsFlag,
|
||||||
utils.IPCDisabledFlag,
|
utils.IPCDisabledFlag,
|
||||||
utils.IPCApiFlag,
|
utils.IPCApiFlag,
|
||||||
utils.IPCPathFlag,
|
utils.IPCPathFlag,
|
||||||
|
|
|
||||||
|
|
@ -287,9 +287,9 @@ var (
|
||||||
Usage: "API's offered over the WS-RPC interface",
|
Usage: "API's offered over the WS-RPC interface",
|
||||||
Value: rpc.DefaultHTTPApis,
|
Value: rpc.DefaultHTTPApis,
|
||||||
}
|
}
|
||||||
WSAllowedDomainsFlag = cli.StringFlag{
|
WSAllowedOriginsFlag = cli.StringFlag{
|
||||||
Name: "wsdomains",
|
Name: "wsorigins",
|
||||||
Usage: "Domains from which to accept websockets requests (can be spoofed)",
|
Usage: "Origins from which to accept websockets requests (can be spoofed)",
|
||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
ExecFlag = cli.StringFlag{
|
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), ","),
|
HTTPModules: strings.Split(ctx.GlobalString(RPCApiFlag.Name), ","),
|
||||||
WSHost: MakeWSRpcHost(ctx),
|
WSHost: MakeWSRpcHost(ctx),
|
||||||
WSPort: ctx.GlobalInt(WSPortFlag.Name),
|
WSPort: ctx.GlobalInt(WSPortFlag.Name),
|
||||||
WSDomains: ctx.GlobalString(WSAllowedDomainsFlag.Name),
|
WSOrigins: ctx.GlobalString(WSAllowedOriginsFlag.Name),
|
||||||
WSModules: strings.Split(ctx.GlobalString(WSApiFlag.Name), ","),
|
WSModules: strings.Split(ctx.GlobalString(WSApiFlag.Name), ","),
|
||||||
}
|
}
|
||||||
// Configure the Ethereum service
|
// Configure the Ethereum service
|
||||||
|
|
|
||||||
|
|
@ -127,10 +127,10 @@ type Config struct {
|
||||||
// ephemeral nodes).
|
// ephemeral nodes).
|
||||||
WSPort int
|
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
|
// aware that the server can only act upon the HTTP request the client sends and
|
||||||
// cannot verify the validity of the request header.
|
// 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.
|
// 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
|
// If the module list is empty, all RPC API endpoints designated public will be
|
||||||
|
|
|
||||||
12
node/node.go
12
node/node.go
|
|
@ -70,7 +70,7 @@ type Node struct {
|
||||||
|
|
||||||
wsEndpoint string // Websocket endpoint (interface + port) to listen at (empty = websocket disabled)
|
wsEndpoint string // Websocket endpoint (interface + port) to listen at (empty = websocket disabled)
|
||||||
wsWhitelist []string // Websocket RPC modules to allow through this endpoint
|
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
|
wsListener net.Listener // Websocket RPC listener socket to server API requests
|
||||||
wsHandler *rpc.Server // Websocket RPC request handler to process the 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,
|
httpCors: conf.HTTPCors,
|
||||||
wsEndpoint: conf.WSEndpoint(),
|
wsEndpoint: conf.WSEndpoint(),
|
||||||
wsWhitelist: conf.WSModules,
|
wsWhitelist: conf.WSModules,
|
||||||
wsDomains: conf.WSDomains,
|
wsOrigins: conf.WSOrigins,
|
||||||
eventmux: new(event.TypeMux),
|
eventmux: new(event.TypeMux),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -231,7 +231,7 @@ func (n *Node) startRPC(services map[reflect.Type]Service) error {
|
||||||
n.stopInProc()
|
n.stopInProc()
|
||||||
return err
|
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.stopHTTP()
|
||||||
n.stopIPC()
|
n.stopIPC()
|
||||||
n.stopInProc()
|
n.stopInProc()
|
||||||
|
|
@ -383,7 +383,7 @@ func (n *Node) stopHTTP() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// startWS initializes and starts the websocket RPC endpoint.
|
// 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
|
// Short circuit if the WS endpoint isn't being exposed
|
||||||
if endpoint == "" {
|
if endpoint == "" {
|
||||||
return nil
|
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 {
|
if listener, err = net.Listen("tcp", endpoint); err != nil {
|
||||||
return err
|
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)
|
glog.V(logger.Info).Infof("WebSocket endpoint opened: ws://%s", endpoint)
|
||||||
|
|
||||||
// All listeners booted successfully
|
// All listeners booted successfully
|
||||||
n.wsEndpoint = endpoint
|
n.wsEndpoint = endpoint
|
||||||
n.wsListener = listener
|
n.wsListener = listener
|
||||||
n.wsHandler = handler
|
n.wsHandler = handler
|
||||||
n.wsDomains = cors
|
n.wsOrigins = origins
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue