hostctl

package
v0.2.0-dev.10 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 30 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 hostctl is the agent's view of the machine it runs on: host facts for Hello, host metrics for StatsBatch, and the host state the agent owns: its nftables tables for port-hop redirects and the SSH brute-force guard, the UDP delivery counter, the fail-open torrent queue, exact UDP/TCP inbound rules in an active UFW firewall, and owner-approved tagged forwarding exceptions limited to Mistgate traffic in host FORWARD chains, the fq + bbr, conntrack and UDP socket-buffer sysctl baseline and the journald size cap. The real implementation is Linux-only behind a build tag; other OSes get a no-op stub so the whole repo still builds and vets.

Index

Constants

View Source
const (
	// MinHopPort and MaxHopSpan bound every port-hop range the node will redirect (F12): a hop range is a
	// DNAT of every incoming packet of that range, so an unbounded one (a typo, a hostile panel) would
	// swallow DNS, NTP, WireGuard or sshd on the same host.
	MinHopPort = 1024
	MaxHopSpan = 20000 // number of ports in the range
)
View Source
const (
	SysctlFilePath   = "/etc/sysctl.d/90-mistgate.conf"
	JournaldFilePath = "/etc/systemd/journald.conf.d/90-mistgate.conf"
	SysctlFileBody   = sysctlFileBody
	JournaldFileBody = journaldFileBody
	// UDPBufferMinBytes is the minimum net.core.rmem_max and net.core.wmem_max value.
	UDPBufferMinBytes = 16 << 20
	// UDPDefaultBufferMinBytes is the minimum receive and send buffer inherited by new UDP sockets.
	UDPDefaultBufferMinBytes = 1 << 20
	// ConntrackMaxMin and ConntrackBucketsMin size the connection tracking table for relayed user traffic.
	ConntrackMaxMin     = 65536
	ConntrackBucketsMin = 16384
	// JournalCapMB is the journal cap in journaldFileBody and the target of VacuumJournal.
	JournalCapMB = 200
)

Exported so the doctor's net_baseline check compares against the baseline ApplyBaseline writes.

View Source
const (
	IPv6AddrOK        = "ok"
	IPv6AddrMissing   = "missing"
	IPv6AddrTentative = "tentative"
	IPv6AddrDADFailed = "dad_failed"
	IPv6AddrDenied    = "denied"
)

