mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-05 05:00:08 +00:00
refactor NodeInfo
This commit is contained in:
@@ -13,58 +13,58 @@ import (
|
||||
|
||||
func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) {
|
||||
switch p.NodeInfo.Type {
|
||||
case "v2ray":
|
||||
if p.NodeInfo.ExtraConfig.EnableVless == "true" {
|
||||
us := make([]option.VLESSUser, len(p.UserInfo))
|
||||
for i := range p.UserInfo {
|
||||
case "vmess", "vless":
|
||||
if p.NodeInfo.Type == "vless" {
|
||||
us := make([]option.VLESSUser, len(p.Users))
|
||||
for i := range p.Users {
|
||||
us[i] = option.VLESSUser{
|
||||
Name: p.UserInfo[i].Uuid,
|
||||
Flow: p.NodeInfo.ExtraConfig.VlessFlow,
|
||||
UUID: p.UserInfo[i].Uuid,
|
||||
Name: p.Users[i].Uuid,
|
||||
Flow: p.VAllss.Flow,
|
||||
UUID: p.Users[i].Uuid,
|
||||
}
|
||||
}
|
||||
err = b.inbounds[p.Tag].(*inbound.VLESS).AddUsers(us)
|
||||
} else {
|
||||
us := make([]option.VMessUser, len(p.UserInfo))
|
||||
for i := range p.UserInfo {
|
||||
us := make([]option.VMessUser, len(p.Users))
|
||||
for i := range p.Users {
|
||||
us[i] = option.VMessUser{
|
||||
Name: p.UserInfo[i].Uuid,
|
||||
UUID: p.UserInfo[i].Uuid,
|
||||
Name: p.Users[i].Uuid,
|
||||
UUID: p.Users[i].Uuid,
|
||||
}
|
||||
}
|
||||
err = b.inbounds[p.Tag].(*inbound.VMess).AddUsers(us)
|
||||
}
|
||||
case "shadowsocks":
|
||||
us := make([]option.ShadowsocksUser, len(p.UserInfo))
|
||||
for i := range p.UserInfo {
|
||||
var password = p.UserInfo[i].Uuid
|
||||
switch p.NodeInfo.Cipher {
|
||||
us := make([]option.ShadowsocksUser, len(p.Users))
|
||||
for i := range p.Users {
|
||||
var password = p.Users[i].Uuid
|
||||
switch p.Shadowsocks.Cipher {
|
||||
case "2022-blake3-aes-128-gcm":
|
||||
password = base64.StdEncoding.EncodeToString([]byte(password[:16]))
|
||||
case "2022-blake3-aes-256-gcm":
|
||||
password = base64.StdEncoding.EncodeToString([]byte(password[:32]))
|
||||
}
|
||||
us[i] = option.ShadowsocksUser{
|
||||
Name: p.UserInfo[i].Uuid,
|
||||
Name: p.Users[i].Uuid,
|
||||
Password: password,
|
||||
}
|
||||
}
|
||||
err = b.inbounds[p.Tag].(*inbound.ShadowsocksMulti).AddUsers(us)
|
||||
case "trojan":
|
||||
us := make([]option.TrojanUser, len(p.UserInfo))
|
||||
for i := range p.UserInfo {
|
||||
us := make([]option.TrojanUser, len(p.Users))
|
||||
for i := range p.Users {
|
||||
us[i] = option.TrojanUser{
|
||||
Name: p.UserInfo[i].Uuid,
|
||||
Password: p.UserInfo[i].Uuid,
|
||||
Name: p.Users[i].Uuid,
|
||||
Password: p.Users[i].Uuid,
|
||||
}
|
||||
}
|
||||
err = b.inbounds[p.Tag].(*inbound.Trojan).AddUsers(us)
|
||||
case "hysteria":
|
||||
us := make([]option.HysteriaUser, len(p.UserInfo))
|
||||
for i := range p.UserInfo {
|
||||
us := make([]option.HysteriaUser, len(p.Users))
|
||||
for i := range p.Users {
|
||||
us[i] = option.HysteriaUser{
|
||||
Name: p.UserInfo[i].Uuid,
|
||||
AuthString: p.UserInfo[i].Uuid,
|
||||
Name: p.Users[i].Uuid,
|
||||
AuthString: p.Users[i].Uuid,
|
||||
}
|
||||
}
|
||||
err = b.inbounds[p.Tag].(*inbound.Hysteria).AddUsers(us)
|
||||
@@ -72,7 +72,7 @@ func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return len(p.UserInfo), err
|
||||
return len(p.Users), err
|
||||
}
|
||||
|
||||
func (b *Box) GetUserTraffic(tag, uuid string, reset bool) (up int64, down int64) {
|
||||
|
||||
Reference in New Issue
Block a user