Documentation
¶
Index ¶
- Constants
- func AllowedForApps(p Protocol, apps ...plugin.ClientID) bool
- func ChangedPointers(a, b json.RawMessage, ptrs []string) []string
- func FlaggedPointers(schema []byte, flag string) ([]string, error)
- func IsPerDevice(p Protocol) bool
- func MaskSecrets(merged json.RawMessage, secretPtrs []string) (json.RawMessage, error)
- func MergeSecrets(public json.RawMessage, secrets map[string]string) (json.RawMessage, error)
- func NormalizePin(s string) (string, bool)
- func ResolveInput(input, base, fresh json.RawMessage, secretPtrs []string) (json.RawMessage, error)
- func SplitSecrets(merged json.RawMessage, secretPtrs []string) (json.RawMessage, map[string]string, error)
- type Check
- type CheckInput
- type CheckScope
- type ClientReq
- type ClientRequirements
- type FieldError
- type Finding
- type InboundInit
- type InboundInitInput
- type InboundInitializer
- type InboundInput
- type InboundView
- type IssueInput
- type Issued
- type NeedsDomainError
- type NodeView
- type NormalizeInput
- type PerDevice
- type PortInHopError
- type ProfileView
- type Protocol
- type Registry
- type RenderInput
- type ServerNameError
- type SettingsNormalizer
Constants ¶
const ( // MaskedSecret is what the API shows instead of a stored secret, and what the client sends back to // say "keep the stored value". MaskedSecret = "••••" // GenerateSecret, like the empty string, asks for a freshly generated secret. GenerateSecret = "$generate" )
Secret handling is done by the framework, not by plugins: a schema property marked "x-secret": true is stored vault-encrypted outside settings_json and masked in the API.
Variables ¶
This section is empty.
Functions ¶
func AllowedForApps ¶
AllowedForApps reports whether a user with the given enabled apps gets the protocol: one of the enabled apps must appear in the protocol's Clients().
func ChangedPointers ¶
func ChangedPointers(a, b json.RawMessage, ptrs []string) []string
ChangedPointers lists the given pointers whose value differs between two documents.
func FlaggedPointers ¶
FlaggedPointers returns the JSON pointers of schema properties carrying the boolean flag (e.g. "x-secret", "x-critical"), sorted. Only "properties" of nested objects are walked.
func IsPerDevice ¶
IsPerDevice reports whether p issues per-device, per-profile credentials.
func MaskSecrets ¶
func MaskSecrets(merged json.RawMessage, secretPtrs []string) (json.RawMessage, error)
MaskSecrets replaces every secret of a merged document by MaskedSecret (for the API).
func MergeSecrets ¶
func MergeSecrets(public json.RawMessage, secrets map[string]string) (json.RawMessage, error)
MergeSecrets puts stored secrets back into the public document.
func NormalizePin ¶
NormalizePin returns the SHA-256 certificate pin a node reported in the form that may be put into a subscription: exactly 64 lowercase hex digits (colons, as in openssl output, are tolerated on the way in). Anything else is not a pin. A node is trusted to serve its own traffic, not to write into the subscription of every user of the inbound, so this is checked where the pin is stored and again where it is rendered.
func ResolveInput ¶
func ResolveInput(input, base, fresh json.RawMessage, secretPtrs []string) (json.RawMessage, error)
ResolveInput turns the settings document sent by a client into the merged settings to validate and store. base is what the client's document is laid over: the stored merged settings on update, or the plugin defaults on create (keys the client omits keep the base value, including generated secrets). Secret fields: MaskedSecret keeps base's value, "" or GenerateSecret takes a fresh value from fresh (a newly generated DefaultSettings document).
func SplitSecrets ¶
func SplitSecrets(merged json.RawMessage, secretPtrs []string) (json.RawMessage, map[string]string, error)
SplitSecrets removes the secret values from merged settings. It returns the public document (safe for settings_json) and the removed values by pointer; only string secrets that are present are returned.
Types ¶
type Check ¶
type Check struct {
ID string
Scope CheckScope
Run func(ctx context.Context, in CheckInput) []Finding
}
Check is one doctor rule. The runner calls Run for every node that has an inbound of this protocol (Scope node) or once (Scope fleet).
type CheckInput ¶
type CheckInput struct {
Node NodeView
Inbounds []InboundView
Now time.Time
// Observations is filled by the health module: last apply results, latest metrics, synthetic check
// results. Kept a map so the first version does not freeze its shape.
Observations map[string]json.RawMessage
}
type ClientReq ¶
type ClientReq struct {
Client plugin.ClientID
App string // display name: "AmneziaVPN"
Min string // tag or version: "5.0.1.5"
}
ClientReq is the minimum version of one client app for a profile's settings.
func MinClientsOf ¶
func MinClientsOf(p Protocol, settings json.RawMessage) []ClientReq
MinClientsOf returns the client requirements of p for the given settings, nil when it has none.
type ClientRequirements ¶
type ClientRequirements interface {
MinClients(settings json.RawMessage) []ClientReq
}
ClientRequirements is an optional interface: the minimum client versions for THIS profile's settings (shown next to every config: an old AmneziaVPN silently drops keys it does not know).
type FieldError ¶
type InboundInit ¶
type InboundInit struct {
State []byte // secret (AWG: the server private key); encrypted by the framework
Public json.RawMessage // not secret (AWG: {"public_key": ...})
}
type InboundInitInput ¶
type InboundInitInput struct {
InboundID string
Profile ProfileView
Node NodeView
}
type InboundInitializer ¶
type InboundInitializer interface {
InitInbound(in InboundInitInput) (InboundInit, error)
}
InboundInitializer is an optional interface: a plugin that needs per-inbound key material implements it. The framework calls InitInbound once when an inbound is created, stores State vault-encrypted (AAD = the inbound id) and Public in clear, and hands both back through InboundInput and RenderInput.
type InboundInput ¶
type InboundInput struct {
Profile ProfileView
Node NodeView
PortOverride uint16 // 0 = none
TLSServerNameOverride string
SpecVersion uint64
Enabled bool
// InboundID and PluginState/PluginPublic carry what InitInbound made for this inbound (AWG: the server
// key pair). PluginState is already decrypted; empty for a protocol without InboundInitializer.
InboundID string
PluginState []byte
PluginPublic json.RawMessage
}
type InboundView ¶
type InboundView struct {
ID string
Node NodeView
Port uint16
HopFrom, HopTo uint16
TLSServerName string // effective SNI
TLSMode plugin.TLSMode
CertPinSHA256 string // reported by the node after apply; empty until then
}
InboundView is the effective facts about one deployed inbound needed to write a client config.
type IssueInput ¶
type IssueInput struct {
UserID, DeviceID string
// L3 protocols (PerDevice): the profile the credential belongs to, its merged settings and the peer index
// the IPAM handed out (address = subnet base + PeerIndex). Zero for hysteria2.
ProfileID string
Settings json.RawMessage
PeerIndex int
}
type Issued ¶
type Issued struct {
Secret string // client-side secret (hy2 auth token); never sent to a node
NodeData json.RawMessage // verifier for UserCred.Data (hy2: {"auth_sha256":"<hex>"})
}
type NeedsDomainError ¶
NeedsDomainError: the certificate is Let's Encrypt, which is issued for a DNS name only, and the inbound has none: the node address is an IP and no SNI is set (neither on the inbound nor in the profile). Reality: the certificate is the one of the node's own site behind a REALITY profile (VLESS), whose other choice is another site as the target; the UI words that refusal apart (reality_needs_domain).
func (*NeedsDomainError) Error ¶
func (*NeedsDomainError) Error() string
type NormalizeInput ¶
type NormalizeInput struct {
Input json.RawMessage // the document the client sent
Old json.RawMessage // the stored merged settings of the profile; nil when the profile is being created
Merged json.RawMessage // Input laid over Old (over the defaults on create), secrets resolved, not yet validated
Save bool // the result will be stored; false for a live preview of a form
}
NormalizeInput is what a SettingsNormalizer sees: the client's document, what it was laid over and the result.
type PerDevice ¶
type PerDevice interface{ PerDevice() bool }
PerDevice is an optional interface. A plugin answering true issues its credential on demand, bound to ONE profile (several live credentials per device, one per profile), so the generic "every device gets one" pass skips it. hysteria2 does not implement it.
type PortInHopError ¶
type PortInHopError struct{ From, To int }
PortInHopError: the port override lies inside the profile's own port-hopping range.
func (*PortInHopError) Error ¶
func (*PortInHopError) Error() string
type ProfileView ¶
type ProfileView struct {
ID string
Version uint32
Settings json.RawMessage
}
type Protocol ¶
type Protocol interface {
ID() string
DisplayName() string
// SettingsSchema is the JSON Schema the admin UI renders the profile form from (vocabulary: see
// proto/admin profile.proto).
SettingsSchema() []byte
// DefaultSettings returns settings for a new profile with secrets already generated.
DefaultSettings() (json.RawMessage, error)
// Validate returns per-field errors (JSON pointers); nil = valid. Must be pure and fast: the UI calls
// it on every edit through PreviewProfile.
Validate(settings json.RawMessage) []FieldError
// Summary is the mono parameter line on the profile card: "UDP 443 · Salamander · Let's Encrypt".
Summary(settings json.RawMessage) string
// BuildInbound translates profile settings + node + overrides into the node-side spec (ports, TLS
// mode, egress are lifted out of the settings into first-class fields; the rest goes to Settings).
BuildInbound(in InboundInput) (plugin.InboundSpec, error)
// IssueCredential creates the credential of one device: Secret is what the client presents (stored
// encrypted, shown in subscriptions), NodeData is the verifier shipped to nodes.
IssueCredential(in IssueInput) (Issued, error)
// Clients lists the client apps that can consume this protocol. A user gets the protocol when one of
// their enabled apps appears here.
Clients() []plugin.ClientSupport
// Render returns this protocol's piece of a subscription in the requested format, or false if the
// format/client cannot carry the protocol (Happ cannot carry AWG and vice versa).
Render(in RenderInput) (plugin.Fragment, bool)
// Doctor returns the protocol-specific checks for the fleet doctor.
Doctor() []Check
}
Protocol is the panel half of a protocol plugin. Settings are always the MERGED JSON (secrets in place); the framework masks/splits secrets using the schema's "x-secret" markers.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the protocol plugins of this panel, by plugin id. It is built once at startup and never changes afterwards, so it needs no lock.
func NewRegistry ¶
NewRegistry registers the given protocols. A duplicate or empty id is a programming error.
type RenderInput ¶
type RenderInput struct {
Format plugin.ClientFormat
Settings json.RawMessage // merged, secrets in place
Inbound InboundView
UserID string
UserName string
DeviceID string
Secret string // decrypted credential secret
MaskSecrets bool // profile preview: render secrets as "••••"
// L3 protocols (awg). For FormatMihomo, Fragment.Data is ONE proxy as an element of a YAML list built
// from yaml.v3 nodes (never string templates: node and user names are hostile input); the assembler
// adds groups, dns and rules.
Label string // device label, for the config's comment / file name
DisplayName string // server name as the subscription shows it (the assembler's remarks())
Peer json.RawMessage // decrypted credential secret of the device ({"priv","psk"} for awg)
InboundPublic json.RawMessage // InboundInit.Public of this inbound
DNS []string // at most 2 plain IPv4 servers (the pair an AWG client carries)
NodeAddr string // host clients connect to (Inbound.Node.Address)
}
type ServerNameError ¶
ServerNameError: the server name set for the inbound is not usable: an IP where Let's Encrypt needs a domain (DomainOnly), or neither a host name nor an IP.
func (*ServerNameError) Error ¶
func (e *ServerNameError) Error() string
type SettingsNormalizer ¶
type SettingsNormalizer interface {
NormalizeSettings(in NormalizeInput) (json.RawMessage, error)
}
SettingsNormalizer is an optional interface: it fixes merged settings before they are validated and stored. AWG uses it so that a schema default never becomes a live config: a profile made without an obfuscation block gets a generated one. It must return Merged itself, byte for byte, when it has nothing to change (the caller compares the bytes to see whether anything changed).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package awg is the panel half of the AmneziaWG protocol plugin: the settings schema, a validator stricter than both implementations, the obfuscation generator with its mimicry presets, the translation of a profile into a node-side inbound, the per-device X25519 credentials and the three client formats (.conf, vpn://, Mihomo proxy).
|
Package awg is the panel half of the AmneziaWG protocol plugin: the settings schema, a validator stricter than both implementations, the obfuscation generator with its mimicry presets, the translation of a profile into a node-side inbound, the per-device X25519 credentials and the three client formats (.conf, vpn://, Mihomo proxy). |
|
mimicry
Package mimicry builds and checks the I1..I5 "custom protocol signature" packets of AmneziaWG 2.0/3.x.
|
Package mimicry builds and checks the I1..I5 "custom protocol signature" packets of AmneziaWG 2.0/3.x. |
|
vpnkey
Package vpnkey encodes and decodes the vpn:// connection key of AmneziaVPN.
|
Package vpnkey encodes and decodes the vpn:// connection key of AmneziaVPN. |
|
Package builtin builds the registry of the protocol plugins shipped with the panel.
|
Package builtin builds the registry of the protocol plugins shipped with the panel. |
|
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.
|
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. |
|
Package jsoncheck lets the tests ask the real cores whether a client config they render is valid: Xray in process (xray-core's own config builder) and sing-box through its binary.
|
Package jsoncheck lets the tests ask the real cores whether a client config they render is valid: Xray in process (xray-core's own config builder) and sing-box through its binary. |
|
Package vless is the panel half of the VLESS protocol plugin.
|
Package vless is the panel half of the VLESS protocol plugin. |