Connect to configuration

This commit is contained in:
Francis Nguyen
2020-02-10 21:36:54 -07:00
parent 8a5dbbe368
commit 2082a42527
3 changed files with 18 additions and 13 deletions

View File

@@ -84,7 +84,7 @@ type Node struct {
Name string
Subnet *net.IPNet
WireGuardIP *net.IPNet
WireGuardPersistentKeepAlive int64
WireGuardPersistentKeepAlive int
}
// Ready indicates whether or not the node is ready.

View File

@@ -69,6 +69,9 @@ type segment struct {
// wireGuardIP is the allocated IP address of the WireGuard
// interface on the leader of the segment.
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.
@@ -117,14 +120,15 @@ func NewTopology(nodes map[string]*Node, peers map[string]*Peer, granularity Gra
privateIPs = append(privateIPs, node.InternalIP.IP)
}
t.segments = append(t.segments, &segment{
allowedIPs: allowedIPs,
endpoint: topoMap[location][leader].ExternalIP.IP,
key: topoMap[location][leader].Key,
location: location,
cidrs: cidrs,
hostnames: hostnames,
leader: leader,
privateIPs: privateIPs,
allowedIPs: allowedIPs,
endpoint: topoMap[location][leader].ExternalIP.IP,
key: topoMap[location][leader].Key,
location: location,
cidrs: cidrs,
hostnames: hostnames,
leader: leader,
privateIPs: privateIPs,
wireGuardPersistentKeepAlive: topoMap[location][leader].WireGuardPersistentKeepAlive,
})
}
// Sort the Topology segments so the result is stable.
@@ -334,7 +338,8 @@ func (t *Topology) Conf() *wireguard.Conf {
IP: s.endpoint,
Port: uint32(t.port),
},
PublicKey: s.key,
PublicKey: s.key,
PersistentKeepalive: s.wireGuardPersistentKeepAlive,
}
c.Peers = append(c.Peers, peer)
}