x-forward header handling
This commit is contained in:
parent
cb493ff1fe
commit
1f0997054e
|
@ -15,6 +15,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HeaderForward = "X-Forwarded-For"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrorServerNotSet = errors.New("Server not set")
|
ErrorServerNotSet = errors.New("Server not set")
|
||||||
ErrorConnectionNotFound = errors.New("Connection not found")
|
ErrorConnectionNotFound = errors.New("Connection not found")
|
||||||
|
@ -41,6 +45,10 @@ type Server struct {
|
||||||
Get ip of socket client
|
Get ip of socket client
|
||||||
*/
|
*/
|
||||||
func (c *Channel) Ip() string {
|
func (c *Channel) Ip() string {
|
||||||
|
forward := c.RequestHeader().Get(HeaderForward)
|
||||||
|
if forward != "" {
|
||||||
|
return forward
|
||||||
|
}
|
||||||
return c.ip
|
return c.ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue