mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 01:38:30 +02:00
fix(websocket): allow localhost origin in WebSocket manager
This commit is contained in:
@@ -44,10 +44,7 @@ var defaultUpgrader = websocket.Upgrader{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if u.Scheme != "http" && u.Scheme != "https" {
|
if u.Host == "" {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if len(u.Host) == 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
originHost := strings.ToLower(u.Hostname())
|
originHost := strings.ToLower(u.Hostname())
|
||||||
@@ -55,8 +52,10 @@ var defaultUpgrader = websocket.Upgrader{
|
|||||||
if h, _, e := net.SplitHostPort(reqHost); e == nil {
|
if h, _, e := net.SplitHostPort(reqHost); e == nil {
|
||||||
reqHost = h
|
reqHost = h
|
||||||
}
|
}
|
||||||
|
if reqHost == "127.0.0.1" || reqHost == "localhost" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
reqHost = strings.ToLower(reqHost)
|
reqHost = strings.ToLower(reqHost)
|
||||||
|
|
||||||
return originHost == reqHost
|
return originHost == reqHost
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user