tinc-gui: Update Node object to correctly parse responses

The application was expecting a different respoonse from tinc
and wouldn't properly it, and thus not start at all.
This commit is contained in:
Martin Weinelt 2015-09-28 05:31:59 +02:00
parent 0c7e0210d9
commit 53333d6d0d

View file

@ -55,31 +55,39 @@ CONTROL = 18
class Node(object): class Node(object):
def __init__(self, args): def __init__(self, args):
self.name = args[0] self.name = args[0]
self.address = args[1] self.id = args[1]
self.port = args[3]
self.cipher = int(args[4]) self.address = args[2]
self.digest = int(args[5]) self.port = args[4]
self.maclength = int(args[6])
self.compression = int(args[7]) self.cipher = int(args[5])
self.options = int(args[8], 0x10) self.digest = int(args[6])
self.status = int(args[9], 0x10) self.maclength = int(args[7])
self.nexthop = args[10]
self.via = args[11] self.compression = int(args[8])
self.distance = int(args[12]) self.options = int(args[9], 0x10)
self.pmtu = int(args[13]) self.status = int(args[10], 0x10)
self.minmtu = int(args[14])
self.maxmtu = int(args[15]) self.nexthop = args[11]
self.last_state_change = float(args[16]) self.via = args[12]
self.distance = int(args[13])
self.pmtu = int(args[14])
self.minmtu = int(args[15])
self.maxmtu = int(args[16])
self.last_state_change = float(args[17])
self.subnets = {} self.subnets = {}
class Edge(object): class Edge(object):
def __init__(self, args): def __init__(self, args):
self.fr = args[0] self.source = args[0]
self.to = args[1] self.sink = args[1]
self.address = args[2] self.address = args[2]
self.port = args[4] self.port = args[4]
self.options = int(args[-2], 16) self.options = int(args[-2], 16)
self.weight = int(args[-1]) self.weight = int(args[-1])
@ -87,13 +95,13 @@ class Edge(object):
class Subnet(object): class Subnet(object):
def __init__(self, args): def __init__(self, args):
if args[0].find('#') >= 0: if args[0].find('#') >= 0:
(address, self.weight) = args[0].split('#', 1) address, self.weight = args[0].split('#', 1)
else: else:
self.weight = 10 self.weight = 10
address = args[0] address = args[0]
if address.find('/') >= 0: if address.find('/') >= 0:
(self.address, self.prefixlen) = address.split('/', 1) self.address, self.prefixlen = address.split('/', 1)
else: else:
self.address = address self.address = address
self.prefixlen = '48' self.prefixlen = '48'
@ -104,11 +112,14 @@ class Subnet(object):
class Connection(object): class Connection(object):
def __init__(self, args): def __init__(self, args):
self.name = args[0] self.name = args[0]
self.address = args[1] self.address = args[1]
self.port = args[3] self.port = args[3]
self.options = int(args[4], 0x10) self.options = int(args[4], 0x10)
self.socket = int(args[5]) self.socket = int(args[5])
self.status = int(args[6], 0x10) self.status = int(args[6], 0x10)
self.weight = 123 self.weight = 123
@ -508,15 +519,15 @@ class EdgesPage(wx.Panel):
for key, edge in vpn.edges.items(): for key, edge in vpn.edges.items():
if self.list.GetItemCount() <= i: if self.list.GetItemCount() <= i:
self.list.InsertStringItem(i, edge.fr) self.list.InsertStringItem(i, edge.source)
else: else:
self.list.SetStringItem(i, 0, edge.fr) self.list.SetStringItem(i, 0, edge.source)
self.list.SetStringItem(i, 1, edge.to) self.list.SetStringItem(i, 1, edge.sink)
self.list.SetStringItem(i, 2, edge.address) self.list.SetStringItem(i, 2, edge.address)
self.list.SetStringItem(i, 3, edge.port) self.list.SetStringItem(i, 3, edge.port)
self.list.SetStringItem(i, 4, format(edge.options, "x")) self.list.SetStringItem(i, 4, format(edge.options, "x"))
self.list.SetStringItem(i, 5, str(edge.weight)) self.list.SetStringItem(i, 5, str(edge.weight))
self.list.itemDataMap[i] = (edge.fr, edge.to, edge.address, edge.port, edge.options, edge.weight) self.list.itemDataMap[i] = (edge.source, edge.sink, edge.address, edge.port, edge.options, edge.weight)
self.list.SetItemData(i, i) self.list.SetItemData(i, i)
i += 1 i += 1