From 00cc4dcbf44d9ecea89befb08cae4ee5561c4247 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Tue, 10 Mar 2015 19:55:22 +0100 Subject: [enh] plugin support basics ++ self ip plugin --- searx/plugins/self_ip.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 searx/plugins/self_ip.py (limited to 'searx/plugins/self_ip.py') diff --git a/searx/plugins/self_ip.py b/searx/plugins/self_ip.py new file mode 100644 index 000000000..0db6c08df --- /dev/null +++ b/searx/plugins/self_ip.py @@ -0,0 +1,17 @@ + +name = "Self IP" +description = "" +default_on = True + + +def pre_search(request, ctx): + if ctx['search'].query == 'ip': + x_forwarded_for = request.headers.getlist("X-Forwarded-For") + if x_forwarded_for: + ip = x_forwarded_for[0] + else: + ip = request.remote_addr + ctx['search'].answers.clear() + ctx['search'].answers.add(ip) + return False + return True -- cgit v1.2.3-54-g00ecf