示例#1
0
文件: main.py 项目: erizhang/fqrouter
def run():
    start_components(comp_wifi, 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()
示例#2
0
文件: main.py 项目: JustLin/fqrouter
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()
示例#3
0
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()
示例#4
0
文件: main.py 项目: kexuejin/fqrouter
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 []:
                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()
示例#5
0
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 []:
                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()