Esempio n. 1
0
def start_nfqueue_ipset():
    global nfqueue_ipset_process
    nfqueue_ipset_process = shell.launch_python(
        'fqsocks.nfqueue_ipset', ('--log-level', 'INFO',
        '--queue-number', '1',
        '--rule', 'dst,china,ACCEPT',
        '--default', '0xdead'), on_exit=stop)
Esempio n. 2
0
def start_nfqueue_ipset():
    global nfqueue_ipset_process
    nfqueue_ipset_process = shell.launch_python('fqsocks.nfqueue_ipset',
                                                '--log-level', 'INFO',
                                                '--queue-number', '1',
                                                '--rule', 'dst,china,ACCEPT',
                                                '--default', '0xdead')
Esempio n. 3
0
def start():
    global fqting_process
    insert_iptables_rules()
    fqting_process = shell.launch_python(
        'fqting', '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router/fqting.log',
        '--queue-number', '2',
        '--mark', '0xcafe')
Esempio n. 4
0
def start():
    if not is_alive():
        global fqting_process
        insert_iptables_rules()
        fqting_process = shell.launch_python(
            'fqting', ('--log-level', 'INFO', '--log-file',
                       '/data/data/fq.router2/log/fqting.log',
                       '--queue-number', '2', '--mark', '0xcafe'),
            on_exit=stop)
Esempio n. 5
0
def start():
    global fqdns_process
    insert_iptables_rules()
    fqdns_process = shell.launch_python(
        'fqdns', ('--log-level', 'INFO',
        '--log-file', '/data/data/fq.router/fqdns.log',
        '--outbound-ip', '10.1.2.3', # send from 10.1.2.3 so we can skip redirecting those traffic
        'serve', '--listen', '10.1.2.3:5353',
        '--enable-china-domain', '--enable-hosted-domain'), on_exit=stop)
Esempio n. 6
0
def start():
    if not is_alive():
        global fqting_process
        insert_iptables_rules()
        fqting_process = shell.launch_python(
            'fqting', ('--log-level', 'INFO',
            '--log-file', '/data/data/fq.router2/log/fqting.log',
            '--queue-number', '2',
            '--mark', '0xcafe'), on_exit=stop)
Esempio n. 7
0
def start_fqsocks():
    global fqsocks_process
    fqsocks_process = shell.launch_python(
        'fqsocks', ('--log-level', 'INFO',
        '--log-file', '/data/data/fq.router/fqsocks.log',
        '--outbound-ip', '10.1.2.3', # send from 10.1.2.3 so we can skip redirecting those traffic
        '--listen', '10.1.2.3:8319',
        '--http-request-mark', '0xbabe', # trigger scrambler
        '--proxy', 'dynamic,n=20,dns_record=proxy#n#.fqrouter.com',
        '--proxy', 'dynamic,n=10,type=goagent,dns_record=goagent#n#.fqrouter.com',
        '--google-host', 'goagent-google-ip.fqrouter.com'), on_exit=stop)
Esempio n. 8
0
def start_fqsocks():
    global fqsocks_process
    args = [
        '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router/log/fqsocks.log',
        '--outbound-ip', '10.1.2.3', # send from 10.1.2.3 so we can skip redirecting those traffic
        '--listen', '10.1.2.3:8319',
        '--http-request-mark', '0xbabe' # trigger scrambler
    ]
    args = configure(args)
    fqsocks_process = shell.launch_python('fqsocks', args, on_exit=stop)
Esempio n. 9
0
def start_fqsocks():
    global fqsocks_process
    args = [
        '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router2/log/fqsocks.log',
        '--outbound-ip', '10.1.2.3', # send from 10.1.2.3 so we can skip redirecting those traffic
        '--listen', '10.1.2.3:8319'
    ]
    if config.read().get('tcp_scrambler_enabled', True):
        args += ['--http-request-mark', '0xbabe'] # trigger scrambler
    args = configure(args)
    fqsocks_process = shell.launch_python('fqsocks', args, on_exit=stop)
Esempio n. 10
0
def restart_fqlan():
    global fqlan_process
    stop()
    if not picked_devices:
        LOGGER.info('no picked devices, fqlan will not start')
        return
    fqlan_process = shell.launch_python(
        'fqlan', '--log-level', 'INFO', '--log-file',
        '/data/data/fq.router/fqlan.log', '--lan-interface',
        comp_wifi.WIFI_INTERFACE, '--ifconfig-command',
        '/data/data/fq.router/busybox', '--ip-command',
        '/data/data/fq.router/busybox', 'forge',
        *['%s,%s' % (ip, mac) for ip, mac in picked_devices.items()])
Esempio n. 11
0
def restart_fqlan():
    global fqlan_process
    stop()
    if not picked_devices:
        LOGGER.info('no picked devices, fqlan will not start')
        return
    fqlan_process = shell.launch_python(
        'fqlan', '--log-level', 'INFO',
        '--log-file', '/data/data/fq.router/fqlan.log',
        '--lan-interface', comp_wifi.WIFI_INTERFACE,
        '--ifconfig-command', '/data/data/fq.router/busybox',
        '--ip-command', '/data/data/fq.router/busybox',
        'forge', *['%s,%s' % (ip, mac) for ip, mac in picked_devices.items()])
