mirror of
https://github.com/fatedier/frp.git
synced 2026-03-08 02:49:10 +08:00
server/group: fix port leak and incorrect Listen port in TCPGroup (#5200)
Fix two bugs in TCPGroup.Listen(): - Release acquired port when net.Listen fails to prevent port leak - Use realPort instead of port for net.Listen to ensure consistency between port manager records and actual listening port
This commit is contained in:
@@ -100,8 +100,9 @@ func (tg *TCPGroup) Listen(proxyName string, group string, groupKey string, addr
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
tcpLn, errRet := net.Listen("tcp", net.JoinHostPort(addr, strconv.Itoa(port)))
|
||||
tcpLn, errRet := net.Listen("tcp", net.JoinHostPort(addr, strconv.Itoa(realPort)))
|
||||
if errRet != nil {
|
||||
tg.ctl.portManager.Release(realPort)
|
||||
err = errRet
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user