Skip to content

Commit

Permalink
修复xray内核vless协议bug,升级xray/sing内核
Browse files Browse the repository at this point in the history
  • Loading branch information
wyx2685 committed Mar 13, 2024
1 parent ed5edda commit 206af02
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 70 deletions.
2 changes: 1 addition & 1 deletion api/panel/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type TlsSettings struct {
ServerPort string `json:"server_port"`
ShortId string `json:"short_id"`
PrivateKey string `json:"private_key"`
Xver uint8 `json:"xver,string"`
Xver uint64 `json:"xver,string"`
}

type RealityConfig struct {
Expand Down
8 changes: 4 additions & 4 deletions core/hy2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const (
defaultStreamReceiveWindow = 8388608 // 8MB
defaultConnReceiveWindow = defaultStreamReceiveWindow * 5 / 2 // 20MB
defaultMaxIdleTimeout = 30 * time.Second
defaultMaxIncomingStreams = 1024
defaultMaxIncomingStreams = 4096
defaultUDPIdleTimeout = 60 * time.Second
)

Expand Down Expand Up @@ -268,7 +268,7 @@ func (n *Hysteria2node) getOutboundConfig(c *serverConfig) (server.Outbound, err
return Outbound, nil
}

func (n *Hysteria2node) getMasqHandler(tlsconfig *server.TLSConfig, conn net.PacketConn, info *panel.NodeInfo, c *serverConfig) (http.Handler, error) {
func (n *Hysteria2node) getMasqHandler(tlsconfig *server.TLSConfig, conn net.PacketConn, c *serverConfig) (http.Handler, error) {
var handler http.Handler
switch strings.ToLower(c.Masquerade.Type) {
case "", "404":
Expand Down Expand Up @@ -347,7 +347,7 @@ func (n *Hysteria2node) getMasqHandler(tlsconfig *server.TLSConfig, conn net.Pac
return MasqHandler, nil
}

func (n *Hysteria2node) getHyConfig(tag string, info *panel.NodeInfo, config *conf.Options, c *serverConfig) (*server.Config, error) {
func (n *Hysteria2node) getHyConfig(info *panel.NodeInfo, config *conf.Options, c *serverConfig) (*server.Config, error) {
tls, err := n.getTLSConfig(config)
if err != nil {
return nil, err
Expand All @@ -364,7 +364,7 @@ func (n *Hysteria2node) getHyConfig(tag string, info *panel.NodeInfo, config *co
if err != nil {
return nil, err
}
Masq, err := n.getMasqHandler(tls, conn, info, c)
Masq, err := n.getMasqHandler(tls, conn, c)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/hy2/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (h *Hysteria2) AddNode(tag string, info *panel.NodeInfo, config *conf.Optio
},
}

hyconfig, err = n.getHyConfig(tag, info, config, &c)
hyconfig, err = n.getHyConfig(info, config, &c)
if err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions core/sing/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/sagernet/sing-box/common/urltest"

"github.com/InazumaV/V2bX/common/format"
"github.com/InazumaV/V2bX/common/rate"

"github.com/InazumaV/V2bX/limiter"
Expand Down Expand Up @@ -95,7 +96,7 @@ func (h *HookServer) RoutedConnection(_ context.Context, conn net.Conn, m adapte
return conn, t
}
ip := m.Source.Addr.String()
if b, r := l.CheckLimit(m.User, ip, true); r {
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, true); r {
conn.Close()
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
return conn, t
Expand Down Expand Up @@ -149,7 +150,7 @@ func (h *HookServer) RoutedPacketConnection(_ context.Context, conn N.PacketConn
return conn, t
}
ip := m.Source.Addr.String()
if b, r := l.CheckLimit(m.User, ip, true); r {
if b, r := l.CheckLimit(format.UserTag(m.Inbound, m.User), ip, true); r {
conn.Close()
log.Error("[", m.Inbound, "] ", "Limited ", m.User, " by ip or conn")
return conn, t
Expand Down
2 changes: 1 addition & 1 deletion core/sing/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func getInboundOptions(tag string, info *panel.NodeInfo, c *conf.Options) (optio
Enabled: true,
ShortID: []string{v.TlsSettings.ShortId},
PrivateKey: v.TlsSettings.PrivateKey,
Xver: v.TlsSettings.Xver,
Xver: uint8(v.TlsSettings.Xver),
Handshake: option.InboundRealityHandshakeOptions{
ServerOptions: option.ServerOptions{
Server: dest,
Expand Down
12 changes: 10 additions & 2 deletions core/xray/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,25 @@ func buildInbound(option *conf.Options, nodeInfo *panel.NodeInfo, tag string) (*
// Reality
in.StreamSetting.Security = "reality"
v := nodeInfo.VAllss
dest := v.TlsSettings.Dest
if dest == "" {
dest = v.TlsSettings.ServerName
}
xver := v.TlsSettings.Xver
if xver == 0 {
xver = v.RealityConfig.Xver
}
d, err := json.Marshal(fmt.Sprintf(
"%s:%s",
v.TlsSettings.ServerName,
dest,
v.TlsSettings.ServerPort))
if err != nil {
return nil, fmt.Errorf("marshal reality dest error: %s", err)
}
mtd, _ := time.ParseDuration(v.RealityConfig.MaxTimeDiff)
in.StreamSetting.REALITYSettings = &coreConf.REALITYConfig{
Dest: d,
Xver: v.RealityConfig.Xver,
Xver: xver,
ServerNames: []string{v.TlsSettings.ServerName},
PrivateKey: v.TlsSettings.PrivateKey,
MinClientVer: v.RealityConfig.MinClientVer,
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ require (
github.com/goccy/go-json v0.10.2
github.com/hashicorp/go-multierror v1.1.1
github.com/juju/ratelimit v1.0.2
github.com/sagernet/sing v0.3.4-beta.1
github.com/sagernet/sing v0.4.0-beta.3
github.com/sagernet/sing-box v1.9.0
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.8
github.com/xtls/xray-core v1.8.10-0.20240313095048-c144470b627f
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.19.0
golang.org/x/sys v0.17.0
google.golang.org/protobuf v1.32.0
golang.org/x/crypto v0.21.0
golang.org/x/sys v0.18.0
google.golang.org/protobuf v1.33.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand Down Expand Up @@ -87,10 +87,10 @@ require (
github.com/gofrs/uuid/v5 v5.0.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20240225044709-fd706174c886 // indirect
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand Down Expand Up @@ -145,7 +145,7 @@ require (
github.com/nrdcg/nodion v0.1.0 // indirect
github.com/nrdcg/porkbun v0.2.0 // indirect
github.com/nzdjb/go-metaname v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.15.0 // indirect
github.com/onsi/ginkgo/v2 v2.16.0 // indirect
github.com/ooni/go-libtor v1.1.8 // indirect
github.com/oracle/oci-go-sdk v24.3.0+incompatible // indirect
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
Expand All @@ -171,7 +171,7 @@ require (
github.com/sagernet/gvisor v0.0.0-20240214044702-a3d61928a32f // indirect
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 // indirect
github.com/sagernet/quic-go v0.41.0-beta.2 // indirect
github.com/sagernet/sing-dns v0.2.0-beta.14 // indirect
github.com/sagernet/sing-dns v0.2.0-beta.15 // indirect
github.com/sagernet/sing-mux v0.2.0 // indirect
github.com/sagernet/sing-quic v0.1.9-beta.1 // indirect
github.com/sagernet/sing-shadowsocks v0.2.6 // indirect
Expand All @@ -195,8 +195,8 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.490 // indirect
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.490 // indirect
Expand All @@ -223,20 +223,20 @@ require (
go.uber.org/ratelimit v0.2.0 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
google.golang.org/grpc v1.62.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect
google.golang.org/grpc v1.62.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/ns1/ns1-go.v2 v2.7.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -246,4 +246,4 @@ require (
)

//github.com/apernet/hysteria/core v1.3.5-0.20240201034858-bb99579bb92c => /root/hysteria/core
replace github.com/sagernet/sing-box v1.9.0 => github.com/wyx2685/sing-box_mod v0.0.5
replace github.com/sagernet/sing-box v1.9.0 => github.com/wyx2685/sing-box_mod v0.0.6
Loading

0 comments on commit 206af02

Please sign in to comment.