|
@@ -5,6 +5,7 @@ import socket
|
|
|
import random, string
|
|
|
import daemon, getopt, sys
|
|
|
import daemon.pidlockfile
|
|
|
+import traceback
|
|
|
import os
|
|
|
|
|
|
def myrandom(length):
|
|
@@ -67,7 +68,7 @@ if __name__ == '__main__':
|
|
|
|
|
|
daemonize = True
|
|
|
port = 1337
|
|
|
- bindTo = '::'
|
|
|
+ bindTo = None
|
|
|
|
|
|
for opt, arg in opts:
|
|
|
if opt in ("-d", "--do-not-daemonize"):
|
|
@@ -76,13 +77,18 @@ if __name__ == '__main__':
|
|
|
port = int(arg)
|
|
|
elif opt in ("-b", "--bind-to"):
|
|
|
try:
|
|
|
- socket.inet_aton(arg)
|
|
|
+ socket.inet_pton(socket.AF_INET6, arg)
|
|
|
bindTo = str(arg)
|
|
|
except:
|
|
|
- print('Listening IP address is either invalid or unset. Using default ::')
|
|
|
+ traceback.print_exc()
|
|
|
+ sys.exit(1)
|
|
|
else:
|
|
|
assert False
|
|
|
|
|
|
+ if bindTo == None:
|
|
|
+ print("Listening IP address is unset. Using default ::")
|
|
|
+ bindTo = "::"
|
|
|
+
|
|
|
if daemonize == False:
|
|
|
serve(port, bindTo)
|
|
|
else:
|