Browse files

added the client IP address to the #arg record

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1027 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent c9bd56d commit 6daa38cd80bee7b97df3269208aaa0ef411e4c78 @klacke committed Sep 20, 2006
Showing with 19 additions and 17 deletions.
  1. +1 −0 include/yaws_api.hrl
  2. +18 −17 src/yaws_server.erl
View
1 include/yaws_api.hrl
@@ -10,6 +10,7 @@
-record(arg, {
clisock, %% the socket leading to the peer client
+ client_ip_port, %% {ClientIp, ClientPort} tuple
headers, %% headers
req, %% request
clidata, %% The client data (as a binary in POST requests)
View
35 src/yaws_server.erl
@@ -1002,23 +1002,7 @@ maybe_auth_log(Item, ARG) ->
ok;
true ->
Req = ARG#arg.req,
- CliSock = ARG#arg.clisock,
- IP = if
- port(CliSock) ->
- case inet:peername(CliSock) of
- {ok, {Ip, _}} ->
- Ip;
- _ ->
- unknown
- end;
- true ->
- case ssl:peername(CliSock) of
- {ok, {Ip, _}} ->
- Ip;
- _ ->
- unknown
- end
- end,
+ {IP,_} = ARG#arg.client_ip_port,
Path = safe_decode_path(Req#http_request.path),
yaws_log:authlog(SC#sconf.servername, IP, Path, Item)
end.
@@ -1297,7 +1281,24 @@ no_body_method(CliSock, Req, Head) ->
make_arg(CliSock, Head, Req, Bin) ->
SC = get(sc),
+ IP = if
+ port(CliSock) ->
+ case inet:peername(CliSock) of
+ {ok, IpPort} ->
+ IpPort;
+ _ ->
+ {unknown, unknown}
+ end;
+ true ->
+ case ssl:peername(CliSock) of
+ {ok, IpPort} ->
+ IpPort;
+ _ ->
+ {unknown, unknown}
+ end
+ end,
ARG = #arg{clisock = CliSock,
+ client_ip_port = IP,
headers = Head,
req = Req,
opaque = SC#sconf.opaque,

0 comments on commit 6daa38c

Please sign in to comment.