mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-13 09:25:14 +03:00
fix(inbounds): refuse 2022-blake3-chacha20-poly1305 on shadowsocks inbounds
xray-core builds a Shadowsocks-2022 inbound with users only for the AES methods: the multi-user identity header is AES-only, so the config builder and the multi-user server both reject chacha20. Every panel inbound carries clients, so picking 2022-blake3-chacha20-poly1305 in the inbound form kept the whole core from starting; its links also failed on the client with "multi-key is not supported". The inbound form no longer offers the method and AddInbound/UpdateInbound reject it. Startup moves stored inbounds to 2022-blake3-aes-256-gcm, which takes the same 32-byte keys, so every stored key stays valid. Outbounds keep the method, since a single-key outbound to such a server works. The share-link generator drops the single-user branch that only this method reached.
This commit is contained in:
@@ -181,6 +181,9 @@ func initModels() error {
|
||||
if err := migrateShadowsocksRemovedCiphers(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := migrateShadowsocks2022ChachaInbounds(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := repairShadowsocks2022ServerKeys(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -990,6 +993,36 @@ func migrateShadowsocksRemovedCiphers() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// migrateShadowsocks2022ChachaInbounds moves 2022-chacha20 inbounds, which the core
|
||||
// refuses with users, to aes-256-gcm: same 32-byte keys, so all keys stay valid.
|
||||
func migrateShadowsocks2022ChachaInbounds() error {
|
||||
var inbounds []model.Inbound
|
||||
if err := db.Where("protocol = ?", model.Shadowsocks).Find(&inbounds).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, inbound := range inbounds {
|
||||
var settings map[string]any
|
||||
if json.Unmarshal([]byte(inbound.Settings), &settings) != nil {
|
||||
continue
|
||||
}
|
||||
method, _ := settings["method"].(string)
|
||||
if !xray.Shadowsocks2022NoMultiUser(method) {
|
||||
continue
|
||||
}
|
||||
settings["method"] = "2022-blake3-aes-256-gcm"
|
||||
newSettings, err := json.MarshalIndent(settings, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := db.Model(&model.Inbound{}).Where("id = ?", inbound.Id).
|
||||
Update("settings", string(newSettings)).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("Inbound %q: switched %s to 2022-blake3-aes-256-gcm; its share links changed", inbound.Tag, method)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// repairShadowsocks2022ServerKeys replaces a stored server key xray-core cannot
|
||||
// parse; that inbound never worked, as the core refuses to start with it.
|
||||
func repairShadowsocks2022ServerKeys() error {
|
||||
|
||||
Reference in New Issue
Block a user