Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Fixed normal domains being added to the host file twice if the extra …
Browse files Browse the repository at this point in the history
…box was ticked.

Changed nullip from 0.0.0.0 to 127.0.0.0
  • Loading branch information
10se1ucgo committed Aug 23, 2015
1 parent 1e740d6 commit 42e3b3b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def revert(self, event):


def modifyhosts(extra, undo):
nullip = "0.0.0.0 " # IP to route domains to
nullip = "127.0.0.0 " # IP to route domains to

# List of tracking domains
normallist = ['a-0001.a-msedge.net', 'a-0002.a-msedge.net', 'a-0003.a-msedge.net',
Expand Down Expand Up @@ -227,16 +227,23 @@ def modifyhosts(extra, undo):
hostspath = os.path.join(os.environ['SYSTEMROOT'], 'System32\\drivers\\etc\\hosts')

if not undo:
try:
with open(hostspath, 'ab') as f:
f.write('\r\n' + '\r\n'.join(normallistip))
if extra:
if not extra:
try:
with open(hostspath, 'ab') as f:
f.write('\r\n' + '\r\n'.join(normallistip))
print "Domains successfully appended to HOSTS file."
except (WindowsError, IOError):
print "Could not access HOSTS file. Is the program not elevated?"

elif extra:
try:
with open(hostspath, 'ab') as f:
f.write('\r\n' + '\r\n'.join(extralistip))
print "Domains successfully appended to HOSTS file."
except (WindowsError, IOError):
print "Could not access HOSTS file. Is the program not elevated?"
print "Extra domains successfully appended to HOSTS file."
except (WindowsError, IOError):
print "Could not access HOSTS file. Is the program not elevated?"

else:
elif undo:
try:
with open(hostspath, 'r') as hostfile, open(hostspath + "temp", 'w') as tempfile:
for line in hostfile:
Expand Down

0 comments on commit 42e3b3b

Please sign in to comment.