public
Fork of KirinDave/fuzed
Description: A new revision of Fuzed, the Erlang-based frontend for web apps. Check out the mailing list at http://groups.google.com/group/fuzed
Clone URL: git://github.com/tmm1/fuzed.git
pass REMOTE_ADDR through
mojombo (author)
Mon Jun 16 23:07:46 -0700 2008
commit  98d177445382cc193f1500b2ad8ec80a55ebd21f
tree    f712de5b2855d0e83924effc1b13b513e6155d01
parent  54a10b2ed8ca703c2e5d285ff7bdab11c0b5daff
...
27
28
29
 
30
31
32
...
43
44
45
46
 
 
 
 
 
 
 
 
 
47
48
49
...
27
28
29
30
31
32
33
...
44
45
46
 
47
48
49
50
51
52
53
54
55
56
57
58
0
@@ -27,6 +27,7 @@ yaws_process_arg(Arg, SC) ->
0
   [{method, yaws_prepare(method, Arg)},
0
    {http_version, yaws_prepare(http_version, Arg)},
0
    {https, determine_ssl(SC)},
0
+ {remote_addr, yaws_prepare(remote_addr, Arg)},
0
    {querypath, yaws_prepare(querypath, Arg)},
0
    {querydata, prep(Arg#arg.querydata)},
0
    {servername, prep(SC#sconf.servername)},
0
@@ -43,7 +44,15 @@ yaws_prepare(http_version, Arg) ->
0
   {array, tuple_to_list(Version)};
0
 yaws_prepare(querypath, Arg) ->
0
   {http_request, _Method, {_Type, Path}, _Version} = Arg#arg.req,
0
- prep(Path).
0
+ prep(Path);
0
+yaws_prepare(remote_addr, Arg) ->
0
+ Socket = Arg#arg.clisock,
0
+ {ok, {AddressIntegerTuple, _Port}} = inet:peername(Socket),
0
+ AddressIntegerList = tuple_to_list(AddressIntegerTuple),
0
+ AddressStringList = lists:map(fun(X) -> integer_to_list(X) end, AddressIntegerList),
0
+ Address = string:join(AddressStringList, "."),
0
+ io:format("~p~n", [Address]),
0
+ prep(Address).
0
 
0
 yaws_prepare_headers(Headers) ->
0
   NormalHeaders = [{connection, prep(Headers#headers.connection)},
...
33
34
35
 
36
37
38
...
57
58
59
 
60
61
62
...
33
34
35
36
37
38
39
...
58
59
60
61
62
63
64
0
@@ -33,6 +33,7 @@ module Rack
0
         
0
         method = request['method']
0
         version = request['http_version'] # => e.g. [1, 1]
0
+ remote_addr = request['remote_addr']
0
         path = request['querypath']
0
         query = request['querydata'] == :undefined ? '' : request['querydata']
0
         server = request['servername']
0
@@ -57,6 +58,7 @@ module Rack
0
                
0
         env = {}
0
         env['REQUEST_METHOD'] = method.to_s
0
+ env['REMOTE_ADDR'] = remote_addr
0
         env['QUERY_STRING'] = query
0
         env["PATH_INFO"] = path
0
         env = headers.inject(env) { |a, x| a[translate[x[0]] || x[0].to_s] = x[1]; a }
...
37
38
39
 
 
 
 
40
41
42
...
37
38
39
40
41
42
43
44
45
46
0
@@ -37,6 +37,10 @@ class MainController < ApplicationController
0
     render :text => request.ssl?.to_s
0
   end
0
   
0
+ def ip
0
+ render :text => request.remote_ip.to_s
0
+ end
0
+
0
   protected
0
 
0
   def authenticate

Comments

    No one has commented yet.