mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
use state_changed as timestamp
This commit is contained in:
@ -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),
|
||||
|
10
backend/testdata/api/neighbor_summary.json
vendored
10
backend/testdata/api/neighbor_summary.json
vendored
@ -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,
|
||||
|
Reference in New Issue
Block a user