mirror of https://github.com/status-im/op-geth.git
rpc: HTTP origin case insensitive
This commit is contained in:
parent
57ba1824ac
commit
5479097790
|
@ -61,22 +61,22 @@ func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http
|
||||||
allowAllOrigins = true
|
allowAllOrigins = true
|
||||||
}
|
}
|
||||||
if origin != "" {
|
if origin != "" {
|
||||||
origins.Add(origin)
|
origins.Add(strings.ToLower(origin))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow localhost if no allowedOrigins are specified
|
// allow localhost if no allowedOrigins are specified.
|
||||||
if len(origins.List()) == 0 {
|
if len(origins.List()) == 0 {
|
||||||
origins.Add("http://localhost")
|
origins.Add("http://localhost")
|
||||||
if hostname, err := os.Hostname(); err == nil {
|
if hostname, err := os.Hostname(); err == nil {
|
||||||
origins.Add("http://" + hostname)
|
origins.Add("http://" + strings.ToLower(hostname))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List())
|
glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List())
|
||||||
|
|
||||||
f := func(cfg *websocket.Config, req *http.Request) error {
|
f := func(cfg *websocket.Config, req *http.Request) error {
|
||||||
origin := req.Header.Get("Origin")
|
origin := strings.ToLower(req.Header.Get("Origin"))
|
||||||
if allowAllOrigins || origins.Has(origin) {
|
if allowAllOrigins || origins.Has(origin) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue