修订代码,完善gui配置代理的功能;url打印出path;其他:

修复quic关闭时闪退的bug;
url打印时若未配置network,去掉首部的加号

Uuid -> UUID
This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 20be4f70f3
commit 40082026e8
24 changed files with 408 additions and 169 deletions
+2 -1
View File
@@ -31,9 +31,10 @@ func (s *Server) GetPath() string {
func (s *Server) Stop() {
if s.listener != nil {
l := s.listener
s.listener = nil
s.listener.Close()
l.Close()
}
}
+2 -2
View File
@@ -355,7 +355,7 @@ func interactively_generateConf(confClient, confServer *proxy.StandardConf) {
}
if i5 == 0 {
uuid := utils.GenerateUUIDStr()
clientDial.Uuid = uuid
clientDial.UUID = uuid
fmt.Println("随机生成的uuid为", uuid)
} else {
promptUUID := promptui.Prompt{
@@ -371,7 +371,7 @@ func interactively_generateConf(confClient, confServer *proxy.StandardConf) {
fmt.Printf("你输入了 %s\n", result)
clientDial.Uuid = result
clientDial.UUID = result
}
var serverListenStruct proxy.ListenConf
+321 -109
View File
@@ -6,7 +6,9 @@ import (
"os"
"github.com/e1732a364fed/ui"
"github.com/e1732a364fed/v2ray_simple/advLayer"
"github.com/e1732a364fed/v2ray_simple/proxy"
"github.com/e1732a364fed/v2ray_simple/utils"
"golang.org/x/exp/slices"
)
@@ -52,120 +54,13 @@ func makeConfPage() ui.Control {
vbox1.SetPadded(true)
hbox2 := ui.NewHorizontalBox()
vbox1.Append(hbox2, false)
hbox2.Append(ui.NewLabel("Listen"), false)
listenCbox := ui.NewCombobox()
hbox2.Append(listenCbox, true)
sc := mainM.DumpStandardConf()
for i, lc := range sc.Listen {
n := lc.Tag
if n == "" {
n = "(no tag)"
}
listenCbox.Append(n)
listenCbox.SetSelected(i)
}
vbox2 := ui.NewVerticalBox()
group2.SetChild(vbox2)
hbox2 = ui.NewHorizontalBox()
vbox2.Append(hbox2, false)
vbox2.Append(ui.NewHorizontalSeparator(), false)
hbox2.Append(ui.NewLabel("Dial"), false)
dialCbox := ui.NewCombobox()
hbox2.Append(dialCbox, true)
curSelectedDial := -1
var update func(shouldChange bool)
for i, dc := range sc.Dial {
n := dc.Tag
if n == "" {
n = "(no tag)"
}
dialCbox.Append(n)
curSelectedDial = i
dialCbox.SetSelected(curSelectedDial)
}
dialCbox.OnSelected(func(c *ui.Combobox) {
curSelectedDial = dialCbox.Selected()
update(false)
})
dialPCbox := ui.NewCombobox()
vbox2.Append(dialPCbox, false)
allDialPs := proxy.AllClientTypeList()
for _, p := range allDialPs {
dialPCbox.Append(p)
}
dialPCbox.OnSelected(func(c *ui.Combobox) {
if curSelectedDial < 0 {
return
}
idx := dialPCbox.Selected()
sc.Dial[curSelectedDial].Protocol = allDialPs[idx]
})
muxC := ui.NewCheckbox("mux")
muxC.OnToggled(func(c *ui.Checkbox) {
if curSelectedDial < 0 {
return
}
sc.Dial[curSelectedDial].Mux = muxC.Checked()
})
vbox2.Append(muxC, false)
update = func(shouldChange bool) {
if curSelectedDial >= 0 {
curD := sc.Dial[curSelectedDial]
muxC.SetChecked(curD.Mux)
dialPCbox.SetSelected(slices.Index(allDialPs, curD.Protocol))
}
if shouldChange {
var shouldStart = false
if mainM.IsRunning() {
mainM.Stop()
shouldStart = true
}
mainM.RemoveAllClient()
mainM.LoadDialConf(sc.Dial)
if shouldStart {
mainM.Start()
}
mainM.PrintAllStateForHuman(os.Stdout)
}
}
update(false)
applyBtn := ui.NewButton("提交修改")
vbox2.Append(ui.NewHorizontalBox(), true)
vbox2.Append(applyBtn, false)
applyBtn.OnClicked(func(b *ui.Button) {
update(true)
})
addConfControls(sc, vbox1, false)
addConfControls(sc, vbox2, true)
// ecbox := ui.NewEditableCombobox()
// vbox.Append(ecbox, false)
@@ -182,3 +77,320 @@ func makeConfPage() ui.Control {
return result
}
func addConfControls(sc proxy.StandardConf, vb *ui.Box, isDial bool) {
allProtocols := proxy.AllServerTypeList()
if isDial {
allProtocols = proxy.AllClientTypeList()
}
allAdvs := utils.GetMapSortedKeySlice(advLayer.ProtocolsMap)
newBtn := ui.NewButton("新增")
rmBtn := ui.NewButton("删除")
randUuidBtn := ui.NewButton("随机uuid")
hbox := ui.NewHorizontalBox()
hbox.SetPadded(true)
hbox.Append(newBtn, false)
hbox.Append(rmBtn, false)
hbox.Append(randUuidBtn, false)
vb.Append(hbox, false)
form := ui.NewForm()
form.SetPadded(true)
vb.Append(form, false)
tagCbox := ui.NewCombobox()
form.Append("", tagCbox, false)
pCbox := ui.NewCombobox()
form.Append("protocol", pCbox, false)
curSelectedTagIdx := -1
var update func(shouldChange bool)
tagE := ui.NewEntry()
form.Append("tag", tagE, false)
hostE := ui.NewEntry()
form.Append("host", hostE, false)
ipE := ui.NewEntry()
form.Append("ip", ipE, false)
portE := ui.NewSpinbox(0, 65535)
form.Append("port", portE, false)
uuidE := ui.NewEntry()
form.Append("uuid", uuidE, false)
tlsC := ui.NewCheckbox("tls")
form.Append("", tlsC, false)
advCbox := ui.NewCombobox()
form.Append("adv", advCbox, false)
pathE := ui.NewEntry()
form.Append("path", pathE, false)
var muxC *ui.Checkbox
{
setUuid := func() {
if isDial {
sc.Dial[curSelectedTagIdx].UUID = uuidE.Text()
} else {
sc.Listen[curSelectedTagIdx].UUID = uuidE.Text()
}
}
randUuidBtn.OnClicked(func(b *ui.Button) {
uuidE.SetText(utils.GenerateUUIDStr())
setUuid()
})
uuidE.OnChanged(func(e *ui.Entry) {
setUuid()
})
newBtn.OnClicked(func(b *ui.Button) {
if isDial {
utils.Splice(&sc.Dial, curSelectedTagIdx, 0, &proxy.DialConf{})
} else {
utils.Splice(&sc.Listen, curSelectedTagIdx, 0, &proxy.ListenConf{})
}
update(false)
})
rmBtn.OnClicked(func(b *ui.Button) {
if isDial {
utils.Splice(&sc.Dial, curSelectedTagIdx, 1)
} else {
utils.Splice(&sc.Listen, curSelectedTagIdx, 1)
}
update(false)
})
tagCbox.OnSelected(func(c *ui.Combobox) {
curSelectedTagIdx = tagCbox.Selected()
update(false)
})
for _, p := range allProtocols {
pCbox.Append(p)
}
pCbox.OnSelected(func(c *ui.Combobox) {
if curSelectedTagIdx < 0 {
return
}
idx := pCbox.Selected()
if isDial {
sc.Dial[curSelectedTagIdx].Protocol = allProtocols[idx]
} else {
sc.Listen[curSelectedTagIdx].Protocol = allProtocols[idx]
}
})
tagE.OnChanged(func(e *ui.Entry) {
if isDial {
sc.Dial[curSelectedTagIdx].Tag = tagE.Text()
} else {
sc.Listen[curSelectedTagIdx].Tag = tagE.Text()
}
update(false)
})
hostE.OnChanged(func(e *ui.Entry) {
if isDial {
sc.Dial[curSelectedTagIdx].Host = hostE.Text()
} else {
sc.Listen[curSelectedTagIdx].Host = hostE.Text()
}
})
ipE.OnChanged(func(e *ui.Entry) {
if isDial {
sc.Dial[curSelectedTagIdx].IP = ipE.Text()
} else {
sc.Listen[curSelectedTagIdx].IP = ipE.Text()
}
})
portE.OnChanged(func(s *ui.Spinbox) {
if isDial {
sc.Dial[curSelectedTagIdx].Port = portE.Value()
} else {
sc.Listen[curSelectedTagIdx].Port = portE.Value()
}
})
tlsC.OnToggled(func(c *ui.Checkbox) {
if isDial {
sc.Dial[curSelectedTagIdx].TLS = tlsC.Checked()
} else {
sc.Listen[curSelectedTagIdx].TLS = tlsC.Checked()
}
update(false)
})
for _, v := range allAdvs {
advCbox.Append(v)
}
advCbox.OnSelected(func(c *ui.Combobox) {
if curSelectedTagIdx < 0 {
return
}
idx := advCbox.Selected()
if isDial {
sc.Dial[curSelectedTagIdx].AdvancedLayer = allAdvs[idx]
} else {
sc.Listen[curSelectedTagIdx].AdvancedLayer = allAdvs[idx]
}
})
pathE.OnChanged(func(e *ui.Entry) {
if isDial {
sc.Dial[curSelectedTagIdx].Path = pathE.Text()
} else {
sc.Listen[curSelectedTagIdx].Path = pathE.Text()
}
})
}
if isDial {
muxC = ui.NewCheckbox("mux")
form.Append("", muxC, false)
muxC.OnToggled(func(c *ui.Checkbox) {
if curSelectedTagIdx < 0 {
return
}
sc.Dial[curSelectedTagIdx].Mux = muxC.Checked()
})
}
update = func(shouldChange bool) {
tagCbox.Clear()
if isDial {
for _, dc := range sc.Dial {
n := dc.Tag
if n == "" {
n = "(no tag)"
}
tagCbox.Append(n)
}
if len(sc.Dial) > 0 && curSelectedTagIdx < 0 {
curSelectedTagIdx = 0
}
if curSelectedTagIdx >= 0 && curSelectedTagIdx < len(sc.Dial) {
tagCbox.SetSelected(curSelectedTagIdx)
}
} else {
for _, lc := range sc.Listen {
n := lc.Tag
if n == "" {
n = "(no tag)"
}
tagCbox.Append(n)
}
if len(sc.Listen) > 0 && curSelectedTagIdx < 0 {
curSelectedTagIdx = 0
}
if curSelectedTagIdx >= 0 && curSelectedTagIdx < len(sc.Listen) {
tagCbox.SetSelected(curSelectedTagIdx)
}
}
if curSelectedTagIdx >= 0 {
var cc proxy.CommonConf
if isDial {
if curSelectedTagIdx >= len(sc.Dial) {
curSelectedTagIdx = len(sc.Dial) - 1
}
if curSelectedTagIdx >= 0 {
curD := sc.Dial[curSelectedTagIdx]
cc = curD.CommonConf
muxC.SetChecked(curD.Mux)
}
} else {
if curSelectedTagIdx >= len(sc.Listen) {
curSelectedTagIdx = len(sc.Listen) - 1
}
if curSelectedTagIdx >= 0 {
curL := sc.Listen[curSelectedTagIdx]
cc = curL.CommonConf
}
}
pCbox.SetSelected(slices.Index(allProtocols, cc.Protocol))
tagE.SetText(cc.Tag)
hostE.SetText(cc.Host)
ipE.SetText(cc.IP)
portE.SetValue(cc.Port)
uuidE.SetText(cc.UUID)
tlsC.SetChecked(cc.TLS)
pathE.SetText(cc.Path)
advCbox.SetSelected(slices.Index(allAdvs, cc.AdvancedLayer))
}
if shouldChange {
var shouldStart = false
if mainM.IsRunning() {
mainM.Stop()
shouldStart = true
}
mainM.RemoveAllClient()
mainM.LoadDialConf(sc.Dial)
mainM.RemoveAllServer()
mainM.LoadListenConf(sc.Listen, false)
if shouldStart {
mainM.Start()
}
mainM.PrintAllStateForHuman(os.Stdout)
}
}
update(false)
if isDial {
applyBtn := ui.NewButton("提交修改")
vb.Append(ui.NewHorizontalBox(), true)
vb.Append(applyBtn, false)
applyBtn.OnClicked(func(b *ui.Button) {
update(true)
})
}
}
+4 -4
View File
@@ -13,7 +13,7 @@ var myvmess_wss = &proxy.DialConf{
CommonConf: proxy.CommonConf{
Protocol: "vmess",
EncryptAlgo: "aes-128-gcm",
Uuid: utils.ExampleUUID,
UUID: utils.ExampleUUID,
TLS: true,
AdvancedLayer: "ws",
Path: "/path1",
@@ -28,7 +28,7 @@ var myss_http = &proxy.DialConf{
CommonConf: proxy.CommonConf{
Protocol: "shadowsocks",
EncryptAlgo: "chacha20",
Uuid: "method:chacha20\npass:" + utils.ExampleUUID,
UUID: "method:chacha20\npass:" + utils.ExampleUUID,
HttpHeader: &httpLayer.HeaderPreset{
Request: &httpLayer.RequestHeader{
Path: []string{"/pathx"},
@@ -48,7 +48,7 @@ var myss_wss = &proxy.DialConf{
CommonConf: proxy.CommonConf{
Protocol: "shadowsocks",
EncryptAlgo: "chacha20",
Uuid: "method:chacha20\npass:" + utils.ExampleUUID,
UUID: "method:chacha20\npass:" + utils.ExampleUUID,
HttpHeader: &httpLayer.HeaderPreset{
Request: &httpLayer.RequestHeader{
Path: []string{"/pathx"},
@@ -67,7 +67,7 @@ var myss_wss = &proxy.DialConf{
},
}
//unexhaustive
// unexhaustive
func TestToQX(t *testing.T) {
if configAdapter.ToQX(myvmess_wss) != "vmess=1.1.1.1:443, method=aes-128-gcm, password=a684455c-b14f-11ea-bf0d-42010aaa0003, obfs=wss, obfs-host=example.com, obfs-uri=/path1, tag=myvmess_wss" {
+2 -2
View File
@@ -35,7 +35,7 @@ func ToSS(cc *proxy.CommonConf, lc *proxy.ListenConf, plain_userinfo bool, sip i
u.Scheme = cc.Protocol
ok, m, p := utils.CommonSplit(cc.Uuid, "method", "pass")
ok, m, p := utils.CommonSplit(cc.UUID, "method", "pass")
if !ok {
return "parsing error when split uuid to get method and pass"
@@ -156,7 +156,7 @@ func ToXray(dc *proxy.DialConf) string {
var u url.URL
u.Scheme = dc.Protocol
u.User = url.User(dc.Uuid)
u.User = url.User(dc.UUID)
if dc.IP != "" {
u.Host = dc.IP + ":" + strconv.Itoa(dc.Port)
} else {
+13 -13
View File
@@ -56,7 +56,7 @@ func ToQX(dc *proxy.DialConf) string {
//vs 中,ss的 加密方法可以在两个地方指定,一个是uuid中的method部分,一个是 EncryptAlgo
//其中,uuid的method部分是必须要给出的
ok, m, p := utils.CommonSplit(dc.Uuid, "method", "pass")
ok, m, p := utils.CommonSplit(dc.UUID, "method", "pass")
if !ok {
return "parsing error when split uuid to get method and pass"
}
@@ -120,7 +120,7 @@ func ToQX(dc *proxy.DialConf) string {
}
sb.WriteString(strings.ToLower(ea))
sb.WriteString(", password=")
sb.WriteString(dc.Uuid)
sb.WriteString(dc.UUID)
var hasObfs bool
@@ -155,8 +155,8 @@ func ToQX(dc *proxy.DialConf) string {
}
case "http":
if dc.Uuid != "" {
ok, u, p := utils.CommonSplit(dc.Uuid, "user", "pass")
if dc.UUID != "" {
ok, u, p := utils.CommonSplit(dc.UUID, "user", "pass")
if !ok {
return "parsing error when split uuid to get user and pass"
}
@@ -169,7 +169,7 @@ func ToQX(dc *proxy.DialConf) string {
trojan_or_http_tlsFunc()
case "trojan":
sb.WriteString(", password=")
sb.WriteString(dc.Uuid)
sb.WriteString(dc.UUID)
trojan_or_http_tlsFunc()
} //switch
@@ -216,7 +216,7 @@ func FromQX(str string) (dc proxy.DialConf) {
case "method":
dc.EncryptAlgo = v
case "password":
dc.Uuid = v
dc.UUID = v
case "tag":
dc.Tag = v
case "obfs-uri":
@@ -256,8 +256,8 @@ func FromQX(str string) (dc proxy.DialConf) {
}
if dc.Protocol == "shadowsocks" {
if dc.Uuid != "" && dc.EncryptAlgo != "" {
dc.Uuid = "method:" + dc.EncryptAlgo + "\n" + "pass:" + dc.Uuid
if dc.UUID != "" && dc.EncryptAlgo != "" {
dc.UUID = "method:" + dc.EncryptAlgo + "\n" + "pass:" + dc.UUID
}
}
if dc.Extra == nil {
@@ -348,7 +348,7 @@ func ToClash(dc *proxy.DialConf) string {
switch dc.Protocol {
case "shadowsocks":
ok, m, p := utils.CommonSplit(dc.Uuid, "method", "pass")
ok, m, p := utils.CommonSplit(dc.UUID, "method", "pass")
if !ok {
return "parsing error when split uuid to get method and pass"
}
@@ -382,7 +382,7 @@ func ToClash(dc *proxy.DialConf) string {
case "vmess":
if dc.Protocol == "vmess" {
sb.WriteString("\n uuid: ")
sb.WriteString(dc.Uuid)
sb.WriteString(dc.UUID)
sb.WriteString("\n alterId: 0")
sb.WriteString("\n cipher: ")
if dc.EncryptAlgo != "" {
@@ -393,7 +393,7 @@ func ToClash(dc *proxy.DialConf) string {
} else {
sb.WriteString("\n password: ")
sb.WriteString(dc.Uuid)
sb.WriteString(dc.UUID)
}
if dc.TLS {
@@ -447,7 +447,7 @@ func ToClash(dc *proxy.DialConf) string {
case "http":
fallthrough
case "socks5":
ok, u, p := utils.CommonSplit(dc.Uuid, "user", "pass")
ok, u, p := utils.CommonSplit(dc.UUID, "user", "pass")
if !ok {
return "parsing error when split uuid to get user and pass"
}
@@ -493,7 +493,7 @@ func ToV2rayN(dc *proxy.DialConf) string {
PS: dc.Tag,
Add: dc.IP,
Port: strconv.Itoa(dc.Port),
ID: dc.Uuid,
ID: dc.UUID,
Security: dc.EncryptAlgo,
Host: dc.Host,
Sni: dc.Host,
+6 -6
View File
@@ -14,14 +14,14 @@ func (m *M) LoadDialConf(conf []*proxy.DialConf) (ok bool) {
for _, d := range conf {
if d.Uuid == "" && m.DefaultUUID != "" {
d.Uuid = m.DefaultUUID
if d.UUID == "" && m.DefaultUUID != "" {
d.UUID = m.DefaultUUID
}
outClient, err := proxy.NewClient(d)
if err != nil {
if ce := utils.CanLogErr("can not create outClient: "); ce != nil {
ce.Write(zap.Error(err))
ce.Write(zap.Error(err), zap.Any("raw", d))
}
ok = false
continue
@@ -54,15 +54,15 @@ func (m *M) LoadListenConf(conf []*proxy.ListenConf, hot bool) (ok bool) {
}
for _, l := range conf {
if l.Uuid == "" && m.DefaultUUID != "" {
l.Uuid = m.DefaultUUID
if l.UUID == "" && m.DefaultUUID != "" {
l.UUID = m.DefaultUUID
}
inServer, err := proxy.NewServer(l)
if err != nil {
if ce := utils.CanLogErr("Can not create listen server"); ce != nil {
ce.Write(zap.Error(err))
ce.Write(zap.Error(err), zap.Any("raw", l))
}
ok = false
continue
+1 -1
View File
@@ -71,7 +71,7 @@ type CommonConf struct {
/////////////////// 代理层 ///////////////////
Protocol string `toml:"protocol"` //代理层; 约定,如果一个Protocol尾缀去掉了一个's'后仍然是一个有效协议,则该协议使用了 tls。这种方法继承自 v2simple,适合极简模式
Uuid string `toml:"uuid"` //代理层用户的唯一标识,视代理层协议而定,一般使用uuid,但trojan协议是随便的password, 而socks5 和 http 则使用 user+pass 的形式。 我们为了简洁、一致,就统一放到了 这个字段里。
UUID string `toml:"uuid"` //代理层用户的唯一标识,视代理层协议而定,一般使用uuid,但trojan协议是随便的password, 而socks5 和 http 则使用 user+pass 的形式。 我们为了简洁、一致,就统一放到了 这个字段里。
Version int `toml:"version"` //可选,代理层协议版本号,vless v1 要用到。
EncryptAlgo string `toml:"encrypt_algo"` //内部加密算法,vmess/ss 等协议可指定
+2 -2
View File
@@ -177,7 +177,7 @@ func URLToCommonConf(u *url.URL, conf *CommonConf) error {
conf.Network = q.Get("network")
conf.Uuid = u.User.Username()
conf.UUID = u.User.Username()
conf.Fullcone = utils.QueryPositive(q, "fullcone")
conf.Tag = u.Fragment
@@ -320,7 +320,7 @@ func ToStandardUrl(cc *CommonConf, dc *DialConf, lc *ListenConf) string {
u.Scheme += "s"
}
u.User = url.User(cc.Uuid)
u.User = url.User(cc.UUID)
if cc.IP != "" {
u.Host = cc.IP + ":" + strconv.Itoa(cc.Port)
} else {
+1 -1
View File
@@ -70,7 +70,7 @@ func (ServerCreator) URLToListenConf(u *url.URL, lc *proxy.ListenConf, format in
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
s := NewServer()
if str := lc.Uuid; str != "" {
if str := lc.UUID; str != "" {
var userPass utils.UserPass
if userPass.InitWithStr(str) {
s.AddUser(&userPass)
+28 -2
View File
@@ -131,6 +131,26 @@ func GetVSI_url(pc BaseInterface, targetNetwork string) string {
sb.WriteString(pc.AddrStr())
}
path := ""
if lc := pc.GetBase().ListenConf; lc != nil {
if lc.Path != "" {
path = lc.Path
}
} else if dc := pc.GetBase().DialConf; dc != nil {
if dc.Path != "" {
path = dc.Path
}
}
if path != "" {
if !strings.HasPrefix(path, "/") {
sb.WriteString("/")
}
sb.WriteString(path)
}
if t := pc.GetTag(); t != "" {
sb.WriteByte('#')
sb.WriteString(t)
@@ -142,8 +162,14 @@ func GetVSI_url(pc BaseInterface, targetNetwork string) string {
func getFullNameBuilder(pc BaseInterface, n string) *strings.Builder {
var sb strings.Builder
sb.WriteString(pc.Network())
sb.WriteString(pc.MiddleName())
ne := pc.Network()
sb.WriteString(ne)
mn := pc.MiddleName()
if ne == "" {
mn = strings.TrimLeft(mn, "+")
}
sb.WriteString(mn)
sb.WriteString(n)
if i, innerProxyName := pc.HasInnerMux(); i == 2 {
+2 -2
View File
@@ -30,7 +30,7 @@ func (ClientCreator) URLToDialConf(u *url.URL, dc *proxy.DialConf, format int) (
if p, set := u.User.Password(); set {
dc.Uuid = "method:" + u.User.Username() + "\npass:" + p
dc.UUID = "method:" + u.User.Username() + "\npass:" + p
}
return dc, nil
@@ -38,7 +38,7 @@ func (ClientCreator) URLToDialConf(u *url.URL, dc *proxy.DialConf, format int) (
func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error) {
uuidStr := dc.Uuid
uuidStr := dc.UUID
var mp MethodPass
if mp.InitWithStr(uuidStr) {
return newClient(mp), nil
+2 -2
View File
@@ -30,7 +30,7 @@ func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
lc.Network = netLayer.DualNetworkName
}
uuidStr := lc.Uuid
uuidStr := lc.UUID
var mp MethodPass
if mp.InitWithStr(uuidStr) {
@@ -50,7 +50,7 @@ func (ServerCreator) URLToListenConf(u *url.URL, lc *proxy.ListenConf, format in
}
if p, set := u.User.Password(); set {
lc.Uuid = "method:" + u.User.Username() + "\npass:" + p
lc.UUID = "method:" + u.User.Username() + "\npass:" + p
}
return lc, nil
+2 -2
View File
@@ -31,7 +31,7 @@ func (ClientCreator) URLToDialConf(u *url.URL, dc *proxy.DialConf, format int) (
}
if p, set := u.User.Password(); set {
dc.Uuid = "user:" + u.User.Username() + "\npass:" + p
dc.UUID = "user:" + u.User.Username() + "\npass:" + p
}
return dc, nil
@@ -39,7 +39,7 @@ func (ClientCreator) URLToDialConf(u *url.URL, dc *proxy.DialConf, format int) (
func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error) {
c := &Client{}
if str := dc.Uuid; str != "" {
if str := dc.UUID; str != "" {
c.InitWithStr(str)
}
return c, nil
+1 -1
View File
@@ -68,7 +68,7 @@ func (ServerCreator) URLToListenConf(u *url.URL, lc *proxy.ListenConf, format in
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
s := NewServer()
if str := lc.Uuid; str != "" {
if str := lc.UUID; str != "" {
var userPass utils.UserPass
if userPass.InitWithStr(str) {
+2 -2
View File
@@ -26,7 +26,7 @@ func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int)
if dc == nil {
dc = &proxy.DialConf{}
uuidStr := url.User.Username()
dc.Uuid = uuidStr
dc.UUID = uuidStr
}
return dc, nil
@@ -37,7 +37,7 @@ func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int)
func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error) {
uuidStr := dc.Uuid
uuidStr := dc.UUID
c := Client{
use_mux: dc.Mux,
+2 -2
View File
@@ -18,7 +18,7 @@ func init() {
type ServerCreator struct{ proxy.CreatorCommonStruct }
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
uuidStr := lc.Uuid
uuidStr := lc.UUID
s := newServer(uuidStr)
@@ -36,7 +36,7 @@ func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format
if lc == nil {
lc = &proxy.ListenConf{}
uuidStr := url.User.Username()
lc.Uuid = uuidStr
lc.UUID = uuidStr
}
return lc, nil
+1 -1
View File
@@ -218,7 +218,7 @@ func GenerateOfficialDraftShareURL(dialconf *proxy.DialConf) string {
var u url.URL
u.Scheme = Name
u.User = url.User(dialconf.Uuid)
u.User = url.User(dialconf.UUID)
if dialconf.IP != "" {
u.Host = dialconf.IP + ":" + strconv.Itoa(dialconf.Port)
} else {
+2 -2
View File
@@ -20,7 +20,7 @@ type ClientCreator struct{ proxy.CreatorCommonStruct }
func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error) {
uuidStr := dc.Uuid
uuidStr := dc.UUID
id, err := utils.NewV2rayUser(uuidStr)
if err != nil {
return nil, err
@@ -60,7 +60,7 @@ func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int)
if dc == nil {
dc = &proxy.DialConf{}
uuidStr := url.User.Username()
dc.Uuid = uuidStr
dc.UUID = uuidStr
}
+2 -2
View File
@@ -22,7 +22,7 @@ type ServerCreator struct{ proxy.CreatorCommonStruct }
// 如果 lc.Version==0, 则只支持 v0.
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
uuidStr := lc.Uuid
uuidStr := lc.UUID
onlyV0 := lc.Version == 0
var s *Server
@@ -54,7 +54,7 @@ func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format
lc = &proxy.ListenConf{}
uuidStr := url.User.Username()
lc.Uuid = uuidStr
lc.UUID = uuidStr
}
return lc, nil
+4 -5
View File
@@ -1,9 +1,8 @@
/* Package vless implements vless v0/v1 for proxy.Client and proxy.Server.
/*
Package vless implements vless v0/v1 for proxy.Client and proxy.Server.
vless的客户端配置 分享url文档:
https://github.com/XTLS/Xray-core/discussions/716
*/
package vless
@@ -31,7 +30,7 @@ const (
CmdMux
)
//依照 vless 协议的格式 依次写入 地址的 port, 域名/ip 信息
// 依照 vless 协议的格式 依次写入 地址的 port, 域名/ip 信息
func WriteAddrTo(writeBuf utils.ByteWriter, raddr netLayer.Addr) {
writeBuf.WriteByte(byte(raddr.Port >> 8))
writeBuf.WriteByte(byte(raddr.Port << 8 >> 8))
@@ -46,7 +45,7 @@ func GenerateXrayShareURL(dc *proxy.DialConf) string {
var u url.URL
u.Scheme = Name
u.User = url.User(dc.Uuid)
u.User = url.User(dc.UUID)
if dc.IP != "" {
u.Host = dc.IP + ":" + strconv.Itoa(dc.Port)
} else {
+2 -2
View File
@@ -59,7 +59,7 @@ func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int)
dc = &proxy.DialConf{}
uuidStr := url.User.Username()
dc.Uuid = uuidStr
dc.UUID = uuidStr
}
@@ -67,7 +67,7 @@ func (ClientCreator) URLToDialConf(url *url.URL, dc *proxy.DialConf, format int)
}
func (ClientCreator) NewClient(dc *proxy.DialConf) (proxy.Client, error) {
uuid, err := utils.StrToUUID(dc.Uuid)
uuid, err := utils.StrToUUID(dc.UUID)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -77,7 +77,7 @@ func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format
lc = &proxy.ListenConf{}
uuidStr := url.User.Username()
lc.Uuid = uuidStr
lc.UUID = uuidStr
}
return lc, nil
@@ -88,7 +88,7 @@ func (ServerCreator) URLToListenConf(url *url.URL, lc *proxy.ListenConf, format
}
func (ServerCreator) NewServer(lc *proxy.ListenConf) (proxy.Server, error) {
uuidStr := lc.Uuid
uuidStr := lc.UUID
s := NewServer()
+2 -1
View File
@@ -159,7 +159,8 @@ func MoveItem[T any](arr *[]T, fromIndex, toIndex int) {
// splices 包在 Nov 10, 2022 添加了Replace函数, 就不用我们自己的实现了
// v0.0.0-20221110155412-d0897a79cd37, 不过我们为了代码兼容依然保存该代码,直到2.x.x版本.
//
// items to insert at start, delete deleteCount items at start
// items to insert at start, delete deleteCount items at start.
//
// See https://github.com/zzwx/splice/blob/main/splice.go
func Splice[T any](source *[]T, start int, deleteCount int, items ...T) (removed []T) {
if start > len(*source) {