diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-05-06 19:51:14 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-05-06 19:51:14 +0300 |
| commit | f22dd6b53d736556377080a305c40be2db3c8cce (patch) | |
| tree | caae9937645094ccf2513ac46a2bfa5ca446df3b /web/service | |
| parent | 735df6bd4ed18d656355067826a6f5e50495c63e (diff) | |
[feature] multi-user shadowsocks @alireza0
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
Diffstat (limited to 'web/service')
| -rw-r--r-- | web/service/inbound.go | 5 | ||||
| -rw-r--r-- | web/service/sub.go | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/web/service/inbound.go b/web/service/inbound.go index b14f7b4f..7e838b5f 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -332,6 +332,9 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) error if oldInbound.Protocol == "trojan" { client_key = "password" } + if oldInbound.Protocol == "shadowsocks" { + client_key = "email" + } inerfaceClients := settings["clients"].([]interface{}) var newClients []interface{} @@ -398,6 +401,8 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin oldClientId := "" if oldInbound.Protocol == "trojan" { oldClientId = oldClient.Password + } else if oldInbound.Protocol == "shadowsocks" { + oldClientId = oldClient.Email } else { oldClientId = oldClient.ID } diff --git a/web/service/sub.go b/web/service/sub.go index 69cafda1..3f8b7685 100644 --- a/web/service/sub.go +++ b/web/service/sub.go @@ -97,6 +97,8 @@ func (s *SubService) getLink(inbound *model.Inbound, email string) string { return s.genVlessLink(inbound, email) case "trojan": return s.genTrojanLink(inbound, email) + case "shadowsocks": + return s.genShadowsocksLink(inbound, email) } return "" } @@ -565,6 +567,28 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string return url.String() } +func (s *SubService) genShadowsocksLink(inbound *model.Inbound, email string) string { + address := s.address + if inbound.Protocol != model.Shadowsocks { + return "" + } + clients, _ := s.inboundService.getClients(inbound) + + var settings map[string]interface{} + json.Unmarshal([]byte(inbound.Settings), &settings) + inboundPassword := settings["password"].(string) + method := settings["method"].(string) + clientIndex := -1 + for i, client := range clients { + if client.Email == email { + clientIndex = i + break + } + } + encPart := fmt.Sprintf("%s:%s:%s", method, inboundPassword, clients[clientIndex].Password) + return fmt.Sprintf("ss://%s@%s:%d#%s", base64.StdEncoding.EncodeToString([]byte(encPart)), address, inbound.Port, clients[clientIndex].Email) +} + func searchKey(data interface{}, key string) (interface{}, bool) { switch val := data.(type) { case map[string]interface{}: |
