Removed vhosts for ws and replaced cors with origins (#574)

* removed vhosts for ws and added replaced cors with origins

* updated script
This commit is contained in:
Pratik Patil 2022-11-04 01:24:57 +05:30 committed by GitHub
parent be3f297379
commit 1ab225c0e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 25 deletions

View file

@ -78,8 +78,7 @@ syncmode = "full"
# prefix = ""
# host = "localhost"
# api = ["web3", "net"]
# vhosts = ["*"]
# corsdomain = ["*"]
# origins = ["*"]
# [jsonrpc.graphql]
# enabled = false
# port = 0

View file

@ -80,6 +80,8 @@ The ```bor server``` command runs the Bor client.
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys
- ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default = 128)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)
### JsonRPC Options
@ -96,9 +98,7 @@ The ```bor server``` command runs the Bor client.
- ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```ws.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced)
- ```ws.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```ws.origins```: Origins from which to accept websockets requests
- ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced)

View file

@ -266,6 +266,9 @@ type APIConfig struct {
// Cors is the list of Cors endpoints
Cors []string `hcl:"corsdomain,optional" toml:"corsdomain,optional"`
// Origins is the list of endpoints to accept requests from (only consumed for websockets)
Origins []string `hcl:"origins,optional" toml:"origins,optional"`
}
type GpoConfig struct {
@ -473,8 +476,7 @@ func DefaultConfig() *Config {
Prefix: "",
Host: "localhost",
API: []string{"net", "web3"},
Cors: []string{"localhost"},
VHost: []string{"localhost"},
Origins: []string{"localhost"},
},
Graphql: &APIConfig{
Enabled: false,
@ -930,7 +932,7 @@ func (c *Config) buildNode() (*node.Config, error) {
HTTPVirtualHosts: c.JsonRPC.Http.VHost,
HTTPPathPrefix: c.JsonRPC.Http.Prefix,
WSModules: c.JsonRPC.Ws.API,
WSOrigins: c.JsonRPC.Ws.Cors,
WSOrigins: c.JsonRPC.Ws.Origins,
WSPathPrefix: c.JsonRPC.Ws.Prefix,
GraphQLCors: c.JsonRPC.Graphql.Cors,
GraphQLVirtualHosts: c.JsonRPC.Graphql.VHost,

View file

@ -363,17 +363,10 @@ func (c *Command) Flags() *flagset.Flagset {
Group: "JsonRPC",
})
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "ws.corsdomain",
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
Value: &c.cliConfig.JsonRPC.Ws.Cors,
Default: c.cliConfig.JsonRPC.Ws.Cors,
Group: "JsonRPC",
})
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "ws.vhosts",
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: &c.cliConfig.JsonRPC.Ws.VHost,
Default: c.cliConfig.JsonRPC.Ws.VHost,
Name: "ws.origins",
Usage: "Origins from which to accept websockets requests",
Value: &c.cliConfig.JsonRPC.Ws.Origins,
Default: c.cliConfig.JsonRPC.Ws.Origins,
Group: "JsonRPC",
})
f.SliceStringFlag(&flagset.SliceStringFlag{

View file

@ -95,7 +95,7 @@ var flagMap = map[string][]string{
"override.arrowglacier": {"notABoolFlag", "No"},
"override.terminaltotaldifficulty": {"notABoolFlag", "No"},
"verbosity": {"notABoolFlag", "YesFV"},
"ws.origins": {"notABoolFlag", "YesF"},
"ws.origins": {"notABoolFlag", "No"},
}
// map from cli flags to corresponding toml tags
@ -150,8 +150,7 @@ var nameTagMap = map[string]string{
"ipcpath": "ipcpath",
"1-corsdomain": "http.corsdomain",
"1-vhosts": "http.vhosts",
"2-corsdomain": "ws.corsdomain",
"2-vhosts": "ws.vhosts",
"origins": "ws.origins",
"3-corsdomain": "graphql.corsdomain",
"3-vhosts": "graphql.vhosts",
"1-enabled": "http",
@ -226,9 +225,8 @@ var replacedFlagsMapFlagAndValue = map[string]map[string]map[string]string{
},
}
var replacedFlagsMapFlag = map[string]string{
"ws.origins": "ws.corsdomain",
}
// Do not remove
var replacedFlagsMapFlag = map[string]string{}
var currentBoolFlags = []string{
"snapshot",