support vless for sing

This commit is contained in:
Yuzuki616 2023-07-30 19:49:42 +08:00
parent f17fd74e86
commit 991b22a317
5 changed files with 38 additions and 18 deletions

View File

@ -2,5 +2,4 @@
package imports
// not yet tested
import _ "github.com/InazumaV/V2bX/core/hy"

View File

@ -46,7 +46,6 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
}
switch info.Type {
case "v2ray":
in.Type = "vmess"
t := option.V2RayTransportOptions{
Type: info.Network,
}
@ -83,10 +82,20 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
return option.Inbound{}, fmt.Errorf("decode NetworkSettings error: %s", err)
}
}
in.VMessOptions = option.VMessInboundOptions{
ListenOptions: listen,
TLS: &tls,
Transport: &t,
if info.ExtraConfig.EnableVless == "true" {
in.Type = "vless"
in.VLESSOptions = option.VLESSInboundOptions{
ListenOptions: listen,
TLS: &tls,
Transport: &t,
}
} else {
in.Type = "vmess"
in.VMessOptions = option.VMessInboundOptions{
ListenOptions: listen,
TLS: &tls,
Transport: &t,
}
}
case "shadowsocks":
in.Type = "shadowsocks"

View File

@ -13,16 +13,25 @@ import (
func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) {
switch p.NodeInfo.Type {
case "v2ray":
us := make([]option.VMessUser, len(p.UserInfo))
for i := range p.UserInfo {
us[i] = option.VMessUser{
Name: p.UserInfo[i].Uuid,
UUID: p.UserInfo[i].Uuid,
if p.NodeInfo.ExtraConfig.EnableVless == "true" {
us := make([]option.VLESSUser, len(p.UserInfo))
for i := range p.UserInfo {
us[i] = option.VLESSUser{
Name: p.UserInfo[i].Uuid,
Flow: p.NodeInfo.ExtraConfig.VlessFlow,
UUID: p.UserInfo[i].Uuid,
}
}
}
err = b.inbounds[p.Tag].(*inbound.VMess).AddUsers(us)
if err != nil {
return 0, err
err = b.inbounds[p.Tag].(*inbound.VLESS).AddUsers(us)
} else {
us := make([]option.VMessUser, len(p.UserInfo))
for i := range p.UserInfo {
us[i] = option.VMessUser{
Name: p.UserInfo[i].Uuid,
UUID: p.UserInfo[i].Uuid,
}
}
err = b.inbounds[p.Tag].(*inbound.VMess).AddUsers(us)
}
case "shadowsocks":
us := make([]option.ShadowsocksUser, len(p.UserInfo))
@ -33,6 +42,9 @@ func (b *Box) AddUsers(p *core.AddUsersParams) (added int, err error) {
}
}
}
if err != nil {
return 0, err
}
return len(p.UserInfo), err
}

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/go-resty/resty/v2 v2.7.0
github.com/goccy/go-json v0.10.2
github.com/hashicorp/go-multierror v1.1.1
github.com/inazumav/sing-box v0.0.0-20230728123002-eb2ba58e499a
github.com/inazumav/sing-box v0.0.0-20230730105931-e8479113c010
github.com/juju/ratelimit v1.0.2
github.com/oschwald/geoip2-golang v1.9.0
github.com/sagernet/sing v0.2.9

4
go.sum
View File

@ -379,8 +379,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df h1:MZf03xP9WdakyXhOWuAD5uPK3wHh96wCsqe3hCMKh8E=
github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhKWFeDesPjMj+wCHReeknARU3wqlyN4=
github.com/inazumav/sing-box v0.0.0-20230728123002-eb2ba58e499a h1:/FGmhOCu6LYt8zd6DpMEvuHlPnUPMr0zziyJkuU1wVI=
github.com/inazumav/sing-box v0.0.0-20230728123002-eb2ba58e499a/go.mod h1:W91us/coe3lvl5jCtw2n6acyagpRbOO16h1IV3/0nrc=
github.com/inazumav/sing-box v0.0.0-20230730105931-e8479113c010 h1:AbH2HERgLu8Jgi4vHi8aRvkds+biIqxw+Btz3L+XTJY=
github.com/inazumav/sing-box v0.0.0-20230730105931-e8479113c010/go.mod h1:W91us/coe3lvl5jCtw2n6acyagpRbOO16h1IV3/0nrc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=