mirror of https://github.com/XTLS/Xray-core
VLESS inbound: Add option to set default `flow` (#5023)
Closes https://github.com/XTLS/Xray-core/issues/4994pull/5026/head
parent
f557bf7da4
commit
aac0d6a6a5
|
@ -32,12 +32,20 @@ type VLessInboundConfig struct {
|
|||
Clients []json.RawMessage `json:"clients"`
|
||||
Decryption string `json:"decryption"`
|
||||
Fallbacks []*VLessInboundFallback `json:"fallbacks"`
|
||||
Flow string `json:"flow"`
|
||||
}
|
||||
|
||||
// Build implements Buildable
|
||||
func (c *VLessInboundConfig) Build() (proto.Message, error) {
|
||||
config := new(inbound.Config)
|
||||
config.Clients = make([]*protocol.User, len(c.Clients))
|
||||
switch c.Flow {
|
||||
case vless.None:
|
||||
c.Flow = ""
|
||||
case "", vless.XRV:
|
||||
default:
|
||||
return nil, errors.New(`VLESS "settings.flow" doesn't support "` + c.Flow + `" in this version`)
|
||||
}
|
||||
for idx, rawUser := range c.Clients {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||
|
@ -55,7 +63,11 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) {
|
|||
account.Id = u.String()
|
||||
|
||||
switch account.Flow {
|
||||
case "", vless.XRV:
|
||||
case "":
|
||||
account.Flow = c.Flow
|
||||
case vless.None:
|
||||
account.Flow = ""
|
||||
case vless.XRV:
|
||||
default:
|
||||
return nil, errors.New(`VLESS clients: "flow" doesn't support "` + account.Flow + `" in this version`)
|
||||
}
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
package vless
|
||||
|
||||
const (
|
||||
XRV = "xtls-rprx-vision"
|
||||
None = "none"
|
||||
XRV = "xtls-rprx-vision"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue