fix: Ensure the required "cipher" field is present in the shadowsocks protocol

This commit is contained in:
HamidReza 2026-03-19 00:13:15 +03:30
parent e718679f26
commit aaabeeb33c

View file

@ -424,6 +424,19 @@ func (j *CheckClientIpJob) disconnectClientTemporarily(inbound *model.Inbound, c
return return
} }
// For Shadowsocks, ensure the required "cipher" field is present by
// reading it from the inbound settings (e.g., settings["method"]).
if string(inbound.Protocol) == "shadowsocks" {
var inboundSettings map[string]any
if err := json.Unmarshal([]byte(inbound.Settings), &inboundSettings); err != nil {
logger.Warningf("[LIMIT_IP] Failed to parse inbound settings for shadowsocks cipher: %v", err)
} else {
if method, ok := inboundSettings["method"].(string); ok && method != "" {
clientConfig["cipher"] = method
}
}
}
// 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 {