(id string, manager routemanager.Manager, operationName string, routeOperation func(routes []route.NetID, allRoutes []route.NetID) error)
| 13 | ) |
| 14 | |
| 15 | func executeRouteToggle(id string, manager routemanager.Manager, |
| 16 | operationName string, |
| 17 | routeOperation func(routes []route.NetID, allRoutes []route.NetID) error) error { |
| 18 | netID := route.NetID(id) |
| 19 | routes := []route.NetID{netID} |
| 20 | |
| 21 | routesMap := manager.GetClientRoutesWithNetID() |
| 22 | routes = route.ExpandV6ExitPairs(routes, routesMap) |
| 23 | |
| 24 | log.Debugf("%s with ids: %v", operationName, routes) |
| 25 | |
| 26 | if err := routeOperation(routes, maps.Keys(routesMap)); err != nil { |
| 27 | log.Debugf("error when %s: %s", operationName, err) |
| 28 | return fmt.Errorf("error %s: %w", operationName, err) |
| 29 | } |
| 30 | |
| 31 | manager.TriggerSelection(manager.GetClientRoutes()) |
| 32 | |
| 33 | return nil |
| 34 | } |
| 35 | |
| 36 | type routeCommand interface { |
| 37 | toggleRoute() error |
no test coverage detected