def server_options(): parser = KmsSrvParser(description = srv_description, epilog = 'version: ' + srv_version) parser.add_argument("ip", nargs = "?", action = "store", default = srv_options['ip']['def'], help = srv_options['ip']['help'], type = str) parser.add_argument("port", nargs = "?", action = "store", default = srv_options['port']['def'], help = srv_options['port']['help'], type = int) parser.add_argument("-e", "--epid", dest = srv_options['epid']['des'], default = srv_options['epid']['def'], help = srv_options['epid']['help'], type = str) parser.add_argument("-l", "--lcid", dest = srv_options['lcid']['des'], default = srv_options['lcid']['def'], help = srv_options['lcid']['help'], type = int) parser.add_argument("-c", "--client-count", dest = srv_options['count']['des'] , default = srv_options['count']['def'], help = srv_options['count']['help'], type = int) parser.add_argument("-a", "--activation-interval", dest = srv_options['activation']['des'], default = srv_options['activation']['def'], help = srv_options['activation']['help'], type = int) parser.add_argument("-r", "--renewal-interval", dest = srv_options['renewal']['des'], default = srv_options['renewal']['def'], help = srv_options['renewal']['help'], type = int) parser.add_argument("-s", "--sqlite", dest = srv_options['sql']['des'], action = "store_const", const = True, default = srv_options['sql']['def'], help = srv_options['sql']['help']) parser.add_argument("-w", "--hwid", dest = srv_options['hwid']['des'], action = "store", default = srv_options['hwid']['def'], help = srv_options['hwid']['help'], type = str) parser.add_argument("-t", "--timeout", dest = srv_options['time']['des'], action = "store", default = srv_options['time']['def'], help = srv_options['time']['help'], type = int) parser.add_argument("-V", "--loglevel", dest = srv_options['llevel']['des'], action = "store", choices = srv_options['llevel']['choi'], default = srv_options['llevel']['def'], help = srv_options['llevel']['help'], type = str) parser.add_argument("-F", "--logfile", nargs = "+", dest = srv_options['lfile']['des'], default = srv_options['lfile']['def'], help = srv_options['lfile']['help'], type = str) parser.add_argument("-S", "--logsize", dest = srv_options['lsize']['des'], action = "store", default = srv_options['lsize']['def'], help = srv_options['lsize']['help'], type = float) try: srv_config.update(vars(parser.parse_args())) # Check logfile. srv_config['logfile'] = check_logfile(srv_config['logfile'], srv_options['lfile']['def'], loggersrv) except KmsSrvException as e: pretty_errors(46, loggersrv, get_text = False, put_text = str(e), log_text = False)
def server_check(): # Setup hidden or not messages. ShellMessage.view = (False if any( i in ['STDOUT', 'FILESTDOUT'] for i in srv_config['logfile']) else True) # Create log. logger_create(loggersrv, srv_config, mode='a') # Random HWID. if srv_config['hwid'] == "RANDOM": randomhwid = uuid.uuid4().hex srv_config['hwid'] = randomhwid[:16] # Sanitize HWID. hexstr = srv_config['hwid'].strip('0x') hexsub = re.sub(r'[^0-9a-fA-F]', '', hexstr) diff = set(hexstr).symmetric_difference(set(hexsub)) if len(diff) != 0: pretty_errors(41, loggersrv, put_text=[hexstr.upper(), diff]) else: lh = len(hexsub) if lh % 2 != 0: pretty_errors(42, loggersrv, put_text=hexsub.upper()) elif lh < 16: pretty_errors(43, loggersrv, put_text=hexsub.upper()) elif lh > 16: pretty_errors(44, loggersrv, put_text=hexsub.upper()) else: srv_config['hwid'] = binascii.a2b_hex(hexsub) # Check LCID. srv_config['lcid'] = check_lcid(srv_config['lcid'], loggersrv) # Check sqlite. try: import sqlite3 except: loggersrv.warning( "Module \"sqlite3\" is not installed, database support disabled.") srv_config['dbSupport'] = False else: srv_config['dbSupport'] = True # Check port. if not 1 <= srv_config['port'] <= 65535: pretty_errors(45, loggersrv, put_text=srv_config['port'])
def handle_timeout(self): pretty_errors(40, loggersrv)