diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-04-20 17:05:27 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2026-04-20 17:05:27 +0300 |
| commit | ae5ad505d04fa347eb96a0d2bfb54ff541c3b709 (patch) | |
| tree | 54a8088e98e15868238be54b063bb051ab84fcb0 /web/service | |
| parent | c188056f64be268dda8f7c16e23f7ef9c90d014f (diff) | |
add hysteria inbound
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/service')
| -rw-r--r-- | web/service/inbound.go | 22 | ||||
| -rw-r--r-- | web/service/xray.go | 4 |
2 files changed, 21 insertions, 5 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go index 81f37389..59dc9e65 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -270,6 +270,10 @@ func (s *InboundService) AddInbound(inbound *model.Inbound) (*model.Inbound, boo if client.Email == "" { return inbound, false, common.NewError("empty client ID") } + case "hysteria": + if client.Auth == "" { + return inbound, false, common.NewError("empty client ID") + } default: if client.ID == "" { return inbound, false, common.NewError("empty client ID") @@ -606,6 +610,10 @@ func (s *InboundService) AddInboundClient(data *model.Inbound) (bool, error) { if client.Email == "" { return false, common.NewError("empty client ID") } + case "hysteria": + if client.Auth == "" { + return false, common.NewError("empty client ID") + } default: if client.ID == "" { return false, common.NewError("empty client ID") @@ -655,6 +663,7 @@ func (s *InboundService) AddInboundClient(data *model.Inbound) (bool, error) { err1 := s.xrayApi.AddUser(string(oldInbound.Protocol), oldInbound.Tag, map[string]any{ "email": client.Email, "id": client.ID, + "auth": client.Auth, "security": client.Security, "flow": client.Flow, "password": client.Password, @@ -690,11 +699,13 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool, email := "" client_key := "id" - if oldInbound.Protocol == "trojan" { + switch oldInbound.Protocol { + case "trojan": client_key = "password" - } - if oldInbound.Protocol == "shadowsocks" { + case "shadowsocks": client_key = "email" + case "hysteria": + client_key = "auth" } interfaceClients := settings["clients"].([]any) @@ -801,6 +812,9 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin case "shadowsocks": oldClientId = oldClient.Email newClientId = clients[0].Email + case "hysteria": + oldClientId = oldClient.Auth + newClientId = clients[0].Auth default: oldClientId = oldClient.ID newClientId = clients[0].ID @@ -921,6 +935,7 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin "id": clients[0].ID, "security": clients[0].Security, "flow": clients[0].Flow, + "auth": clients[0].Auth, "password": clients[0].Password, "cipher": cipher, }) @@ -1813,6 +1828,7 @@ func (s *InboundService) ResetClientTraffic(id int, clientEmail string) (bool, e err1 := s.xrayApi.AddUser(string(inbound.Protocol), inbound.Tag, map[string]any{ "email": client.Email, "id": client.ID, + "auth": client.Auth, "security": client.Security, "flow": client.Flow, "password": client.Password, diff --git a/web/service/xray.go b/web/service/xray.go index be140ce6..ab440ac2 100644 --- a/web/service/xray.go +++ b/web/service/xray.go @@ -148,10 +148,10 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) { // clear client config for additional parameters for key := range c { - if key != "email" && key != "id" && key != "password" && key != "flow" && key != "method" { + if key != "email" && key != "id" && key != "password" && key != "flow" && key != "method" && key != "auth" { delete(c, key) } - if c["flow"] == "xtls-rprx-vision-udp443" { + if flow, ok := c["flow"].(string); ok && flow == "xtls-rprx-vision-udp443" { c["flow"] = "xtls-rprx-vision" } } |
