MCPcopy Index your code
hub / github.com/XTLS/Xray-core / Build

Method Build

infra/conf/vless.go:41–203  ·  view source on GitHub ↗

Build implements Buildable

()

Source from the content-addressed store, hash-verified

39
40// Build implements Buildable
41func (c *VLessInboundConfig) Build() (proto.Message, error) {
42 config := new(inbound.Config)
43 config.Clients = make([]*protocol.User, len(c.Clients))
44 switch c.Flow {
45 case vless.XRV, "":
46 default:
47 return nil, errors.New(`VLESS "settings.flow" doesn't support "` + c.Flow + `" in this version`)
48 }
49 for idx, rawUser := range c.Clients {
50 user := new(protocol.User)
51 if err := json.Unmarshal(rawUser, user); err != nil {
52 return nil, errors.New(`VLESS clients: invalid user`).Base(err)
53 }
54 account := new(vless.Account)
55 if err := json.Unmarshal(rawUser, account); err != nil {
56 return nil, errors.New(`VLESS clients: invalid user`).Base(err)
57 }
58
59 u, err := uuid.ParseString(account.Id)
60 if err != nil {
61 return nil, err
62 }
63 account.Id = u.String()
64
65 switch account.Flow {
66 case "":
67 account.Flow = c.Flow
68 case vless.XRV:
69 default:
70 return nil, errors.New(`VLESS clients: "flow" doesn't support "` + account.Flow + `" in this version`)
71 }
72
73 if len(account.Testseed) < 4 {
74 account.Testseed = c.Testseed
75 }
76
77 if account.Encryption != "" {
78 return nil, errors.New(`VLESS clients: "encryption" should not be in inbound settings`)
79 }
80
81 if account.Reverse != nil {
82 if account.Reverse.Tag == "" {
83 return nil, errors.New(`VLESS clients: "tag" can't be empty for "reverse"`)
84 }
85 if account.Reverse.Sniffing != nil { // may not be reached: error json unmarshal
86 return nil, errors.New(`VLESS clients: inbound's "reverse" can't have "sniffing"`)
87 }
88 }
89
90 user.Account = serial.ToTypedMessage(account)
91 config.Clients[idx] = user
92 }
93
94 config.Decryption = c.Decryption
95 if !func() bool {
96 s := strings.Split(config.Decryption, ".")
97 if len(s) < 4 || s[0] != "mlkem768x25519plus" {
98 return false

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
ParseStringFunction · 0.92
ToTypedMessageFunction · 0.92
BaseMethod · 0.80
TrimSuffixMethod · 0.80
UnmarshalMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected