feat(session): 实现同平台抢登互踢功能,优化会话踢下线逻辑
新增同平台会话踢下线能力,将iOS/Android/mobile归为同一移动分组,web仅匹配web;扩展会话存储接口支持按平台、带原因踢除会话,同步更新集群广播逻辑与各调用点,统一传递踢下线原因参数
This commit is contained in:
@@ -741,6 +741,27 @@ func platformFromUA(ua string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// sameEvictPlatform reports whether two session platforms belong to the same
|
||||
// eviction group for same-platform login eviction (顶号互踢): identical
|
||||
// identifiers match, and ios/android/mobile are all treated as one mobile group
|
||||
// (an iOS login evicts Android sessions and vice versa). Web only matches web.
|
||||
func sameEvictPlatform(a, b string) bool {
|
||||
if a == "" || b == "" {
|
||||
return false
|
||||
}
|
||||
if strings.EqualFold(a, b) {
|
||||
return true
|
||||
}
|
||||
switch strings.ToLower(a) {
|
||||
case "ios", "android", "mobile":
|
||||
switch strings.ToLower(b) {
|
||||
case "ios", "android", "mobile":
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func parseTLSConfig(tlsEnabled bool, jsconfig json.RawMessage) (*tls.Config, error) {
|
||||
type tlsAutocertConfig struct {
|
||||
// Domains to support by autocert
|
||||
|
||||
Reference in New Issue
Block a user