hysteria2

package
v0.2.2-dev.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const ID = "hysteria2"

ID is the plugin id.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hop

type Hop struct {
	From int `json:"from"`
	To   int `json:"to"`
}

type Masquerade

type Masquerade struct {
	Type string `json:"type"` // decoy | none (proxy, file, string: when the node supports them)
}

type NodeMasq

type NodeMasq struct {
	Type string `json:"type"`
}

type NodeObfs

type NodeObfs struct {
	Type     string `json:"type"`
	Password string `json:"password,omitempty"`
}

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 Obfs

type Obfs struct {
	Type     string `json:"type"` // none | salamander | gecko
	Password string `json:"password"`
}

type Protocol

type Protocol struct{}

Protocol implements protocols.Protocol.

func New

func New() *Protocol

New returns the plugin.

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) DisplayName() string

func (*Protocol) Doctor

func (*Protocol) Doctor() []protocols.Check

func (*Protocol) ID

func (*Protocol) ID() string

func (*Protocol) IssueCredential

func (*Protocol) IssueCredential(protocols.IssueInput) (protocols.Issued, error)

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) SettingsSchema() []byte

func (*Protocol) Summary

func (p *Protocol) Summary(raw json.RawMessage) string

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL