Use of WHOOGLE_TOR_CONF as env var
This commit is contained in:
parent
e1d6ed23f8
commit
7f56e16329
|
@ -337,12 +337,13 @@ There are a few optional environment variables available for customizing a Whoog
|
|||
| WHOOGLE_ALT_RD | The reddit.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_ALT_TL | The Google Translate alternative to use. This is used for all "translate ____" searches. |
|
||||
| WHOOGLE_ALT_MD | The medium.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_ALT_IMG | The imgur.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_ALT_WIKI | The wikipedia.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_ALT_IMG | The imgur.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_ALT_WIKI | The wikipedia.com alternative to use when site alternatives are enabled in the config. |
|
||||
| WHOOGLE_AUTOCOMPLETE | Controls visibility of autocomplete/search suggestions. Default on -- use '0' to disable |
|
||||
| WHOOGLE_MINIMAL | Remove everything except basic result cards from all search queries. |
|
||||
| WHOOGLE_CSP | Sets a default set of 'Content-Security-Policy' headers |
|
||||
| WHOOGLE_RESULTS_PER_PAGE | Set the number of results per page |
|
||||
| WHOOGLE_RESULTS_PER_PAGE | Set the number of results per page |
|
||||
| WHOOGLE_TOR_CONF | The absolute path to the config file containing the password for the tor control port. Default: {whoogle path}/misc/tor/control.conf |
|
||||
|
||||
### Config Environment Variables
|
||||
These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time.
|
||||
|
|
|
@ -149,7 +149,12 @@ app.jinja_env.globals.update(
|
|||
Session(app)
|
||||
|
||||
# Attempt to acquire tor identity, to determine if Tor config is available
|
||||
send_tor_signal(Signal.HEARTBEAT)
|
||||
try:
|
||||
send_tor_signal(
|
||||
Signal.HEARTBEAT,
|
||||
confloc=os.getenv('WHOOGLE_TOR_CONF'))
|
||||
except TypeError:
|
||||
send_tor_signal(Signal.HEARTBEAT)
|
||||
|
||||
from app import routes # noqa
|
||||
|
||||
|
|
|
@ -37,18 +37,19 @@ class TorError(Exception):
|
|||
super().__init__(message)
|
||||
|
||||
|
||||
def send_tor_signal(signal: Signal) -> bool:
|
||||
def send_tor_signal(signal: Signal, confloc='./misc/tor/control.conf') -> bool:
|
||||
with open(confloc, "r") as conf:
|
||||
for line in conf:
|
||||
pass
|
||||
secret = line
|
||||
conf.close()
|
||||
try:
|
||||
# Try to authenticate with password.
|
||||
with Controller.from_port(port=9051) as c:
|
||||
with open("./misc/tor/control.conf", "r") as conf:
|
||||
for line in conf:
|
||||
pass
|
||||
secret = line
|
||||
authenticate_password(c, password=secret)
|
||||
c.signal(signal)
|
||||
os.environ['TOR_AVAILABLE'] = '1'
|
||||
return True
|
||||
return True
|
||||
except (
|
||||
SocketError,
|
||||
ConnectionRefusedError,
|
||||
|
@ -66,8 +67,7 @@ def send_tor_signal(signal: Signal) -> bool:
|
|||
os.environ['TOR_AVAILABLE'] = '0'
|
||||
print(
|
||||
"Unable to authenticate with tor control port." +
|
||||
"Tor will be unavailable."
|
||||
)
|
||||
" Tor will be unavailable.")
|
||||
return False
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user