예제 #1
0
파일: main.py 프로젝트: acekiller/fqrouter
def run():
    iptables.init_fq_chains()
    shutdown_hook.add(iptables.flush_fq_chain)
    iptables.insert_rules(DNS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, DNS_RULES))
    iptables.insert_rules(SOCKS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, SOCKS_RULES))
    wifi.setup_lo_alias()
    try:
        comp_scrambler.start()
        shutdown_hook.add(comp_scrambler.stop)
    except:
        LOGGER.exception('failed to start comp_scrambler')
        comp_scrambler.stop()
    try:
        comp_shortcut.start()
        shutdown_hook.add(comp_shortcut.stop)
    except:
        LOGGER.exception('failed to start comp_shortcut')
        comp_shortcut.stop()
    args = [
        '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router2/log/fqsocks.log',
        '--ifconfig-command', '/data/data/fq.router2/busybox',
        '--ip-command', '/data/data/fq.router2/busybox',
        '--outbound-ip', '10.1.2.3',
        '--tcp-gateway-listen', '10.1.2.3:12345',
        '--dns-server-listen', '10.1.2.3:12345']
    args = config.configure_fqsocks(args)
    fqsocks.fqsocks.main(args)
예제 #2
0
파일: main.py 프로젝트: zylucifer/fqrouter
def run():
    iptables.init_fq_chains()
    shutdown_hook.add(iptables.flush_fq_chain)
    iptables.insert_rules(DNS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, DNS_RULES))
    iptables.insert_rules(SOCKS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, SOCKS_RULES))
    wifi.setup_lo_alias()
    args = [
        '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router2/log/fqsocks.log',
        '--ifconfig-command', '/data/data/fq.router2/busybox',
        '--ip-command', '/data/data/fq.router2/busybox',
        '--outbound-ip', '10.1.2.3',
        '--tcp-gateway-listen', '10.1.2.3:12345',
        '--dns-server-listen', '10.1.2.3:12345']
    if shell.USE_SU:
        args.append('--no-tcp-scrambler')
    args = config.configure_fqsocks(args)
    fqsocks.fqsocks.init_config(args)
    if fqsocks.config_file.read_config()['tcp_scrambler_enabled']:
        try:
            comp_scrambler.start()
            shutdown_hook.add(comp_scrambler.stop)
        except:
            LOGGER.exception('failed to start comp_scrambler')
            comp_scrambler.stop()
    if fqsocks.config_file.read_config()['china_shortcut_enabled']:
        try:
            comp_shortcut.start()
            shutdown_hook.add(comp_shortcut.stop)
        except:
            LOGGER.exception('failed to start comp_shortcut')
            comp_shortcut.stop()
    fqsocks.fqsocks.main()
예제 #3
0
파일: wifi.py 프로젝트: GD-HBX/fqrouter
def setup_networking(hotspot_interface):
    netd_execute('interface setcfg %s 192.168.49.1 24' % hotspot_interface)
    netd_execute('tether stop')
    netd_execute('tether interface add %s' % hotspot_interface)
    netd_execute('tether start 192.168.49.2 192.168.49.254')
    netd_execute('tether dns set 8.8.8.8')
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES)
예제 #4
0
파일: wifi.py 프로젝트: jieah/fqrouter
def setup_networking(hotspot_interface):
    control_socket_dir = get_wpa_supplicant_control_socket_dir()
    netd_execute('interface setcfg %s 192.168.49.1 24' % hotspot_interface)
    netd_execute('tether stop')
    netd_execute('tether interface add %s' % hotspot_interface)
    netd_execute('tether start 192.168.49.2 192.168.49.254')
    log_upstream_wifi_status('after tether started', control_socket_dir)
    netd_execute('tether dns set 8.8.8.8')
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES)
    log_upstream_wifi_status('after setup networking', control_socket_dir)
예제 #5
0
def setup_networking(hotspot_interface):
    control_socket_dir = get_wpa_supplicant_control_socket_dir()
    netd_execute('interface setcfg %s 192.168.49.1 24' % hotspot_interface)
    netd_execute('tether stop')
    netd_execute('tether interface add %s' % hotspot_interface)
    netd_execute('tether start 192.168.49.2 192.168.49.254')
    log_upstream_wifi_status('after tether started', control_socket_dir)
    netd_execute('tether dns set 8.8.8.8')
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES)
    log_upstream_wifi_status('after setup networking', control_socket_dir)
예제 #6
0
파일: wifi.py 프로젝트: gegp/fqrouter
def setup_networking(hotspot_interface):
    control_socket_dir = get_wpa_supplicant_control_socket_dir()
    setup_network_interface_ip(hotspot_interface, '10.24.1.1', '255.255.255.0')
    try:
        shell_execute('%s dnsmasq' % KILLALL_PATH)
    except:
        LOGGER.exception('failed to killall dnsmasq')
    shell_execute('%s -i %s --dhcp-authoritative --no-negcache --user=root --no-resolv --no-hosts '
                  '--server=8.8.8.8 --dhcp-range=10.24.1.2,10.24.1.254,12h '
                  '--dhcp-leasefile=/data/data/fq.router/dnsmasq.leases '
                  '--pid-file=/data/data/fq.router/dnsmasq.pid' % (DNSMASQ_PATH, hotspot_interface))
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES)
    log_upstream_wifi_status('after setup networking', control_socket_dir)
