From 82f290a206b1510c34e1f470f01aa9f0b952c6ee Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Tue, 3 Dec 2013 00:52:24 +0530 Subject: [PATCH] Fix: The auto-detected ip was wrong as the forwarded address was always 127.0.0.1 --- bifrost/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bifrost/views.py b/bifrost/views.py index 0b7115f..08c31c0 100644 --- a/bifrost/views.py +++ b/bifrost/views.py @@ -16,7 +16,11 @@ def update_view(request): password = request.registry.settings['webfaction.password'] current_ip = request.GET.get('ip',None) if current_ip is None: - current_ip = request.remote_addr + if 'X-Forwarded-For' in request.headers: + current_ip = request.headers['X-Forwarded-For'] + else: + current_ip = request.remote_addr + domain = request.GET['domain'] db = load(file) @@ -28,7 +32,7 @@ def update_view(request): db[domain] = current_ip update(file, db) - log.info('{0} updated to {1} at {3}'.format(domain, current_ip)) + log.info('{0} updated to {1}'.format(domain, current_ip)) else: log.info('{0} not updated'.format(domain)) return {}