diff --git a/ethdb/memorydb/memorydb.go b/ethdb/memorydb/memorydb.go index f9f74322b5..cd37c937bf 100644 --- a/ethdb/memorydb/memorydb.go +++ b/ethdb/memorydb/memorydb.go @@ -32,9 +32,9 @@ var ( // invocation of a data access operation. errMemorydbClosed = errors.New("database closed") - // errMemorydbNotFound is returned if a key is requested that is not found in + // ErrMemorydbNotFound is returned if a key is requested that is not found in // the provided memory database. - errMemorydbNotFound = errors.New("not found") + ErrMemorydbNotFound = errors.New("not found") // errSnapshotReleased is returned if callers want to retrieve data from a // released snapshot. @@ -98,7 +98,7 @@ func (db *Database) Get(key []byte) ([]byte, error) { if entry, ok := db.db[string(key)]; ok { return common.CopyBytes(entry), nil } - return nil, errMemorydbNotFound + return nil, ErrMemorydbNotFound } // Put inserts the given value into the key-value store. @@ -377,7 +377,7 @@ func (snap *snapshot) Get(key []byte) ([]byte, error) { if entry, ok := snap.db[string(key)]; ok { return common.CopyBytes(entry), nil } - return nil, errMemorydbNotFound + return nil, ErrMemorydbNotFound } // Release releases associated resources. Release should always succeed and can diff --git a/node/config.go b/node/config.go index 1765811e8c..f508980871 100644 --- a/node/config.go +++ b/node/config.go @@ -146,6 +146,16 @@ type Config struct { // for the authenticated api. This is by default {'localhost'}. AuthVirtualHosts []string `toml:",omitempty"` + // AuthModules is a list of API modules to expose via the Auth RPC interface. + // If the module list is empty, all RPC API endpoints designated public will be + // exposed. + AuthModules []string + + // AuthOrigins is the list of domain 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. + AuthOrigins []string `toml:",omitempty"` + // 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 diff --git a/node/defaults.go b/node/defaults.go index fcfbc934bf..6624ba57a5 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -51,6 +51,8 @@ var DefaultConfig = Config{ AuthAddr: DefaultAuthHost, AuthPort: DefaultAuthPort, AuthVirtualHosts: DefaultAuthVhosts, + AuthModules: DefaultAuthModules, + AuthOrigins: DefaultAuthOrigins, HTTPModules: []string{"net", "web3"}, HTTPVirtualHosts: []string{"localhost"}, HTTPTimeouts: rpc.DefaultHTTPTimeouts, diff --git a/node/node.go b/node/node.go index 5ee9d06ae5..c1530b6371 100644 --- a/node/node.go +++ b/node/node.go @@ -450,7 +450,7 @@ func (n *Node) startRPC() error { if err := server.enableRPC(allAPIs, httpConfig{ CorsAllowedOrigins: DefaultAuthCors, Vhosts: n.config.AuthVirtualHosts, - Modules: DefaultAuthModules, + Modules: n.config.AuthModules, prefix: DefaultAuthPrefix, jwtSecret: secret, }); err != nil { @@ -463,8 +463,8 @@ func (n *Node) startRPC() error { return err } if err := server.enableWS(allAPIs, wsConfig{ - Modules: DefaultAuthModules, - Origins: DefaultAuthOrigins, + Modules: n.config.AuthModules, + Origins: n.config.AuthOrigins, prefix: DefaultAuthPrefix, jwtSecret: secret, }); err != nil {