LOL. i am a silly ninny.

https://github.com/svinota/pyroute2/issues/703
This commit is contained in:
brent s. 2020-05-10 05:17:53 -04:00
parent 24ebe9082b
commit 68092a514a
Signed by: bts
GPG Key ID: 8C004C2F93481F6B

View File

@ -8,7 +8,6 @@ import socket
## ##
import requests import requests
import requests.auth import requests.auth
from pyroute2 import IPDB
from pyroute2 import IPRoute from pyroute2 import IPRoute




@ -72,12 +71,12 @@ class TunnelBroker(object):
if not self.ipr: if not self.ipr:
self.ipr = IPRoute() self.ipr = IPRoute()
self.ipr.link('add', self.ipr.link('add',
ifname = 'sit_he-{0}'.format(self.tun_id), ifname = 'he-{0}'.format(self.tun_id),
kind = 'sit', kind = 'sit',
ipip_local = self.my_ip, sit_local = self.my_ip,
ipip_remote = self.server, sit_remote = self.server,
ipip_ttl = 255) sit_ttl = 255)
self.iface_idx = self.ipr.link_lookup(ifname = 'sit_he-{0}'.format(self.tun_id))[0] self.iface_idx = self.ipr.link_lookup(ifname = 'he-{0}'.format(self.tun_id))[0]
self.ipr.link('set', index = self.iface_idx, state = 'up', mtu = 1480) self.ipr.link('set', index = self.iface_idx, state = 'up', mtu = 1480)
for a in self.addrs: for a in self.addrs:
self.ipr.addr('add', self.ipr.addr('add',
@ -92,7 +91,7 @@ class TunnelBroker(object):
def stop(self): def stop(self):
if not self.ipr: if not self.ipr:
self.ipr = IPRoute() self.ipr = IPRoute()
self.iface_idx = self.ipr.link_lookup(ifname = 'sit_he-{0}'.format(self.tun_id))[0] self.iface_idx = self.ipr.link_lookup(ifname = 'he-{0}'.format(self.tun_id))[0]
self.ipr.link('set', index = self.iface_idx, state = 'down') self.ipr.link('set', index = self.iface_idx, state = 'down')
self.ipr.route('del', dst = '::', mask = 0, oif = self.iface_idx, family = socket.AF_INET6) self.ipr.route('del', dst = '::', mask = 0, oif = self.iface_idx, family = socket.AF_INET6)
self.ipr.link('set', index = self.iface_idx, state = 'down') self.ipr.link('set', index = self.iface_idx, state = 'down')
@ -143,15 +142,14 @@ def parseArgs():
args.add_argument('oper', args.add_argument('oper',
metavar = 'OPERATION', metavar = 'OPERATION',
choices = ('update', 'start', 'stop'), choices = ('update', 'start', 'stop'),
help = ('The operation to perform. "update" is performed automatically by "start", ' help = ('The operation to perform ("start", "stop", or "update"). "update" is performed '
'but otherwise will just update the IPv4 address on record at tunnelbroker')) 'automatically by "start", but otherwise will just update the IPv4 address on record '
'at tunnelbroker'))
return(args) return(args)




def main(): def main():
args = parseArgs().parse_args() args = parseArgs().parse_args()
import pprint
pprint.pprint(vars(args))
tb = TunnelBroker(**vars(args)) tb = TunnelBroker(**vars(args))
if args.oper == 'start': if args.oper == 'start':
tb.start() tb.start()