diff --git a/backend/sources/birdwatcher/parsers.go b/backend/sources/birdwatcher/parsers.go index 8846ade..e0b8906 100644 --- a/backend/sources/birdwatcher/parsers.go +++ b/backend/sources/birdwatcher/parsers.go @@ -160,19 +160,22 @@ func parseNeighbours(bird ClientResponse, config Config) (api.Neighbours, error) func parseNeighborSummary( bird ClientResponse, config Config, ) (api.Neighbours, error) { - birdNeighbors := bird["neighbours"].([]interface{}) + birdNeighbors := bird["neighbors"].([]interface{}) neighbors := make(api.Neighbours, 0, len(birdNeighbors)) for _, b := range birdNeighbors { n := b.(map[string]interface{}) + + uptime := parseRelativeServerTime(n["state_changed"], config) + // Parse neighbor from response neighbor := &api.Neighbour{ Id: mustString(n["id"], "unknown"), - Address: mustString(n["neighbour"], "unknown"), + Address: mustString(n["neighbor"], "unknown"), Asn: mustInt(n["asn"], 0), State: mustString(n["state"], "unknown"), - Uptime: time.Duration(mustInt(n["uptime"], 0)), + Uptime: uptime, Description: mustString(n["description"], "unknown"), RoutesReceived: mustInt(n["routes_received"], -1), RoutesAccepted: mustInt(n["routes_accepted"], -1), diff --git a/backend/testdata/api/neighbor_summary.json b/backend/testdata/api/neighbor_summary.json index 834e7fb..0857c09 100644 --- a/backend/testdata/api/neighbor_summary.json +++ b/backend/testdata/api/neighbor_summary.json @@ -11,13 +11,13 @@ "orig_ttl" : 0 } }, - "neighbours": [ + "neighbors": [ { "id": "R58_29", - "neighbour": "185.1.58.29", + "neighbor": "185.1.58.29", "asn": 42, "state": "up", - "uptime": 5033318900526, + "state_changed": "2018-07-14 15:08:30", "description": "Test Peer 2001", "routes_received": 161, "routes_accepted": 161, @@ -26,10 +26,10 @@ }, { "id": "R002a_0_1", - "neighbour": "2001:7f8:9e::2a:0:1", + "neighbor": "2001:7f8:9e::2a:0:1", "asn": 23, "state": "start", - "uptime": 7038818900526, + "state_changed": "2018-07-14 15:08:30", "description": "Test Peer 2000", "routes_received": 154, "routes_accepted": 152,