Re: [go-nuts] websocket.Conn RemoteAddr() possible issue

837 views
Skip to first unread message

Jesse McNelis

unread,
Aug 11, 2012, 10:09:24 PM8/11/12
to Steven Wiley, golan...@googlegroups.com
On Sun, Aug 12, 2012 at 4:58 AM, Steven Wiley <steven...@gmail.com> wrote:
> Shouldn't the ws.RemoteAddr() return value contain the client url (.105) and
> not the server url (.102), or am I not thinking about this correctly?

"RemoteAddr returns the WebSocket location for the connection for
client, or the Websocket Origin for server."
http://go.pkgdoc.org/code.google.com/p/go.net/websocket#Conn.RemoteAddr

So the ws.RemoteAddr() isn't related to the client's ip address at
all, since that information is usually quite irrelevant.
It refers to the origin of the page that the client is on when it is
making the websocket connection, which is important for figuring out
if the connection should be allowed.

If you want the client IP address, then you'll want:
clientIP := ws.Request().RemoteAddr






--
=====================
http://jessta.id.au

Steven Wiley

unread,
Aug 12, 2012, 2:06:55 PM8/12/12
to golan...@googlegroups.com, Steven Wiley, jes...@jessta.id.au
Thanks for clarifying that for me Jesse. 

So, then is it true that the server of the page the client is on when making the connection can be different the one serving the websocket?

I guess I am used to thinking about a Java applet situation which will not allow a connection to a server other than the one that pushed out the applet, a limitation which I have run into in the past.

thanks again,
Steve

Jesse McNelis

unread,
Aug 12, 2012, 7:35:51 PM8/12/12
to Steven Wiley, golan...@googlegroups.com
On Mon, Aug 13, 2012 at 4:06 AM, Steven Wiley <steven...@gmail.com> wrote:
> Thanks for clarifying that for me Jesse.
>
> So, then is it true that the server of the page the client is on when making
> the connection can be different the one serving the websocket?

Yep, It's up to servers to reject connections from pages they don't
want connecting, which is why the connecting client is required to
provide the url of the page it's on.


> I guess I am used to thinking about a Java applet situation which will not
> allow a connection to a server other than the one that pushed out the
> applet, a limitation which I have run into in the past.
>
> thanks again,
> Steve
>
>
> On Saturday, August 11, 2012 7:09:24 PM UTC-7, Jesse McNelis wrote:
>>
>> On Sun, Aug 12, 2012 at 4:58 AM, Steven Wiley <steven...@gmail.com> wrote:
>> > Shouldn't the ws.RemoteAddr() return value contain the client url (.105)
>> > and
>> > not the server url (.102), or am I not thinking about this correctly?
>>
>> "RemoteAddr returns the WebSocket location for the connection for
>> client, or the Websocket Origin for server."
>> http://go.pkgdoc.org/code.google.com/p/go.net/websocket#Conn.RemoteAddr
>>
>> So the ws.RemoteAddr() isn't related to the client's ip address at
>> all, since that information is usually quite irrelevant.
>> It refers to the origin of the page that the client is on when it is
>> making the websocket connection, which is important for figuring out
>> if the connection should be allowed.
>>
>> If you want the client IP address, then you'll want:
>> clientIP := ws.Request().RemoteAddr
>>
>>
>>
>>
>>
>>
>> --
>> =====================
>> http://jessta.id.au



--
=====================
http://jessta.id.au
Reply all
Reply to author
Forward
0 new messages