mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
mv builder to xray
This commit is contained in:
51
core/xray/vmess.go
Normal file
51
core/xray/vmess.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package xray
|
||||
|
||||
import (
|
||||
"github.com/Yuzuki616/V2bX/api/panel"
|
||||
"github.com/Yuzuki616/V2bX/common/format"
|
||||
"github.com/xtls/xray-core/common/protocol"
|
||||
"github.com/xtls/xray-core/common/serial"
|
||||
"github.com/xtls/xray-core/infra/conf"
|
||||
"github.com/xtls/xray-core/proxy/vless"
|
||||
)
|
||||
|
||||
func buildVmessUsers(tag string, userInfo []panel.UserInfo) (users []*protocol.User) {
|
||||
users = make([]*protocol.User, len(userInfo))
|
||||
for i, user := range userInfo {
|
||||
users[i] = buildVmessUser(tag, &user)
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func buildVmessUser(tag string, userInfo *panel.UserInfo) (user *protocol.User) {
|
||||
vmessAccount := &conf.VMessAccount{
|
||||
ID: userInfo.Uuid,
|
||||
AlterIds: 0,
|
||||
Security: "auto",
|
||||
}
|
||||
return &protocol.User{
|
||||
Level: 0,
|
||||
Email: format.UserTag(tag, userInfo.Uuid), // Uid: InboundTag|email
|
||||
Account: serial.ToTypedMessage(vmessAccount.Build()),
|
||||
}
|
||||
}
|
||||
|
||||
func buildVlessUsers(tag string, userInfo []panel.UserInfo, flow string) (users []*protocol.User) {
|
||||
users = make([]*protocol.User, len(userInfo))
|
||||
for i := range userInfo {
|
||||
users[i] = buildVlessUser(tag, &(userInfo)[i], flow)
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func buildVlessUser(tag string, userInfo *panel.UserInfo, flow string) (user *protocol.User) {
|
||||
vlessAccount := &vless.Account{
|
||||
Id: userInfo.Uuid,
|
||||
}
|
||||
vlessAccount.Flow = flow
|
||||
return &protocol.User{
|
||||
Level: 0,
|
||||
Email: format.UserTag(tag, userInfo.Uuid),
|
||||
Account: serial.ToTypedMessage(vlessAccount),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user