Shorten keepalive key

This commit is contained in:
Francis Nguyen
2020-02-11 19:17:41 -07:00
parent 2082a42527
commit dca1a2b5ae
4 changed files with 66 additions and 66 deletions

View File

@@ -79,12 +79,12 @@ type Node struct {
LastSeen int64
// Leader is a suggestion to Kilo that
// the node wants to lead its segment.
Leader bool
Location string
Name string
Subnet *net.IPNet
WireGuardIP *net.IPNet
WireGuardPersistentKeepAlive int
Leader bool
Location string
Name string
PersistentKeepAlive int
Subnet *net.IPNet
WireGuardIP *net.IPNet
}
// Ready indicates whether or not the node is ready.

View File

@@ -64,14 +64,14 @@ type segment struct {
hostnames []string
// leader is the index of the leader of the segment.
leader int
// persistentKeepAlive is the interval in seconds of the emission
// of keepalive packets to the peer.
persistentKeepAlive int
// privateIPs is a slice of private IPs of all peers in the segment.
privateIPs []net.IP
// 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.
@@ -120,15 +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,
wireGuardPersistentKeepAlive: topoMap[location][leader].WireGuardPersistentKeepAlive,
allowedIPs: allowedIPs,
endpoint: topoMap[location][leader].ExternalIP.IP,
key: topoMap[location][leader].Key,
location: location,
cidrs: cidrs,
hostnames: hostnames,
leader: leader,
privateIPs: privateIPs,
persistentKeepAlive: topoMap[location][leader].PersistentKeepAlive,
})
}
// Sort the Topology segments so the result is stable.
@@ -339,7 +339,7 @@ func (t *Topology) Conf() *wireguard.Conf {
Port: uint32(t.port),
},
PublicKey: s.key,
PersistentKeepalive: s.wireGuardPersistentKeepAlive,
PersistentKeepalive: s.persistentKeepAlive,
}
c.Peers = append(c.Peers, peer)
}