mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
Firezone needs to deterministically handle overlapping CIDR routes. The way we handle this is that more specific routes are preferred over less specific one. In case of an exact overlap, the sorting of the resource ID acts as a tie-breaker: "Smaller" resource IDs preferred over "larger" ones. This ensures that regardless of which order the resources are added / enabled in, Firezone behaves deterministically. In addition to the above rules, existing connections to Gateways always have precedence: In other words, if we are connected to resource A via Gateway 1 and resource B exactly overlaps with A yet needs to be routed to Gateway B and B < A, we still retain resource A in order to not interrupt existing connections. When a connection to a Gateway fails, these mappings are cleaned up. The proptests seeds added in this PR identify a routing mismatch in case a (relayed) connection is cut, followed by adding a non-CIDR resource: `connlib` recalculated the CIDR routes as part of adding the new resource, even though the CIDR resources didn't actually change. This could potentially result in a connection suddenly being routed to a different Gateway despite nothing about that resource changing. To fix this, we add a check for updating the CIDR routes and only perform it in case CIDR resources get changed.
Connlib
Firezone's connectivity library shared by all clients.
Building Connlib
You shouldn't need to build connlib directly; it's typically built as a dependency of one of the other Firezone components. See READMEs in those directories for relevant instructions.