Use of WHOOGLE_TOR_CONF as env var
This commit is contained in:
parent
e1d6ed23f8
commit
7f56e16329
|
@ -343,6 +343,7 @@ There are a few optional environment variables available for customizing a Whoog
|
|||
| 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_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,14 +37,15 @@ class TorError(Exception):
|
|||
super().__init__(message)
|
||||
|
||||
|
||||
def send_tor_signal(signal: Signal) -> bool:
|
||||
try:
|
||||
# Try to authenticate with password.
|
||||
with Controller.from_port(port=9051) as c:
|
||||
with open("./misc/tor/control.conf", "r") as conf:
|
||||
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:
|
||||
authenticate_password(c, password=secret)
|
||||
c.signal(signal)
|
||||
os.environ['TOR_AVAILABLE'] = '1'
|
||||
|
@ -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