States of one wanted address (the doctor's owned param).

View Source
const (
	// NftRelayTable is the table of the relay forwards. The doctor treats it as ours.
	NftRelayTable = "mistgate_relay"
	// MaxForwards bounds the forwards of one node.
	MaxForwards = 64
	// MinForwardPort is the lowest port a forward may listen on, besides 443: well-known ports, sshd 22 and ACME 80 stay out of reach.
	MinForwardPort = 1024
)
View Source
const (
	// ResolverModeResolved configures systemd-resolved through a drop-in; ResolverModeResolvConf rewrites
	// /etc/resolv.conf (backup kept).
	ResolverModeResolved   = "resolved"
	ResolverModeResolvConf = "resolv_conf"
)
View Source
const (
	// NftTunnelTable is the table of the tunnel rules. The doctor treats it as ours.
	NftTunnelTable = "mistgate_awg"
	// NftWarpTable is the table of the WARP manager (internal/node/warp.NftTable, a test in cmd/mistgate-node keeps
	// the two equal); the doctor treats it as ours too, and the two tables are the only ones besides NftTable.
	NftWarpTable = "mistgate_warp"
	// TunnelIfacePrefix is the name prefix of every interface the AWG engine creates (awg.IfaceName, a test in
	// internal/node/awg keeps the two equal). Cleanup deletes links that carry it.
	TunnelIfacePrefix = "mgawg"
	// WarpIface is the WARP tunnel device (warp.DefaultIface, same test).
	WarpIface = "mgwarp"
)
View Source
const MaxOwnedIPv6 = 4

MaxOwnedIPv6 is how many addresses the agent holds at once.

View Source
const (
	// NftTable is the agent's own table; the agent never touches any other.
	NftTable = "mistgate_node"
)
View Source
const (
	// NftTorrentTable is Mistgate's independent, fail-open NFQUEUE ruleset.
	NftTorrentTable = "mistgate_torrentguard"
)
View Source
const NftUDPCheckTable = "mistgate_udpcheck"
View Source
const OwnedIPv6File = "ipv6-owned.json"

OwnedIPv6File is the file in the state dir that names the addresses the agent put on the host.

View Source
const ProvisionUFWTag = "mistgate-node-provision-v1"

ProvisionUFWTag is the UFW comment the panel's SSH install puts on the 80/tcp, 443/tcp and 443/udp rules it adds to an active UFW (internal/panel/provision). Those rules belong to the node: Cleanup removes them when it is retired. The SSH rule the install adds carries no tag and is never removed.

Variables

View Source
var ErrForwardDrop = errors.New("forward_drop")

ErrForwardDrop is returned by SetRelays when a FORWARD chain of the host drops forwarded packets by default (UFW's default, Docker): nothing is installed.

View Source
var ErrUnsupported = errors.New("hostctl: not supported on this OS")

ErrUnsupported is returned by the non-Linux stub.

Functions

func CleanupOwnedIPv6 added in v0.1.67

func CleanupOwnedIPv6(ctx context.Context, stateDir string) error

CleanupOwnedIPv6 is the host-less form for `mistgate-node cleanup-net --ipv6-addresses`: it removes the addresses that the file in stateDir names, and only those.

func CleanupTunnels

func CleanupTunnels(ctx context.Context) error

CleanupTunnels is the stateless form for the unit's ExecStopPost (a crashed agent leaves its interfaces and its table behind): it deletes the tunnel table and every link named mgawg* or mgwarp. The WARP routing rules and routes are removed by internal/node/warp.CleanupHost, which the same subcommand calls.

func CleanupUDPCount added in v0.1.28

func CleanupUDPCount(ctx context.Context) error

CleanupUDPCount deletes the check table without needing host state.

func ForwardsEqual added in v0.1.65

func ForwardsEqual(a, b []Forward) bool

ForwardsEqual reports whether two sets install the same rules (order does not matter).

func IsOwnAddr added in v0.1.65

func IsOwnAddr(a netip.Addr) bool

IsOwnAddr says whether a is assigned to one of this host's interfaces. If the list cannot be read it says yes: failing closed is safer than pointing a forward at the node itself. A public address that only a cloud's NAT knows is not seen.

func NICCounters added in v0.1.20

func NICCounters() (iface string, rx, tx uint64, ok bool)

NICCounters returns the byte counters since boot of the main network interface (the default route's, see defaultIface): its name, bytes received and bytes sent. It is what the host metrics' NetRxBps and NetTxBps are computed from, and what the bandwidth test reads to count the people already using the node. ok = false where there is no /proc or no default route.

func NICCountersAt added in v0.1.20

func NICCountersAt(procRoot string) (iface string, rx, tx uint64, ok bool)

NICCountersAt is NICCounters under another /proc root (tests).

func NeedsV6

func NeedsV6(ts []Tunnel) bool

NeedsV6 reports whether any tunnel has an IPv6 subnet (IPv6 forwarding is wanted).

func NotUplink(name string) bool

NotUplink says whether an interface name is one that never carries the node's uplink.

func OwnIPv4s added in v0.1.65

func OwnIPv4s() ([]netip.Addr, error)

OwnIPv4s lists the IPv4 addresses assigned to this host's interfaces, loopback aside (a packet to 127.0.0.1 is the node talking to itself, never a person to forward). The relay table matches destinations against it.

func OwnNftTable added in v0.1.16

func OwnNftTable(family, name string) bool

OwnNftTable says whether an nft table is one the agent itself creates (all of them are inet): the firewall and port hops, the UDP delivery check, AmneziaWG tunnels, WARP, the relay forwards and the torrent guard. A new table goes here, or the doctor calls it foreign.

func PublicIPv4 added in v0.1.65

func PublicIPv4(a netip.Addr) bool

PublicIPv4 says whether a is a public unicast IPv4 address: not private, CGNAT, loopback, link-local (which holds the cloud metadata address), multicast, "this network" or reserved. Documentation ranges pass: they are what tests use.

func RenderHops

func RenderHops(hops []Hop) (string, error)

RenderHops renders the agent's table with only the port-hop redirects (no SSH guard).

func RenderRelays added in v0.1.65

func RenderRelays(fs []Forward, local []netip.Addr) (string, error)

RenderRelays returns the nft script that atomically replaces the relay table. `add` + `delete` first makes it work whether or not the table exists; nft applies a whole -f file as one transaction. No forwards renders the delete only. The forwards are sorted by id; each is checked as ValidateForward does without the node's context.

func RenderRuleset

func RenderRuleset(hops []Hop, sshPorts []uint16) (string, error)

RenderRuleset returns the nft script that atomically replaces the agent's table with one redirect rule per hop and, when sshPorts is not empty, the SSH brute-force guard (ssh.go). `add` + `delete` first makes the script work whether or not the table exists, and nft applies a whole -f file as one transaction. No hops and no ssh ports renders the delete only (= cleanup). Every hop goes through ValidateHop, with the ssh ports reserved.

`redirect` (DNAT to the local address of the incoming interface) works for IPv4 and IPv6 in the inet family (kernel >= 5.2) and needs no knowledge of the node's address.

func RenderTorrentGuard added in v0.1.5

func RenderTorrentGuard(ifaces []string) (string, error)

RenderTorrentGuard returns an atomic replacement for Mistgate's own nft table. Only what a client sends out through the exact active AWG interface set is queued, and only the start of a flow: the first packets of a TCP connection the client opened, and UDP datagrams of a conntrack entry that has seen no reply yet. Traffic that enters and leaves through AWG interfaces is excluded, and queue bypass keeps traffic flowing without a userspace listener.

A block is enforced in the kernel: the runtime repeats the packet with BlockMark, the first rule turns it into the connection's ct mark and drops it, and the second drops every later packet of that connection in both directions. `ct original packets` makes nft switch conntrack accounting on (the kernel does it when such a rule is loaded); a connection older than that has no counter and stays queued, which is correct, only not cheaper.

func RenderTunnels

func RenderTunnels(ts []Tunnel, published []PublishedPort) (string, error)

RenderTunnels returns the nft script that atomically replaces the tunnel table. `add` + `delete` first makes it work whether or not the table exists; nft applies a whole -f file as one transaction. No tunnels renders the delete only. TCP 443 is always included for a panel that shares the node's address; other published listeners are explicit.

func RenderUDPCount added in v0.1.28

func RenderUDPCount(tag [8]byte, ports []uint16) (string, error)

RenderUDPCount returns an atomic nft script that replaces the UDP check table.

func TorrentGuardSupported added in v0.1.5

func TorrentGuardSupported() bool

TorrentGuardSupported reports that this build includes the Linux NFQUEUE runtime.

func TunnelIface

func TunnelIface(port uint16) string

TunnelIface is the interface name of a tunnel inbound on a UDP port.

func TunnelsEqual

func TunnelsEqual(a, b []Tunnel) bool

TunnelsEqual reports whether two tunnel sets install the same rules (order does not matter).

func ValidateForward added in v0.1.65

func ValidateForward(f Forward, accepted []Forward, g ForwardGuard) error

ValidateForward is the one place that says whether a forward may be installed, like ValidateHop. accepted are the forwards already accepted in this round (the caller visits them in id order, so the earlier id wins a clash).

func ValidateForwardPort

func ValidateForwardPort(id, network string, port uint16, accepted []Forward, g ForwardGuard) error

ValidateForwardPort checks ownership and conflicts for a relay listener without resolving or validating a DNAT target. Reverse relays use this same port policy but never install a host forward.

func ValidateHop

func ValidateHop(h Hop, reserved []uint16) error

ValidateHop is the one place that says whether a hop may be installed. reserved are ports a range must never cover (the sshd ports, other inbounds' ports): the caller knows them, this package cannot. The inbound's own Port may lie inside its range.

func ValidateTunnel

func ValidateTunnel(t Tunnel) error

ValidateTunnel checks one tunnel before it reaches nft. The strings that get into the script are interface names and address literals rendered by the netip package; the name is additionally restricted.

Types

type Count added in v0.1.28

type Count struct {
	Packets uint64
	Bytes   uint64
}

Count holds the packet and byte counters nft observed for one UDP port.

type Facts

type Facts struct {
	Hostname  string
	OS        string
	Kernel    string
	Arch      string
	CPUCount  int
	RAMTotal  uint64
	DiskTotal uint64
	Virt      string // systemd-detect-virt style: "kvm", "openvz", "lxc", "none", "unknown"
	HasIPv6   bool
	Boot      time.Time
}

type Fixer

type Fixer interface {
	// VacuumJournal runs journalctl --vacuum-size=200M --vacuum-time=7d.
	VacuumJournal(ctx context.Context) error
	// ResolverPlan says what SetResolver would do, changing nothing.
	ResolverPlan(ctx context.Context, servers []string) (ResolverPlan, error)
	// SetResolver points the host resolver at servers (IPs, optionally host:port where the mode allows it).
	// The previous configuration is kept so Cleanup can restore it.
	SetResolver(ctx context.Context, servers []string) error
}

Fixer is the part of the host the doctor's safe fixes need beyond Host. The Linux host implements it, the stub returns ErrUnsupported; a caller type-asserts (`fx, ok := host.(Fixer)`). Cleanup undoes SetResolver.

type Forward added in v0.1.65

type Forward struct {
	ID      string // the panel's relay id
	Network string // "tcp" | "udp"
	Port    uint16 // listened on here
	ToIP    netip.Addr
	ToPort  uint16
}

Forward is one forwarded port after the exit's name has been resolved.

type ForwardExceptionFixer added in v0.1.65

type ForwardExceptionFixer interface {
	PlanForwardExceptions(ctx context.Context) (ForwardExceptionPlan, error)
	ApplyForwardExceptions(ctx context.Context) (uint32, error)
}

ForwardExceptionFixer plans and applies the doctor's explicit, narrow forwarding exception fix.

type ForwardExceptionPlan added in v0.1.65

type ForwardExceptionPlan struct {
	Needed        bool
	AddRules      int
	RemoveRules   int
	DropChains    int
	RelayForwards int
	Backend       string
}

ForwardExceptionPlan is the read-only preview of the firewall rules the fix needs to add or remove.

type ForwardExceptionReassertor added in v0.1.65

type ForwardExceptionReassertor interface {
	ReassertForwardExceptions(ctx context.Context) error
}

ForwardExceptionReassertor restores a previously approved forwarding fix after a firewall reload.

type ForwardGuard added in v0.1.65

type ForwardGuard struct {
	SSHPorts []uint16  // sshd, any network
	Ports    []NetPort // listeners of the node's own inbounds
	Hops     []Hop     // port-hop ranges of the node's own inbounds
	// IsSelf says whether an address is one of the node's own; nil = no address is.
	IsSelf func(netip.Addr) bool
}

ForwardGuard is what ValidateForward needs to know about the node and this package cannot: the caller fills it in.

type Hop

type Hop struct {
	InboundID string
	Network   string // "udp" | "tcp"
	From, To  uint16
	Port      uint16
}

Hop is one port-hopping range: packets to Network/From-To are redirected to the inbound's real Port.

type Host

type Host interface {
	// Facts are read once per connection (Hello).
	Facts(ctx context.Context) Facts
	// Metrics is sampled once per stats interval; rates are averaged since the previous call.
	Metrics() Metrics
	// ApplyBaseline installs the sysctl and journald baseline and the SSH brute-force guard. Idempotent; a
	// failure is returned but is never fatal for the agent (OpenVZ/LXC may not allow live sysctl writes).
	ApplyBaseline(ctx context.Context) error
	// SetPortHops makes the hop part of the agent's nft table match hops exactly. Atomic; the SSH guard
	// (installed by ApplyBaseline) stays. Every hop must pass ValidateHop.
	SetPortHops(ctx context.Context, hops []Hop) error
	// SyncInboundPorts reconciles exact Mistgate UDP listener ports and hop ranges and TCP listener ports in a supported,
	// already-active host firewall. It never enables a firewall or edits provider-level rules.
	SyncInboundPorts(ctx context.Context, udp []UDPInboundPort, tcp []uint16) error
	// SSHPorts are the sshd ports found by the last ApplyBaseline (22 when detection found nothing):
	// the SSH guard rate-limits them and no port-hop range may cover them.
	SSHPorts() []uint16
	// Cleanup removes everything the agent installed (nft tables with hops, SSH guard, UDP delivery checks and torrent queue, tagged UFW inbound rules
	// and the UFW rules the SSH install tagged with ProvisionUFWTag, sysctl and journald drop-ins,
	// the owner-approved tagged forwarding exceptions,
	// and the resolver fix of the doctor: resolved drop-in, resolv.conf restored from its backup; the IPv6 addresses of
	// ipv6-owned.json (never an address the host had); the tunnel table
	// "mistgate_awg", the relay table "mistgate_relay" and every link named mgawg* or mgwarp). The WARP routing rules and routes are the WARP
	// manager's (warp.Cleanup).
	// Live sysctl values are not reverted (the previous values are not recorded).
	Cleanup(ctx context.Context) error
}

Host is implemented by the Linux host owner and by the stub.

func New

func New(log *slog.Logger) Host

New returns the real Linux host owner.

nftables is driven through the `nft` binary, not github.com/google/nftables: the ruleset is one short text script applied with `nft -f -` (a single atomic transaction, replace-or-create, easy to read in an incident and to assert in a test by rendering it), while the library would add a netlink dependency and a hand-built expression tree for the same three lines. The price is that `nft` must be installed (it is on Debian 12 and Ubuntu 22.04+); SetPortHops reports a clear error if it is not.

type Metrics

type Metrics struct {
	CPUPct     float64
	SoftirqPct float64 // part of CPUPct spent in softirq
	Load1      float64
	RAMUsed    uint64
	RAMTotal   uint64
	DiskUsed   uint64
	DiskTotal  uint64
	NetRxBps   uint64
	NetTxBps   uint64
	UptimeS    uint64

	// Parts of the machine's CPU: steal (given by the hypervisor to other guests; inside CPUPct) and I/O wait (not in
	// CPUPct).
	StealPct, IOWaitPct float64
	SwapUsed, SwapTotal uint64
	// Connection tracking entries and limit (0, 0 = conntrack not loaded).
	ConntrackCount, ConntrackMax uint64
	// Sockets in use, IPv4 and IPv6 together.
	TCPSockets, UDPSockets uint32
	// Link speed of the main NIC in Mbit/s; 0 = the driver does not say (most virtual NICs).
	NICSpeedMbps uint32
}

type NetPort added in v0.1.65

type NetPort struct {
	Network string
	Port    uint16
}

NetPort is a port of one network.

type OwnedIPv6Host added in v0.1.67

type OwnedIPv6Host interface {
	// SyncOwnedIPv6 makes the agent's addresses on the uplink match wanted exactly: it adds what is missing (after the
	// policy allows it), keeps what is there and removes what the agent added earlier and is no longer wanted. A nil list
	// with nothing owned does not touch the kernel. Idempotent.
	SyncOwnedIPv6(ctx context.Context, wanted []netip.Addr) (OwnedIPv6Result, error)
	// KeepOwnedIPv6 is the sync for a panel that says nothing about the addresses: it adds none and removes none, and only
	// puts back what ipv6-owned.json names.
	KeepOwnedIPv6(ctx context.Context) (OwnedIPv6Result, error)
	// CleanupOwnedIPv6 removes every address of ipv6-owned.json (retire, uninstall). The file goes only when all of them
	// are gone; while one is not, it stays, so that a later cleanup can finish.
	CleanupOwnedIPv6(ctx context.Context) error
}

OwnedIPv6Host is implemented by the Linux host owner. A caller type-asserts it (`h, ok := host.(hostctl.OwnedIPv6Host)`); the stub does not implement it, so an agent on another OS does not list "ipv6-addr/1".

type OwnedIPv6Result added in v0.1.67

type OwnedIPv6Result struct {
	States []OwnedIPv6State
	// Readded are owned addresses that a network manager had removed and the sync put back.
	Readded []netip.Addr
	// ReaddedEvent says that the journal should hear of it: Readded is not empty and the last time it said so, kept in
	// ipv6-owned.json, is over an hour ago (a manager that removes the address at every reconfigure would fill the journal).
	ReaddedEvent bool
}

OwnedIPv6Result is one SyncOwnedIPv6.

type OwnedIPv6State added in v0.1.67

type OwnedIPv6State struct {
	Addr   netip.Addr
	State  string
	Reason string // why it is denied or missing; for the log, never sent
}

OwnedIPv6State is what one wanted address came to.

type PublishedPort

type PublishedPort struct {
	Network string
	Port    uint32
}

PublishedPort is a client-facing listener that packets from a tunnel may reach on the host's other addresses. Network must be "tcp" or "udp"; Port is uint32 so the renderer can reject values outside 1..65535.

type RelayHost added in v0.1.65

type RelayHost interface {
	// RelaySupported says whether this host can forward (nft is installed).
	RelaySupported() bool
	// SetRelays atomically replaces the relay table with the rules of fs (no forwards = the table is deleted) and turns IPv4
	// forwarding on. A call with the set that is already installed does nothing. Before anything is installed the host
	// looks for a FORWARD chain that drops: then it installs nothing, removes a table it had, and returns ErrForwardDrop.
	SetRelays(ctx context.Context, fs []Forward) error
}

RelayHost is the part of the host that the relay forwards need beyond Host. The Linux host implements it, the stub does not (so the capability is not announced).

type ResolverPlan

type ResolverPlan struct {
	Mode   string   // "resolved" (systemd-resolved drop-in) or "resolv_conf" (/etc/resolv.conf rewritten)
	Before []string // nameservers in effect now
	After  []string // nameservers that will be configured (validated, deduplicated)
}

ResolverPlan is the dry run of SetResolver.

type StateDirSetter added in v0.1.65

type StateDirSetter interface {
	SetStateDir(dir string)
}

StateDirSetter lets the agent keep approved host fixes beside its persistent node state.

type TorrentDetection added in v0.1.5

type TorrentDetection struct {
	L4Protocol  string
	Signature   torrentguard.Protocol
	Evidence    torrentguard.Evidence
	DstPort     uint16
	TunnelIface string
	TunnelIP    netip.Addr
}

TorrentDetection describes one BitTorrent request an AWG client sent. TunnelIP is the client's tunnel address, used only to find the user; the destination is only a port, never an address.

type TorrentGuardHost added in v0.1.5

type TorrentGuardHost interface {
	// SetTorrentGuard inspects the start of the TCP/UDP flows clients open
	// through exactly the supplied active AWG interfaces. Passing no interfaces
	// removes Mistgate's queue table and stops its runtime. Queue failures are fail-open.
	SetTorrentGuard(ctx context.Context, ifaces []string, onAttempt func(TorrentDetection)) error
}

TorrentGuardHost owns the optional Linux userspace flow inspector.

type Tunnel

type Tunnel struct {
	Iface            string // mgawg<port>
	Subnet4, Subnet6 netip.Prefix
	Addr4, Addr6     netip.Addr // the node's own addresses inside the subnets (.1)
	UDPPort          uint16
	// ViaWarp: the egress of this tunnel is WARP. No masquerade here, the WARP table does it.
	ViaWarp bool
	// RejectV6: "IPv6 for clients" is off on this node. IPv6 forwarded from this tunnel to anything but a tunnel
	// interface is answered with a TCP RST (TCP) or ICMPv6 admin-prohibited (the rest), so the app falls back to IPv4 at
	// once. The panel gives a client no IPv6 address of the tunnel here, but a config issued earlier still has one: it
	// keeps the ::/0 route (without it its real IPv6 would leave outside the tunnel). Not rendered for a ViaWarp
	// tunnel (the exit is Cloudflare's, not this node's uplink) or one without an IPv6 subnet.
	RejectV6 bool
}

Tunnel is one tunnel interface as the firewall sees it.

type TunnelHost

type TunnelHost interface {
	// SetTunnels atomically replaces the tunnel table with the rules of ts and the published listeners (no tunnels =
	// the table is deleted), and turns forwarding on: net.ipv4.ip_forward, and IPv6 forwarding when a tunnel has an IPv6
	// subnet. A call with the set that is already installed does nothing (the counters keep counting).
	SetTunnels(ctx context.Context, ts []Tunnel, published []PublishedPort) error
	// TunnelCounters returns, per UDP port of an installed tunnel, the datagrams received since the tunnel was first
	// installed by this process (a replacement of the table does not reset them).
	TunnelCounters(ctx context.Context) (map[uint16]uint64, error)
}

TunnelHost is the part of the host that the L3 protocols need beyond Host. The Linux host implements it, the stub accepts and does nothing; a caller type-asserts (`th, ok := host.(TunnelHost)`).

type UDPCountCleaner added in v0.1.28

type UDPCountCleaner interface {
	CleanupUDPCount(context.Context) error
}

UDPCountCleaner is implemented by hosts that can remove a leftover UDP check table.

type UDPCounter added in v0.1.28

type UDPCounter interface {
	CountUDP(tag [8]byte, ports []uint16) error
	TakeUDPCount() (map[uint16]Count, error)
}

UDPCounter is implemented by a host that can count tagged UDP datagrams. One count at a time; the caller keeps which tag is armed.

type UDPInboundPort added in v0.1.1

type UDPInboundPort struct {
	Port     uint16
	From, To uint16
}

UDPInboundPort describes one exact UDP port or one exact Hysteria2 hop range. Set Port for a single listener; set From and To for a range.

type V6FallbackHost added in v0.1.23

type V6FallbackHost interface {
	TunnelV6Fallback() string
}

V6FallbackHost is implemented by a host that can tell the IPv6 rule of the tunnel table is not the one asked for: the kernel refused nft reject, so IPv6 from the tunnels is dropped ("drop") or not filtered at all ("none"); "" = as asked.

Jump to

Keyboard shortcuts

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