Unverified Commit cd3dca8d authored by Eric_Lee's avatar Eric_Lee Committed by GitHub

Merge pull request #122 from jumpserver/bugfix_remoteip

[Bugfix] fix web ssh remote ip
parents c24324c2 5c86d4b6
...@@ -119,9 +119,21 @@ func OnHostHandler(c *neffos.NSConn, msg neffos.Message) (err error) { ...@@ -119,9 +119,21 @@ func OnHostHandler(c *neffos.NSConn, msg neffos.Message) (err error) {
c.Emit("data", neffos.Marshal(dataMsg)) c.Emit("data", neffos.Marshal(dataMsg))
return return
} }
userR, userW := io.Pipe() userR, userW := io.Pipe()
addr, _, _ := net.SplitHostPort(cc.Socket().Request().RemoteAddr) var addr string
request := cc.Socket().Request()
header := request.Header
remoteAddr := header.Get("X-Forwarded-For")
if remoteAddr == "" {
if host, _, err := net.SplitHostPort(request.RemoteAddr); err == nil {
addr = host
} else {
addr = request.RemoteAddr
}
} else {
addr = strings.Split(remoteAddr, ",")[0]
}
client := &Client{ client := &Client{
Uuid: roomID, addr: addr, Uuid: roomID, addr: addr,
WinChan: make(chan ssh.Window, 100), Conn: c, WinChan: make(chan ssh.Window, 100), Conn: c,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment