JuliaWeb / WebSockets.jl

A WebSockets library for Julia
MIT License
158 stars 57 forks source link

How to get the IP address of the request? #95

Closed essenciary closed 6 years ago

essenciary commented 6 years ago

Is it possible to get the IP address of the request, please?

With HttpServer it could be done like this:

http.events["connect"] = (http_client) -> handle_connect(http_client)

function handle_connect(client::HTTP.Client)
  try
    ip, port = getsockname(isa(client.sock, MbedTLS.SSLContext) ? client.sock.bio : client.sock)
  catch
  end
 end
hustf commented 6 years ago

That is a useful tip, thank you!

I would continue to use HttpServer for it so far. There are comments about supporting events in the future with HTTP, in the source code. There is also a mention of using something else than libuv for establishing the connections in the future, somewhere.

If you find a way to modify serve code for HTTP in this module, now is a good time to incorporate it here

essenciary commented 6 years ago

Oops, I had too many tabs open - this issue was meant for HTTP.jl