Add annotated keepalive value to peer functions

This commit is contained in:
Francis Nguyen 2020-02-12 21:58:08 -07:00
parent 331c225c36
commit 1f8e06b911
2 changed files with 69 additions and 56 deletions

View File

@ -368,6 +368,7 @@ func (t *Topology) AsPeer() *wireguard.Peer {
IP: s.endpoint,
Port: uint32(t.port),
},
PersistentKeepalive: s.persistentKeepalive,
PublicKey: s.key,
}
}
@ -384,6 +385,7 @@ func (t *Topology) PeerConf(name string) *wireguard.Conf {
IP: s.endpoint,
Port: uint32(t.port),
},
PersistentKeepalive: s.persistentKeepalive,
PublicKey: s.key,
}
c.Peers = append(c.Peers, peer)

View File

@ -45,6 +45,7 @@ func setup(t *testing.T) (map[string]*Node, map[string]*Peer, []byte, uint32) {
Location: "1",
Subnet: &net.IPNet{IP: net.ParseIP("10.2.1.0"), Mask: net.CIDRMask(24, 32)},
Key: []byte("key1"),
PersistentKeepalive: 25,
},
"b": {
Name: "b",
@ -124,6 +125,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -160,6 +162,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -196,6 +199,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -232,6 +236,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -278,6 +283,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -324,6 +330,7 @@ func TestNewTopology(t *testing.T) {
cidrs: []*net.IPNet{nodes["a"].Subnet},
hostnames: []string{"a"},
privateIPs: []net.IP{nodes["a"].InternalIP.IP},
persistentKeepalive: nodes["a"].PersistentKeepalive,
wireGuardIP: w1,
},
{
@ -1027,6 +1034,7 @@ AllowedIPs = 10.5.0.3/24
[Peer]
PublicKey = key1
Endpoint = 10.1.0.1:51820
PersistentKeepalive = 25
AllowedIPs = 10.2.1.0/24, 192.168.0.1/32, 10.4.0.1/32
[Peer]
@ -1051,6 +1059,7 @@ AllowedIPs = 10.5.0.3/24
[Peer]
PublicKey = key1
Endpoint = 10.1.0.1:51820
PersistentKeepalive = 25
AllowedIPs = 10.2.1.0/24, 192.168.0.1/32, 10.4.0.1/32
[Peer]
@ -1104,6 +1113,7 @@ AllowedIPs = 10.5.0.3/24
[Peer]
PublicKey = key1
Endpoint = 10.1.0.1:51820
PersistentKeepalive = 25
AllowedIPs = 10.2.1.0/24, 192.168.0.1/32, 10.4.0.1/32
[Peer]
@ -1133,6 +1143,7 @@ AllowedIPs = 10.5.0.3/24
[Peer]
PublicKey = key1
Endpoint = 10.1.0.1:51820
PersistentKeepalive = 25
AllowedIPs = 10.2.1.0/24, 192.168.0.1/32, 10.4.0.1/32
[Peer]