pkg/mesh/mesh.go: ignore Kilo IP during discovery
This ensures that Kilo will not select an IP assigned to the Kilo interface when discovering public and private IPs. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
parent
e7855825cf
commit
95c0143b1a
@ -108,15 +108,6 @@ func New(backend Backend, enc encapsulation.Encapsulator, granularity Granularit
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to query netlink for CNI device: %v", err)
|
return nil, fmt.Errorf("failed to query netlink for CNI device: %v", err)
|
||||||
}
|
}
|
||||||
privateIP, publicIP, err := getIP(hostname, enc.Index(), cniIndex)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to find public IP: %v", err)
|
|
||||||
}
|
|
||||||
ifaces, err := interfacesForIP(privateIP)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to find interface for private IP: %v", err)
|
|
||||||
}
|
|
||||||
privIface := ifaces[0].Index
|
|
||||||
var kiloIface int
|
var kiloIface int
|
||||||
if createIface {
|
if createIface {
|
||||||
kiloIface, _, err = wireguard.New(iface)
|
kiloIface, _, err = wireguard.New(iface)
|
||||||
@ -130,6 +121,15 @@ func New(backend Backend, enc encapsulation.Encapsulator, granularity Granularit
|
|||||||
}
|
}
|
||||||
kiloIface = link.Attrs().Index
|
kiloIface = link.Attrs().Index
|
||||||
}
|
}
|
||||||
|
privateIP, publicIP, err := getIP(hostname, kiloIface, enc.Index(), cniIndex)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to find public IP: %v", err)
|
||||||
|
}
|
||||||
|
ifaces, err := interfacesForIP(privateIP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to find interface for private IP: %v", err)
|
||||||
|
}
|
||||||
|
privIface := ifaces[0].Index
|
||||||
if enc.Strategy() != encapsulation.Never {
|
if enc.Strategy() != encapsulation.Never {
|
||||||
if err := enc.Init(privIface); err != nil {
|
if err := enc.Init(privIface); err != nil {
|
||||||
return nil, fmt.Errorf("failed to initialize encapsulator: %v", err)
|
return nil, fmt.Errorf("failed to initialize encapsulator: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user