Пример #1
0
    def init_func(self, debug, configs):
        self.create_poll()

        signal.signal(signal.SIGINT, self.__exit)

        self.__routes = {}
        self.__configs = configs

        self.__mbuf = utils.mbuf()
        self.__debug = debug
        self.__tundev_fileno = self.create_handler(-1, tundev.tundevc,
                                                   self.__DEVNAME)

        self.__port_mapv4 = port_map.port_map(is_ipv6=False)
        self.__port_mapv6 = port_map.port_map(is_ipv6=True)

        self.__ROUTE_TIMEOUT = 1200
        self.__route_timer = timer.timer()

        conn = configs["connection"]

        m = "freenet.lib.crypto.noany"
        try:
            self.__tcp_crypto = importlib.import_module("%s.noany_tcp" % m)
            self.__udp_crypto = importlib.import_module("%s.noany_udp" % m)
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        crypto_fpath = "%s/fdslight_etc/noany.json" % BASE_DIR

        if not os.path.isfile(crypto_fpath):
            print("crypto configfile not exists")
            sys.exit(-1)

        try:
            crypto_configs = proto_utils.load_crypto_configfile(crypto_fpath)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        self.__crypto_configs = crypto_configs

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
        ''''''
Пример #2
0
    def init_func(self, mode, debug, configs):
        self.create_poll()

        signal.signal(signal.SIGINT, self.__exit)

        self.__router_timer = timer.timer()
        self.__routers = {}
        self.__configs = configs

        if mode == "local":
            self.__mode = _MODE_LOCAL
        else:
            self.__mode = _MODE_GW

        self.__mbuf = utils.mbuf()
        self.__debug = debug

        self.__tundev_fileno = self.create_handler(-1, tundev.tundevc,
                                                   self.__DEVNAME)

        public = configs["public"]
        gateway = configs["gateway"]

        self.__enable_ipv6_traffic = bool(int(public["enable_ipv6_traffic"]))

        is_ipv6 = utils.is_ipv6_address(public["remote_dns"])

        if self.__mode == _MODE_GW:
            self.__dns_fileno = self.create_handler(-1,
                                                    dns_proxy.dnsc_proxy,
                                                    gateway["dnsserver_bind"],
                                                    debug=debug,
                                                    server_side=True,
                                                    is_ipv6=False)
            self.get_handler(self.__dns_fileno).set_parent_dnsserver(
                public["remote_dns"], is_ipv6=is_ipv6)

            if self.__enable_ipv6_traffic:
                self.__dns_listen6 = self.create_handler(
                    -1,
                    dns_proxy.dnsc_proxy,
                    gateway["dnsserver_bind6"],
                    debug=debug,
                    server_side=True,
                    is_ipv6=True)
                self.get_handler(self.__dns_listen6).set_parent_dnsserver(
                    public["remote_dns"], is_ipv6=is_ipv6)
        else:
            self.__dns_fileno = self.create_handler(-1,
                                                    dns_proxy.dnsc_proxy,
                                                    public["remote_dns"],
                                                    debug=debug,
                                                    server_side=False)

        self.__set_host_rules(None, None)

        if self.__mode == _MODE_GW:
            self.__load_kernel_mod()
            udp_global = bool(int(gateway["dgram_global_proxy"]))
            if udp_global:
                self.__dgram_fetch_fileno = self.create_handler(
                    -1,
                    traffic_pass.traffic_read,
                    self.__configs["gateway"],
                    enable_ipv6=self.__enable_ipv6_traffic)
            ''''''
        else:
            local = configs["local"]
            vir_dns = local["virtual_dns"]
            vir_dns6 = local["virtual_dns6"]

            self.set_router(vir_dns, is_ipv6=False, is_dynamic=False)
            if self.__enable_ipv6_traffic:
                self.set_router(vir_dns6, is_ipv6=True, is_dynamic=False)

        conn = configs["connection"]

        m = "freenet.lib.crypto.%s" % conn["crypto_module"]
        try:
            self.__tcp_crypto = importlib.import_module(
                "%s.%s_tcp" % (m, conn["crypto_module"]))
            self.__udp_crypto = importlib.import_module(
                "%s.%s_udp" % (m, conn["crypto_module"]))
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        crypto_fpath = "%s/fdslight_etc/%s" % (BASE_DIR,
                                               conn["crypto_configfile"])

        if not os.path.isfile(crypto_fpath):
            print("crypto configfile not exists")
            sys.exit(-1)

        try:
            crypto_configs = proto_utils.load_crypto_configfile(crypto_fpath)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        self.__crypto_configs = crypto_configs

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
        ''''''

        signal.signal(signal.SIGUSR1, self.__set_host_rules)
