Connect to configuration
This commit is contained in:
parent
8a5dbbe368
commit
2082a42527
@ -263,9 +263,9 @@ func translateNode(node *v1.Node) *mesh.Node {
|
|||||||
if !ok {
|
if !ok {
|
||||||
internalIP = node.ObjectMeta.Annotations[internalIPAnnotationKey]
|
internalIP = node.ObjectMeta.Annotations[internalIPAnnotationKey]
|
||||||
}
|
}
|
||||||
// Set Wireguard PersistentKeepAliveKey.
|
// Set Wireguard PersistentKeepAlive setting for the node.
|
||||||
var wireGuardPersistentKeepAlive int64
|
var wireGuardPersistentKeepAlive int64
|
||||||
if wgKeepAlive, ok := node.ObjectMeta.Annotations[wireGuardIPAnnotationKey]; !ok {
|
if wgKeepAlive, ok := node.ObjectMeta.Annotations[wireGuardPersistentKeepAliveKey]; !ok {
|
||||||
wireGuardPersistentKeepAlive = 0
|
wireGuardPersistentKeepAlive = 0
|
||||||
} else {
|
} else {
|
||||||
if wireGuardPersistentKeepAlive, err = strconv.ParseInt(wgKeepAlive, 10, 64); err != nil {
|
if wireGuardPersistentKeepAlive, err = strconv.ParseInt(wgKeepAlive, 10, 64); err != nil {
|
||||||
@ -297,7 +297,7 @@ func translateNode(node *v1.Node) *mesh.Node {
|
|||||||
// the node's agent has not yet reconciled. In either case, the IP
|
// the node's agent has not yet reconciled. In either case, the IP
|
||||||
// will parse as nil.
|
// will parse as nil.
|
||||||
WireGuardIP: normalizeIP(node.ObjectMeta.Annotations[wireGuardIPAnnotationKey]),
|
WireGuardIP: normalizeIP(node.ObjectMeta.Annotations[wireGuardIPAnnotationKey]),
|
||||||
WireGuardPersistentKeepAlive: wireGuardPersistentKeepAlive,
|
WireGuardPersistentKeepAlive: int(wireGuardPersistentKeepAlive),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ type Node struct {
|
|||||||
Name string
|
Name string
|
||||||
Subnet *net.IPNet
|
Subnet *net.IPNet
|
||||||
WireGuardIP *net.IPNet
|
WireGuardIP *net.IPNet
|
||||||
WireGuardPersistentKeepAlive int64
|
WireGuardPersistentKeepAlive int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ready indicates whether or not the node is ready.
|
// Ready indicates whether or not the node is ready.
|
||||||
|
@ -69,6 +69,9 @@ type segment struct {
|
|||||||
// wireGuardIP is the allocated IP address of the WireGuard
|
// wireGuardIP is the allocated IP address of the WireGuard
|
||||||
// interface on the leader of the segment.
|
// interface on the leader of the segment.
|
||||||
wireGuardIP net.IP
|
wireGuardIP net.IP
|
||||||
|
// wireGuardPersistentKeepAlive is the interval in seconds of the emission
|
||||||
|
// of keepalive packets to the peer.
|
||||||
|
wireGuardPersistentKeepAlive int
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTopology creates a new Topology struct from a given set of nodes and peers.
|
// NewTopology creates a new Topology struct from a given set of nodes and peers.
|
||||||
@ -117,14 +120,15 @@ func NewTopology(nodes map[string]*Node, peers map[string]*Peer, granularity Gra
|
|||||||
privateIPs = append(privateIPs, node.InternalIP.IP)
|
privateIPs = append(privateIPs, node.InternalIP.IP)
|
||||||
}
|
}
|
||||||
t.segments = append(t.segments, &segment{
|
t.segments = append(t.segments, &segment{
|
||||||
allowedIPs: allowedIPs,
|
allowedIPs: allowedIPs,
|
||||||
endpoint: topoMap[location][leader].ExternalIP.IP,
|
endpoint: topoMap[location][leader].ExternalIP.IP,
|
||||||
key: topoMap[location][leader].Key,
|
key: topoMap[location][leader].Key,
|
||||||
location: location,
|
location: location,
|
||||||
cidrs: cidrs,
|
cidrs: cidrs,
|
||||||
hostnames: hostnames,
|
hostnames: hostnames,
|
||||||
leader: leader,
|
leader: leader,
|
||||||
privateIPs: privateIPs,
|
privateIPs: privateIPs,
|
||||||
|
wireGuardPersistentKeepAlive: topoMap[location][leader].WireGuardPersistentKeepAlive,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// Sort the Topology segments so the result is stable.
|
// Sort the Topology segments so the result is stable.
|
||||||
@ -334,7 +338,8 @@ func (t *Topology) Conf() *wireguard.Conf {
|
|||||||
IP: s.endpoint,
|
IP: s.endpoint,
|
||||||
Port: uint32(t.port),
|
Port: uint32(t.port),
|
||||||
},
|
},
|
||||||
PublicKey: s.key,
|
PublicKey: s.key,
|
||||||
|
PersistentKeepalive: s.wireGuardPersistentKeepAlive,
|
||||||
}
|
}
|
||||||
c.Peers = append(c.Peers, peer)
|
c.Peers = append(c.Peers, peer)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user