MCPcopy Create free account
hub / github.com/PasarGuard/node / syncUsers

Method syncUsers

backend/xray/config.go:121–203  ·  view source on GitHub ↗
(users []*common.User)

Source from the content-addressed store, hash-verified

119}
120
121func (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)

Callers

nothing calls this directly

Calls 14

NewVmessAccountFunction · 0.92
NewVlessAccountFunction · 0.92
NewTrojanAccountFunction · 0.92
NewShadowsocksAccountFunction · 0.92
NewShadowsocksTcpAccountFunction · 0.92
NewHysteriaAccountFunction · 0.92
checkShadowsocks2022Function · 0.85
GetVmessMethod · 0.80
GetProxiesMethod · 0.80
GetVlessMethod · 0.80
GetTrojanMethod · 0.80
GetShadowsocksMethod · 0.80

Tested by

no test coverage detected