Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usability changes #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions fakedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,14 @@ def __init__(self, file_):

for rule in rules:

# ignore blank lines or lines starting with hashmark (coments)
# ignore blank lines or lines starting with hashmark (comments)
if len(rule.strip()) == 0 or rule.lstrip()[0] == "#" or rule == '\n':
# thank you to github user cambid for the comments suggestion
continue

# remove any hashmarks (comments) at the end of a rule
if "#" in rule:
rule = rule.split("#", 1)[0]

# Confirm that the rule has at least three columns to it
if len(rule.split()) < 3:
Expand Down Expand Up @@ -692,7 +696,10 @@ def signal_handler(signal, frame):
try:
server = ThreadedUDPServer((interface, int(port)), UDPHandler)
except socket.error:
print(">> Could not start server -- is another program on udp:{0}?".format(port))
if os.geteuid() != 0 and int(port) < 1024:
print("Root privileges may be required to run on udp:{0}".format(port));
else:
print(">> Could not start server -- is another program on udp:{0}?".format(port))
exit(1)

server.daemon = True
Expand Down