(users []*common.User)
| 119 | } |
| 120 | |
| 121 | func (i *Inbound) syncUsers(users []*common.User) { |
| 122 | i.mu.Lock() |
| 123 | defer i.mu.Unlock() |
| 124 | |
| 125 | // Clear existing clients map |
| 126 | i.clients = make(map[string]api.Account) |
| 127 | |
| 128 | switch i.Protocol { |
| 129 | case Vmess: |
| 130 | for _, user := range users { |
| 131 | if user.GetProxies().GetVmess() == nil { |
| 132 | continue |
| 133 | } |
| 134 | if slices.Contains(user.Inbounds, i.Tag) { |
| 135 | account, err := api.NewVmessAccount(user) |
| 136 | if err != nil { |
| 137 | log.Println("error for user", user.GetEmail(), ":", err) |
| 138 | continue |
| 139 | } |
| 140 | i.clients[user.GetEmail()] = account |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | case Vless: |
| 145 | for _, user := range users { |
| 146 | if user.GetProxies().GetVless() == nil { |
| 147 | continue |
| 148 | } |
| 149 | if slices.Contains(user.Inbounds, i.Tag) { |
| 150 | account, err := api.NewVlessAccount(user) |
| 151 | if err != nil { |
| 152 | log.Println("error for user", user.GetEmail(), ":", err) |
| 153 | continue |
| 154 | } |
| 155 | i.clients[user.GetEmail()] = account |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | case Trojan: |
| 160 | for _, user := range users { |
| 161 | if user.GetProxies().GetTrojan() == nil { |
| 162 | continue |
| 163 | } |
| 164 | if slices.Contains(user.Inbounds, i.Tag) { |
| 165 | i.clients[user.GetEmail()] = api.NewTrojanAccount(user) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | case Shadowsocks: |
| 170 | method, methodOk := i.Settings["method"].(string) |
| 171 | if methodOk && strings.HasPrefix(method, "2022-blake3") { |
| 172 | for _, user := range users { |
| 173 | if user.GetProxies().GetShadowsocks() == nil { |
| 174 | continue |
| 175 | } |
| 176 | if slices.Contains(user.Inbounds, i.Tag) { |
| 177 | account := api.NewShadowsocksAccount(user) |
| 178 | newAccount := checkShadowsocks2022(method, *account) |
nothing calls this directly
no test coverage detected