aboutsummaryrefslogtreecommitdiffstats
path: root/node/config.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-02-05 21:08:48 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-02-05 22:53:47 +0800
commit7486904b92449c5955bb682f4ff98752906912b8 (patch)
tree87d1119581754ba411396c0c698fdab4bd65b253 /node/config.go
parenta13bc9d7a1bc96fab93ace40045c0f0fea4da836 (diff)
downloadgo-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar.gz
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar.bz2
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar.lz
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar.xz
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.tar.zst
go-tangerine-7486904b92449c5955bb682f4ff98752906912b8.zip
cmd, node, rpc: move websockets into node, break singleton
Diffstat (limited to 'node/config.go')
-rw-r--r--node/config.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/node/config.go b/node/config.go
index 94c6e2e56..f8252b63a 100644
--- a/node/config.go
+++ b/node/config.go
@@ -117,6 +117,25 @@ type Config struct {
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
HttpModules []string
+
+ // WsHost is the host interface on which to start the websocket RPC server. If
+ // this field is empty, no websocket API endpoint will be started.
+ WsHost string
+
+ // WsPort is the TCP port number on which to start the websocket RPC server. The
+ // default zero value is/ valid and will pick a port number randomly (useful for
+ // ephemeral nodes).
+ WsPort int
+
+ // WsCors is the Cross-Origin Resource Sharing header to send to requesting clients.
+ // Please be aware that CORS is a browser enforced security, it's fully useless
+ // for custom websocket clients.
+ WsCors 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
+ // exposed.
+ WsModules []string
}
// IpcEndpoint resolves an IPC endpoint based on a configured value, taking into
@@ -165,6 +184,21 @@ func DefaultHttpEndpoint() string {
return config.HttpEndpoint()
}
+// WsEndpoint resolves an websocket endpoint based on the configured host interface
+// and port parameters.
+func (c *Config) WsEndpoint() string {
+ if c.WsHost == "" {
+ return ""
+ }
+ return fmt.Sprintf("%s:%d", c.WsHost, c.WsPort)
+}
+
+// DefaultWsEndpoint returns the websocket endpoint used by default.
+func DefaultWsEndpoint() string {
+ config := &Config{WsHost: common.DefaultWsHost, WsPort: common.DefaultWsPort}
+ return config.WsEndpoint()
+}
+
// NodeKey retrieves the currently configured private key of the node, checking
// first any manually set key, falling back to the one found in the configured
// data folder. If no key can be found, a new one is generated.