예제 #7
0
파일: main.py 프로젝트: fbzhong/fqrouter
def run():
    iptables.init_fq_chains()
    shutdown_hook.add(iptables.flush_fq_chain)
    iptables.insert_rules(DNS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, DNS_RULES))
    iptables.insert_rules(SOCKS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, SOCKS_RULES))
    wifi.setup_lo_alias()
    args = [
        '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router2/log/fqsocks.log',
        '--ifconfig-command', '/data/data/fq.router2/busybox',
        '--ip-command', '/data/data/fq.router2/busybox',
        '--outbound-ip', '10.1.2.3',
        '--tcp-gateway-listen', '10.1.2.3:12345',
        '--dns-server-listen', '10.1.2.3:12345']
    if shell.USE_SU:
        args.append('--no-tcp-scrambler')
    args = config.configure_fqsocks(args)
    fqsocks.fqsocks.init_config(args)
    if fqsocks.config_file.read_config()['tcp_scrambler_enabled']:
        try:
            comp_scrambler.start()
            shutdown_hook.add(comp_scrambler.stop)
        except:
            LOGGER.exception('failed to start comp_scrambler')
            comp_scrambler.stop()
    if fqsocks.config_file.read_config()['china_shortcut_enabled']:
        try:
            comp_shortcut.start()
            shutdown_hook.add(comp_shortcut.stop)
        except:
            LOGGER.exception('failed to start comp_shortcut')
            comp_shortcut.stop()
    fqsocks.fqsocks.DNS_HANDLER.set_dns_bypass(fqsocks.config_file.read_config()['dns']['bypass'])
    fqsocks.fqsocks.get_default_dns_server = config.get_default_dns_server
    fqsocks.fqsocks.main()
예제 #8
0
파일: wifi.py 프로젝트: fewewf/Xndroid
def setup_lo_alias():
    setup_network_interface_ip('lo:1', '10.1.2.3', '255.255.255.255')
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES, to_fq_chain=False)
예제 #9
0
def setup_lo_alias():
    setup_network_interface_ip('lo:1', '10.1.2.3', '255.255.255.255')
    enable_ipv4_forward()
    shell_execute('iptables -P FORWARD ACCEPT')
    iptables.insert_rules(RULES, to_fq_chain=False)
예제 #10
0
def insert_iptables_rules():
    shutdown_hook.add(delete_iptables_rules)
    iptables.insert_rules(RULES)
예제 #11
0
def run():
    iptables.tables = {}
    iptables.init_fq_chains()
    shutdown_hook.add(iptables.flush_fq_chain)
    if not os.getenv('NO_FQDNS'):
        iptables.insert_rules(DNS_RULES)
        shutdown_hook.add(functools.partial(iptables.delete_rules, DNS_RULES))
    setup_nat()
    iptables.insert_rules(SOCKS_RULES)
    shutdown_hook.add(functools.partial(iptables.delete_rules, SOCKS_RULES))
    wifi.setup_lo_alias()

    if not os.getenv('NO_TEREDO'):
        LOGGER.info('init teredo and tun')
        sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
        sock.bind(('10.1.2.3', 0))
        teredo_client = teredo.teredo_client(
            sock, teredo.get_default_teredo_server())
        teredo_ip = None
        try:
            teredo_ip = teredo_client.start()
        except:
            LOGGER.exception('start teredo fail')
        if not teredo_ip:
            LOGGER.error('start teredo client fail, use default:%s' %
                         default_loacl_teredo_ip)
            teredo_ip = default_loacl_teredo_ip
        else:
            LOGGER.info('teredo start succeed, teredo ip:%s' % teredo_ip)

        tun_fd = init_tun(teredo_ip)
        if not tun_fd:
            LOGGER.error('init tun fail!')
        else:
            teredo.tun_fd = tun_fd
            teredo_client.server_forever(teredo_ip)
            gevent.spawn(redirect_tun_traffic, tun_fd, teredo_client)

    args = [
        '--log-level',
        'DEBUG' if os.getenv('DEBUG') else 'INFO',
        '--log-file',
        LOG_DIR + '/fqsocks.log',
        '--ifconfig-command',
        home_path + '/../busybox',
        #'--ip-command', 'ip',
        '--outbound-ip',
        '10.1.2.3',
        '--tcp-gateway-listen',
        '10.1.2.3:12345',
        '--dns-server-listen',
        '10.1.2.3:12345'
    ]
    if shell.USE_SU:
        args.append('--no-tcp-scrambler')
    args = config.configure_fqsocks(args)
    fqsocks.fqsocks.init_config(args)
    if fqsocks.config_file.read_config()['tcp_scrambler_enabled']:
        try:
            comp_scrambler.start()
            shutdown_hook.add(comp_scrambler.stop)
        except:
            LOGGER.exception('failed to start comp_scrambler')
            comp_scrambler.stop()
    if fqsocks.config_file.read_config(
    )['china_shortcut_enabled'] and comp_shortcut_enabled:
        try:
            comp_shortcut.start()
            shutdown_hook.add(comp_shortcut.stop)
        except:
            LOGGER.exception('failed to start comp_shortcut')
            comp_shortcut.stop()
    iptables.tables = {}
    fqsocks.fqsocks.main()
예제 #12
0
def insert_iptables_rules():
    iptables.insert_rules(RULES)
예제 #13
0
def insert_iptables_rules():
    shutdown_hook.add(delete_iptables_rules)
    iptables.insert_rules(RULES)
예제 #14
0
def insert_iptables_rules():
    iptables.insert_rules(RULES)