Skip to content

Commit

Permalink
Add pre-checking conversion for VLESS & VMess UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
RPRX authored Jan 12, 2021
1 parent 40271c0 commit 1579188
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions infra/conf/vless.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/common/uuid"
"github.com/xtls/xray-core/proxy/vless"
"github.com/xtls/xray-core/proxy/vless/inbound"
"github.com/xtls/xray-core/proxy/vless/outbound"
Expand Down Expand Up @@ -45,6 +46,12 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) {
return nil, newError(`VLESS clients: invalid user`).Base(err)
}

u, err := uuid.ParseString(account.Id)
if err != nil {
return nil, err
}
account.Id = u.String()

switch account.Flow {
case "", "xtls-rprx-origin", "xtls-rprx-direct":
case "xtls-rprx-splice":
Expand Down Expand Up @@ -167,6 +174,12 @@ func (c *VLessOutboundConfig) Build() (proto.Message, error) {
return nil, newError(`VLESS users: invalid user`).Base(err)
}

u, err := uuid.ParseString(account.Id)
if err != nil {
return nil, err
}
account.Id = u.String()

switch account.Flow {
case "", "xtls-rprx-origin", "xtls-rprx-origin-udp443", "xtls-rprx-direct", "xtls-rprx-direct-udp443":
case "xtls-rprx-splice", "xtls-rprx-splice-udp443":
Expand Down
15 changes: 15 additions & 0 deletions infra/conf/vmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/common/uuid"
"github.com/xtls/xray-core/proxy/vmess"
"github.com/xtls/xray-core/proxy/vmess/inbound"
"github.com/xtls/xray-core/proxy/vmess/outbound"
Expand Down Expand Up @@ -105,6 +106,13 @@ func (c *VMessInboundConfig) Build() (proto.Message, error) {
if err := json.Unmarshal(rawData, account); err != nil {
return nil, newError("invalid VMess user").Base(err)
}

u, err := uuid.ParseString(account.ID)
if err != nil {
return nil, err
}
account.ID = u.String()

user.Account = serial.ToTypedMessage(account.Build())
config.User[idx] = user
}
Expand Down Expand Up @@ -149,6 +157,13 @@ func (c *VMessOutboundConfig) Build() (proto.Message, error) {
if err := json.Unmarshal(rawUser, account); err != nil {
return nil, newError("invalid VMess user").Base(err)
}

u, err := uuid.ParseString(account.ID)
if err != nil {
return nil, err
}
account.ID = u.String()

user.Account = serial.ToTypedMessage(account.Build())
spec.User = append(spec.User, user)
}
Expand Down

0 comments on commit 1579188

Please sign in to comment.