Documentation
¶
Overview ¶
Package hysteria2 is the panel half of the Hysteria2 protocol plugin: the settings schema, validation, translation of a profile into a node-side inbound spec, credential issuing and the hysteria2:// URI.
Node-side settings (plugin.InboundSpec.Settings, settings_json on the wire) are the profile settings minus what became first-class fields (port, hop, sni, tls_mode, egress): see NodeSettings.
Index ¶
- Constants
- type Hop
- type Masquerade
- type NodeMasq
- type NodeObfs
- type NodeSettings
- type Obfs
- type Protocol
- func (p *Protocol) BuildInbound(in protocols.InboundInput) (plugin.InboundSpec, error)
- func (*Protocol) Clients() []plugin.ClientSupport
- func (*Protocol) DefaultSettings() (json.RawMessage, error)
- func (*Protocol) DisplayName() string
- func (*Protocol) Doctor() []protocols.Check
- func (*Protocol) ID() string
- func (*Protocol) IssueCredential(protocols.IssueInput) (protocols.Issued, error)
- func (*Protocol) Render(in protocols.RenderInput) (plugin.Fragment, bool)
- func (*Protocol) SettingsSchema() []byte
- func (p *Protocol) Summary(raw json.RawMessage) string
- func (*Protocol) Validate(raw json.RawMessage) []protocols.FieldError
- type Settings
Constants ¶
const ID = "hysteria2"
ID is the plugin id.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Masquerade ¶
type Masquerade struct {
Type string `json:"type"` // decoy | none (proxy, file, string: when the node supports them)
}
type NodeSettings ¶
type NodeSettings struct {
Obfs NodeObfs `json:"obfs"`
Masquerade NodeMasq `json:"masquerade"`
IgnoreClientBandwidth bool `json:"ignore_client_bandwidth"`
BBRProfile string `json:"bbr_profile"`
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
UDP bool `json:"udp"`
}
NodeSettings is the JSON the node engine receives in InboundSpec.Settings. Field order and omitempty rules are part of the contract: the bytes feed the state hash, so they must be deterministic. Obfs.Password is present only when Obfs.Type is not "none". The node's optional masquerade.tcp_port is not sent: the node default (TCP 443 next to the QUIC port) applies.
type Protocol ¶
type Protocol struct{}
Protocol implements protocols.Protocol.
func (*Protocol) BuildInbound ¶
func (p *Protocol) BuildInbound(in protocols.InboundInput) (plugin.InboundSpec, error)
BuildInbound lifts port, hop, TLS and egress out of the settings into first-class spec fields. The caller (access) sets InboundSpec.ID: InboundInput does not carry it.
func (*Protocol) Clients ¶
func (*Protocol) Clients() []plugin.ClientSupport
Clients: Happ (and other Xray/sing-box based apps that take a URI list) carry Hysteria2, and so do the Mihomo core and its apps (Clash Verge, FlClash, ...) from a Mihomo YAML profile; Amnezia does not. The Xray JSON array (Happ and the other Xray apps, by a rule of the owner) and the sing-box profile (the official sing-box apps) are served from the same Render.
func (*Protocol) DefaultSettings ¶
func (*Protocol) DefaultSettings() (json.RawMessage, error)
func (*Protocol) DisplayName ¶
func (*Protocol) IssueCredential ¶
IssueCredential makes a random 32-byte token. The client keeps the token; nodes get sha256(token) hex, which is what the engine computes from the auth string of a connecting client.
func (*Protocol) Render ¶
Render returns the hysteria2:// URI. Format: hysteria2://<auth>@<host>:<port>/?insecure=1&obfs=..&obfs-password=.. &pinSHA256=..&sni=..#<name>, query keys in alphabetical order as in the scheme document (https://v2.hysteria.network/docs/developers/URI-Scheme/); pinSHA256 is plain lowercase hex. One port only; the hop range is not put into the URI until the multi-port form is verified against Happ.
func (*Protocol) SettingsSchema ¶
func (*Protocol) Validate ¶
func (*Protocol) Validate(raw json.RawMessage) []protocols.FieldError
type Settings ¶
type Settings struct {
Port int `json:"port"`
Hop Hop `json:"hop"`
SNI string `json:"sni"`
TLSMode string `json:"tls_mode"` // acme_domain | self_signed (acme_ip: later)
Obfs Obfs `json:"obfs"`
Masquerade Masquerade `json:"masquerade"`
IgnoreClientBandwidth bool `json:"ignore_client_bandwidth"`
BBRProfile string `json:"bbr_profile"` // standard | conservative | aggressive
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
UDP bool `json:"udp"`
Egress string `json:"egress"` // direct | warp
}
Settings is the merged profile settings document (secrets in place).