mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 08:11:49 +08:00
添加 空闲链接超时自动断开
This commit is contained in:
@@ -89,10 +89,13 @@ func initIpPool() {
|
||||
// }
|
||||
|
||||
// AcquireIp 获取动态ip
|
||||
func AcquireIp(username, macAddr string, uniqueMac bool) net.IP {
|
||||
base.Trace("AcquireIp:", username, macAddr, uniqueMac)
|
||||
func AcquireIp(username, macAddr string, uniqueMac bool) (newIp net.IP) {
|
||||
base.Trace("AcquireIp start:", username, macAddr, uniqueMac)
|
||||
ipPoolMux.Lock()
|
||||
defer ipPoolMux.Unlock()
|
||||
defer func() {
|
||||
ipPoolMux.Unlock()
|
||||
base.Trace("AcquireIp end:", username, macAddr, uniqueMac, newIp)
|
||||
}()
|
||||
|
||||
var (
|
||||
err error
|
||||
|
@@ -49,6 +49,7 @@ type ConnSession struct {
|
||||
BandwidthDownAll atomic2.Uint64 // 使用下行带宽总量
|
||||
closeOnce sync.Once
|
||||
CloseChan chan struct{}
|
||||
LastDataTime atomic2.Time // 最后数据传输时间
|
||||
PayloadIn chan *Payload
|
||||
PayloadOutCstp chan *Payload // Cstp的数据
|
||||
PayloadOutDtls chan *Payload // Dtls的数据
|
||||
@@ -219,6 +220,7 @@ func (s *Session) NewConn() *ConnSession {
|
||||
PayloadOutDtls: make(chan *Payload, 64),
|
||||
dSess: &atomic.Value{},
|
||||
}
|
||||
cSess.LastDataTime.Store(time.Now())
|
||||
|
||||
dSess := &DtlsSession{
|
||||
isActive: -1,
|
||||
|
Reference in New Issue
Block a user