From 13349d32d7d03c17bb1bd4789a3581de5bf9d0fe Mon Sep 17 00:00:00 2001 From: madhavipuliraju Date: Tue, 1 Nov 2016 15:08:30 +0530 Subject: [PATCH] update gateway ip to get client/user ip --- src/runtime/rest/api.org | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/rest/api.org b/src/runtime/rest/api.org index 77ef0bf..4322424 100755 --- a/src/runtime/rest/api.org +++ b/src/runtime/rest/api.org @@ -31,7 +31,7 @@ def get_generic_feedback(): abort(500, "the request does not contain data in json") try: - gateway_ip = str(request.headers.getlist("X-Forwarded-For")[0].rpartition(' ')[-1]) + gateway_ip = str(request.access_route[-1]) data_dict["gateway_ip"] = gateway_ip fb = SystemInterface.add_generic_feedback(data_dict) return jsonify('{"status":"sucess"}') @@ -210,7 +210,7 @@ def get_add_feedback(): abort(400, 'Either lab name or key or version or responses' ' are not passed') else: - gateway_ip = str(request.remote_addr) + gateway_ip = str(request.access_route[-1]) current_app.logger.debug("lab_name = %s, responses=%s, " "version=%s, key=%s, " %(data_dict['lab_name'], data_dict['responses'], @@ -644,7 +644,7 @@ class TestGetFeedbackDump(TestCase): @api.route('/get_gateway_ip', methods=['GET']) def get_gateway_ip(): try: - gateway_ip = str(request.headers.getlist("X-Forwarded-For")[0].rpartition(' ')[-1]) + gateway_ip = str(request.access_route[-1]) return jsonify({'gateway_ip': gateway_ip}) except Exception as e: return "Error in getting the gateway_ip"