|
@@ -20,7 +20,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func BenchmarkHotPath(b *testing.B) {
|
|
func BenchmarkHotPath(b *testing.B) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, _, _, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, _, _, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|
|
@@ -44,7 +44,7 @@ func BenchmarkHotPath(b *testing.B) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestGoodHandshake(t *testing.T) {
|
|
func TestGoodHandshake(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|
|
@@ -95,7 +95,7 @@ func TestGoodHandshake(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestWrongResponderHandshake(t *testing.T) {
|
|
func TestWrongResponderHandshake(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
// The IPs here are chosen on purpose:
|
|
// The IPs here are chosen on purpose:
|
|
// The current remote handling will sort by preference, public, and then lexically.
|
|
// The current remote handling will sort by preference, public, and then lexically.
|
|
@@ -164,7 +164,7 @@ func TestStage1Race(t *testing.T) {
|
|
// This tests ensures that two hosts handshaking with each other at the same time will allow traffic to flow
|
|
// This tests ensures that two hosts handshaking with each other at the same time will allow traffic to flow
|
|
// But will eventually collapse down to a single tunnel
|
|
// But will eventually collapse down to a single tunnel
|
|
|
|
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|
|
@@ -241,7 +241,7 @@ func TestStage1Race(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestUncleanShutdownRaceLoser(t *testing.T) {
|
|
func TestUncleanShutdownRaceLoser(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|
|
@@ -290,7 +290,7 @@ func TestUncleanShutdownRaceLoser(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestUncleanShutdownRaceWinner(t *testing.T) {
|
|
func TestUncleanShutdownRaceWinner(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|
|
@@ -341,7 +341,7 @@ func TestUncleanShutdownRaceWinner(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestRelays(t *testing.T) {
|
|
func TestRelays(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, _, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
myControl, myVpnIpNet, _, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
@@ -372,7 +372,7 @@ func TestRelays(t *testing.T) {
|
|
|
|
|
|
func TestStage1RaceRelays(t *testing.T) {
|
|
func TestStage1RaceRelays(t *testing.T) {
|
|
//NOTE: this is a race between me and relay resulting in a full tunnel from me to them via relay
|
|
//NOTE: this is a race between me and relay resulting in a full tunnel from me to them via relay
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
@@ -421,7 +421,7 @@ func TestStage1RaceRelays(t *testing.T) {
|
|
|
|
|
|
func TestStage1RaceRelays2(t *testing.T) {
|
|
func TestStage1RaceRelays2(t *testing.T) {
|
|
//NOTE: this is a race between me and relay resulting in a full tunnel from me to them via relay
|
|
//NOTE: this is a race between me and relay resulting in a full tunnel from me to them via relay
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, _ := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
@@ -508,7 +508,7 @@ func TestStage1RaceRelays2(t *testing.T) {
|
|
////TODO: assert hostmaps
|
|
////TODO: assert hostmaps
|
|
}
|
|
}
|
|
func TestRehandshakingRelays(t *testing.T) {
|
|
func TestRehandshakingRelays(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, _, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
myControl, myVpnIpNet, _, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 1}, m{"relay": m{"use_relays": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, relayConfig := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
relayControl, relayVpnIpNet, relayUdpAddr, relayConfig := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 128}, m{"relay": m{"am_relay": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
@@ -538,7 +538,111 @@ func TestRehandshakingRelays(t *testing.T) {
|
|
// When I update the certificate for the relay, both me and them will have 2 host infos for the relay,
|
|
// When I update the certificate for the relay, both me and them will have 2 host infos for the relay,
|
|
// and the main host infos will not have any relay state to handle the me<->relay<->them tunnel.
|
|
// and the main host infos will not have any relay state to handle the me<->relay<->them tunnel.
|
|
r.Log("Renew relay certificate and spin until me and them sees it")
|
|
r.Log("Renew relay certificate and spin until me and them sees it")
|
|
- _, _, myNextPrivKey, myNextPEM := newTestCert(ca, caKey, "relay", time.Now(), time.Now().Add(5*time.Minute), relayVpnIpNet, nil, []string{"new group"})
|
|
|
|
|
|
+ _, _, myNextPrivKey, myNextPEM := NewTestCert(ca, caKey, "relay", time.Now(), time.Now().Add(5*time.Minute), relayVpnIpNet, nil, []string{"new group"})
|
|
|
|
+
|
|
|
|
+ caB, err := ca.MarshalToPEM()
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ relayConfig.Settings["pki"] = m{
|
|
|
|
+ "ca": string(caB),
|
|
|
|
+ "cert": string(myNextPEM),
|
|
|
|
+ "key": string(myNextPrivKey),
|
|
|
|
+ }
|
|
|
|
+ rc, err := yaml.Marshal(relayConfig.Settings)
|
|
|
|
+ assert.NoError(t, err)
|
|
|
|
+ relayConfig.ReloadConfigString(string(rc))
|
|
|
|
+
|
|
|
|
+ for {
|
|
|
|
+ r.Log("Assert the tunnel works between myVpnIpNet and relayVpnIpNet")
|
|
|
|
+ assertTunnel(t, myVpnIpNet.IP, relayVpnIpNet.IP, myControl, relayControl, r)
|
|
|
|
+ c := myControl.GetHostInfoByVpnIp(iputil.Ip2VpnIp(relayVpnIpNet.IP), false)
|
|
|
|
+ if len(c.Cert.Details.Groups) != 0 {
|
|
|
|
+ // We have a new certificate now
|
|
|
|
+ r.Log("Certificate between my and relay is updated!")
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ time.Sleep(time.Second)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for {
|
|
|
|
+ r.Log("Assert the tunnel works between theirVpnIpNet and relayVpnIpNet")
|
|
|
|
+ assertTunnel(t, theirVpnIpNet.IP, relayVpnIpNet.IP, theirControl, relayControl, r)
|
|
|
|
+ c := theirControl.GetHostInfoByVpnIp(iputil.Ip2VpnIp(relayVpnIpNet.IP), false)
|
|
|
|
+ if len(c.Cert.Details.Groups) != 0 {
|
|
|
|
+ // We have a new certificate now
|
|
|
|
+ r.Log("Certificate between their and relay is updated!")
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ time.Sleep(time.Second)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ r.Log("Assert the relay tunnel still works")
|
|
|
|
+ assertTunnel(t, theirVpnIpNet.IP, myVpnIpNet.IP, theirControl, myControl, r)
|
|
|
|
+ r.RenderHostmaps("working hostmaps", myControl, relayControl, theirControl)
|
|
|
|
+ // We should have two hostinfos on all sides
|
|
|
|
+ for len(myControl.GetHostmap().Indexes) != 2 {
|
|
|
|
+ t.Logf("Waiting for myControl hostinfos (%v != 2) to get cleaned up from lack of use...", len(myControl.GetHostmap().Indexes))
|
|
|
|
+ r.Log("Assert the relay tunnel still works")
|
|
|
|
+ assertTunnel(t, theirVpnIpNet.IP, myVpnIpNet.IP, theirControl, myControl, r)
|
|
|
|
+ r.Log("yupitdoes")
|
|
|
|
+ time.Sleep(time.Second)
|
|
|
|
+ }
|
|
|
|
+ t.Logf("myControl hostinfos got cleaned up!")
|
|
|
|
+ for len(theirControl.GetHostmap().Indexes) != 2 {
|
|
|
|
+ t.Logf("Waiting for theirControl hostinfos (%v != 2) to get cleaned up from lack of use...", len(theirControl.GetHostmap().Indexes))
|
|
|
|
+ r.Log("Assert the relay tunnel still works")
|
|
|
|
+ assertTunnel(t, theirVpnIpNet.IP, myVpnIpNet.IP, theirControl, myControl, r)
|
|
|
|
+ r.Log("yupitdoes")
|
|
|
|
+ time.Sleep(time.Second)
|
|
|
|
+ }
|
|
|
|
+ t.Logf("theirControl hostinfos got cleaned up!")
|
|
|
|
+ for len(relayControl.GetHostmap().Indexes) != 2 {
|
|
|
|
+ t.Logf("Waiting for relayControl hostinfos (%v != 2) to get cleaned up from lack of use...", len(relayControl.GetHostmap().Indexes))
|
|
|
|
+ r.Log("Assert the relay tunnel still works")
|
|
|
|
+ assertTunnel(t, theirVpnIpNet.IP, myVpnIpNet.IP, theirControl, myControl, r)
|
|
|
|
+ r.Log("yupitdoes")
|
|
|
|
+ time.Sleep(time.Second)
|
|
|
|
+ }
|
|
|
|
+ t.Logf("relayControl hostinfos got cleaned up!")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func TestRehandshakingRelaysPrimary(t *testing.T) {
|
|
|
|
+ // This test is the same as TestRehandshakingRelays but one of the terminal types is a primary swap winner
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
+ myControl, myVpnIpNet, _, _ := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 128}, m{"relay": m{"use_relays": true}})
|
|
|
|
+ relayControl, relayVpnIpNet, relayUdpAddr, relayConfig := newSimpleServer(ca, caKey, "relay ", net.IP{10, 0, 0, 1}, m{"relay": m{"am_relay": true}})
|
|
|
|
+ theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them ", net.IP{10, 0, 0, 2}, m{"relay": m{"use_relays": true}})
|
|
|
|
+
|
|
|
|
+ // Teach my how to get to the relay and that their can be reached via the relay
|
|
|
|
+ myControl.InjectLightHouseAddr(relayVpnIpNet.IP, relayUdpAddr)
|
|
|
|
+ myControl.InjectRelays(theirVpnIpNet.IP, []net.IP{relayVpnIpNet.IP})
|
|
|
|
+ relayControl.InjectLightHouseAddr(theirVpnIpNet.IP, theirUdpAddr)
|
|
|
|
+
|
|
|
|
+ // Build a router so we don't have to reason who gets which packet
|
|
|
|
+ r := router.NewR(t, myControl, relayControl, theirControl)
|
|
|
|
+ defer r.RenderFlow()
|
|
|
|
+
|
|
|
|
+ // Start the servers
|
|
|
|
+ myControl.Start()
|
|
|
|
+ relayControl.Start()
|
|
|
|
+ theirControl.Start()
|
|
|
|
+
|
|
|
|
+ t.Log("Trigger a handshake from me to them via the relay")
|
|
|
|
+ myControl.InjectTunUDPPacket(theirVpnIpNet.IP, 80, 80, []byte("Hi from me"))
|
|
|
|
+
|
|
|
|
+ p := r.RouteForAllUntilTxTun(theirControl)
|
|
|
|
+ r.Log("Assert the tunnel works")
|
|
|
|
+ assertUdpPacket(t, []byte("Hi from me"), p, myVpnIpNet.IP, theirVpnIpNet.IP, 80, 80)
|
|
|
|
+ r.RenderHostmaps("working hostmaps", myControl, relayControl, theirControl)
|
|
|
|
+
|
|
|
|
+ // When I update the certificate for the relay, both me and them will have 2 host infos for the relay,
|
|
|
|
+ // and the main host infos will not have any relay state to handle the me<->relay<->them tunnel.
|
|
|
|
+ r.Log("Renew relay certificate and spin until me and them sees it")
|
|
|
|
+ _, _, myNextPrivKey, myNextPEM := NewTestCert(ca, caKey, "relay", time.Now(), time.Now().Add(5*time.Minute), relayVpnIpNet, nil, []string{"new group"})
|
|
|
|
|
|
caB, err := ca.MarshalToPEM()
|
|
caB, err := ca.MarshalToPEM()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -611,7 +715,7 @@ func TestRehandshakingRelays(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestRehandshaking(t *testing.T) {
|
|
func TestRehandshaking(t *testing.T) {
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, myConfig := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 2}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, myConfig := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, theirConfig := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, theirConfig := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 1}, nil)
|
|
|
|
|
|
@@ -633,7 +737,7 @@ func TestRehandshaking(t *testing.T) {
|
|
r.RenderHostmaps("Starting hostmaps", myControl, theirControl)
|
|
r.RenderHostmaps("Starting hostmaps", myControl, theirControl)
|
|
|
|
|
|
r.Log("Renew my certificate and spin until their sees it")
|
|
r.Log("Renew my certificate and spin until their sees it")
|
|
- _, _, myNextPrivKey, myNextPEM := newTestCert(ca, caKey, "me", time.Now(), time.Now().Add(5*time.Minute), myVpnIpNet, nil, []string{"new group"})
|
|
|
|
|
|
+ _, _, myNextPrivKey, myNextPEM := NewTestCert(ca, caKey, "me", time.Now(), time.Now().Add(5*time.Minute), myVpnIpNet, nil, []string{"new group"})
|
|
|
|
|
|
caB, err := ca.MarshalToPEM()
|
|
caB, err := ca.MarshalToPEM()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -707,7 +811,7 @@ func TestRehandshaking(t *testing.T) {
|
|
func TestRehandshakingLoser(t *testing.T) {
|
|
func TestRehandshakingLoser(t *testing.T) {
|
|
// The purpose of this test is that the race loser renews their certificate and rehandshakes. The final tunnel
|
|
// The purpose of this test is that the race loser renews their certificate and rehandshakes. The final tunnel
|
|
// Should be the one with the new certificate
|
|
// Should be the one with the new certificate
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, myConfig := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 2}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, myConfig := newSimpleServer(ca, caKey, "me ", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, theirConfig := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, theirConfig := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 1}, nil)
|
|
|
|
|
|
@@ -733,7 +837,7 @@ func TestRehandshakingLoser(t *testing.T) {
|
|
r.RenderHostmaps("Starting hostmaps", myControl, theirControl)
|
|
r.RenderHostmaps("Starting hostmaps", myControl, theirControl)
|
|
|
|
|
|
r.Log("Renew their certificate and spin until mine sees it")
|
|
r.Log("Renew their certificate and spin until mine sees it")
|
|
- _, _, theirNextPrivKey, theirNextPEM := newTestCert(ca, caKey, "them", time.Now(), time.Now().Add(5*time.Minute), theirVpnIpNet, nil, []string{"their new group"})
|
|
|
|
|
|
+ _, _, theirNextPrivKey, theirNextPEM := NewTestCert(ca, caKey, "them", time.Now(), time.Now().Add(5*time.Minute), theirVpnIpNet, nil, []string{"their new group"})
|
|
|
|
|
|
caB, err := ca.MarshalToPEM()
|
|
caB, err := ca.MarshalToPEM()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -808,7 +912,7 @@ func TestRaceRegression(t *testing.T) {
|
|
// This test forces stage 1, stage 2, stage 1 to be received by me from them
|
|
// This test forces stage 1, stage 2, stage 1 to be received by me from them
|
|
// We had a bug where we were not finding the duplicate handshake and responding to the final stage 1 which
|
|
// We had a bug where we were not finding the duplicate handshake and responding to the final stage 1 which
|
|
// caused a cross-linked hostinfo
|
|
// caused a cross-linked hostinfo
|
|
- ca, _, caKey, _ := newTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
|
|
|
|
+ ca, _, caKey, _ := NewTestCaCert(time.Now(), time.Now().Add(10*time.Minute), []*net.IPNet{}, []*net.IPNet{}, []string{})
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
myControl, myVpnIpNet, myUdpAddr, _ := newSimpleServer(ca, caKey, "me", net.IP{10, 0, 0, 1}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
theirControl, theirVpnIpNet, theirUdpAddr, _ := newSimpleServer(ca, caKey, "them", net.IP{10, 0, 0, 2}, nil)
|
|
|
|
|