mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
rpc: add wildcard support for rpcallowedhosts + go fmt
This commit is contained in:
parent
226aef18c8
commit
5d0c42e35f
4 changed files with 6 additions and 5 deletions
|
|
@ -385,7 +385,7 @@ var (
|
|||
}
|
||||
RPCAllowedHostsFlag = cli.StringFlag{
|
||||
Name: "rpcallowedhosts",
|
||||
Usage: "Comma separated list of hostnames from which to accept requests (server enforced)",
|
||||
Usage: "Comma separated list of hostnames from which to accept requests (server enforced). Set to * to disable this protection.",
|
||||
Value: "localhost,127.0.0.1",
|
||||
}
|
||||
RPCApiFlag = cli.StringFlag{
|
||||
|
|
|
|||
|
|
@ -224,8 +224,9 @@ func (h *hostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
hostpart := parseHost(r.Host)
|
||||
requestAllowed := false
|
||||
for _, allowedHost := range h.AllowedHosts {
|
||||
if strings.ToLower(allowedHost) == hostpart {
|
||||
if strings.ToLower(allowedHost) == hostpart || allowedHost == "*" {
|
||||
requestAllowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !requestAllowed {
|
||||
|
|
|
|||
Loading…
Reference in a new issue