|
@@ -8,12 +8,13 @@ import (
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/astaxie/beego/logs"
|
|
"github.com/astaxie/beego/logs"
|
|
|
|
+ "github.com/xtaci/kcp-go"
|
|
|
|
+
|
|
"github.com/cnlh/nps/lib/common"
|
|
"github.com/cnlh/nps/lib/common"
|
|
"github.com/cnlh/nps/lib/config"
|
|
"github.com/cnlh/nps/lib/config"
|
|
"github.com/cnlh/nps/lib/conn"
|
|
"github.com/cnlh/nps/lib/conn"
|
|
"github.com/cnlh/nps/lib/crypt"
|
|
"github.com/cnlh/nps/lib/crypt"
|
|
"github.com/cnlh/nps/lib/mux"
|
|
"github.com/cnlh/nps/lib/mux"
|
|
- "github.com/xtaci/kcp-go"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type TRPClient struct {
|
|
type TRPClient struct {
|
|
@@ -165,7 +166,7 @@ func (s *TRPClient) handleChan(src net.Conn) {
|
|
lk.Host = common.FormatAddress(lk.Host)
|
|
lk.Host = common.FormatAddress(lk.Host)
|
|
//if Conn type is http, read the request and log
|
|
//if Conn type is http, read the request and log
|
|
if lk.ConnType == "http" {
|
|
if lk.ConnType == "http" {
|
|
- if targetConn, err := net.Dial(common.CONN_TCP, lk.Host); err != nil {
|
|
|
|
|
|
+ if targetConn, err := net.DialTimeout(common.CONN_TCP, lk.Host, lk.Option.Timeout); err != nil {
|
|
logs.Warn("connect to %s error %s", lk.Host, err.Error())
|
|
logs.Warn("connect to %s error %s", lk.Host, err.Error())
|
|
src.Close()
|
|
src.Close()
|
|
} else {
|
|
} else {
|
|
@@ -189,7 +190,7 @@ func (s *TRPClient) handleChan(src net.Conn) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
//connect to target if conn type is tcp or udp
|
|
//connect to target if conn type is tcp or udp
|
|
- if targetConn, err := net.Dial(lk.ConnType, lk.Host); err != nil {
|
|
|
|
|
|
+ if targetConn, err := net.DialTimeout(lk.ConnType, lk.Host, lk.Option.Timeout); err != nil {
|
|
logs.Warn("connect to %s error %s", lk.Host, err.Error())
|
|
logs.Warn("connect to %s error %s", lk.Host, err.Error())
|
|
src.Close()
|
|
src.Close()
|
|
} else {
|
|
} else {
|