-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #5676 disable v2 onion addresses on restore on Focal
We filter out any v2 onion address related line from /etc/tor/torrc and also the directories from /var/lib/tor/services. This will happen only on Focal. On Xenial, everything stays the same.
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
install_files/ansible-base/roles/restore/files/disable_v2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
# To execute on prod: | ||
# python3 disable_v2.py /etc/tor/torrc /etc/tor/torrc | ||
# To execute for testing locally: | ||
# python3 disable_v2.py /etc/tor/torrc /tmp/dumytorrc | ||
import sys | ||
|
||
|
||
def filter_v2(filename): | ||
# Read the file | ||
with open(filename) as f: | ||
data = f.readlines() | ||
# We will store the filtered lines to result | ||
result = [] | ||
|
||
i = 0 | ||
while i < len(data): | ||
line = data[i] | ||
if line == "HiddenServiceDir /var/lib/tor/services/source\n": | ||
i += 1 | ||
while data[i].strip() == "": | ||
i += 1 | ||
line = data[i] | ||
if line == "HiddenServiceVersion 2\n": | ||
i += 1 | ||
line = data[i] | ||
while data[i].strip() == "": | ||
i += 1 | ||
line = data[i] | ||
if line == "HiddenServicePort 80 127.0.0.1:80\n": | ||
i += 1 | ||
continue | ||
# Now check for journalist | ||
if line == "HiddenServiceDir /var/lib/tor/services/journalist\n": | ||
i += 1 | ||
while data[i].strip() == "": | ||
i += 1 | ||
line = data[i] | ||
if line == "HiddenServiceVersion 2\n": | ||
i += 1 | ||
line = data[i] | ||
while data[i].strip() == "": | ||
i += 1 | ||
line = data[i] | ||
if line == "HiddenServicePort 80 127.0.0.1:8080\n": | ||
i += 1 | ||
line = data[i] | ||
while data[i].strip() == "": | ||
i += 1 | ||
line = data[i] | ||
if line == "HiddenServiceAuthorizeClient stealth journalist\n": | ||
i += 1 | ||
continue | ||
|
||
result.append(line) | ||
i += 1 | ||
|
||
# Now return the result | ||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
filename = sys.argv[1] | ||
outputfilename = sys.argv[2] | ||
result = filter_v2(filename) | ||
with open(outputfilename, "w") as fobj: | ||
for line in result: | ||
fobj.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters