@@ -41,45 +41,28 @@ func setupUserAccount(user *common.User) (api.ProxySettings, error) {
4141 return settings , nil
4242}
4343
44- func checkVless (inbound * Inbound , account api.VlessAccount ) api.VlessAccount {
45- if account .Flow != "" {
46-
47- networkType , ok := inbound .StreamSettings ["network" ]
48- if ! ok || ! (networkType == "tcp" || networkType == "raw" || networkType == "kcp" ) {
49- account .Flow = ""
50- return account
51- }
52-
53- securityType , ok := inbound .StreamSettings ["security" ]
54- if ! ok || ! (securityType == "tls" || securityType == "reality" ) {
55- account .Flow = ""
56- return account
57- }
58-
59- rawMap , ok := inbound .StreamSettings ["rawSettings" ].(map [string ]interface {})
60- if ! ok {
61- rawMap , ok = inbound .StreamSettings ["tcpSettings" ].(map [string ]interface {})
62- if ! ok {
63- return account
64- }
65- }
66-
67- headerMap , ok := rawMap ["header" ].(map [string ]interface {})
68- if ! ok {
69- return account
70- }
44+ func inboundFlow (inbound * Inbound ) string {
45+ if inbound == nil || inbound .Settings == nil {
46+ return ""
47+ }
48+ flow , _ := inbound .Settings ["flow" ].(string )
49+ return flow
50+ }
7151
72- headerType , ok := headerMap ["Type" ].(string )
73- if ! ok {
74- return account
75- }
52+ func accountForAPI (inbound * Inbound , account api.Account ) api.Account {
53+ vlessAccount , ok := account .(* api.VlessAccount )
54+ if ! ok {
55+ return account
56+ }
7657
77- if headerType == "http" {
78- account .Flow = ""
79- return account
80- }
58+ overrideFlow := inboundFlow (inbound )
59+ if overrideFlow == "" {
60+ return account
8161 }
82- return account
62+
63+ copy := * vlessAccount
64+ copy .Flow = overrideFlow
65+ return & copy
8366}
8467
8568func checkShadowsocks2022 (method string , account api.ShadowsocksAccount ) api.ShadowsocksAccount {
@@ -95,8 +78,7 @@ func isActiveInbound(inbound *Inbound, inbounds []string, settings api.ProxySett
9578 if settings .Vless == nil {
9679 return nil , false
9780 }
98- account := checkVless (inbound , * settings .Vless )
99- return & account , true
81+ return settings .Vless , true
10082
10183 case Vmess :
10284 if settings .Vmess == nil {
@@ -157,7 +139,7 @@ func (x *Xray) SyncUser(ctx context.Context, user *common.User) error {
157139 account , isActive := isActiveInbound (inbound , userInbounds , proxySetting )
158140 if isActive {
159141 inbound .updateUser (account )
160- err = handler .AddInboundUser (ctx , inbound .Tag , account )
142+ err = handler .AddInboundUser (ctx , inbound .Tag , accountForAPI ( inbound , account ) )
161143 if err != nil {
162144 log .Println (err )
163145 errMessage += "\n " + err .Error ()
@@ -204,7 +186,7 @@ func (x *Xray) UpdateUsers(ctx context.Context, users []*common.User) error {
204186
205187 for _ , account := range update .accounts {
206188 _ = handler .RemoveInboundUser (ctx , tag , account .GetEmail ())
207- if err := handler .AddInboundUser (ctx , tag , account ); err != nil {
189+ if err := handler .AddInboundUser (ctx , tag , accountForAPI ( inbound , account ) ); err != nil {
208190 log .Println (err )
209191 errMessage += "\n " + err .Error ()
210192 }
0 commit comments