mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-17 18:45:03 +03:00
fix(inbound): regenerate SS-2022 client PSKs on method key-size change
Switching a Shadowsocks-2022 inbound between ciphers of different key sizes (e.g. aes-256 <-> aes-128) resized the server PSK but left existing client PSKs at the old length. xray rejects a wrong-length uPSK, so links stopped connecting. Regenerate mismatched client keys on inbound add/update, mirroring the single-client form's existing self-heal. Affected clients must re-subscribe.
This commit is contained in:
@@ -619,6 +619,12 @@ func (s *InboundService) AddInbound(inbound *model.Inbound) (*model.Inbound, boo
|
||||
}
|
||||
}
|
||||
|
||||
// Defensively fix any Shadowsocks-2022 client PSK whose length doesn't match
|
||||
// the inbound method (e.g. an API caller supplied a wrong-size key).
|
||||
if normalized, changed := normalizeShadowsocksClientKeys(inbound.Settings); changed {
|
||||
inbound.Settings = normalized
|
||||
}
|
||||
|
||||
// Secure client ID
|
||||
for _, client := range clients {
|
||||
switch inbound.Protocol {
|
||||
@@ -1041,6 +1047,14 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
|
||||
}
|
||||
}
|
||||
|
||||
// A Shadowsocks-2022 method change resizes the key, but existing client PSKs
|
||||
// keep their old length and would be rejected by xray. Regenerate mismatched
|
||||
// client keys so the inbound stays connectable.
|
||||
if normalized, changed := normalizeShadowsocksClientKeys(inbound.Settings); changed {
|
||||
inbound.Settings = normalized
|
||||
logger.Warning("Shadowsocks inbound", inbound.Id, "method change resized keys; regenerated mismatched client PSK(s)")
|
||||
}
|
||||
|
||||
oldInbound.Total = inbound.Total
|
||||
oldInbound.Remark = inbound.Remark
|
||||
oldInbound.SubSortIndex = inbound.SubSortIndex
|
||||
|
||||
Reference in New Issue
Block a user