Skip to content

Commit

Permalink
Rename Interface to Interface_IP
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Azif committed Mar 19, 2018
1 parent cbfb49f commit 3195d9d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion settings.json
@@ -1,5 +1,5 @@
{
"Interface": "",
"Interface_IP": "",
"Debug": false,
"DNS": true,
"HTTP": true,
Expand Down
31 changes: 16 additions & 15 deletions start.py
Expand Up @@ -324,7 +324,7 @@ def ip_display():

server_string = center_menu_item(server_string)

ip_string = 'Your {} IP is {}'.format(server_type, SETTINGS['Interface'])
ip_string = 'Your {} IP is {}'.format(server_type, SETTINGS['Interface_IP'])
ip_string = center_menu_item(ip_string)

print_line()
Expand Down Expand Up @@ -365,7 +365,7 @@ def default_settings():
global SETTINGS

SETTINGS = {
"Interface": get_lan(),
"Interface_IP": get_lan(),
"Debug": False,
"DNS": True,
"HTTP": True,
Expand Down Expand Up @@ -438,15 +438,15 @@ def import_settings():
print('ERROR: Malformed settings.json, using default')
return

if validate_setting(imported, 'Interface', str):
if validate_setting(imported, 'Interface_IP', str):
try:
ipaddress.ip_address(imported['Interface'])
SETTINGS['Interface'] = imported['Interface']
ipaddress.ip_address(imported['Interface_IP'])
SETTINGS['Interface_IP'] = imported['Interface_IP']
except ValueError:
if imported['Interface'] != '':
print('WARNING: "Interface" in settings is not a valid IP, using default')
if imported['Interface_IP'] != '':
print('WARNING: "Interface_IP" in settings is not a valid IP, using default')
else:
print('WARNING: "Interface" in settings is invalid, using default')
print('WARNING: "Interface_IP" in settings is invalid, using default')

if validate_setting(imported, 'Debug', bool):
SETTINGS['Debug'] = imported['Debug']
Expand Down Expand Up @@ -606,11 +606,12 @@ def import_settings():


def validate_setting(imported, value, type):
if value:
check_var = imported[value]
else:
check_var = imported
try:
if value:
check_var = imported[value]
else:
check_var = imported

if isinstance(check_var, type):
return True
except (KeyError, ValueError):
Expand Down Expand Up @@ -640,7 +641,7 @@ def generate_dns_rules():
rules = []

for entry in SETTINGS['DNS_Rules']['Self']:
rules.append('A {} {}'.format(entry, SETTINGS['Interface']))
rules.append('A {} {}'.format(entry, SETTINGS['Interface_IP']))

for entry in SETTINGS['DNS_Rules']['Block']:
rules.append('A {} 0.0.0.0'.format(entry))
Expand All @@ -650,15 +651,15 @@ def generate_dns_rules():

def start_servers():
if SETTINGS['DNS']:
FAKEDNS.main(SETTINGS['Interface'],
FAKEDNS.main(SETTINGS['Interface_IP'],
generate_dns_rules(),
SETTINGS['DNS_Rules']['Pass_Through'],
SETTINGS['Debug'])
print('>> DNS server thread is running...')

if SETTINGS['HTTP']:
try:
server = ThreadedHTTPServer((SETTINGS['Interface'], 80), MyHandler)
server = ThreadedHTTPServer((SETTINGS['Interface_IP'], 80), MyHandler)
thread = threading.Thread(name='HTTP_Server',
target=server.serve_forever,
args=(),
Expand Down

0 comments on commit 3195d9d

Please sign in to comment.