From 4d82eff51885705486132ad788d962aa413184e0 Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Wed, 17 Jul 2024 09:21:57 +0900 Subject: [PATCH] update Xray-core 1.8.18 --- core/sing/node.go | 35 ++++++++++++++++++++++++++++++++--- core/xray/inbound.go | 20 ++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- node/user.go | 3 +-- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/core/sing/node.go b/core/sing/node.go index dde9811..bc875d2 100644 --- a/core/sing/node.go +++ b/core/sing/node.go @@ -40,6 +40,15 @@ type WsNetworkConfig struct { Headers map[string]string `json:"headers"` } +type GrpcNetworkConfig struct { + ServiceName string `json:"serviceName"` +} + +type HttpupgradeNetworkConfig struct { + Path string `json:"path"` + Host string `json:"host"` +} + func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (option.Inbound, error) { addr, err := netip.ParseAddr(c.ListenIP) if err != nil { @@ -170,12 +179,28 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio Headers: headers, } case "grpc": + network := GrpcNetworkConfig{} if len(n.NetworkSettings) != 0 { - err := json.Unmarshal(n.NetworkSettings, &t.GRPCOptions) + err := json.Unmarshal(n.NetworkSettings, &network) if err != nil { return option.Inbound{}, fmt.Errorf("decode NetworkSettings error: %s", err) } } + t.GRPCOptions = option.V2RayGRPCOptions{ + ServiceName: network.ServiceName, + } + case "httpupgrade": + network := HttpupgradeNetworkConfig{} + if len(n.NetworkSettings) != 0 { + err := json.Unmarshal(n.NetworkSettings, &network) + if err != nil { + return option.Inbound{}, fmt.Errorf("decode NetworkSettings error: %s", err) + } + } + t.HTTPUpgradeOptions = option.V2RayHTTPUpgradeOptions{ + Path: network.Path, + Host: network.Host, + } } if info.Type == "vless" { in.Type = "vless" @@ -203,7 +228,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio switch n.Cipher { case "2022-blake3-aes-128-gcm": keyLength = 16 - case "2022-blake3-aes-256-gcm": + case "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305": keyLength = 32 default: keyLength = 16 @@ -263,12 +288,16 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio Headers: headers, } case "grpc": + network := GrpcNetworkConfig{} if len(n.NetworkSettings) != 0 { - err := json.Unmarshal(n.NetworkSettings, &t.GRPCOptions) + err := json.Unmarshal(n.NetworkSettings, &network) if err != nil { return option.Inbound{}, fmt.Errorf("decode NetworkSettings error: %s", err) } } + t.GRPCOptions = option.V2RayGRPCOptions{ + ServiceName: network.ServiceName, + } default: t.Type = "" } diff --git a/core/xray/inbound.go b/core/xray/inbound.go index 8408775..8dc7338 100644 --- a/core/xray/inbound.go +++ b/core/xray/inbound.go @@ -208,6 +208,26 @@ func buildV2ray(config *conf.Options, nodeInfo *panel.NodeInfo, inbound *coreCon if err != nil { return fmt.Errorf("unmarshal grpc settings error: %s", err) } + case "http": + err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.HTTPSettings) + if err != nil { + return fmt.Errorf("unmarshal grpc settings error: %s", err) + } + case "quic": + err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.QUICSettings) + if err != nil { + return fmt.Errorf("unmarshal grpc settings error: %s", err) + } + case "httpupgrade": + err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.HTTPUPGRADESettings) + if err != nil { + return fmt.Errorf("unmarshal grpc settings error: %s", err) + } + case "splithttp": + err := json.Unmarshal(v.NetworkSettings, &inbound.StreamSetting.SplitHTTPSettings) + if err != nil { + return fmt.Errorf("unmarshal grpc settings error: %s", err) + } default: return errors.New("the network type is not vail") } diff --git a/go.mod b/go.mod index e187d3a..7c7bb7f 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.15.0 - github.com/xtls/xray-core v1.8.17 + github.com/xtls/xray-core v1.8.18 go.uber.org/zap v1.27.0 golang.org/x/crypto v0.25.0 golang.org/x/sys v0.22.0 diff --git a/go.sum b/go.sum index 75be755..db7f037 100644 --- a/go.sum +++ b/go.sum @@ -949,8 +949,8 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= -github.com/xtls/xray-core v1.8.17 h1:T+A/hkBB33P0sEGXDiuKrQMZUOYxbZ84JlsYfyRiK8w= -github.com/xtls/xray-core v1.8.17/go.mod h1:qEVGJD2suPN7EArG3r5EX6pYGV0QLiSRTlDMn0paJkc= +github.com/xtls/xray-core v1.8.18 h1:o4SnyQ78vh5o9dp3NoIKwEeN7AUWlEGawQ5PkogTC1w= +github.com/xtls/xray-core v1.8.18/go.mod h1:z7D4GwOXWwque0B5DJ+/+eGEVE4V5kFRhl0qbecMeY0= github.com/yandex-cloud/go-genproto v0.0.0-20240318083951-4fe6125f286e h1:jLIqA7M9qY31g/Nw/5htVD0DFbxmLnlFZcHKJiG3osI= github.com/yandex-cloud/go-genproto v0.0.0-20240318083951-4fe6125f286e/go.mod h1:HEUYX/p8966tMUHHT+TsS0hF/Ca/NYwqprC5WXSDMfE= github.com/yandex-cloud/go-sdk v0.0.0-20240318084659-dfa50323a0b4 h1:wtzLQJmghkSUb1YkeFphIh7ST7NNVDaVOJZSAJcjMdw= diff --git a/node/user.go b/node/user.go index 95c80d4..8466931 100644 --- a/node/user.go +++ b/node/user.go @@ -1,7 +1,6 @@ package node import ( - "fmt" "strconv" "github.com/InazumaV/V2bX/api/panel" @@ -60,7 +59,7 @@ func (c *Controller) reportUserTrafficTask() (err error) { data := make(map[int][]string) for _, onlineuser := range result { // json structure: { UID1:["ip1","ip2"],UID2:["ip3","ip4"] } - data[onlineuser.UID] = append(data[onlineuser.UID], fmt.Sprintf("%s_%d", onlineuser.IP, c.info.Id)) + data[onlineuser.UID] = append(data[onlineuser.UID], onlineuser.IP) if _, ok := reportOnline[onlineuser.UID]; ok { reportOnline[onlineuser.UID]++ } else {