|
|
@ -1,6 +1,6 @@
|
|
|
|
#!/usr/bin/python3
|
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
|
|
|
|
import os, re, _thread, socket, sys, re, yaml, logging as log
|
|
|
|
import shutil, os, re, _thread, socket, sys, re, yaml, logging as log
|
|
|
|
|
|
|
|
|
|
|
|
import dnslib as dns
|
|
|
|
import dnslib as dns
|
|
|
|
|
|
|
|
|
|
|
@ -8,6 +8,7 @@ config = None
|
|
|
|
def main(args):
|
|
|
|
def main(args):
|
|
|
|
setupLogging(True)
|
|
|
|
setupLogging(True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setupEnvironment()
|
|
|
|
|
|
|
|
|
|
|
|
global config
|
|
|
|
global config
|
|
|
|
config = readConfig("/data/config.yml")
|
|
|
|
config = readConfig("/data/config.yml")
|
|
|
@ -16,6 +17,31 @@ def main(args):
|
|
|
|
|
|
|
|
|
|
|
|
startListen(s)
|
|
|
|
startListen(s)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setupEnvironment():
|
|
|
|
|
|
|
|
if not os.path.exists('/data'):
|
|
|
|
|
|
|
|
os.mkdir("/data")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(all, some) = copyAllFiles("data/", "/data")
|
|
|
|
|
|
|
|
if all:
|
|
|
|
|
|
|
|
log.warn("Configuration-files were created!")
|
|
|
|
|
|
|
|
log.warn(" Make sure to change them according to your setup")
|
|
|
|
|
|
|
|
elif some:
|
|
|
|
|
|
|
|
log.warn("Some configuration-files were recreated, because they were missing")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copyAllFiles(src, dst, overwrite=False):
|
|
|
|
|
|
|
|
all=True
|
|
|
|
|
|
|
|
some=False
|
|
|
|
|
|
|
|
for file in os.listdir(src):
|
|
|
|
|
|
|
|
src_file = os.path.join(src, file)
|
|
|
|
|
|
|
|
dst_file = os.path.join(dst, file)
|
|
|
|
|
|
|
|
if os.path.isfile(src_file):
|
|
|
|
|
|
|
|
if overwrite or not os.path.exists(dst_file):
|
|
|
|
|
|
|
|
shutil.copyfile(src_file, dst_file)
|
|
|
|
|
|
|
|
some=True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
all=False
|
|
|
|
|
|
|
|
return (all, some)
|
|
|
|
|
|
|
|
|
|
|
|
def setupSocket(address, port):
|
|
|
|
def setupSocket(address, port):
|
|
|
|
# IPv4/IPv6-check
|
|
|
|
# IPv4/IPv6-check
|
|
|
|
if address == "" or ":" in address:
|
|
|
|
if address == "" or ":" in address:
|
|
|
|