fix bug for vless

This commit is contained in:
Yuzuki616 2023-08-23 19:13:36 +08:00
parent 0fce6588da
commit 9b3970348c
2 changed files with 15 additions and 10 deletions

View File

@ -3,12 +3,13 @@ package panel
import ( import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"github.com/InazumaV/V2bX/common/crypt" "log"
"reflect" "reflect"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/InazumaV/V2bX/common/crypt"
"github.com/goccy/go-json" "github.com/goccy/go-json"
) )
@ -70,7 +71,7 @@ type VAllssNode struct {
} }
type TlsSettings struct { type TlsSettings struct {
ServerName []string `json:"sever_name"` ServerName string `json:"server_name"`
ServerPort string `json:"server_port"` ServerPort string `json:"server_port"`
ShortIds []string `json:"short_ids"` ShortIds []string `json:"short_ids"`
PrivateKey string `json:"-"` PrivateKey string `json:"-"`
@ -142,15 +143,15 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) {
node.VAllss = rsp node.VAllss = rsp
node.Security = node.VAllss.Tls node.Security = node.VAllss.Tls
if len(rsp.NetworkSettings) > 0 { if len(rsp.NetworkSettings) > 0 {
/*err = json.Unmarshal(rsp.NetworkSettings, &rsp.RealityConfig) err = json.Unmarshal(rsp.NetworkSettings, &rsp.RealityConfig)
if err != nil { if err != nil {
return nil, fmt.Errorf("decode reality config error: %s", err) 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": case "shadowsocks":
rsp := &ShadowsocksNode{} rsp := &ShadowsocksNode{}
err = json.Unmarshal(r.Body(), rsp) err = json.Unmarshal(r.Body(), rsp)
@ -233,6 +234,7 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) {
cm.BaseConfig = nil cm.BaseConfig = nil
c.nodeEtag = r.Header().Get("ETag") c.nodeEtag = r.Header().Get("ETag")
log.Print(node.VAllss.TlsSettings.ServerName)
return return
} }

View File

@ -57,7 +57,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
case panel.Reality: case panel.Reality:
tls.Enabled = true tls.Enabled = true
v := info.VAllss v := info.VAllss
tls.ServerName = v.TlsSettings.ServerName[0] tls.ServerName = v.TlsSettings.ServerName
if len(v.TlsSettings.ShortIds) == 0 { if len(v.TlsSettings.ShortIds) == 0 {
v.TlsSettings.ShortIds = []string{""} 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), MaxTimeDifference: option.Duration(time.Duration(mtd) * time.Second),
Handshake: option.InboundRealityHandshakeOptions{ Handshake: option.InboundRealityHandshakeOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: v.TlsSettings.ServerName[0], Server: tls.ServerName,
ServerPort: uint16(dest), ServerPort: uint16(dest),
}, },
}, },
@ -207,11 +207,14 @@ func (b *Box) AddNode(tag string, info *panel.NodeInfo, config *conf.Options) er
c, c,
nil, nil,
) )
b.inbounds[tag] = in if err != nil {
return fmt.Errorf("init inbound error %s", err)
}
err = in.Start() err = in.Start()
if err != nil { if err != nil {
return fmt.Errorf("start inbound error: %s", err) return fmt.Errorf("start inbound error: %s", err)
} }
b.inbounds[tag] = in
err = b.router.AddInbound(in) err = b.router.AddInbound(in)
if err != nil { if err != nil {
return fmt.Errorf("add inbound error: %s", err) return fmt.Errorf("add inbound error: %s", err)