From 5568376be32d85290a7b0971c2c827dcd17178ce Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sat, 28 Jun 2008 01:50:39 -0300 Subject: [PATCH 1/1] Use ip command to configure VPN networks in vpn service (closes #34) --- services/vpn/handler.py | 15 ++++++--------- services/vpn/templates/tinc-up | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/services/vpn/handler.py b/services/vpn/handler.py index a628f79..89dfac7 100644 --- a/services/vpn/handler.py +++ b/services/vpn/handler.py @@ -18,28 +18,25 @@ __all__ = ('VpnHandler',) class Vpn(Sequence): - def __init__(self, name, connect_to, local_ip, mask, + def __init__(self, name, connect_to, local_addr, public_key=None, private_key=None): self.name = name self.connect_to = connect_to - self.local_ip = local_ip - self.mask = mask + self.local_addr = local_addr self.public_key = public_key self.private_key = private_key self.hosts = dict() self._delete = False def as_tuple(self): - return (self.name, self.connect_to, self.local_ip, self.mask, + return (self.name, self.connect_to, self.local_addr, self.public_key, self.private_key) - def update(self, connect_to=None, local_ip=None, mask=None): + def update(self, connect_to=None, local_addr=None): if connect_to is not None: self.connect_to = connect_to - if local_ip is not None: - self.local_ip = local_ip - if mask is not None: - self.mask = mask + if local_addr is not None: + self.local_addr = local_addr class VpnHandler(Restorable, ConfigWriter, diff --git a/services/vpn/templates/tinc-up b/services/vpn/templates/tinc-up index 282a7a1..5276570 100644 --- a/services/vpn/templates/tinc-up +++ b/services/vpn/templates/tinc-up @@ -1,2 +1,2 @@ #!/bin/sh -ifconfig $INTERFACE ${vpn.local_ip} netmask ${vpn.mask} +ip addr add ${vpn.local_addr} dev $INTERFACE -- 2.43.0