mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-05 01:47:15 +00:00
Give AmneziaWG its own case in client add/update protocol switches
AmneziaWG previously fell into these switches' default branch (just checking client.ID isn't empty), unlike WireGuard's own dedicated case validating PublicKey -- even though AmneziaWG clients need a real key exactly like WireGuard ones (defaultAmneziaWGClients already auto-generates/derives PublicKey the same way). Worked in practice only because the real UI form happens to always populate a UUID regardless of protocol; a minimal API payload with just an email and no key would incorrectly pass validation and no clientId for update lookups. Mirror the existing wireguard cases exactly: validate PublicKey on add, use Email as the update-lookup id (matching is always by email regardless, per the existing comment -- this only affects the non-empty check).
This commit is contained in:
@@ -441,6 +441,10 @@ func (s *ClientService) addInboundClient(inboundSvc *InboundService, data *model
|
|||||||
if client.PublicKey == "" {
|
if client.PublicKey == "" {
|
||||||
return false, common.NewError("wireguard client requires a key")
|
return false, common.NewError("wireguard client requires a key")
|
||||||
}
|
}
|
||||||
|
case "amneziawg":
|
||||||
|
if client.PublicKey == "" {
|
||||||
|
return false, common.NewError("amneziawg client requires a key")
|
||||||
|
}
|
||||||
case "mtproto":
|
case "mtproto":
|
||||||
if client.Secret == "" {
|
if client.Secret == "" {
|
||||||
return false, common.NewError("mtproto client requires a secret")
|
return false, common.NewError("mtproto client requires a secret")
|
||||||
@@ -622,6 +626,8 @@ func (s *ClientService) UpdateInboundClient(inboundSvc *InboundService, data *mo
|
|||||||
newClientId = clients[0].Auth
|
newClientId = clients[0].Auth
|
||||||
case "wireguard":
|
case "wireguard":
|
||||||
newClientId = clients[0].Email
|
newClientId = clients[0].Email
|
||||||
|
case "amneziawg":
|
||||||
|
newClientId = clients[0].Email
|
||||||
case "mtproto":
|
case "mtproto":
|
||||||
newClientId = clients[0].Email
|
newClientId = clients[0].Email
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user