all: some optimization

pull/12/head
fatedier 9 years ago
parent 45c21b2705
commit 52f99bbc00

@ -3,7 +3,7 @@ language: go
go: go:
- 1.4.2 - 1.4.2
- 1.5.1 - 1.5.3
install: install:
- make - make

@ -28,64 +28,98 @@ import (
"frp/utils/log" "frp/utils/log"
) )
var connection *conn.Conn = nil
var heartBeatTimer *time.Timer = nil
func ControlProcess(cli *client.ProxyClient, wait *sync.WaitGroup) { func ControlProcess(cli *client.ProxyClient, wait *sync.WaitGroup) {
defer wait.Done() defer wait.Done()
msgSendChan := make(chan interface{}, 1024)
c, err := loginToServer(cli) c, err := loginToServer(cli)
if err != nil { if err != nil {
log.Error("ProxyName [%s], connect to server failed!", cli.Name) log.Error("ProxyName [%s], connect to server failed!", cli.Name)
return return
} }
connection = c defer c.Close()
defer connection.Close()
go heartbeatSender(c, msgSendChan)
go msgSender(cli, c, msgSendChan)
msgReader(cli, c, msgSendChan)
close(msgSendChan)
}
// loop for reading messages from frpc after control connection is established
func msgReader(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface{}) error {
// for heartbeat
var heartbeatTimeout bool = false
timer := time.AfterFunc(time.Duration(client.HeartBeatTimeout)*time.Second, func() {
heartbeatTimeout = true
c.Close()
log.Error("ProxyName [%s], heartbeatRes from frps timeout", cli.Name)
})
defer timer.Stop()
for { for {
// ignore response content now buf, err := c.ReadLine()
content, err := connection.ReadLine() if err == io.EOF || c == nil || c.IsClosed() {
if err == io.EOF || nil == connection || connection.IsClosed() { c.Close()
log.Debug("ProxyName [%s], server close this control conn", cli.Name) log.Warn("ProxyName [%s], frps close this control conn!", cli.Name)
var sleepTime time.Duration = 1 var delayTime time.Duration = 1
// loop until connect to server // loop until reconnect to frps
for { for {
log.Debug("ProxyName [%s], try to reconnect to server[%s:%d]...", cli.Name, client.ServerAddr, client.ServerPort) log.Info("ProxyName [%s], try to reconnect to frps [%s:%d]...", cli.Name, client.ServerAddr, client.ServerPort)
tmpConn, err := loginToServer(cli) c, err = loginToServer(cli)
if err == nil { if err == nil {
connection.Close() go heartbeatSender(c, msgSendChan)
connection = tmpConn
break break
} }
if sleepTime < 60 { if delayTime < 60 {
sleepTime = sleepTime * 2 delayTime = delayTime * 2
} }
time.Sleep(sleepTime * time.Second) time.Sleep(delayTime * time.Second)
} }
continue
} else if err != nil { } else if err != nil {
log.Warn("ProxyName [%s], read from server error, %v", cli.Name, err) log.Warn("ProxyName [%s], read from frps error: %v", cli.Name, err)
continue continue
} }
clientCtlRes := &msg.ClientCtlRes{} ctlRes := &msg.ControlRes{}
if err := json.Unmarshal([]byte(content), clientCtlRes); err != nil { if err := json.Unmarshal([]byte(buf), &ctlRes); err != nil {
log.Warn("Parse err: %v : %s", err, content) log.Warn("ProxyName [%s], parse msg from frps error: %v : %s", cli.Name, err, buf)
continue continue
} }
if consts.SCHeartBeatRes == clientCtlRes.GeneralRes.Code {
if heartBeatTimer != nil { switch ctlRes.Type {
log.Debug("Client rcv heartbeat response") case consts.HeartbeatRes:
heartBeatTimer.Reset(time.Duration(client.HeartBeatTimeout) * time.Second) log.Debug("ProxyName [%s], receive heartbeat response", cli.Name)
} else { timer.Reset(time.Duration(client.HeartBeatTimeout) * time.Second)
log.Error("heartBeatTimer is nil") case consts.NoticeUserConn:
} log.Debug("ProxyName [%s], new user connection", cli.Name)
continue cli.StartTunnel(client.ServerAddr, client.ServerPort)
default:
log.Warn("ProxyName [%s}, unsupport msgType [%d]", cli.Name, ctlRes.Type)
}
}
return nil
}
// loop for sending messages from channel to frps
func msgSender(cli *client.ProxyClient, c *conn.Conn, msgSendChan chan interface{}) {
for {
msg, ok := <-msgSendChan
if !ok {
break
} }
cli.StartTunnel(client.ServerAddr, client.ServerPort) buf, _ := json.Marshal(msg)
err := c.Write(string(buf) + "\n")
if err != nil {
log.Warn("ProxyName [%s], write to client error, proxy exit", cli.Name)
c.Close()
break
}
} }
} }
@ -96,8 +130,8 @@ func loginToServer(cli *client.ProxyClient) (c *conn.Conn, err error) {
return return
} }
req := &msg.ClientCtlReq{ req := &msg.ControlReq{
Type: consts.CtlConn, Type: consts.NewCtlConn,
ProxyName: cli.Name, ProxyName: cli.Name,
Passwd: cli.Passwd, Passwd: cli.Passwd,
} }
@ -115,53 +149,31 @@ func loginToServer(cli *client.ProxyClient) (c *conn.Conn, err error) {
} }
log.Debug("ProxyName [%s], read [%s]", cli.Name, res) log.Debug("ProxyName [%s], read [%s]", cli.Name, res)
clientCtlRes := &msg.ClientCtlRes{} ctlRes := &msg.ControlRes{}
if err = json.Unmarshal([]byte(res), &clientCtlRes); err != nil { if err = json.Unmarshal([]byte(res), &ctlRes); err != nil {
log.Error("ProxyName [%s], format server response error, %v", cli.Name, err) log.Error("ProxyName [%s], format server response error, %v", cli.Name, err)
return return
} }
if clientCtlRes.Code != 0 { if ctlRes.Code != 0 {
log.Error("ProxyName [%s], start proxy error, %s", cli.Name, clientCtlRes.Msg) log.Error("ProxyName [%s], start proxy error, %s", cli.Name, ctlRes.Msg)
return c, fmt.Errorf("%s", clientCtlRes.Msg) return c, fmt.Errorf("%s", ctlRes.Msg)
} }
go startHeartBeat(c) log.Debug("ProxyName [%s], connect to server [%s:%d] success!", cli.Name, client.ServerAddr, client.ServerPort)
log.Debug("ProxyName [%s], connect to server[%s:%d] success!", cli.Name, client.ServerAddr, client.ServerPort)
return return
} }
func startHeartBeat(c *conn.Conn) { func heartbeatSender(c *conn.Conn, msgSendChan chan interface{}) {
f := func() { heartbeatReq := &msg.ControlReq{
log.Error("HeartBeat timeout!") Type: consts.HeartbeatReq,
if c != nil {
c.Close()
}
}
heartBeatTimer = time.AfterFunc(time.Duration(client.HeartBeatTimeout)*time.Second, f)
defer heartBeatTimer.Stop()
clientCtlReq := &msg.ClientCtlReq{
Type: consts.CSHeartBeatReq,
ProxyName: "",
Passwd: "",
} }
request, err := json.Marshal(clientCtlReq) log.Info("Start to send heartbeat to frps")
if err != nil {
log.Warn("Serialize clientCtlReq err! Err: %v", err)
}
log.Debug("Start to send heartbeat")
for { for {
time.Sleep(time.Duration(client.HeartBeatInterval) * time.Second) time.Sleep(time.Duration(client.HeartBeatInterval) * time.Second)
if c != nil && !c.IsClosed() { if c != nil && !c.IsClosed() {
log.Debug("Send heartbeat to server") log.Debug("Send heartbeat to server")
err = c.Write(string(request) + "\n") msgSendChan <- heartbeatReq
if err != nil {
log.Error("Send hearbeat to server failed! Err:%v", err)
continue
}
} else { } else {
break break
} }

@ -33,87 +33,162 @@ func ProcessControlConn(l *conn.Listener) {
if err != nil { if err != nil {
return return
} }
log.Debug("Get one new conn, %v", c.GetRemoteAddr()) log.Debug("Get new connection, %v", c.GetRemoteAddr())
go controlWorker(c) go controlWorker(c)
} }
} }
// connection from every client and server // connection from every client and server
func controlWorker(c *conn.Conn) { func controlWorker(c *conn.Conn) {
// the first message is from client to server // if login message type is NewWorkConn, don't close this connection
// if error, close connection var closeFlag bool = true
res, err := c.ReadLine() var s *server.ProxyServer
defer func() {
if closeFlag {
c.Close()
if s != nil {
s.Close()
}
}
}()
// get login message
buf, err := c.ReadLine()
if err != nil { if err != nil {
log.Warn("Read error, %v", err) log.Warn("Read error, %v", err)
return return
} }
log.Debug("get: %s", res) log.Debug("Get msg from frpc: %s", buf)
clientCtlReq := &msg.ClientCtlReq{} cliReq := &msg.ControlReq{}
clientCtlRes := &msg.ClientCtlRes{} if err := json.Unmarshal([]byte(buf), &cliReq); err != nil {
if err := json.Unmarshal([]byte(res), &clientCtlReq); err != nil { log.Warn("Parse msg from frpc error: %v : %s", err, buf)
log.Warn("Parse err: %v : %s", err, res)
return return
} }
// check // do login when type is NewCtlConn or NewWorkConn
succ, info, needRes := checkProxy(clientCtlReq, c) ret, info := doLogin(cliReq, c)
if !succ { s, ok := server.ProxyServers[cliReq.ProxyName]
clientCtlRes.Code = 1 if !ok {
clientCtlRes.Msg = info log.Warn("ProxyName [%s] is not exist", cliReq.ProxyName)
return
} }
// if login type is NewWorkConn, nothing will be send to frpc
if needRes { if cliReq.Type != consts.NewWorkConn {
defer c.Close() cliRes := &msg.ControlRes{
Type: consts.NewCtlConnRes,
buf, _ := json.Marshal(clientCtlRes) Code: ret,
err = c.Write(string(buf) + "\n") Msg: info,
}
byteBuf, _ := json.Marshal(cliRes)
err = c.Write(string(byteBuf) + "\n")
if err != nil { if err != nil {
log.Warn("Write error, %v", err) log.Warn("ProxyName [%s], write to client error, proxy exit", s.Name)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
return return
} }
} else { } else {
// work conn, just return closeFlag = false
return return
} }
// other messages is from server to client // create a channel for sending messages
s, ok := server.ProxyServers[clientCtlReq.ProxyName] msgSendChan := make(chan interface{}, 1024)
if !ok { go msgSender(s, c, msgSendChan)
log.Warn("ProxyName [%s] is not exist", clientCtlReq.ProxyName) go noticeUserConn(s, msgSendChan)
return
}
// read control msg from client // loop for reading control messages from frpc and deal with different types
go readControlMsgFromClient(s, c) msgReader(s, c, msgSendChan)
serverCtlReq := &msg.ClientCtlReq{} close(msgSendChan)
serverCtlReq.Type = consts.WorkConn log.Info("ProxyName [%s], I'm dead!", s.Name)
return
}
// when frps get one new user connection, send NoticeUserConn message to frpc and accept one new WorkConn later
func noticeUserConn(s *server.ProxyServer, msgSendChan chan interface{}) {
for { for {
closeFlag := s.WaitUserConn() closeFlag := s.WaitUserConn()
if closeFlag { if closeFlag {
log.Debug("ProxyName [%s], goroutine for dealing user conn is closed", s.Name) log.Debug("ProxyName [%s], goroutine for noticing user conn is closed", s.Name)
break break
} }
buf, _ := json.Marshal(serverCtlReq) notice := &msg.ControlRes{
err = c.Write(string(buf) + "\n") Type: consts.NoticeUserConn,
}
msgSendChan <- notice
log.Debug("ProxyName [%s], notice client to add work conn", s.Name)
}
}
// loop for reading messages from frpc after control connection is established
func msgReader(s *server.ProxyServer, c *conn.Conn, msgSendChan chan interface{}) error {
// for heartbeat
var heartbeatTimeout bool = false
timer := time.AfterFunc(time.Duration(server.HeartBeatTimeout)*time.Second, func() {
heartbeatTimeout = true
s.Close()
c.Close()
log.Error("ProxyName [%s], client heartbeat timeout", s.Name)
})
defer timer.Stop()
for {
buf, err := c.ReadLine()
if err != nil { if err != nil {
log.Warn("ProxyName [%s], write to client error, proxy exit", s.Name) if err == io.EOF {
s.Close() log.Warn("ProxyName [%s], client is dead!", s.Name)
return return err
} else if c == nil || c.IsClosed() {
log.Warn("ProxyName [%s], client connection is closed", s.Name)
return err
}
log.Warn("ProxyName [%s], read error: %v", s.Name, err)
continue
}
cliReq := &msg.ControlReq{}
if err := json.Unmarshal([]byte(buf), &cliReq); err != nil {
log.Warn("ProxyName [%s], parse msg from frpc error: %v : %s", s.Name, err, buf)
continue
} }
log.Debug("ProxyName [%s], write to client to add work conn success", s.Name) switch cliReq.Type {
case consts.HeartbeatReq:
log.Debug("ProxyName [%s], get heartbeat", s.Name)
timer.Reset(time.Duration(server.HeartBeatTimeout) * time.Second)
heartbeatRes := msg.ControlRes{
Type: consts.HeartbeatRes,
}
msgSendChan <- heartbeatRes
default:
log.Warn("ProxyName [%s}, unsupport msgType [%d]", s.Name, cliReq.Type)
}
} }
return nil
}
log.Info("ProxyName [%s], I'm dead!", s.Name) // loop for sending messages from channel to frpc
return func msgSender(s *server.ProxyServer, c *conn.Conn, msgSendChan chan interface{}) {
for {
msg, ok := <-msgSendChan
if !ok {
break
}
buf, _ := json.Marshal(msg)
err := c.Write(string(buf) + "\n")
if err != nil {
log.Warn("ProxyName [%s], write to client error, proxy exit", s.Name)
s.Close()
break
}
}
} }
func checkProxy(req *msg.ClientCtlReq, c *conn.Conn) (succ bool, info string, needRes bool) { // if success, ret equals 0, otherwise greater than 0
succ = false func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string) {
needRes = true ret = 1
// check if proxy name exist // check if proxy name exist
s, ok := server.ProxyServers[req.ProxyName] s, ok := server.ProxyServers[req.ProxyName]
if !ok { if !ok {
@ -130,89 +205,35 @@ func checkProxy(req *msg.ClientCtlReq, c *conn.Conn) (succ bool, info string, ne
} }
// control conn // control conn
if req.Type == consts.CtlConn { if req.Type == consts.NewCtlConn {
if s.Status != consts.Idle { if s.Status != consts.Idle {
info = fmt.Sprintf("ProxyName [%s], already in use", req.ProxyName) info = fmt.Sprintf("ProxyName [%s], already in use", req.ProxyName)
log.Warn(info) log.Warn(info)
return return
} }
// start proxy and listen for user conn, no block // start proxy and listen for user connections, no block
err := s.Start() err := s.Start()
if err != nil { if err != nil {
info = fmt.Sprintf("ProxyName [%s], start proxy error: %v", req.ProxyName, err.Error()) info = fmt.Sprintf("ProxyName [%s], start proxy error: %v", req.ProxyName, err)
log.Warn(info) log.Warn(info)
return return
} }
log.Info("ProxyName [%s], start proxy success", req.ProxyName) log.Info("ProxyName [%s], start proxy success", req.ProxyName)
} else if req.Type == consts.WorkConn { } else if req.Type == consts.NewWorkConn {
// work conn // work conn
needRes = false
if s.Status != consts.Working { if s.Status != consts.Working {
log.Warn("ProxyName [%s], is not working when it gets one new work conn", req.ProxyName) log.Warn("ProxyName [%s], is not working when it gets one new work connnection", req.ProxyName)
return return
} }
// the connection will close after join over
s.GetNewCliConn(c) s.RecvNewWorkConn(c)
} else { } else {
info = fmt.Sprintf("ProxyName [%s], type [%d] unsupport", req.ProxyName, req.Type) info = fmt.Sprintf("Unsupport login message type [%d]", req.Type)
log.Warn(info) log.Warn("Unsupport login message type [%d]", req.Type)
return return
} }
succ = true ret = 0
return return
} }
func readControlMsgFromClient(s *server.ProxyServer, c *conn.Conn) {
isContinueRead := true
f := func() {
isContinueRead = false
s.Close()
log.Error("ProxyName [%s], client heartbeat timeout", s.Name)
}
timer := time.AfterFunc(time.Duration(server.HeartBeatTimeout)*time.Second, f)
defer timer.Stop()
for isContinueRead {
content, err := c.ReadLine()
if err != nil {
if err == io.EOF {
log.Warn("ProxyName [%s], client is dead!", s.Name)
s.Close()
break
} else if nil == c || c.IsClosed() {
log.Warn("ProxyName [%s], client connection is closed", s.Name)
break
}
log.Error("ProxyName [%s], read error: %v", s.Name, err)
continue
}
clientCtlReq := &msg.ClientCtlReq{}
if err := json.Unmarshal([]byte(content), clientCtlReq); err != nil {
log.Warn("Parse err: %v : %s", err, content)
continue
}
if consts.CSHeartBeatReq == clientCtlReq.Type {
log.Debug("ProxyName [%s], get heartbeat", s.Name)
timer.Reset(time.Duration(server.HeartBeatTimeout) * time.Second)
clientCtlRes := &msg.ClientCtlRes{}
clientCtlRes.GeneralRes.Code = consts.SCHeartBeatRes
response, err := json.Marshal(clientCtlRes)
if err != nil {
log.Warn("Serialize ClientCtlRes err! err: %v", err)
continue
}
err = c.Write(string(response) + "\n")
if err != nil {
log.Error("Send heartbeat response to client failed! Err:%v", err)
continue
}
}
}
}

@ -51,8 +51,8 @@ func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err
return return
} }
req := &msg.ClientCtlReq{ req := &msg.ControlReq{
Type: consts.WorkConn, Type: consts.NewWorkConn,
ProxyName: p.Name, ProxyName: p.Name,
Passwd: p.Passwd, Passwd: p.Passwd,
} }
@ -79,7 +79,7 @@ func (p *ProxyClient) StartTunnel(serverAddr string, serverPort int64) (err erro
} }
// l means local, r means remote // l means local, r means remote
log.Debug("Join two conns, (l[%s] r[%s]) (l[%s] r[%s])", localConn.GetLocalAddr(), localConn.GetRemoteAddr(), log.Debug("Join two connections, (l[%s] r[%s]) (l[%s] r[%s])", localConn.GetLocalAddr(), localConn.GetRemoteAddr(),
remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr()) remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr())
// go conn.Join(localConn, remoteConn) // go conn.Join(localConn, remoteConn)
go conn.JoinMore(localConn, remoteConn, p.Passwd) go conn.JoinMore(localConn, remoteConn, p.Passwd)

