def process(self): self.confips = [] # collect a list of configured vpns for file in os.listdir(self.VPNCONFDIR): m = re.search("^ipsec.vpn-(.*).conf", file) if m: self.confips.append(m.group(1)) for vpn in self.dbag: if vpn == "id": continue local_ip = self.dbag[vpn]['local_public_ip'] dev = CsHelper.get_device(local_ip) if dev == "": logging.error("Request for ipsec to %s not possible because ip is not configured", local_ip) continue CsHelper.start_if_stopped("ipsec") self.configure_iptables(dev, self.dbag[vpn]) self.configure_ipsec(self.dbag[vpn]) # Delete vpns that are no longer in the configuration for ip in self.confips: self.deletevpn(ip)
def process(self): self.confips = [] logging.debug(self.dbag) for public_ip in self.dbag: if public_ip == "id": continue vpnconfig = self.dbag[public_ip] #Enable remote access vpn if vpnconfig['create']: logging.debug("Enabling remote access vpn on " + public_ip) dev = CsHelper.get_device(public_ip) if dev == "": logging.error( "Request for ipsec to %s not possible because ip is not configured", public_ip) continue CsHelper.start_if_stopped("ipsec") self.configure_l2tpIpsec(public_ip, self.dbag[public_ip]) logging.debug("Remote accessvpn data bag %s", self.dbag) self.remoteaccessvpn_iptables(public_ip, self.dbag[public_ip]) CsHelper.execute("ipsec update") CsHelper.execute("service xl2tpd start") CsHelper.execute("ipsec rereadsecrets") else: logging.debug("Disabling remote access vpn .....") #disable remote access vpn CsHelper.execute("ipsec down L2TP-PSK") CsHelper.execute("service xl2tpd stop")
def process(self): self.confips = [] # collect a list of configured vpns for file in os.listdir(self.VPNCONFDIR): m = re.search("^ipsec.vpn-(.*).conf", file) if m: self.confips.append(m.group(1)) for vpn in self.dbag: if vpn == "id": continue local_ip = self.dbag[vpn]['local_public_ip'] dev = CsHelper.get_device(local_ip) if dev == "": logging.error( "Request for ipsec to %s not possible because ip is not configured", local_ip) continue CsHelper.start_if_stopped("ipsec") self.configure_iptables(dev, self.dbag[vpn]) self.configure_ipsec(self.dbag[vpn]) # Delete vpns that are no longer in the configuration for ip in self.confips: self.deletevpn(ip)
def process(self): self.confips = [] logging.debug(self.dbag) for public_ip in self.dbag: if public_ip == "id": continue vpnconfig=self.dbag[public_ip] #Enable remote access vpn if vpnconfig['create']: logging.debug("Enabling remote access vpn on "+ public_ip) dev = CsHelper.get_device(public_ip) if dev == "": logging.error("Request for ipsec to %s not possible because ip is not configured", public_ip) continue CsHelper.start_if_stopped("ipsec") self.configure_l2tpIpsec(public_ip, self.dbag[public_ip]) logging.debug("Remote accessvpn data bag %s", self.dbag) self.remoteaccessvpn_iptables(public_ip, self.dbag[public_ip]) CsHelper.execute("ipsec update") CsHelper.execute("service xl2tpd start") CsHelper.execute("ipsec rereadsecrets") else: logging.debug("Disabling remote access vpn .....") #disable remote access vpn CsHelper.execute("ipsec down L2TP-PSK") CsHelper.execute("service xl2tpd stop")