Skip to content

Commit

Permalink
fix: close too many udp conn (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
wencaiwulue authored Feb 19, 2024
1 parent ab510d5 commit 72ddbbe
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/sshvpn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {

func NewTunnelCommand() *cobra.Command {
return &cobra.Command{
Use: "tunnel",
Use: "sshvpn",
Short: "connect to remote network",
Long: `
connect to remote network.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240217121107-1f32a129b698
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240219134652-6e679cc2f189
golang.org/x/crypto v0.18.0
golang.org/x/net v0.20.0
gvisor.dev/gvisor v0.0.0-20230603040744-5c9219dedd33
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240217103841-597023bdeabb h1:aHJJ0W
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240217103841-597023bdeabb/go.mod h1:zQ0OPDSjBv24+nfsWtNcb94fowfjk2i5bBSt1dBIfwE=
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240217121107-1f32a129b698 h1:0qg7Xm5dmb4J8H+0SskgY+/YXXViNVEvtjMJxLvaI5M=
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240217121107-1f32a129b698/go.mod h1:zQ0OPDSjBv24+nfsWtNcb94fowfjk2i5bBSt1dBIfwE=
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240219134652-6e679cc2f189 h1:xsC1bc95FrPIPL45JGPX/MKULg8wQRCBPtHG3TkSgMo=
github.com/wencaiwulue/kubevpn/v2 v2.2.3-0.20240219134652-6e679cc2f189/go.mod h1:zQ0OPDSjBv24+nfsWtNcb94fowfjk2i5bBSt1dBIfwE=
github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand Down
7 changes: 3 additions & 4 deletions pkg/client/udphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ func UDPHandler(s *stack.Stack, device *net.Interface, udpAddr string) func(id s
log.Debugf("[TUN-UDP] Error: can not create endpoint: %v", tErr)
return
}

ctx := context.Background()
c, err := forwardChain.Node().Client.Dial(context.Background(), forwardChain.Node().Addr)
c, err := forwardChain.Node().Client.Dial(ctx, forwardChain.Node().Addr)
if err != nil {
log.Debugf("[TUN-TCP] Error: failed to dial remote conn: %v", err)
return
Expand All @@ -75,9 +74,9 @@ func UDPHandler(s *stack.Stack, device *net.Interface, udpAddr string) func(id s
go func() {
i := config.LPool.Get().([]byte)[:]
defer config.LPool.Put(i[:])
written, err2 := io.CopyBuffer(remote, conn, i)
written, err := io.CopyBuffer(remote, conn, i)
log.Debugf("[TUN-UDP] Debug: write length %d data to remote", written)
errChan <- err2
errChan <- err
}()
go func() {
i := config.LPool.Get().([]byte)[:]
Expand Down

0 comments on commit 72ddbbe

Please sign in to comment.