cmd/geth, cmd/utils, node: rename ws domains to origins

This commit is contained in:
Péter Szilágyi 2016-04-04 15:00:45 +03:00
parent 3a2da31c3e
commit 9b4fd775d5
5 changed files with 14 additions and 14 deletions

View file

@ -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,

View file

@ -94,7 +94,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.WSListenAddrFlag,
utils.WSPortFlag,
utils.WSApiFlag,
utils.WSAllowedDomainsFlag,
utils.WSAllowedOriginsFlag,
utils.IPCDisabledFlag,
utils.IPCApiFlag,
utils.IPCPathFlag,

View file

@ -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

View file

@ -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

View file

@ -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
}