.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, 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 32 of file tor_check.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 38 of file tor_check.py.

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

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 50 of file tor_check.py.

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

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 40 of file tor_check.py.


The documentation for this class was generated from the following file: