mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
Merge branch 'fix_some_bugs' of https://github.com/Hurricanezwf/frp into Hurricanezwf-fix_some_bugs
Conflicts: cmd/frpc/config.go cmd/frpc/control.go cmd/frpc/main.go cmd/frps/config.go cmd/frps/control.go cmd/frps/main.go pkg/models/server.go
This commit is contained in:
@@ -63,6 +63,7 @@ func (p *ProxyClient) StartTunnel(serverAddr string, serverPort int64) (err erro
|
||||
return
|
||||
}
|
||||
|
||||
// l means local, r means remote
|
||||
log.Debug("Join two conns, (l[%s] r[%s]) (l[%s] r[%s])", localConn.GetLocalAddr(), localConn.GetRemoteAddr(),
|
||||
remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr())
|
||||
go conn.Join(localConn, remoteConn)
|
||||
|
||||
@@ -19,17 +19,19 @@ type ProxyServer struct {
|
||||
BindAddr string
|
||||
ListenPort int64
|
||||
|
||||
Status int64
|
||||
Listener *conn.Listener // accept new connection from remote users
|
||||
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
|
||||
UserConnList *list.List // store user conns
|
||||
Mutex sync.Mutex
|
||||
Status int64
|
||||
Listener *conn.Listener // accept new connection from remote users
|
||||
CtlMsgChan chan int64 // every time accept a new user conn, put "1" to the channel
|
||||
StopBlockChan chan int64 // put any number to the channel, if you want to stop wait user conn
|
||||
CliConnChan chan *conn.Conn // get client conns from control goroutine
|
||||
UserConnList *list.List // store user conns
|
||||
Mutex sync.Mutex
|
||||
}
|
||||
|
||||
func (p *ProxyServer) Init() {
|
||||
p.Status = Idle
|
||||
p.CtlMsgChan = make(chan int64)
|
||||
p.StopBlockChan = make(chan int64)
|
||||
p.CliConnChan = make(chan *conn.Conn)
|
||||
p.UserConnList = list.New()
|
||||
}
|
||||
@@ -87,11 +89,13 @@ func (p *ProxyServer) Start() (err error) {
|
||||
p.UserConnList.Remove(element)
|
||||
} else {
|
||||
cliConn.Close()
|
||||
p.Unlock()
|
||||
continue
|
||||
}
|
||||
p.Unlock()
|
||||
|
||||
// msg will transfer to another without modifying
|
||||
// l means local, r means remote
|
||||
log.Debug("Join two conns, (l[%s] r[%s]) (l[%s] r[%s])", cliConn.GetLocalAddr(), cliConn.GetRemoteAddr(),
|
||||
userConn.GetLocalAddr(), userConn.GetRemoteAddr())
|
||||
go conn.Join(cliConn, userConn)
|
||||
@@ -110,7 +114,15 @@ func (p *ProxyServer) Close() {
|
||||
p.Unlock()
|
||||
}
|
||||
|
||||
func (p *ProxyServer) WaitUserConn() (res int64) {
|
||||
res = <-p.CtlMsgChan
|
||||
return
|
||||
func (p *ProxyServer) WaitUserConn() (res int64, isStop bool) {
|
||||
select {
|
||||
case res = <-p.CtlMsgChan:
|
||||
return res, false
|
||||
case <-p.StopBlockChan:
|
||||
return 0, true
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProxyServer) StopWaitUserConn() {
|
||||
p.StopBlockChan <- 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user