You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem. Thanks.
What steps will reproduce the problem?
0. websocket#Conn.RemoteAddr() returns 'host' address for connection.
1. src/pkg/websocket/websocket.go defines (* Conn)RemoteAddr() as:
func (ws *Conn) RemoteAddr() net.Addr { return WebSocketAddr(ws.Location) }
2. as a result, it returns the same value as (*Conn)LocalAddr()
3. ws.Location and ws.Orgin are instantiated by websocket.newConn()
What is the expected output?
Intuitively, I thought I'd get the address of the remote end of the connection - the same
as with http.Request.RemoteAddr (and formerly http.ResponseWriter.RemoteAddr()).
What do you see instead? --
I hacked websocket.go to replace RemoteAddr() with:
func (ws *Conn) RemoteAddr() net.Addr {
if conn, ok := ws.rwc.(net.Conn); ok {
return conn.RemoteAddr()
}
return nil
}
It now provides the address for the remote end of the connection, as I believe it should.
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g
Which operating system are you using?
darwin
Which revision are you using? (hg identify)
37171a06ed48+ tip
Please provide any additional information below.
Let me know if you'd like this submitted as a Mecurial change.
The text was updated successfully, but these errors were encountered:
My original post was not clear.
websocket.Conn.RemoteAddr() does not return the expected value if invoked on the
Listener end of the connection - using *websocket.Conn value passed as the argument for
the websocket handler function. It does not return the Dialer address, as I had
expected based on the behavior of http.ResponseWriter.RemoteAddr(), etc.
So I guess the real issue is: How can one retrieve the Dialer address for a websocket
connection in a websocket handler function on a server?
mikioh
changed the title
hacked websocket.go (* Conn)RemoteAddr() to return intuitive value
x/net/websocket: hacked websocket.go (* Conn)RemoteAddr() to return intuitive value
Jul 30, 2015
by clbanning:
The text was updated successfully, but these errors were encountered: