Skip to content

Commit

Permalink
测试:增加hysteria2内核
Browse files Browse the repository at this point in the history
  • Loading branch information
wyx2685 committed Feb 6, 2024
1 parent 77ec030 commit 0d274bc
Show file tree
Hide file tree
Showing 15 changed files with 933 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ jobs:
run: |
echo "version: $version"
mkdir -p build_assets
go build -v -o build_assets/V2bX -tags "sing xray with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid="
go build -v -o build_assets/V2bX -tags "sing xray hysteria2 with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid="
- name: Build Mips softfloat V2bX
if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle'
run: |
echo "version: $version"
GOMIPS=softfloat go build -v -o build_assets/V2bX_softfloat -tags "sing xray with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid="
GOMIPS=softfloat go build -v -o build_assets/V2bX_softfloat -tags "sing xray hysteria2 with_reality_server with_quic with_grpc with_utls with_wireguard with_acme" -trimpath -ldflags "-X 'github.com/InazumaV/V2bX/cmd.version=$version' -s -w -buildid="
- name: Rename Windows V2bX
if: matrix.goos == 'windows'
run: |
Expand Down
12 changes: 8 additions & 4 deletions conf/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
)

type CoreConfig struct {
Type string `json:"Type"`
Name string `json:"Name"`
XrayConfig *XrayConfig `json:"-"`
SingConfig *SingConfig `json:"-"`
Type string `json:"Type"`
Name string `json:"Name"`
XrayConfig *XrayConfig `json:"-"`
SingConfig *SingConfig `json:"-"`
Hysteria2Config *Hysteria2Config `json:"-"`
}

type _CoreConfig CoreConfig
Expand All @@ -25,6 +26,9 @@ func (c *CoreConfig) UnmarshalJSON(b []byte) error {
case "sing":
c.SingConfig = NewSingConfig()
return json.Unmarshal(b, c.SingConfig)
case "hysteria2":
c.Hysteria2Config = NewHysteria2Config()
return json.Unmarshal(b, c.Hysteria2Config)
}
return nil
}
100 changes: 100 additions & 0 deletions conf/hy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package conf

import "time"

type Hysteria2Config struct {
LogConfig Hysteria2LogConfig `json:"Log"`
}

type Hysteria2LogConfig struct {
Level string `json:"Level"`
}

func NewHysteria2Config() *Hysteria2Config {
return &Hysteria2Config{
LogConfig: Hysteria2LogConfig{
Level: "error",
},
}
}

type Hysteria2Options struct {
QUICConfig QUICConfig `json:"QUICConfig"`
Outbounds []Outbounds `json:"Outbounds"`
IgnoreClientBandwidth bool `json:"IgnoreClientBandwidth"`
DisableUDP bool `json:"DisableUDP"`
UDPIdleTimeout time.Duration `json:"UDPIdleTimeout"`
Masquerade serverConfigMasquerade `json:"masquerade"`
}

type QUICConfig struct {
InitialStreamReceiveWindow uint64
MaxStreamReceiveWindow uint64
InitialConnectionReceiveWindow uint64
MaxConnectionReceiveWindow uint64
MaxIdleTimeout time.Duration
MaxIncomingStreams int64
DisablePathMTUDiscovery bool // The server may still override this to true on unsupported platforms.
}

type ServerConfigOutboundDirect struct {
Mode string `json:"mode"`
BindIPv4 string `json:"bindIPv4"`
BindIPv6 string `json:"bindIPv6"`
BindDevice string `json:"bindDevice"`
}

type ServerConfigOutboundSOCKS5 struct {
Addr string `json:"addr"`
Username string `json:"username"`
Password string `json:"password"`
}

type ServerConfigOutboundHTTP struct {
URL string `json:"url"`
Insecure bool `json:"insecure"`
}

type Outbounds struct {
Name string `json:"name"`
Type string `json:"type"`
Direct ServerConfigOutboundDirect `json:"direct"`
SOCKS5 ServerConfigOutboundSOCKS5 `json:"socks5"`
HTTP ServerConfigOutboundHTTP `json:"http"`
}

type serverConfigMasqueradeFile struct {
Dir string `json:"dir"`
}

type serverConfigMasqueradeProxy struct {
URL string `json:"url"`
RewriteHost bool `json:"rewriteHost"`
}

type serverConfigMasqueradeString struct {
Content string `json:"content"`
Headers map[string]string `json:"headers"`
StatusCode int `json:"statusCode"`
}

type serverConfigMasquerade struct {
Type string `json:"type"`
File serverConfigMasqueradeFile `json:"file"`
Proxy serverConfigMasqueradeProxy `json:"proxy"`
String serverConfigMasqueradeString `json:"string"`
ListenHTTP string `json:"listenHTTP"`
ListenHTTPS string `json:"listenHTTPS"`
ForceHTTPS bool `json:"forceHTTPS"`
}

func NewHysteria2Options() *Hysteria2Options {
return &Hysteria2Options{
QUICConfig: QUICConfig{},
Outbounds: []Outbounds{},
IgnoreClientBandwidth: false,
DisableUDP: false,
UDPIdleTimeout: time.Duration(time.Duration.Seconds(30)),
Masquerade: serverConfigMasquerade{},
}
}
26 changes: 15 additions & 11 deletions conf/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
}

type Options struct {
Name string `json:"Name"`
Core string `json:"Core"`
CoreName string `json:"CoreName"`
ListenIP string `json:"ListenIP"`
SendIP string `json:"SendIP"`
DeviceOnlineMinTraffic int64 `json:"DeviceOnlineMinTraffic"`
LimitConfig LimitConfig `json:"LimitConfig"`
RawOptions json.RawMessage `json:"RawOptions"`
XrayOptions *XrayOptions `json:"XrayOptions"`
SingOptions *SingOptions `json:"SingOptions"`
CertConfig *CertConfig `json:"CertConfig"`
Name string `json:"Name"`
Core string `json:"Core"`
CoreName string `json:"CoreName"`
ListenIP string `json:"ListenIP"`
SendIP string `json:"SendIP"`
DeviceOnlineMinTraffic int64 `json:"DeviceOnlineMinTraffic"`
LimitConfig LimitConfig `json:"LimitConfig"`
RawOptions json.RawMessage `json:"RawOptions"`
XrayOptions *XrayOptions `json:"XrayOptions"`
SingOptions *SingOptions `json:"SingOptions"`
Hysteria2Options *Hysteria2Options `json:"Hysteria2Options"`
CertConfig *CertConfig `json:"CertConfig"`
}

func (o *Options) UnmarshalJSON(data []byte) error {
Expand All @@ -129,6 +130,9 @@ func (o *Options) UnmarshalJSON(data []byte) error {
case "sing":
o.SingOptions = NewSingOptions()
return json.Unmarshal(data, o.SingOptions)
case "hysteria2":
o.Hysteria2Options = NewHysteria2Options()
return json.Unmarshal(data, o.Hysteria2Options)
default:
o.Core = ""
o.RawOptions = data
Expand Down
Loading

0 comments on commit 0d274bc

Please sign in to comment.