Skip to content

Commit 42434e7

Browse files
committed
test
1 parent bd1340a commit 42434e7

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

vpn/router.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"net/netip"
66

77
"tailscale.com/wgengine/router"
8+
9+
"github.com/coder/coder/v2/coderd/util/ptr"
810
)
911

1012
func NewRouter(t *Tunnel) router.Router {
@@ -70,7 +72,7 @@ func convertRouterConfig(cfg *router.Config) *NetworkSettingsRequest {
7072
}
7173

7274
return &NetworkSettingsRequest{
73-
Mtu: uint32(cfg.NewMTU),
75+
Mtu: ptr.Ref(uint32(cfg.NewMTU)),
7476
Ipv4Settings: &NetworkSettingsRequest_IPv4Settings{
7577
Addrs: v4LocalAddrs,
7678
IncludedRoutes: v4Routes,
@@ -81,8 +83,8 @@ func convertRouterConfig(cfg *router.Config) *NetworkSettingsRequest {
8183
IncludedRoutes: v6Routes,
8284
ExcludedRoutes: v6ExcludedRoutes,
8385
},
84-
TunnelOverheadBytes: 0, // N/A
85-
TunnelRemoteAddress: "", // N/A
86+
TunnelOverheadBytes: nil, // N/A
87+
TunnelRemoteAddress: nil, // N/A
8688
}
8789
}
8890

vpn/router_internal_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
"github.com/stretchr/testify/require"
88
"tailscale.com/wgengine/router"
9+
10+
"github.com/coder/coder/v2/coderd/util/ptr"
911
)
1012

1113
func TestConvertRouterConfig(t *testing.T) {
@@ -25,7 +27,7 @@ func TestConvertRouterConfig(t *testing.T) {
2527
NewMTU: 1500,
2628
},
2729
expected: &NetworkSettingsRequest{
28-
Mtu: 1500,
30+
Mtu: ptr.Ref(uint32(1500)),
2931
Ipv4Settings: &NetworkSettingsRequest_IPv4Settings{
3032
Addrs: []string{"100.64.0.1/32"},
3133
IncludedRoutes: []*NetworkSettingsRequest_IPv4Settings_IPv4Route{
@@ -62,6 +64,11 @@ func TestConvertRouterConfig(t *testing.T) {
6264
},
6365
},
6466
},
67+
{
68+
name: "Nil",
69+
cfg: nil,
70+
expected: &NetworkSettingsRequest{},
71+
},
6572
}
6673
//nolint:paralleltest // outdated rule
6774
for _, tt := range tests {

vpn/tunnel_internal_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"google.golang.org/protobuf/types/known/timestamppb"
1717
"tailscale.com/util/dnsname"
1818

19+
"github.com/coder/coder/v2/coderd/util/ptr"
1920
"github.com/coder/coder/v2/tailnet"
2021
"github.com/coder/coder/v2/tailnet/proto"
2122
"github.com/coder/coder/v2/testutil"
@@ -245,7 +246,7 @@ func TestTunnel_NetworkSettings(t *testing.T) {
245246
// When: we inform the tunnel of network settings
246247
go func() {
247248
err := tun.ApplyNetworkSettings(ctx, &NetworkSettingsRequest{
248-
Mtu: 1200,
249+
Mtu: ptr.Ref(uint32(1200)),
249250
})
250251
errCh <- err
251252
}()
@@ -317,12 +318,8 @@ func TestUpdater_createPeerUpdate(t *testing.T) {
317318
},
318319
})
319320
require.Len(t, update.UpsertedAgents, 1)
320-
slices.SortFunc(update.UpsertedAgents[0].Fqdn, func(a, b string) int {
321-
return strings.Compare(a, b)
322-
})
323-
slices.SortFunc(update.DeletedAgents[0].Fqdn, func(a, b string) int {
324-
return strings.Compare(a, b)
325-
})
321+
slices.SortFunc(update.UpsertedAgents[0].Fqdn, strings.Compare)
322+
slices.SortFunc(update.DeletedAgents[0].Fqdn, strings.Compare)
326323
require.Equal(t, update, &PeerUpdate{
327324
UpsertedWorkspaces: []*Workspace{
328325
{Id: w1ID[:], Name: "w1", Status: Workspace_Status(proto.Workspace_STARTING)},

vpn/vpn.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ message Agent {
117117
// macOS. It is a request/response message with response NetworkSettingsResponse
118118
message NetworkSettingsRequest {
119119
optional uint32 tunnel_overhead_bytes = 1;
120+
// If zero, the MTU is unchanged. If null, it should be reset.
120121
optional uint32 mtu = 2;
121122

122123
message DNSSettings {

0 commit comments

Comments
 (0)