Example #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,
    )
Example #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'), on_exit=stop)
Example #3
0
def start():
    if not is_alive():
        global fqting_process
        insert_iptables_rules()
        fqting_process = shell.launch_python(
            'fqting',
            ('--log-level', 'INFO', '--log-file', home_path +
             '/log/fqting.log', '--queue-number', '2', '--mark', '0xcafe'),
            on_exit=stop)
Example #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)
Example #5
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()
Example #6
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()