mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-24 11:57:15 +00:00
fix(clients): parse only settings.clients across protocols (#5855)
* fix(clients): parse only settings.clients across protocols Several inbound settings readers decoded the whole settings object into map[string][]model.Client. Real protocol settings include scalar keys such as VLESS decryption and Hysteria version, so that shape can fail before callers reach settings.clients or leave them relying on decoder side effects. Add one shared helper that extracts only the clients field through json.RawMessage, then use it from GetClients, SearchClientTraffic and the IP-limit job fallback paths. Regression tests cover VLESS and Hysteria settings with scalar protocol fields. * fix(clients): reject empty inbound settings
This commit is contained in:
@@ -440,17 +440,7 @@ func (s *InboundService) GetInboundsByTrafficReset(period string) ([]*model.Inbo
|
||||
}
|
||||
|
||||
func (s *InboundService) GetClients(inbound *model.Inbound) ([]model.Client, error) {
|
||||
settings := map[string][]model.Client{}
|
||||
_ = json.Unmarshal([]byte(inbound.Settings), &settings)
|
||||
if settings == nil {
|
||||
return nil, fmt.Errorf("setting is null")
|
||||
}
|
||||
|
||||
clients := settings["clients"]
|
||||
if clients == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return clients, nil
|
||||
return ParseInboundSettingsClients(inbound.Settings)
|
||||
}
|
||||
|
||||
// GetClientsBySubId returns the inbound's clients with the given subscription
|
||||
|
||||
Reference in New Issue
Block a user