Skip to content

Commit

Permalink
Web: get real ip (on proxy use)
Browse files Browse the repository at this point in the history
  • Loading branch information
treemo committed Jun 10, 2015
1 parent 16d52a1 commit e6ab052
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion circuits/web/wrappers.py
Expand Up @@ -174,7 +174,16 @@ def __init__(self, sock, method="GET", scheme="http", path="/",

self.cookie = SimpleCookie()

if sock is not None:
# get real ip (on proxy)
real_ip = None
for index in ('X-Real-IP', 'X-Forwarded-For'):
real_ip = self.headers.get(index)
break

if real_ip is not None:
self.remote = Host(real_ip, "", real_ip)

elif sock is not None:
name = sock.getpeername()
if name is not None:
self.remote = Host(*name)
Expand Down

0 comments on commit e6ab052

Please sign in to comment.