@ -20,18 +20,12 @@ const (
Working Working
) )
// connection type // msg type
const ( const (
CtlConn = iota NewCtlConn = iota
WorkConn NewWorkConn
) NoticeUserConn
NewCtlConnRes
// msg from client to server HeartbeatReq
const ( HeartbeatRes
CSHeartBeatReq = 1
)
// msg from server to client
const (
SCHeartBeatRes = 100
) )

@ -19,16 +19,15 @@ type GeneralRes struct {
Msg string `json:"msg"` Msg string `json:"msg"`
} }
type ClientCtlReq struct { // messages between control connection of frpc and frps
type ControlReq struct {
Type int64 `json:"type"` Type int64 `json:"type"`
ProxyName string `json:"proxy_name"` ProxyName string `json:"proxy_name,omitempty"`
Passwd string `json:"passwd"` Passwd string `json:"passwd, omitempty"`
} }
type ClientCtlRes struct { type ControlRes struct {
GeneralRes Type int64 `json:"type"`
} Code int64 `json:"code"`
Msg string `json:"msg"`
type ServerCtlReq struct {
Type int64 `json:"type"`
} }

@ -33,14 +33,14 @@ type ProxyServer struct {
listener *conn.Listener // accept new connection from remote users listener *conn.Listener // accept new connection from remote users
ctlMsgChan chan int64 // every time accept a new user conn, put "1" to the channel ctlMsgChan chan int64 // every time accept a new user conn, put "1" to the channel
cliConnChan chan *conn.Conn // get client conns from control goroutine workConnChan chan *conn.Conn // get new work conns from control goroutine
userConnList *list.List // store user conns userConnList *list.List // store user conns
mutex sync.Mutex mutex sync.Mutex
} }
func (p *ProxyServer) Init() { func (p *ProxyServer) Init() {
p.Status = consts.Idle p.Status = consts.Idle
p.cliConnChan = make(chan *conn.Conn) p.workConnChan = make(chan *conn.Conn)
p.ctlMsgChan = make(chan int64) p.ctlMsgChan = make(chan int64)
p.userConnList = list.New() p.userConnList = list.New()
} }
@ -109,7 +109,7 @@ func (p *ProxyServer) Start() (err error) {
// start another goroutine for join two conns from client and user // start another goroutine for join two conns from client and user
go func() { go func() {
for { for {
cliConn, ok := <-p.cliConnChan workConn, ok := <-p.workConnChan
if !ok { if !ok {
return return
} }
@ -122,7 +122,7 @@ func (p *ProxyServer) Start() (err error) {
userConn = element.Value.(*conn.Conn) userConn = element.Value.(*conn.Conn)
p.userConnList.Remove(element) p.userConnList.Remove(element)
} else { } else {
cliConn.Close() workConn.Close()
p.Unlock() p.Unlock()
continue continue
} }
@ -130,10 +130,10 @@ func (p *ProxyServer) Start() (err error) {
// msg will transfer to another without modifying // msg will transfer to another without modifying
// l means local, r means remote // l means local, r means remote
log.Debug("Join two conns, (l[%s] r[%s]) (l[%s] r[%s])", cliConn.GetLocalAddr(), cliConn.GetRemoteAddr(), log.Debug("Join two connections, (l[%s] r[%s]) (l[%s] r[%s])", workConn.GetLocalAddr(), workConn.GetRemoteAddr(),
userConn.GetLocalAddr(), userConn.GetRemoteAddr()) userConn.GetLocalAddr(), userConn.GetRemoteAddr())
// go conn.Join(cliConn, userConn) // go conn.Join(workConn, userConn)
go conn.JoinMore(userConn, cliConn, p.Passwd) go conn.JoinMore(userConn, workConn, p.Passwd)
} }
}() }()
@ -147,7 +147,7 @@ func (p *ProxyServer) Close() {
p.listener.Close() p.listener.Close()
} }
close(p.ctlMsgChan) close(p.ctlMsgChan)
close(p.cliConnChan) close(p.workConnChan)
p.userConnList = list.New() p.userConnList = list.New()
p.Unlock() p.Unlock()
} }
@ -162,6 +162,6 @@ func (p *ProxyServer) WaitUserConn() (closeFlag bool) {
return return
} }
func (p *ProxyServer) GetNewCliConn(c *conn.Conn) { func (p *ProxyServer) RecvNewWorkConn(c *conn.Conn) {
p.cliConnChan <- c p.workConnChan <- c
} }

@ -153,7 +153,7 @@ func Join(c1 *Conn, c2 *Conn) {
var err error var err error
_, err = io.Copy(to.TcpConn, from.TcpConn) _, err = io.Copy(to.TcpConn, from.TcpConn)
if err != nil { if err != nil {
log.Warn("join conns error, %v", err) log.Warn("join connections error, %v", err)
} }
} }
@ -171,10 +171,8 @@ func JoinMore(local *Conn, remote *Conn, cryptoKey string) {
defer to.Close() defer to.Close()
defer wait.Done() defer wait.Done()
err := PipeEncryptoWriter(from.TcpConn, to.TcpConn, key) // we don't care about errors here
if err != nil { PipeEncryptoWriter(from.TcpConn, to.TcpConn, key)
log.Warn("join conns error, %v", err)
}
} }
decryptoPipe := func(to *Conn, from *Conn, key string) { decryptoPipe := func(to *Conn, from *Conn, key string) {
@ -182,16 +180,15 @@ func JoinMore(local *Conn, remote *Conn, cryptoKey string) {
defer to.Close() defer to.Close()
defer wait.Done() defer wait.Done()
err := PipeDecryptoReader(to.TcpConn, from.TcpConn, key) // we don't care about errors here
if err != nil { PipeDecryptoReader(to.TcpConn, from.TcpConn, key)
log.Warn("join conns error, %v", err)
}
} }
wait.Add(2) wait.Add(2)
go encrypPipe(local, remote, cryptoKey) go encrypPipe(local, remote, cryptoKey)
go decryptoPipe(remote, local, cryptoKey) go decryptoPipe(remote, local, cryptoKey)
wait.Wait() wait.Wait()
log.Debug("One tunnel stopped")
return return
} }

@ -19,7 +19,7 @@ import (
"strings" "strings"
) )
var version string = "0.2.0" var version string = "0.3.0"
func Full() string { func Full() string {
return version return version

Loading…
Cancel
Save