From 606696328911cf09a82d2dfcf50c57ded0c27832 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Sun, 16 Jun 2019 19:59:21 +0200 Subject: [PATCH] parse ip address in babel library correct --- respond/daemon/neighbours.go | 9 +++++---- respond/daemon/nodeinfo.go | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/respond/daemon/neighbours.go b/respond/daemon/neighbours.go index 3dc4234..e1ddf98 100644 --- a/respond/daemon/neighbours.go +++ b/respond/daemon/neighbours.go @@ -2,6 +2,7 @@ package respondd import ( "errors" + "net" "github.com/Vivena/babelweb2/parser" @@ -35,10 +36,10 @@ func (d *Daemon) updateNeighbours(iface string, resp *data.ResponseData) { return nil } if t.Data["up"].(bool) { - addr := t.Data["ipv6"].(string) + addr := t.Data["ipv6"].(net.IP) resp.Neighbours.Babel[string(t.Field)] = data.BabelNeighbours{ Protocol: "babel", - LinkLocalAddress: addr, + LinkLocalAddress: addr.String(), Neighbours: make(map[string]data.BabelLink), } } @@ -53,7 +54,7 @@ func (d *Daemon) updateNeighbours(iface string, resp *data.ResponseData) { if !ok { return errors.New("neighbour without if") } - addr, ok := t.Data["address"].(string) + addr, ok := t.Data["address"].(net.IP) if !ok { return errors.New("neighbour without address") } @@ -63,7 +64,7 @@ func (d *Daemon) updateNeighbours(iface string, resp *data.ResponseData) { TXCost: int(t.Data["txcost"].(uint64)), Cost: int(t.Data["cost"].(uint64)), } - bIfname.Neighbours[addr] = link + bIfname.Neighbours[addr.String()] = link return nil } return errors.New("ifname not found during parsing") diff --git a/respond/daemon/nodeinfo.go b/respond/daemon/nodeinfo.go index 15d3374..283b980 100644 --- a/respond/daemon/nodeinfo.go +++ b/respond/daemon/nodeinfo.go @@ -102,7 +102,8 @@ func (d *Daemon) updateNodeinfo(iface string, resp *data.ResponseData) { return nil } if t.Data["up"].(bool) { - addr := t.Data["ipv6"].(string) + addrIP := t.Data["ipv6"].(net.IP) + addr := addrIP.String() meshBabel.Interfaces.Tunnel = append(meshBabel.Interfaces.Tunnel, addr) resp.Nodeinfo.Network.Addresses = append(resp.Nodeinfo.Network.Addresses, addr) }