hy2内核支持sniff设置

This commit is contained in:
wyx2685
2025-03-02 23:19:27 +09:00
parent 96baa0a99c
commit d71df3a0df
6 changed files with 72 additions and 30 deletions

View File

@@ -37,7 +37,7 @@ type Limiter struct {
ProtocolRules []string
SpeedLimit int
UserOnlineIP *sync.Map // Key: Name, value: {Key: Ip, value: Uid}
OldUserOnline *sync.Map // Key: Ip, value: Uid
OldUserOnline *sync.Map // Key: Ip, value: Uid
UUIDtoUID map[string]int // Key: UUID, value: Uid
UserLimitInfo *sync.Map // Key: Uid value: UserLimitInfo
ConnLimiter *ConnLimiter // Key: Uid value: ConnLimiter
@@ -164,6 +164,8 @@ func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool, noSSUDP bool
} else {
userLimit = determineSpeedLimit(u.SpeedLimit, u.DynamicSpeedLimit)
}
} else {
return nil, true
}
if noSSUDP {
// Store online user for device limit
@@ -181,8 +183,8 @@ func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool, noSSUDP bool
return nil, true
}
}
}
} else if v, ok := l.OldUserOnline.Load(ip); ok{
}
} else if v, ok := l.OldUserOnline.Load(ip); ok {
if v.(int) == uid {
l.OldUserOnline.Delete(ip)
}