@@ -15,11 +15,16 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
15(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
15(C) 2015 by Adam Tauber, <asciimoo@gmail.com>
17from flask.ext.babel import gettext
17from flask.ext.babel import gettext
18−name = "Self IP"
19+name = "Self Informations"
19−description = gettext('Display your source IP address if the query expression is "ip"')
20+description = gettext('Correct Duckduckgo instant answers with your own informations (IP and User Agent)')
20default_on = True
21default_on = True
24+# Self User Agent regex
25+p = re.compile('.*user[ -]agent.*', re.IGNORECASE)
23# attach callback to the post search hook
28# attach callback to the post search hook
24# request: flask request object
29# request: flask request object
25# ctx: the whole local context of the pre search hook
30# ctx: the whole local context of the pre search hook
@@ -32,4 +37,8 @@ def post_search(request, ctx):
32 ip = request.remote_addr
37 ip = request.remote_addr
33 ctx['search'].answers.clear()
38 ctx['search'].answers.clear()
34 ctx['search'].answers.add(ip)
39 ctx['search'].answers.add(ip)
40+ elif p.match(ctx['search'].query):
41+ ua = request.user_agent
42+ ctx['search'].answers.clear()
43+ ctx['search'].answers.add(ua)
35 return True
44 return True