Пример #3
0
    def init_func(self, debug, configs, enable_nat_module=False):
        self.create_poll()

        self.__configs = configs
        self.__debug = debug

        self.__ip6_dgram = {}
        self.__dgram_proxy = {}
        self.__ip4_fragment = {}
        self.__enable_nat_module = enable_nat_module

        if enable_nat_module: self.__load_nat_module()

        signal.signal(signal.SIGINT, self.__exit)
        signal.signal(signal.SIGUSR1, self.__handle_user_change_signal)

        conn_config = self.__configs["connection"]
        mod_name = "freenet.access.%s" % conn_config["access_module"]

        try:
            access = importlib.import_module(mod_name)
        except ImportError:
            print("cannot found access module")
            sys.exit(-1)

        crypto_mod_name = conn_config["crypto_module"]

        tcp_crypto = "freenet.lib.crypto.%s.%s_tcp" % (crypto_mod_name,
                                                       crypto_mod_name)
        udp_crypto = "freenet.lib.crypto.%s.%s_udp" % (crypto_mod_name,
                                                       crypto_mod_name)

        crypto_configfile = "%s/fdslight_etc/%s" % (
            BASE_DIR, conn_config["crypto_configfile"])
        try:
            self.__tcp_crypto = importlib.import_module(tcp_crypto)
            self.__udp_crypto = importlib.import_module(udp_crypto)
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        if not os.path.isfile(crypto_configfile):
            print("cannot found crypto configfile")
            sys.exit(-1)

        try:
            self.__crypto_configs = proto_utils.load_crypto_configfile(
                crypto_configfile)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        enable_ipv6 = bool(int(conn_config["enable_ipv6"]))

        listen_port = int(conn_config["listen_port"])

        conn_timeout = int(conn_config["conn_timeout"])

        listen_ip = conn_config["listen_ip"]
        listen_ip6 = conn_config["listen_ip6"]

        listen = (
            listen_ip,
            listen_port,
        )
        listen6 = (listen_ip6, listen_port)

        over_http = bool(int(conn_config["tunnel_over_http"]))

        if enable_ipv6:
            self.__tcp6_fileno = self.create_handler(-1,
                                                     tunnels.tcp_tunnel,
                                                     listen6,
                                                     self.__tcp_crypto,
                                                     self.__crypto_configs,
                                                     conn_timeout=conn_timeout,
                                                     is_ipv6=True,
                                                     over_http=over_http)
            self.__udp6_fileno = self.create_handler(-1,
                                                     tunnels.udp_tunnel,
                                                     listen6,
                                                     self.__udp_crypto,
                                                     self.__crypto_configs,
                                                     is_ipv6=True)

        self.__tcp_fileno = self.create_handler(-1,
                                                tunnels.tcp_tunnel,
                                                listen,
                                                self.__tcp_crypto,
                                                self.__crypto_configs,
                                                conn_timeout=conn_timeout,
                                                is_ipv6=False,
                                                over_http=over_http)
        self.__udp_fileno = self.create_handler(-1,
                                                tunnels.udp_tunnel,
                                                listen,
                                                self.__udp_crypto,
                                                self.__crypto_configs,
                                                is_ipv6=False)

        self.__tundev_fileno = self.create_handler(-1, tundev.tundevs,
                                                   self.__DEVNAME)

        self.__raw_fileno = self.create_handler(-1, traffic_pass.ip4_raw_send)

        self.__access = access.access(self)

        self.__mbuf = utils.mbuf()

        nat_config = configs["nat"]

        try:
            self.__ip4_mtu = int(nat_config["p2p_mtu"])
        except KeyError:
            self.__ip4_mtu = 1400

        try:
            self.__ip6_mtu = int(nat_config["p2p6_mtu"])
        except KeyError:
            self.__ip6_mtu = 1280

        dns_addr = nat_config["dns"]
        if utils.is_ipv6_address(dns_addr):
            is_ipv6 = True
        else:
            is_ipv6 = False

        self.__dns_is_ipv6 = is_ipv6
        self.__dns_addr = dns_addr

        self.__dns_fileno = self.create_handler(-1,
                                                dns_proxy.dnsd_proxy,
                                                dns_addr,
                                                is_ipv6=is_ipv6)

        enable_ipv6 = bool(int(nat_config["enable_nat66"]))
        subnet, prefix = utils.extract_subnet_info(
            nat_config["virtual_ip6_subnet"])
        eth_name = nat_config["eth_name"]
        ip6_gw = nat_config["ip6_gw"]

        self.__ip6_udp_cone_nat = bool(
            int(nat_config.get("ip6_udp_cone_nat", 0)))

        if enable_ipv6:
            self.__nat6 = nat.nat((
                subnet,
                prefix,
            ), is_ipv6=True)
            self.__enable_nat6 = True
            self.__config_gateway6(subnet, prefix, ip6_gw, eth_name)

        subnet, prefix = utils.extract_subnet_info(
            nat_config["virtual_ip_subnet"])
        self.__nat4 = nat.nat((
            subnet,
            prefix,
        ), is_ipv6=False)
        self.__config_gateway(subnet, prefix, eth_name)

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
Пример #4
0
    def init_func(self, debug, configs, enable_nat_module=False):
        self.create_poll()

        self.__configs = configs
        self.__debug = debug

        self.__port_mapv4 = port_map.port_map(is_ipv6=False)
        self.__port_mapv6 = port_map.port_map(is_ipv6=True)

        signal.signal(signal.SIGUSR1, self.__sig_handle)

        conn_config = self.__configs["connection"]

        tcp_crypto = "freenet.lib.crypto.noany.noany_tcp"
        udp_crypto = "freenet.lib.crypto.noany.noany_udp"

        crypto_configfile = "%s/fdslight_etc/noany.json" % BASE_DIR

        try:
            self.__tcp_crypto = importlib.import_module(tcp_crypto)
            self.__udp_crypto = importlib.import_module(udp_crypto)
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        if not os.path.isfile(crypto_configfile):
            print("cannot found crypto configfile")
            sys.exit(-1)

        try:
            self.__crypto_configs = proto_utils.load_crypto_configfile(
                crypto_configfile)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        conn_config = self.__configs["connection"]
        mod_name = "freenet.port_map_access.%s" % conn_config["access_module"]

        try:
            access = importlib.import_module(mod_name)
        except ImportError:
            print("cannot found access module %s" % mod_name)
            sys.exit(-1)

        enable_ipv6 = bool(int(conn_config["enable_ipv6"]))
        listen_port = int(conn_config["port"])
        conn_timeout = int(conn_config["conn_timeout"])

        listen_ip = conn_config["listen_ip"]
        listen_ip6 = conn_config["listen_ip6"]

        listen = (
            listen_ip,
            listen_port,
        )
        listen6 = (listen_ip6, listen_port)

        over_http = bool(int(conn_config["tunnel_over_http"]))
        self.__mbuf = utils.mbuf()

        self.__access = access.access(self)

        if enable_ipv6:
            self.__tcp6_fileno = self.create_handler(-1,
                                                     tunnels.tcp_tunnel,
                                                     listen6,
                                                     self.__tcp_crypto,
                                                     self.__crypto_configs,
                                                     conn_timeout=conn_timeout,
                                                     is_ipv6=True,
                                                     over_http=over_http)
            self.__udp6_fileno = self.create_handler(-1,
                                                     tunnels.udp_tunnel,
                                                     listen6,
                                                     self.__udp_crypto,
                                                     self.__crypto_configs,
                                                     is_ipv6=True)
        self.__tcp_fileno = self.create_handler(-1,
                                                tunnels.tcp_tunnel,
                                                listen,
                                                self.__tcp_crypto,
                                                self.__crypto_configs,
                                                conn_timeout=conn_timeout,
                                                is_ipv6=False,
                                                over_http=over_http)
        self.__udp_fileno = self.create_handler(-1,
                                                tunnels.udp_tunnel,
                                                listen,
                                                self.__udp_crypto,
                                                self.__crypto_configs,
                                                is_ipv6=False)

        self.__tundev_fileno = self.create_handler(-1, tundev.tundevs,
                                                   self.__DEVNAME)

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
Пример #5
0
    def init_func(self, mode, debug, configs):
        self.create_poll()

        signal.signal(signal.SIGINT, self.__exit)

        self.__route_timer = timer.timer()
        self.__routes = {}
        self.__configs = configs

        if mode == "local":
            self.__mode = _MODE_LOCAL
        else:
            self.__mode = _MODE_GW

        self.__mbuf = utils.mbuf()
        self.__debug = debug

        self.__tundev_fileno = self.create_handler(-1, tundev.tundevc, self.__DEVNAME)

        public = configs["public"]
        gateway = configs["gateway"]

        self.__enable_ipv6_traffic = bool(int(public["enable_ipv6_traffic"]))

        is_ipv6 = utils.is_ipv6_address(public["remote_dns"])

        if self.__mode == _MODE_GW:
            self.__dns_fileno = self.create_handler(-1, dns_proxy.dnsc_proxy, gateway["dnsserver_bind"], debug=debug,
                                                    server_side=True, is_ipv6=False)
            self.get_handler(self.__dns_fileno).set_parent_dnsserver(public["remote_dns"], is_ipv6=is_ipv6)

            if self.__enable_ipv6_traffic:
                self.__dns_listen6 = self.create_handler(-1, dns_proxy.dnsc_proxy, gateway["dnsserver_bind6"],
                                                         debug=debug, server_side=True, is_ipv6=True)
                self.get_handler(self.__dns_listen6).set_parent_dnsserver(public["remote_dns"], is_ipv6=is_ipv6)
        else:
            self.__dns_fileno = self.create_handler(-1, dns_proxy.dnsc_proxy, public["remote_dns"], debug=debug,
                                                    server_side=False)

        self.__set_host_rules(None, None)

        if self.__mode == _MODE_GW:
            self.__load_kernel_mod()
            udp_global = bool(int(gateway["dgram_global_proxy"]))
            if udp_global:
                self.__dgram_fetch_fileno = self.create_handler(-1, traffic_pass.traffic_read,
                                                                self.__configs["gateway"],
                                                                enable_ipv6=self.__enable_ipv6_traffic)
            ''''''
        else:
            local = configs["local"]
            vir_dns = local["virtual_dns"]
            vir_dns6 = local["virtual_dns6"]

            self.set_route(vir_dns, is_ipv6=False, is_dynamic=False)
            if self.__enable_ipv6_traffic: self.set_route(vir_dns6, is_ipv6=True, is_dynamic=False)

        conn = configs["connection"]

        m = "freenet.lib.crypto.%s" % conn["crypto_module"]
        try:
            self.__tcp_crypto = importlib.import_module("%s.%s_tcp" % (m, conn["crypto_module"]))
            self.__udp_crypto = importlib.import_module("%s.%s_udp" % (m, conn["crypto_module"]))
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        crypto_fpath = "%s/fdslight_etc/%s" % (BASE_DIR, conn["crypto_configfile"])

        if not os.path.isfile(crypto_fpath):
            print("crypto configfile not exists")
            sys.exit(-1)

        try:
            crypto_configs = proto_utils.load_crypto_configfile(crypto_fpath)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        self.__crypto_configs = crypto_configs

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
        ''''''

        signal.signal(signal.SIGUSR1, self.__set_host_rules)
Пример #6
0
    def init_func(self, debug, configs):
        self.create_poll()

        self.__configs = configs
        self.__debug = debug

        self.__ip6_dgram = {}
        self.__dgram_proxy = {}
        self.__ip4_fragment = {}

        signal.signal(signal.SIGINT, self.__exit)

        conn_config = self.__configs["connection"]
        mod_name = "freenet.access.%s" % conn_config["access_module"]

        try:
            access = importlib.import_module(mod_name)
        except ImportError:
            print("cannot found access module")
            sys.exit(-1)

        crypto_mod_name = conn_config["crypto_module"]

        tcp_crypto = "freenet.lib.crypto.%s.%s_tcp" % (crypto_mod_name, crypto_mod_name)
        udp_crypto = "freenet.lib.crypto.%s.%s_udp" % (crypto_mod_name, crypto_mod_name)

        crypto_configfile = "%s/fdslight_etc/%s" % (BASE_DIR, conn_config["crypto_configfile"])

        try:
            self.__tcp_crypto = importlib.import_module(tcp_crypto)
            self.__udp_crypto = importlib.import_module(udp_crypto)
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        if not os.path.isfile(crypto_configfile):
            print("cannot found crypto configfile")
            sys.exit(-1)

        try:
            self.__crypto_configs = proto_utils.load_crypto_configfile(crypto_configfile)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        enable_ipv6 = bool(int(conn_config["enable_ipv6"]))

        listen_port = int(conn_config["listen_port"])

        conn_timeout = int(conn_config["conn_timeout"])

        listen_ip = conn_config["listen_ip"]
        listen_ip6 = conn_config["listen_ip6"]

        listen = (listen_ip, listen_port,)
        listen6 = (listen_ip6, listen_port)

        if enable_ipv6:
            self.__tcp6_fileno = self.create_handler(-1, tunnels.tcp_tunnel, listen6, self.__tcp_crypto,
                                                     self.__crypto_configs, conn_timeout=conn_timeout, is_ipv6=True)
            self.__udp6_fileno = self.create_handler(-1, tunnels.udp_tunnel, listen6, self.__udp_crypto,
                                                     self.__crypto_configs, is_ipv6=True)

        self.__tcp_fileno = self.create_handler(-1, tunnels.tcp_tunnel, listen, self.__tcp_crypto,
                                                self.__crypto_configs, conn_timeout=conn_timeout, is_ipv6=False)
        self.__udp_fileno = self.create_handler(-1, tunnels.udp_tunnel, listen, self.__udp_crypto,
                                                self.__crypto_configs, is_ipv6=False)

        self.__tundev_fileno = self.create_handler(-1, tundev.tundevs, self.__DEVNAME)

        self.__raw_fileno = self.create_handler(-1, traffic_pass.ip4_raw_send)

        self.__access = access.access(self)

        self.__mbuf = utils.mbuf()

        nat_config = configs["nat"]

        try:
            self.__ip4_mtu = int(nat_config["p2p_mtu"])
        except KeyError:
            self.__ip4_mtu = 1400

        try:
            self.__ip6_mtu = int(nat_config["p2p6_mtu"])
        except KeyError:
            self.__ip6_mtu = 1280

        dns_addr = nat_config["dns"]
        if utils.is_ipv6_address(dns_addr):
            is_ipv6 = True
        else:
            is_ipv6 = False

        self.__dns_is_ipv6 = is_ipv6
        self.__dns_addr = dns_addr

        self.__dns_fileno = self.create_handler(-1, dns_proxy.dnsd_proxy, dns_addr, is_ipv6=is_ipv6)

        enable_ipv6 = bool(int(nat_config["enable_nat66"]))
        subnet, prefix = utils.extract_subnet_info(nat_config["virtual_ip6_subnet"])
        eth_name = nat_config["eth_name"]
        ip6_gw = nat_config["ip6_gw"]

        self.__ip6_udp_cone_nat = bool(int(nat_config.get("ip6_udp_cone_nat", 0)))

        if enable_ipv6:
            self.__nat6 = nat.nat((subnet, prefix,), is_ipv6=True)
            self.__enable_nat6 = True
            self.__config_gateway6(subnet, prefix, ip6_gw, eth_name)

        subnet, prefix = utils.extract_subnet_info(nat_config["virtual_ip_subnet"])
        self.__nat4 = nat.nat((subnet, prefix,), is_ipv6=False)
        self.__config_gateway(subnet, prefix, eth_name)

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")
Пример #7
0
    def init_func(self, debug, configs):
        self.create_poll()

        self.__configs = configs
        self.__debug = debug

        self.__ipfragments = {}
        self.__dgram_proxy = {}

        signal.signal(signal.SIGINT, self.__exit)

        conn_config = self.__configs["connection"]
        mod_name = "freenet.access.%s" % conn_config["access_module"]

        try:
            access = importlib.import_module(mod_name)
        except ImportError:
            print("cannot found access module")
            sys.exit(-1)

        crypto_mod_name = conn_config["crypto_module"]

        tcp_crypto = "freenet.lib.crypto.%s.%s_tcp" % (crypto_mod_name, crypto_mod_name)
        udp_crypto = "freenet.lib.crypto.%s.%s_udp" % (crypto_mod_name, crypto_mod_name)

        crypto_configfile = "./fdslight_etc/%s" % conn_config["crypto_configfile"]

        try:
            self.__tcp_crypto = importlib.import_module(tcp_crypto)
            self.__udp_crypto = importlib.import_module(udp_crypto)
        except ImportError:
            print("cannot found tcp or udp crypto module")
            sys.exit(-1)

        if not os.path.isfile(crypto_configfile):
            print("cannot found crypto configfile")
            sys.exit(-1)

        try:
            self.__crypto_configs = proto_utils.load_crypto_configfile(crypto_configfile)
        except:
            print("crypto configfile should be json file")
            sys.exit(-1)

        enable_ipv6 = bool(int(conn_config["enable_ipv6"]))

        tcp_port = int(conn_config["listen_tcp_port"])
        udp_port = int(conn_config["listen_udp_port"])

        conn_timeout = int(conn_config["conn_timeout"])

        listen_ip = conn_config["listen_ip"]
        listen_ip6 = conn_config["listen_ip6"]

        listen_tcp = (listen_ip, tcp_port,)
        listen_udp = (listen_ip, udp_port,)

        listen6_tcp = (listen_ip6, tcp_port,)
        listen6_udp = (listen_ip6, udp_port,)

        if enable_ipv6:
            self.__tcp6_fileno = self.create_handler(
                -1, tunnels.tcp_tunnel,
                listen6_tcp, self.__tcp_crypto, self.__crypto_configs, conn_timeout=conn_timeout, is_ipv6=True
            )
            self.__udp6_fileno = self.create_handler(
                -1, tunnels.udp_tunnel,
                listen6_udp, self.__udp_crypto, self.__crypto_configs, is_ipv6=True
            )

        self.__tcp_fileno = self.create_handler(
            -1, tunnels.tcp_tunnel,
            listen_tcp, self.__tcp_crypto, self.__crypto_configs, conn_timeout=conn_timeout, is_ipv6=False
        )
        self.__udp_fileno = self.create_handler(
            -1, tunnels.udp_tunnel,
            listen_udp, self.__udp_crypto, self.__crypto_configs, is_ipv6=False
        )

        self.__tundev_fileno = self.create_handler(
            -1, tundev.tundevs, self.__DEVNAME
        )

        self.__access = access.access(self)

        self.__mbuf = utils.mbuf()

        nat_config = configs["nat"]

        dns_addr = nat_config["dns"]
        if utils.is_ipv6_address(dns_addr):
            is_ipv6 = True
        else:
            is_ipv6 = False

        self.__dns_fileno = self.create_handler(
            -1, dns_proxy.dnsd_proxy, dns_addr, is_ipv6=is_ipv6
        )

        enable_ipv6 = bool(int(nat_config["enable_nat66"]))
        subnet, prefix = utils.extract_subnet_info(nat_config["virtual_ip6_subnet"])
        eth_name = nat_config["eth_name"]
        ip6_gw = nat_config["ip6_gw"]

        if enable_ipv6:
            self.__nat6 = nat.nat((subnet, prefix,), is_ipv6=True)
            self.__enable_nat6 = True
            self.__config_gateway6(subnet, prefix, ip6_gw, eth_name)

        subnet, prefix = utils.extract_subnet_info(nat_config["virtual_ip_subnet"])
        self.__nat4 = nat.nat((subnet, prefix,), is_ipv6=False)
        self.__config_gateway(subnet, prefix, eth_name)

        if not debug:
            sys.stdout = open(LOG_FILE, "a+")
            sys.stderr = open(ERR_FILE, "a+")