.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.tor_check Namespace Reference

Functions

list[Answerpost_search (request, search)
 

Variables

bool default_on = False
 
 name = gettext("Tor check plugin")
 
 description
 
str preference_section = 'query'
 
list query_keywords = ['tor-check']
 
str query_examples = ''
 
 reg = re.compile(r"(?<=ExitAddress )\S+")
 
str url_exit_list = "https://check.torproject.org/exit-addresses"
 

Detailed Description

A plugin to check if the ip address of the request is a Tor exit-node if the
user searches for ``tor-check``.  It fetches the tor exit node list from
:py:obj:`url_exit_list` and parses all the IPs into a list, then checks if the
user's IP address is in it.

Enable in ``settings.yml``:

.. code:: yaml

  enabled_plugins:
    ..
    - 'Tor check plugin'

Function Documentation

◆ post_search()

list[Answer] searx.plugins.tor_check.post_search ( request,
search )

Definition at line 54 of file tor_check.py.

54def post_search(request, search) -> list[Answer]:
55 results = []
56
57 if search.search_query.pageno > 1:
58 return results
59
60 if search.search_query.query.lower() == "tor-check":
61
62 # Request the list of tor exit nodes.
63 try:
64 resp = get(url_exit_list)
65 node_list = re.findall(reg, resp.text) # type: ignore
66
67 except HTTPError:
68 # No answer, return error
69 msg = gettext("Could not download the list of Tor exit-nodes from")
70 Answer(results=results, answer=f"{msg} {url_exit_list}")
71 return results
72
73 x_forwarded_for = request.headers.getlist("X-Forwarded-For")
74
75 if x_forwarded_for:
76 ip_address = x_forwarded_for[0]
77 else:
78 ip_address = request.remote_addr
79
80 if ip_address in node_list:
81 msg = gettext("You are using Tor and it looks like you have the external IP address")
82 Answer(results=results, answer=f"{msg} {ip_address}")
83
84 else:
85 msg = gettext("You are not using Tor and you have the external IP address")
86 Answer(results=results, answer=f"{msg} {ip_address}")
87
88 return results

Variable Documentation

◆ default_on

bool searx.plugins.tor_check.default_on = False

Definition at line 27 of file tor_check.py.

◆ description

searx.plugins.tor_check.description
Initial value:
1= gettext(
2 "This plugin checks if the address of the request is a Tor exit-node, and"
3 " informs the user if it is; like check.torproject.org, but from SearXNG."
4)

Definition at line 32 of file tor_check.py.

◆ name

searx.plugins.tor_check.name = gettext("Tor check plugin")

Definition at line 29 of file tor_check.py.

◆ preference_section

str searx.plugins.tor_check.preference_section = 'query'

Definition at line 38 of file tor_check.py.

◆ query_examples

str searx.plugins.tor_check.query_examples = ''

Definition at line 44 of file tor_check.py.

◆ query_keywords

list searx.plugins.tor_check.query_keywords = ['tor-check']

Definition at line 41 of file tor_check.py.

◆ reg

searx.plugins.tor_check.reg = re.compile(r"(?<=ExitAddress )\S+")

Definition at line 48 of file tor_check.py.

◆ url_exit_list

str searx.plugins.tor_check.url_exit_list = "https://check.torproject.org/exit-addresses"

Definition at line 50 of file tor_check.py.