mirror of
https://github.com/internetee/epp_proxy.git
synced 2025-08-22 15:20:47 +02:00
Add logging of IP address and process number
At the beginning of each client connection, log the IP address along with Erlang's process number associated with the socket. This allows us to pinpoint clients who encounter problems and help them out.
This commit is contained in:
parent
65d5e6ccc9
commit
9902b5ac72
1 changed files with 6 additions and 0 deletions
|
@ -40,6 +40,7 @@ handle_cast(serve,
|
|||
State = #state{socket = Socket,
|
||||
session_id = _SessionId}) ->
|
||||
{ok, {PeerIp, _PeerPort}} = ssl:peername(Socket),
|
||||
log_opened_connection(PeerIp),
|
||||
case ssl:handshake(Socket) of
|
||||
{ok, SecureSocket} ->
|
||||
NewState = state_from_socket(SecureSocket, State),
|
||||
|
@ -168,6 +169,11 @@ log_on_invalid_handshake(Ip, Error) ->
|
|||
[ReadableIp, Error]),
|
||||
exit(normal).
|
||||
|
||||
log_opened_connection(Ip) ->
|
||||
ReadableIp = epp_util:readable_ip(Ip),
|
||||
lager:info("New client connection. IP: ~s, Process: ~p.~n",
|
||||
[ReadableIp, self()]).
|
||||
|
||||
%% Extract state info from socket. Fail if you must.
|
||||
state_from_socket(Socket, State) ->
|
||||
{ok, PeerCert} = ssl:peercert(Socket),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue