@@ -25,11 +25,12 @@ import (
2525
2626func BenchmarkHotPath (b * testing.B ) {
2727 ca , _ , caKey , _ := cert_test .NewTestCaCert (cert .Version1 , cert .Curve_CURVE25519 , time .Now (), time .Now ().Add (10 * time .Minute ), nil , nil , []string {})
28- myControl , myVpnIpNet , _ , _ := newSimpleServer (cert .Version1 , ca , caKey , "me" , "10.128.0.1/24" , nil )
28+ myControl , myVpnIpNet , myUdpAddr , _ := newSimpleServer (cert .Version1 , ca , caKey , "me" , "10.128.0.1/24" , nil )
2929 theirControl , theirVpnIpNet , theirUdpAddr , _ := newSimpleServer (cert .Version1 , ca , caKey , "them" , "10.128.0.2/24" , nil )
3030
3131 // Put their info in our lighthouse
3232 myControl .InjectLightHouseAddr (theirVpnIpNet [0 ].Addr (), theirUdpAddr )
33+ theirControl .InjectLightHouseAddr (myVpnIpNet [0 ].Addr (), myUdpAddr )
3334
3435 // Start the servers
3536 myControl .Start ()
@@ -38,13 +39,49 @@ func BenchmarkHotPath(b *testing.B) {
3839 r := router .NewR (b , myControl , theirControl )
3940 r .CancelFlowLogs ()
4041
42+ assertTunnel (b , myVpnIpNet [0 ].Addr (), theirVpnIpNet [0 ].Addr (), myControl , theirControl , r )
43+ b .ResetTimer ()
44+
45+ for n := 0 ; n < b .N ; n ++ {
46+ myControl .InjectTunUDPPacket (theirVpnIpNet [0 ].Addr (), 80 , myVpnIpNet [0 ].Addr (), 80 , []byte ("Hi from me" ))
47+ _ = r .RouteForAllUntilTxTun (theirControl )
48+ }
49+
50+ myControl .Stop ()
51+ theirControl .Stop ()
52+ }
53+
54+ func BenchmarkHotPathRelay (b * testing.B ) {
55+ ca , _ , caKey , _ := cert_test .NewTestCaCert (cert .Version1 , cert .Curve_CURVE25519 , time .Now (), time .Now ().Add (10 * time .Minute ), nil , nil , []string {})
56+ myControl , myVpnIpNet , _ , _ := newSimpleServer (cert .Version1 , ca , caKey , "me " , "10.128.0.1/24" , m {"relay" : m {"use_relays" : true }})
57+ relayControl , relayVpnIpNet , relayUdpAddr , _ := newSimpleServer (cert .Version1 , ca , caKey , "relay " , "10.128.0.128/24" , m {"relay" : m {"am_relay" : true }})
58+ theirControl , theirVpnIpNet , theirUdpAddr , _ := newSimpleServer (cert .Version1 , ca , caKey , "them " , "10.128.0.2/24" , m {"relay" : m {"use_relays" : true }})
59+
60+ // Teach my how to get to the relay and that their can be reached via the relay
61+ myControl .InjectLightHouseAddr (relayVpnIpNet [0 ].Addr (), relayUdpAddr )
62+ myControl .InjectRelays (theirVpnIpNet [0 ].Addr (), []netip.Addr {relayVpnIpNet [0 ].Addr ()})
63+ relayControl .InjectLightHouseAddr (theirVpnIpNet [0 ].Addr (), theirUdpAddr )
64+
65+ // Build a router so we don't have to reason who gets which packet
66+ r := router .NewR (b , myControl , relayControl , theirControl )
67+ r .CancelFlowLogs ()
68+
69+ // Start the servers
70+ myControl .Start ()
71+ relayControl .Start ()
72+ theirControl .Start ()
73+
74+ assertTunnel (b , theirVpnIpNet [0 ].Addr (), myVpnIpNet [0 ].Addr (), theirControl , myControl , r )
75+ b .ResetTimer ()
76+
4177 for n := 0 ; n < b .N ; n ++ {
4278 myControl .InjectTunUDPPacket (theirVpnIpNet [0 ].Addr (), 80 , myVpnIpNet [0 ].Addr (), 80 , []byte ("Hi from me" ))
4379 _ = r .RouteForAllUntilTxTun (theirControl )
4480 }
4581
4682 myControl .Stop ()
4783 theirControl .Stop ()
84+ relayControl .Stop ()
4885}
4986
5087func TestGoodHandshake (t * testing.T ) {
0 commit comments