Skip to content

Commit

Permalink
Fix tcp connection not closing correctly
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Jul 16, 2020
1 parent 882065d commit 503eb93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.13
require (
github.com/nknorg/ncp-go v1.0.1
github.com/nknorg/nkn-sdk-go v1.3.0
github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3
github.com/nknorg/nkn-tuna-session v0.1.0
github.com/nknorg/tuna v0.0.0-20200714222241-1d03b8a3603c
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ github.com/nknorg/ncp-go v1.0.1 h1:oJKmcaAcVC1oCJiJ4tDvot7kved8uUGBYXldDHxc8vM=
github.com/nknorg/ncp-go v1.0.1/go.mod h1:LfiwrFlKZAAoMwhCBA959jSzVD8E9RGOH9nyfXkQSfY=
github.com/nknorg/nkn-sdk-go v1.3.0 h1:iT/MqUx7VyqVo3ivz3VIBbB+VvaByld0YrQiVIlfdCI=
github.com/nknorg/nkn-sdk-go v1.3.0/go.mod h1:SeHZ25YcKIXDauhPw/v4XZjprWd+DtLDPNs3/U9/5qE=
github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3 h1:N8Sx6cCtXVpZaROLUW5CAX4Ed0tdqlkqWw3IXyPcC3Y=
github.com/nknorg/nkn-tuna-session v0.0.0-20200716030938-96a9604ca2d3/go.mod h1:yKHEfiZt7xKgfzi1ONoXp1MuXwki7t8gmmmYtOcnYCM=
github.com/nknorg/nkn-tuna-session v0.1.0 h1:SF4G1jbh0H6vP92vN9QJ1h+zEfofzRaSbr4pGs1omNM=
github.com/nknorg/nkn-tuna-session v0.1.0/go.mod h1:yKHEfiZt7xKgfzi1ONoXp1MuXwki7t8gmmmYtOcnYCM=
github.com/nknorg/nkn/v2 v2.0.0-20200703083743-f83cde273fe2 h1:YJL1RuRWLXcjRjm52aPn9JYryS41HBgfQvIVd5kGxZE=
github.com/nknorg/nkn/v2 v2.0.0-20200703083743-f83cde273fe2/go.mod h1:LxKZTpn5VZTAbjsACSFL5nlQAQ4+WQKyIpVZUYopXm4=
github.com/nknorg/nkn/v2 v2.0.2 h1:0bwUFFYkeVO6z+Odi52zHQ6IFs254D8GQfX5pfdfe+E=
Expand Down
10 changes: 2 additions & 8 deletions tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"net"
"strings"
"sync"

"github.com/nknorg/ncp-go"
nkn "github.com/nknorg/nkn-sdk-go"
Expand Down Expand Up @@ -143,17 +142,12 @@ func (t *Tunnel) Start() error {
}

func pipe(a, b net.Conn) {
var wg sync.WaitGroup
wg.Add(2)
go func() {
defer wg.Done()
io.Copy(a, b)
a.Close()
}()
go func() {
defer wg.Done()
io.Copy(b, a)
b.Close()
}()
wg.Wait()
a.Close()
b.Close()
}

0 comments on commit 503eb93

Please sign in to comment.