Esempio n. 12
0
def start_fqsocks():
    global fqsocks_process
    args = [
        "--log-level",
        "INFO",
        "--log-file",
        "/data/data/fq.router2/log/fqsocks.log",
        "--outbound-ip",
        "10.1.2.3",  # send from 10.1.2.3 so we can skip redirecting those traffic
        "--listen",
        "10.1.2.3:8319",
    ]
    if config.read().get("tcp_scrambler_enabled", True):
        args += ["--http-request-mark", "0xbabe"]  # trigger scrambler
    args = configure(args)
    fqsocks_process = shell.launch_python("fqsocks", args, on_exit=stop)
Esempio n. 13
0
def start():
    global fqdns_process
    insert_iptables_rules()
    fqdns_process = shell.launch_python(
        'fqdns',
        '--log-level',
        'INFO',
        '--log-file',
        '/data/data/fq.router/fqdns.log',
        '--outbound-ip',
        '10.1.2.3',  # send from 10.1.2.3 so we can skip redirecting those traffic
        'serve',
        '--listen',
        '10.1.2.3:5353',
        '--enable-china-domain',
        '--enable-hosted-domain')
Esempio n. 14
0
def start():
    global fqdns_process
    insert_iptables_rules()
    fqdns_process = shell.launch_python(
        "fqdns",
        "--log-level",
        "INFO",
        "--log-file",
        "/data/data/fq.router/fqdns.log",
        "--outbound-ip",
        "10.1.2.3",  # send from 10.1.2.3 so we can skip redirecting those traffic
        "serve",
        "--listen",
        "10.1.2.3:5353",
        "--enable-china-domain",
        "--enable-hosted-domain",
    )
Esempio n. 15
0
def start_fqsocks():
    global fqsocks_process
    fqsocks_process = shell.launch_python(
        'fqsocks',
        '--log-level',
        'INFO',
        '--log-file',
        '/data/data/fq.router/fqsocks.log',
        '--outbound-ip',
        '10.1.2.3',  # send from 10.1.2.3 so we can skip redirecting those traffic
        '--listen',
        '10.1.2.3:8319',
        '--http-request-mark',
        '0xbabe',  # trigger scrambler
        '--proxy',
        'dynamic,n=20,dns_record=proxy#n#.fqrouter.com',
        '--proxy',
        'dynamic,n=10,type=goagent,dns_record=goagent#n#.fqrouter.com',
        '--google-host',
        'goagent-google-ip.fqrouter.com')
Esempio n. 16
0
def start():
    if not is_alive():
        global fqdns_process
        insert_iptables_rules()
        fqdns_process = shell.launch_python(
            'fqdns',
            (
                '--log-level',
                'INFO',
                '--log-file',
                '/data/data/fq.router2/log/fqdns.log',
                '--outbound-ip',
                '10.1.2.3',  # send from 10.1.2.3 so we can skip redirecting those traffic
                'serve',
                '--listen',
                '10.1.2.3:5353',
                '--enable-china-domain',
                '--enable-hosted-domain',
                '--original-upstream',
                get_default_dns_server()),
            on_exit=stop)
Esempio n. 17
0
def netd_execute(command):
    if shell.USE_SU:
        return shell.launch_python('main', ['netd-execute', '"%s"' % command])
    global netd_sequence_number
    netd_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    try:
        netd_socket.connect('/dev/socket/netd')
        if netd_sequence_number:
            netd_sequence_number += 1
            LOGGER.info('send: %s %s' % (netd_sequence_number, command))
            netd_socket.send('%s %s\0' % (netd_sequence_number, command))
        else:
            LOGGER.info('send: %s' % command)
            netd_socket.send('%s\0' % command)
        output = netd_socket.recv(1024)
        LOGGER.info('received: %s' % output)
        if not netd_sequence_number and 'Invalid sequence number' in output:
            LOGGER.info('resend command to netd with sequence number')
            netd_sequence_number = 1
            netd_execute(command)
    finally:
        netd_socket.close()
Esempio n. 18
0
def netd_execute(command):
    if shell.USE_SU:
        return shell.launch_python('main', ['netd-execute', '"%s"' % command])
    global netd_sequence_number
    netd_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    try:
        netd_socket.connect('/dev/socket/netd')
        if netd_sequence_number:
            netd_sequence_number += 1
            LOGGER.info('send: %s %s' % (netd_sequence_number, command))
            netd_socket.send('%s %s\0' % (netd_sequence_number, command))
        else:
            LOGGER.info('send: %s' % command)
            netd_socket.send('%s\0' % command)
        output = netd_socket.recv(1024)
        LOGGER.info('received: %s' % output)
        if not netd_sequence_number and 'Invalid sequence number' in output:
            LOGGER.info('resend command to netd with sequence number')
            netd_sequence_number = 1
            netd_execute(command)
    finally:
        netd_socket.close()