mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-18 20:49:56 +00:00
Refactor CheckRoutes to return resource IDs for matching source and destination addresses
This commit is contained in:
@@ -367,10 +367,8 @@ func (d *Status) RemovePeerStateRoute(peer string, route string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckRoutes checks for both the source and destination IP addresses in the local peer routes first,
|
||||
// and then in the remote peers' routes. It returns the IP address of the matching peer (as a string)
|
||||
// for source and destination. If a match is found in local peer routes, the local peer IP is returned;
|
||||
// otherwise, the remote peer IP is returned. If no match is found, an empty string is returned for that IP.
|
||||
// CheckRoutes checks if the source and destination addresses are within the same route
|
||||
// and returns the resource ID of the route that contains the addresses
|
||||
func (d *Status) CheckRoutes(src, dst netip.Addr, direction nftypes.Direction) (srcResId string, dstResId string) {
|
||||
d.mux.Lock()
|
||||
d.resIdMux.Lock()
|
||||
@@ -383,6 +381,10 @@ func (d *Status) CheckRoutes(src, dst netip.Addr, direction nftypes.Direction) (
|
||||
} else if route.Contains(dst) {
|
||||
dstResId = resId
|
||||
}
|
||||
|
||||
if srcResId != "" && dstResId != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user