mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
测试:增加hysteria2内核
This commit is contained in:
12
conf/core.go
12
conf/core.go
@@ -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
|
||||
@@ -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
conf/hy.go
Normal file
100
conf/hy.go
Normal file
@@ -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
conf/node.go
26
conf/node.go
@@ -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 {
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user