Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cba296c

Browse files
committed
fix goleak
1 parent 411536a commit cba296c

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ replace github.com/tcnksm/go-httpstat => github.com/kylecarbs/go-httpstat v0.0.0
4040

4141
// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
4242
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
43-
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20230206232023-2d8652e2964c
44-
45-
replace golang.zx2c4.com/wireguard => github.com/coder/wireguard-go v0.0.0-20230206223559-7bd7dc31300a
43+
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20230208230335-91b5d109b142
4644

4745
// Switch to our fork that imports fixes from http://github.com/tailscale/ssh.
4846
// See: https://github.com/coder/coder/issues/3371
@@ -160,7 +158,7 @@ require (
160158
golang.org/x/text v0.6.0
161159
golang.org/x/tools v0.4.1-0.20221208213631-3f74d914ae6d
162160
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
163-
golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c
161+
golang.zx2c4.com/wireguard v0.0.0-20230207233929-ebbd4a433088
164162
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b
165163
google.golang.org/api v0.103.0
166164
google.golang.org/grpc v1.52.3

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ github.com/coder/retry v1.3.0 h1:5lAAwt/2Cm6lVmnfBY7sOMXcBOwcwJhmV5QGSELIVWY=
368368
github.com/coder/retry v1.3.0/go.mod h1:tXuRgZgWjUnU5LZPT4lJh4ew2elUhexhlnXzrJWdyFY=
369369
github.com/coder/ssh v0.0.0-20220811105153-fcea99919338 h1:tN5GKFT68YLVzJoA8AHuiMNJ0qlhoD3pGN3JY9gxSko=
370370
github.com/coder/ssh v0.0.0-20220811105153-fcea99919338/go.mod h1:ZSS+CUoKHDrqVakTfTWUlKSr9MtMFkC4UvtQKD7O914=
371-
github.com/coder/tailscale v1.1.1-0.20230206232023-2d8652e2964c h1:0DagYyLcOiPLbqjDcpEUBcuAorJR+AurzlYp2usDoTc=
372-
github.com/coder/tailscale v1.1.1-0.20230206232023-2d8652e2964c/go.mod h1:qRwWrKmrcq+Irbtu2vJIinViqfifgQk5cZL+U6wVCDI=
371+
github.com/coder/tailscale v1.1.1-0.20230208230335-91b5d109b142 h1:YQqRjPEkY1LmE3M0MXE+0RUuRN819GK/PWQKZUC3Uxo=
372+
github.com/coder/tailscale v1.1.1-0.20230208230335-91b5d109b142/go.mod h1:qRwWrKmrcq+Irbtu2vJIinViqfifgQk5cZL+U6wVCDI=
373373
github.com/coder/terraform-provider-coder v0.6.11 h1:xdzopnSgy6bMBQlIkAgyyF0m6C3HzEQiF9DnHYpbIFU=
374374
github.com/coder/terraform-provider-coder v0.6.11/go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY=
375375
github.com/coder/wireguard-go v0.0.0-20230206223559-7bd7dc31300a h1:UKFEQxrsi0RoUYU1zPXg9uxZmDSZjTmbxrkDDT0jK4A=
@@ -2574,6 +2574,8 @@ golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3j
25742574
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
25752575
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
25762576
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
2577+
golang.zx2c4.com/wireguard v0.0.0-20230207233929-ebbd4a433088 h1:AterY3udavhM90Dum0CUGAD5ZuYahpmBuYCPT3Pwe3A=
2578+
golang.zx2c4.com/wireguard v0.0.0-20230207233929-ebbd4a433088/go.mod h1:whfbyDBt09xhCYQWtO2+3UVjlaq6/9hDZrjg2ZE6SyA=
25772579
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b h1:9JncmKXcUwE918my+H6xmjBdhK2jM/UTUNXxhRG1BAk=
25782580
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b/go.mod h1:yp4gl6zOlnDGOZeWeDfMwQcsdOIQnMdhuPx9mwwWBL4=
25792581
golang.zx2c4.com/wireguard/windows v0.5.3 h1:On6j2Rpn3OEMXqBq00QEDC7bWSZrPIHKIus8eIuExIE=

tailnet/conn.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ func NewConn(options *Options) (*Conn, error) {
149149
return nil, xerrors.New("get wireguard internals")
150150
}
151151

152-
connStats := connstats.NewStatistics(0, 0, nil)
153-
// stats.TestExtract()
154-
155-
tunDevice.SetStatistics(connStats)
156-
157152
// Update the keys for the magic connection!
158153
err = magicConn.SetPrivateKey(nodePrivateKey)
159154
if err != nil {
@@ -206,7 +201,6 @@ func NewConn(options *Options) (*Conn, error) {
206201
LocalAddrs: netMap.Addresses,
207202
},
208203
wireguardEngine: wireguardEngine,
209-
trafficStats: connStats,
210204
}
211205
wireguardEngine.SetStatusCallback(func(s *wgengine.Status, err error) {
212206
server.logger.Debug(context.Background(), "wireguard status", slog.F("status", s), slog.F("err", err))
@@ -542,9 +536,11 @@ func (c *Conn) Close() error {
542536
_ = c.wireguardMonitor.Close()
543537
_ = c.tunDevice.Close()
544538
c.wireguardEngine.Close()
545-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
546-
defer cancel()
547-
_ = c.trafficStats.Shutdown(ctx)
539+
if c.trafficStats != nil {
540+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
541+
defer cancel()
542+
_ = c.trafficStats.Shutdown(ctx)
543+
}
548544
return nil
549545
}
550546

0 commit comments

Comments
 (0)