fix: Disconnect only the supported protocols client

This commit is contained in:
HamidReza 2026-03-19 00:09:46 +03:30
parent 334e1038e9
commit e718679f26

View file

@ -414,6 +414,16 @@ func (j *CheckClientIpJob) disconnectClientTemporarily(inbound *model.Inbound, c
return return
} }
// Only perform remove/re-add for protocols supported by XrayAPI.AddUser
protocol := string(inbound.Protocol)
switch protocol {
case "vmess", "vless", "trojan", "shadowsocks":
// supported protocols, continue
default:
logger.Warningf("[LIMIT_IP] Temporary disconnect is not supported for protocol %s on inbound %s", protocol, inbound.Tag)
return
}
// Remove user to disconnect all connections // Remove user to disconnect all connections
err = xrayAPI.RemoveUser(inbound.Tag, clientEmail) err = xrayAPI.RemoveUser(inbound.Tag, clientEmail)
if err != nil { if err != nil {
@ -425,7 +435,7 @@ func (j *CheckClientIpJob) disconnectClientTemporarily(inbound *model.Inbound, c
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
// Re-add user to allow new connections // Re-add user to allow new connections
err = xrayAPI.AddUser(string(inbound.Protocol), inbound.Tag, clientConfig) err = xrayAPI.AddUser(protocol, inbound.Tag, clientConfig)
if err != nil { if err != nil {
logger.Warningf("[LIMIT_IP] Failed to re-add user %s: %v", clientEmail, err) logger.Warningf("[LIMIT_IP] Failed to re-add user %s: %v", clientEmail, err)
} }