Skip to content

Commit

Permalink
add new lines at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Schleizer committed Jan 21, 2018
1 parent acf2c23 commit b1b5c50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Expand Up @@ -1453,6 +1453,8 @@ def io(self):
# for proxy in proxies['proxies'][Common.well_known_proxy_setting]:
# f.write('{0}\n'.format(proxy))

f.write('\n')


def parseTorrc(self):
if os.path.exists(Common.torrc_file_path):
Expand Down
Expand Up @@ -12,13 +12,14 @@
whonix=True
else:
whonix=False

def repair_torrc():
repair_torrc_d()

if not os.path.exists('/etc/tor/torrc'):
with open('/etc/tor/torrc', "w+") as f:
f.write("%include /etc/torrc.d")
f.write('\n')
else:
with open('/etc/tor/torrc', "r") as f:
lines = f.readlines()
Expand All @@ -33,6 +34,7 @@ def repair_torrc():
if not torrcd_line_exists:
with open('/etc/tor/torrc', "a") as f:
f.write("%include /etc/torrc.d\n")
f.write('\n')


'''repair_torrc_d() will gurantee the existence of /etc/torrc.d
Expand Down
Expand Up @@ -58,6 +58,7 @@ def set_enabled():
if status == "no_torrc":
with open(DisableNetwork_torrc_path,'w+') as f:
f.write('DisableNetwork 0')
f.write('\n')
elif status == "tor_disabled":
for i, line in enumerate(fileinput.input(DisableNetwork_torrc_path, inplace=1)):
sys.stdout.write(line.replace('DisableNetwork 1', 'DisableNetwork 0'))
Expand All @@ -67,6 +68,7 @@ def set_enabled():
elif status == "missing_disablenetwork_line":
with open(DisableNetwork_torrc_path,'a') as f:
f.write('DisableNetwork 0')
f.write('\n')

## start the Tor now
command = 'systemctl --no-pager restart tor@default'
Expand All @@ -89,6 +91,7 @@ def set_disabled():
if status == "no_torrc":
with open(DisableNetwork_torrc_path,'w+') as f:
f.write('DisableNetwork 1')
f.write('\n')
elif status == "tor_disabled":
# do nothing
pass
Expand All @@ -98,6 +101,7 @@ def set_disabled():
elif status == "missing_disablenetwork_line":
with open(DisableNetwork_torrc_path,'a') as f:
f.write('DisableNetwork 1')
f.write('\n')

## stop the Tor now
command = 'systemctl --no-pager stop tor@default'
Expand Down

0 comments on commit b1b5c50

Please sign in to comment.