def run(): skipped_components = [] LOGGER.info('environment: %s' % os.environ.items()) if not config.read().getboolean('fqrouter', 'BypassDirectlyEnabled'): LOGGER.info('scrambler component disabled by config') COMPONENTS.remove(comp_scrambler) for comp in COMPONENTS: try: shutdown_hook.add(comp.stop) handlers = comp.start() for method, url, handler in handlers or []: HANDLERS[(method, url)] = handler LOGGER.info('started component: %s' % comp.__name__) except: LOGGER.exception('failed to start component: %s' % comp.__name__) comp.stop() if getattr(comp, '__MANDATORY__', False): raise skipped_components.append(comp.__name__) LOGGER.info('all components started except: %s' % skipped_components) try: httpd = WSGIServer(('127.0.0.1', 8318), handle_request) LOGGER.info('serving HTTP on port 8318...') except: LOGGER.exception('failed to start HTTP server on port 8318') sys.exit(1) httpd.serve_forever()
def start_components(*components): for comp in components: try: shutdown_hook.add(comp.stop) handlers = comp.start() for method, url, handler in handlers or []: httpd.HANDLERS[(method, url)] = handler LOGGER.info('started component: %s' % comp.__name__) except: LOGGER.exception('failed to start component: %s' % comp.__name__) comp.stop() if getattr(comp, '__MANDATORY__', False): raise LOGGER.info('skipped component: %s' % comp.__name__)
def run(): iptables.init_fq_chains() shutdown_hook.add(iptables.flush_fq_chain) if config.read().get('comp_wifi_enabled', True): start_components(comp_wifi, comp_lan) else: LOGGER.info('wifi component disabled by config') comp_wifi.setup_lo_alias() start_components(comp_lan) httpd.HANDLERS[('GET', 'ping')] = handle_ping httpd.HANDLERS[('POST', 'free-internet/connect')] = handle_free_internet_connect httpd.HANDLERS[('POST', 'free-internet/disconnect')] = handle_free_internet_disconnect httpd.HANDLERS[('GET', 'free-internet/is-connected')] = handle_free_internet_is_connected httpd.serve_forever()
def run(): iptables.init_fq_chains() shutdown_hook.add(iptables.flush_fq_chain) if config.read().get('comp_wifi_enabled', True): start_components(comp_wifi, comp_lan) else: LOGGER.info('wifi component disabled by config') comp_wifi.setup_lo_alias() start_components(comp_lan) httpd.HANDLERS[('GET', 'ping')] = handle_ping httpd.HANDLERS[('POST', 'free-internet/connect')] = handle_free_internet_connect httpd.HANDLERS[('POST', 'free-internet/disconnect')] = handle_free_internet_disconnect httpd.HANDLERS[('GET', 'free-internet/is-connected')] = handle_free_internet_is_connected gevent.spawn(check_ping) httpd.serve_forever()
def start_components(*components): LOGGER.info('environment: %s' % os.environ.items()) for comp in components: try: shutdown_hook.add(comp.stop) handlers = comp.start() for method, url, handler in handlers or []: httpd.HANDLERS[(method, url)] = handler LOGGER.info('started component: %s' % comp.__name__) except: LOGGER.exception('failed to start component: %s' % comp.__name__) comp.stop() if getattr(comp, '__MANDATORY__', False): raise LOGGER.info('skipped component: %s' % comp.__name__)
def run(): skipped_components = [] LOGGER.info('environment: %s' % os.environ.items()) if not config.read()['tcp_scrambler_enabled']: LOGGER.info('scrambler component disabled by config') COMPONENTS.remove(comp_scrambler) for comp in COMPONENTS: try: shutdown_hook.add(comp.stop) handlers = comp.start() for method, url, handler in handlers or []: httpd.HANDLERS[(method, url)] = handler LOGGER.info('started component: %s' % comp.__name__) except: LOGGER.exception('failed to start component: %s' % comp.__name__) comp.stop() if getattr(comp, '__MANDATORY__', False): raise skipped_components.append(comp.__name__) LOGGER.info('all components started except: %s' % skipped_components) httpd.HANDLERS[('GET', 'ping')] = handle_ping httpd.serve_forever()