Merge branch 'develop' of ssh://github.com/alice-lg/alice-lg into develop
This commit is contained in:
commit
4c1909a659
@ -16,77 +16,58 @@ func (src *SingleTableBirdwatcher) fetchReceivedRoutes(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
neighborID string,
|
neighborID string,
|
||||||
) (*api.Meta, api.Routes, error) {
|
) (*api.Meta, api.Routes, error) {
|
||||||
// Query birdwatcher
|
res, err := src.client.GetEndpoint(ctx, "/routes/protocol/"+neighborID)
|
||||||
bird, err := src.client.GetJSON(ctx, "/routes/protocol/"+neighborID)
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
meta, routes, err := parseRoutesResponseStream(res.Body, src.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use api status from first request
|
return meta, routes, nil
|
||||||
apiStatus, err := parseAPIStatus(bird, src.config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the routes
|
|
||||||
received, err := parseRoutes(bird, src.config, true)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("WARNING Could not retrieve received routes:", err)
|
|
||||||
log.Println("Is the 'routes_protocol' module active in birdwatcher?")
|
|
||||||
return apiStatus, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiStatus, received, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (src *SingleTableBirdwatcher) fetchFilteredRoutes(
|
func (src *SingleTableBirdwatcher) fetchFilteredRoutes(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
neighborID string,
|
neighborID string,
|
||||||
) (*api.Meta, api.Routes, error) {
|
) (*api.Meta, api.Routes, error) {
|
||||||
// Query birdwatcher
|
res, err := src.client.GetEndpoint(ctx, "/routes/filtered/"+neighborID)
|
||||||
bird, err := src.client.GetJSON(ctx, "/routes/filtered/"+neighborID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use api status from first request
|
|
||||||
apiStatus, err := parseAPIStatus(bird, src.config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the routes
|
|
||||||
filtered, err := parseRoutes(bird, src.config, true)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("WARNING Could not retrieve filtered routes:", err)
|
log.Println("WARNING Could not retrieve filtered routes:", err)
|
||||||
log.Println("Is the 'routes_filtered' module active in birdwatcher?")
|
log.Println("Is the 'routes_filtered' module active in birdwatcher?")
|
||||||
return apiStatus, nil, err
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
meta, routes, err := parseRoutesResponseStream(res.Body, src.config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiStatus, filtered, nil
|
return meta, routes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (src *SingleTableBirdwatcher) fetchNotExportedRoutes(
|
func (src *SingleTableBirdwatcher) fetchNotExportedRoutes(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
neighborID string,
|
neighborID string,
|
||||||
) (*api.Meta, api.Routes, error) {
|
) (*api.Meta, api.Routes, error) {
|
||||||
// Query birdwatcher
|
res, err := src.client.GetEndpoint(ctx, "/routes/noexport/"+neighborID)
|
||||||
bird, _ := src.client.GetJSON(ctx, "/routes/noexport/"+neighborID)
|
if err != nil {
|
||||||
|
log.Println("WARNING Could not retrieve routes not exported:", err)
|
||||||
|
log.Println("Is the 'routes_noexport' module active in birdwatcher?")
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
// Use api status from first request
|
meta, routes, err := parseRoutesResponseStream(res.Body, src.config)
|
||||||
apiStatus, err := parseAPIStatus(bird, src.config)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the routes
|
return meta, routes, nil
|
||||||
notExported, err := parseRoutes(bird, src.config, true)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("WARNING Could not retrieve routes not exported:", err)
|
|
||||||
log.Println("Is the 'routes_noexport' module active in birdwatcher?")
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiStatus, notExported, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoutesRequired is a specialized request to fetch:
|
// RoutesRequired is a specialized request to fetch:
|
||||||
@ -316,40 +297,38 @@ func (src *SingleTableBirdwatcher) AllRoutes(
|
|||||||
) (*api.RoutesResponse, error) {
|
) (*api.RoutesResponse, error) {
|
||||||
// First fetch all routes from the master table
|
// First fetch all routes from the master table
|
||||||
mainTable := src.GenericBirdwatcher.config.MainTable
|
mainTable := src.GenericBirdwatcher.config.MainTable
|
||||||
birdImported, err := src.client.GetJSON(ctx, "/routes/table/"+mainTable)
|
|
||||||
|
// Routes received
|
||||||
|
res, err := src.client.GetEndpoint(ctx, "/routes/table/"+mainTable)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
meta, birdImported, err := parseRoutesResponseStream(res.Body, src.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then fetch all filtered routes from the master table
|
// Routes filtered
|
||||||
birdFiltered, err := src.client.GetJSON(ctx, "/routes/table/"+mainTable+"/filtered")
|
res, err = src.client.GetEndpoint(ctx, "/routes/table/"+mainTable+"/filtered")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
// Use api status from second request
|
_, birdFiltered, err := parseRoutesResponseStream(res.Body, src.config)
|
||||||
apiStatus, err := parseAPIStatus(birdFiltered, src.config)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
response := &api.RoutesResponse{
|
response := &api.RoutesResponse{
|
||||||
Response: api.Response{
|
Response: api.Response{
|
||||||
Meta: apiStatus,
|
Meta: meta,
|
||||||
},
|
},
|
||||||
|
Imported: birdImported,
|
||||||
|
Filtered: birdFiltered,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the routes
|
|
||||||
imported := parseRoutesData(birdImported["routes"].([]interface{}), src.config, false)
|
|
||||||
// Sort routes for deterministic ordering
|
|
||||||
// sort.Sort(imported)
|
|
||||||
response.Imported = imported
|
|
||||||
|
|
||||||
// Parse the routes
|
|
||||||
filtered := parseRoutesData(birdFiltered["routes"].([]interface{}), src.config, false)
|
|
||||||
// Sort routes for deterministic ordering
|
|
||||||
// sort.Sort(filtered)
|
|
||||||
response.Filtered = filtered
|
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user