Source-based routing in Golang
|
||
---|---|---|
balancer.go | ||
dialer.go | ||
dialer_hostname_test.go | ||
dialer_integration_test.go | ||
go.mod | ||
go.sum | ||
health.go | ||
health_integration_test.go | ||
interface.go | ||
Makefile | ||
README.md |
Source-based routing in Golang
Consider this routing table:
10.11.70.0/23 dev data0 proto kernel scope link src 10.11.70.42
10.11.70.0/23 dev data1 proto kernel scope link src 10.11.71.42
192.168.123.0/24 dev internal0 proto kernel scope link src 192.168.123.42
192.168.123.0/24 dev internal1 proto kernel scope link src 192.168.123.142
Simple net.Dial
to either 10.11.70.42
or 10.11.71.42
will match the first subnet and be routed via data0.
This problems is usually solved by bonds.
But sometimes you need to invent a bicycle.
Usage
import "git.frostfs.info/TrueCloudLab/multinet"
d, err := multinet.NewDialer(Config{
Subnets: []string{"10.11.70.0/23", "192.168.123.0/24"},
Balancer: multinet.BalancerTypeRoundRobin,
})
if err != nil {
// handle error
}
conn, err := d.DialContext(ctx, "tcp", "10.11.70.42")
if err != nil {
// handle error
}
// do stuff
Updating interface state
Multidialer
exposes UpdateInterface()
method for updating state of a single link.
NetlinkWatcher
can wrap Multidialer
type and perform all updates automatically.
TODO: describe needed capabilities here.