Skip to content

Commit

Permalink
Honor HTTP header 'X-Real-IP' when available
Browse files Browse the repository at this point in the history
Fix #5.
  • Loading branch information
pini-gh committed Mar 2, 2021
1 parent 628cd91 commit 62f8cfd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tmate/ws_api/websocket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ defmodule Tmate.WsApi.WebSocket do
:ok ->
ip = case req do
%{proxy_header: %{src_address: ip}} -> ip
%{headers: %{"x-real-ip" => ipstring}} ->
{_, ip} = :inet.parse_address(ipstring |> to_charlist)
ip
%{peer: {ip, _port}} -> ip
end
ip = :inet_parse.ntoa(ip) |> to_string
Expand Down

0 comments on commit 62f8cfd

Please sign in to comment.