x-forward header handling

This commit is contained in:
Gennadii Kovalev 2017-03-15 15:30:24 +02:00
parent cb493ff1fe
commit 1f0997054e
1 changed files with 8 additions and 0 deletions

View File

@ -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
} }