From 9b3970348cc39f29784c1e7974e2d9357e4d6b0a Mon Sep 17 00:00:00 2001 From: Yuzuki616 Date: Wed, 23 Aug 2023 19:13:36 +0800 Subject: [PATCH] fix bug for vless --- api/panel/node.go | 16 +++++++++------- core/sing/node.go | 9 ++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/api/panel/node.go b/api/panel/node.go index 6fe226e..2192b74 100644 --- a/api/panel/node.go +++ b/api/panel/node.go @@ -3,12 +3,13 @@ package panel import ( "encoding/base64" "fmt" - "github.com/InazumaV/V2bX/common/crypt" + "log" "reflect" "strconv" "strings" "time" + "github.com/InazumaV/V2bX/common/crypt" "github.com/goccy/go-json" ) @@ -70,7 +71,7 @@ type VAllssNode struct { } type TlsSettings struct { - ServerName []string `json:"sever_name"` + ServerName string `json:"server_name"` ServerPort string `json:"server_port"` ShortIds []string `json:"short_ids"` PrivateKey string `json:"-"` @@ -142,15 +143,15 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) { node.VAllss = rsp node.Security = node.VAllss.Tls if len(rsp.NetworkSettings) > 0 { - /*err = json.Unmarshal(rsp.NetworkSettings, &rsp.RealityConfig) + err = json.Unmarshal(rsp.NetworkSettings, &rsp.RealityConfig) if err != nil { return nil, fmt.Errorf("decode reality config error: %s", err) - }*/ - if node.Security == Reality { - key := crypt.GenX25519Private([]byte(strconv.Itoa(c.NodeId) + c.NodeType + c.Token)) - rsp.TlsSettings.PrivateKey = base64.RawURLEncoding.EncodeToString(key) } } + if node.Security == Reality { + key := crypt.GenX25519Private([]byte(strconv.Itoa(c.NodeId) + c.NodeType + c.Token)) + rsp.TlsSettings.PrivateKey = base64.RawURLEncoding.EncodeToString(key) + } case "shadowsocks": rsp := &ShadowsocksNode{} err = json.Unmarshal(r.Body(), rsp) @@ -233,6 +234,7 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) { cm.BaseConfig = nil c.nodeEtag = r.Header().Get("ETag") + log.Print(node.VAllss.TlsSettings.ServerName) return } diff --git a/core/sing/node.go b/core/sing/node.go index a6d7cc4..dba0919 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -57,7 +57,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio case panel.Reality: tls.Enabled = true v := info.VAllss - tls.ServerName = v.TlsSettings.ServerName[0] + tls.ServerName = v.TlsSettings.ServerName if len(v.TlsSettings.ShortIds) == 0 { v.TlsSettings.ShortIds = []string{""} } @@ -70,7 +70,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio MaxTimeDifference: option.Duration(time.Duration(mtd) * time.Second), Handshake: option.InboundRealityHandshakeOptions{ ServerOptions: option.ServerOptions{ - Server: v.TlsSettings.ServerName[0], + Server: tls.ServerName, ServerPort: uint16(dest), }, }, @@ -207,11 +207,14 @@ func (b *Box) AddNode(tag string, info *panel.NodeInfo, config *conf.Options) er c, nil, ) - b.inbounds[tag] = in + if err != nil { + return fmt.Errorf("init inbound error: %s", err) + } err = in.Start() if err != nil { return fmt.Errorf("start inbound error: %s", err) } + b.inbounds[tag] = in err = b.router.AddInbound(in) if err != nil { return fmt.Errorf("add inbound error: %s", err)