.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.plugins.tor_check.SXNGPlugin Class Reference
Inheritance diagram for searx.plugins.tor_check.SXNGPlugin:
Collaboration diagram for searx.plugins.tor_check.SXNGPlugin:

Public Member Functions

None __init__ (self, "PluginCfg" plg_cfg)
EngineResults post_search (self, "SXNG_Request" request, "SearchWithPlugins" search)
Public Member Functions inherited from searx.plugins._core.Plugin
None __init__ (self, "PluginCfg" plg_cfg)
int __hash__ (self)
 __eq__ (self, typing.Any other)
bool init (self, "flask.Flask" app)
bool pre_search (self, SXNG_Request request, "SearchWithPlugins" search)
bool on_result (self, SXNG_Request request, "SearchWithPlugins" search, Result result)

Public Attributes

 info

Additional Inherited Members

Static Public Attributes inherited from searx.plugins._core.Plugin
str id = ""
typing active .ClassVar[bool]
list keywords = []
logging log .Logger
str fqn = ""

Detailed Description

Rewrite hostnames, remove results or prioritize them.

Definition at line 31 of file tor_check.py.

Constructor & Destructor Documentation

◆ __init__()

None searx.plugins.tor_check.SXNGPlugin.__init__ ( self,
"PluginCfg" plg_cfg )

Definition at line 37 of file tor_check.py.

37 def __init__(self, plg_cfg: "PluginCfg") -> None:
38 super().__init__(plg_cfg)
39 self.info = PluginInfo(
40 id=self.id,
41 name=gettext("Tor check plugin"),
42 description=gettext(
43 "This plugin checks if the address of the request is a Tor exit-node, and"
44 " informs the user if it is; like check.torproject.org, but from SearXNG."
45 ),
46 preference_section="query",
47 )
48

References __init__().

Referenced by __init__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ post_search()

EngineResults searx.plugins.tor_check.SXNGPlugin.post_search ( self,
"SXNG_Request" request,
"SearchWithPlugins" search )
Runs AFTER the search request.  Can return a list of
:py:obj:`Result <searx.result_types._base.Result>` objects to be added to the
final result list.

Reimplemented from searx.plugins._core.Plugin.

Definition at line 49 of file tor_check.py.

49 def post_search(self, request: "SXNG_Request", search: "SearchWithPlugins") -> EngineResults:
50 results = EngineResults()
51
52 if search.search_query.pageno > 1:
53 return results
54
55 if search.search_query.query.lower() in self.keywords:
56
57 # Request the list of tor exit nodes.
58 try:
59 resp = get(url_exit_list)
60 node_list = re.findall(reg, resp.text) # type: ignore
61
62 except HTTPError:
63 # No answer, return error
64 msg = gettext("Could not download the list of Tor exit-nodes from")
65 results.add(results.types.Answer(answer=f"{msg} {url_exit_list}"))
66 return results
67
68 real_ip = ip_address(address=str(request.remote_addr)).compressed
69
70 if real_ip in node_list:
71 msg = gettext("You are using Tor and it looks like you have the external IP address")
72 results.add(results.types.Answer(answer=f"{msg} {real_ip}"))
73
74 else:
75 msg = gettext("You are not using Tor and you have the external IP address")
76 results.add(results.types.Answer(answer=f"{msg} {real_ip}"))
77
78 return results

References searx.answerers._core.Answerer.keywords, searx.answerers._core.AnswererInfo.keywords, searx.answerers._core.ModuleAnswerer.keywords, searx.answerers.random.SXNGAnswerer.keywords, searx.answerers.statistics.SXNGAnswerer.keywords, searx.plugins._core.Plugin.keywords, and searx.plugins._core.PluginInfo.keywords.

Member Data Documentation

◆ info

searx.plugins.tor_check.SXNGPlugin.info
Initial value:
= PluginInfo(
id=self.id,
name=gettext("Tor check plugin"),
description=gettext(
"This plugin checks if the address of the request is a Tor exit-node, and"
" informs the user if it is; like check.torproject.org, but from SearXNG."
),
preference_section="query",
)

Definition at line 39 of file tor_check.py.


The documentation for this class was generated from the following file:
  • /home/andrew/Documents/code/public/searxng/searx/plugins/tor_check.py