summaryrefslogtreecommitdiff
path: root/searx/plugins/self_info.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/plugins/self_info.py')
-rw-r--r--searx/plugins/self_info.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/searx/plugins/self_info.py b/searx/plugins/self_info.py
index 8d6c661ad..4fdfb4288 100644
--- a/searx/plugins/self_info.py
+++ b/searx/plugins/self_info.py
@@ -16,13 +16,13 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
'''
from flask_babel import gettext
import re
-name = "Self Informations"
+name = gettext('Self Informations')
description = gettext('Displays your IP if the query is "ip" and your user agent if the query contains "user agent".')
default_on = True
# Self User Agent regex
-p = re.compile(b'.*user[ -]agent.*', re.IGNORECASE)
+p = re.compile('.*user[ -]agent.*', re.IGNORECASE)
# attach callback to the post search hook
@@ -31,16 +31,14 @@ p = re.compile(b'.*user[ -]agent.*', re.IGNORECASE)
def post_search(request, search):
if search.search_query.pageno > 1:
return True
- if search.search_query.query == b'ip':
+ if search.search_query.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
- search.result_container.answers.clear()
- search.result_container.answers.add(ip)
+ search.result_container.answers['ip'] = {'answer': ip}
elif p.match(search.search_query.query):
ua = request.user_agent
- search.result_container.answers.clear()
- search.result_container.answers.add(ua)
+ search.result_container.answers['user-agent'] = {'answer': ua}
return True