Skip to content

Commit

Permalink
idle timeout parsed from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Mar 21, 2020
1 parent 020a3b6 commit 0629b1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ func (c *Client) Run() error {
listener, err := net.Listen("tcp", c.config.LocalAddr.String())
//TODO
ctx, _ := context.WithCancel(context.Background())
if c.config.TCP.MuxIdleTimeout > 0 {
go c.checkAndCloseIdleMuxClient()
}
c.ctx = ctx
if err != nil {
return err
Expand All @@ -231,9 +234,6 @@ func (c *Client) Run() error {
logger.Error("error occured when accpeting conn", err)
continue
}
if c.config.TCP.MuxIdleTimeout > 0 {
go c.checkAndCloseIdleMuxClient()
}
if c.config.TCP.Mux {
go c.handleMuxConn(conn)
} else {
Expand Down
5 changes: 1 addition & 4 deletions proxy/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io/ioutil"
"net"
"testing"
"time"

"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/conf"
Expand Down Expand Up @@ -39,7 +38,6 @@ func TestClient(t *testing.T) {
config: config,
}
c.Run()
time.Sleep(time.Hour)
}

func TestMuxClient(t *testing.T) {
Expand All @@ -66,14 +64,14 @@ func TestMuxClient(t *testing.T) {
},
Hash: map[string]string{common.SHA224String(password): password},
}
config.TCP.MuxIdleTimeout = 1
config.TLS.CertPool = pool
config.TLS.SNI = "localhost"

c := Client{
config: config,
}
c.Run()
time.Sleep(time.Hour)
}

func TestClientWithJSON(t *testing.T) {
Expand All @@ -86,5 +84,4 @@ func TestClientWithJSON(t *testing.T) {
config: config,
}
client.Run()
time.Sleep(time.Hour)
}

0 comments on commit 0629b1b

Please sign in to comment.