good morning!!!!

Skip to content
Snippets Groups Projects
Commit 6326ba38 authored by a's avatar a
Browse files

add psudo support for origin as fallback, fixed tests

parent 35ad0853
Branches
Tags
No related merge requests found
......@@ -176,7 +176,7 @@ func TestHTTPPeerInfo(t *testing.T) {
t.Fatal(err)
}
c.SetHeader("user-agent", "ua-testing")
c.SetHeader("origin", "origin.example.com")
c.SetHeader("x-forwarded-for", "origin.example.com")
// Request peer information.
var info PeerInfo
......
......@@ -120,7 +120,6 @@ func wsClientHeaders(endpoint, origin string) (string, http.Header, error) {
header := make(http.Header)
if origin != "" {
header.Add("origin", origin)
header.Add("X-Forwarded-For", origin)
}
if endpointURL.User != nil {
b64auth := base64.StdEncoding.EncodeToString([]byte(endpointURL.User.String()))
......@@ -177,10 +176,16 @@ func newWebsocketCodec(ctx context.Context, c *websocket.Conn, host string, req
}
// Fill in connection details.
wc.info.HTTP.Host = host
// traefik proxy protocol headers
wc.info.HTTP.Origin = req.Get("X-Real-Ip")
if wc.info.HTTP.Origin == "" {
wc.info.HTTP.Origin = req.Get("X-Forwarded-For")
}
// origin header fallback
if wc.info.HTTP.Origin == "" {
wc.info.HTTP.Origin = req.Get("origin")
}
wc.info.RemoteAddr = wc.info.HTTP.Origin
wc.info.HTTP.UserAgent = req.Get("User-Agent")
wc.info.HTTP.Headers = req
// Start pinger.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment