Esempio n. 1
0
    def cgroup_vpn(self):
        self.kill_dnsmasq()

        if self.tun_bypass is not None:
            dev_bypass = self.tun_bypass
            bypass.create_cgroup(self.net["user"],
                                 self.net["group"],
                                 dev_bypass,
                                 default_int=self.interface)

            if self.tun is not None:
                interface = self.tun

            else:
                interface = self.interface

            interface_bypass = self.tun_bypass
            dns_manager.set_dns("127.0.0.1")
            dns_manager.dnsmasq(interface, "53", self.dns, self.dns_2, "")

        else:
            dev_bypass = self.interface
            dns_manager.set_dns(self.dns, self.dns_2)

        if self.config["bypass"] == 1:
            dns_manager.dnsmasq(dev_bypass, "5354", self.dns_bypass,
                                self.dns_2_bypass, "_bypass")

            bypass.create_cgroup(self.net["user"],
                                 self.net["group"],
                                 dev_bypass,
                                 gw=self.gw,
                                 gw_6=self.gw_6,
                                 default_int=self.interface)
Esempio n. 2
0
    def cgroup_vpn(self):
        self.kill_dnsmasq()
        no_dnsmasq = config.settings["no_dnsmasq"]

        if self.tun_bypass is not None:
            dev_bypass = self.tun_bypass
            bypass.create_cgroup(
                            self.net["user"],
                            self.net["group"],
                            dev_bypass,
                            default_int=self.interface,
                            no_dnsmasq=no_dnsmasq
                            )

            if self.tun is not None:
                interface = self.tun

            else:
                interface = self.interface

            interface_bypass = self.tun_bypass
            if config.settings["dns_off"] == 0:
                dns_manager.set_dns("127.0.0.1")

            if no_dnsmasq == 0:
                dns_manager.dnsmasq(
                                    interface,
                                    "53",
                                    self.dns,
                                    self.dns_2,
                                    ""
                                    )

        else:
            dev_bypass = self.interface
            if config.settings["dns_off"] == 0:
                dns_manager.set_dns(self.dns, self.dns_2)

        if config.settings["bypass"] == 1:
            if no_dnsmasq == 0:
                dns_manager.dnsmasq(
                                    dev_bypass,
                                    "5354",
                                    self.dns_bypass,
                                    self.dns_2_bypass,
                                    "_bypass"
                                    )

            bypass.create_cgroup(
                                self.net["user"],
                                self.net["group"],
                                dev_bypass,
                                gw=self.gw,
                                gw_6=self.gw_6,
                                default_int=self.interface,
                                no_dnsmasq=no_dnsmasq
                                )
Esempio n. 3
0
    def bypass(self, net):
        self.net = net
        #default_routes = self.default_gateway_check()
        self.gw = self.net["gateway"]
        self.gw_6 = self.net["gateway_6"]
        default_interface_4 = self.net["interface"]
        default_interface_6 = self.net["interface_6"]
        no_dnsmasq = config.settings["no_dnsmasq"]

        if self.gw != "None" or self.gw_6 != "None":

            if default_interface_6 != "None":
                self.interface = default_interface_6

            elif default_interface_4 != "None":
                self.interface = default_interface_4

            else:
                self.interface = "None"

            if config.settings["bypass"] == 1:
                bypass.create_cgroup(
                    self.net["user"],
                    self.net["group"],
                    self.interface,
                    gw=self.gw,
                    gw_6=self.gw_6,
                    default_int=self.interface,
                    no_dnsmasq=no_dnsmasq
                    )

                self.kill_dnsmasq()

                #dnsmasq is needed to handle requests from bypass
                if no_dnsmasq == 0:
                    dns_manager.dnsmasq(
                                        self.interface,
                                        "5354",
                                        config.settings["alt_dns1"],
                                        config.settings["alt_dns2"],
                                        "_bypass"
                                        )

            elif config.settings["bypass"] == 0:

                try:
                    bypass.delete_cgroup(self.interface)
                except AttributeError:
                    pass
Esempio n. 4
0
    def bypass(self, net):
        self.net = net
        #default_routes = self.default_gateway_check()
        self.gw = self.net["gateway"]
        self.gw_6 = self.net["gateway_6"]
        default_interface_4 = self.net["interface"]
        default_interface_6 = self.net["interface_6"]

        if self.gw != "None" or self.gw_6 != "None":
            try:

                if default_interface_6 != "None":
                    self.interface = default_interface_6

                elif default_interface_4 != "None":
                    self.interface = default_interface_4

                else:
                    self.interface = "None"

                if self.config["bypass"] == 1:
                    bypass.create_cgroup(self.net["user"],
                                         self.net["group"],
                                         self.interface,
                                         gw=self.gw,
                                         gw_6=self.gw_6,
                                         default_int=self.interface)

                    self.kill_dnsmasq()

                    #dnsmasq is needed to handle requests from bypass
                    dns_manager.dnsmasq(self.interface, "5354",
                                        self.config["alt_dns1"],
                                        self.config["alt_dns2"], "_bypass")

                elif self.config["bypass"] == 0:

                    try:
                        bypass.delete_cgroup(self.interface)
                    except AttributeError:
                        pass

            except KeyError:
                self.logger.warning(
                    'Config file corrupted - bypass option does not exist')
Esempio n. 5
0
    def bypass(self, ug):
        try:
            self.kill_pid(self.dnsmasq_pid)
        except AttributeError:
            pass

        default_gateway = self.default_gateway_check()["gateway"]
        if default_gateway != "None":
            try:
                if self.config["bypass"] == 1:
                    pid = bypass.create_cgroup(ug["user"], ug["group"],
                                               self.default_interface,
                                               default_gateway)
                    self.dnsmasq_pid = (pid, "dnsmasq")
                elif self.config["bypass"] == 0:
                    try:
                        bypass.delete_cgroup(self.default_interface)
                    except AttributeError:
                        pass
            except KeyError:
                self.logger.warning('Could not read all values from  file')