Skip to content

Lowering inbounds and outbounds

Source files: 58 · checked against katana v6.1.0 · Etemenanki 46c12e4
  • katana/src/lower/inbound.rs
  • katana/src/lower/outbound.rs
  • katana/src/lower/mod.rs
  • katana/src/config.rs
  • katana/src/api/mod.rs
  • katana/src/rule.rs
  • katana/src/runtime.rs
  • katana/src/main.rs
  • katana/src/manager/node.rs
  • katana/src/api/newv2board.rs
  • katana/src/api/hysteria.rs
  • katana/src/api/helium.rs
  • katana/tests/unit/lower/inbound.rs
  • katana/tests/unit/lower/outbound.rs
  • katana/tests/unit/lower/spec.rs
  • katana/tests/unit/runtime.rs
  • katana/tests/unit/manager/node.rs
  • katana/tests/unit/api/newv2board.rs
  • katana/tests/unit/e2e.rs
  • katana/tests/integration/xray_interop.rs
  • katana/tests/integration/hysteria_interop.rs
  • katana/tests/integration/sniff.rs
  • katana/tests/support/mod.rs
  • Etemenanki/supervisor/src/topology/spec_plan/mod.rs
  • Etemenanki/supervisor/src/topology/spec_plan/inbound.rs
  • Etemenanki/supervisor/src/topology/spec_plan/outbound.rs
  • Etemenanki/supervisor/src/topology/spec_plan/transport.rs
  • Etemenanki/supervisor/src/topology/spec_plan/dns.rs
  • Etemenanki/supervisor/src/topology/spec_plan/plan.rs
  • Etemenanki/supervisor/src/topology/inbound/mod.rs
  • Etemenanki/supervisor/src/entity/user.rs
  • Etemenanki/supervisor/src/policy.rs
  • Etemenanki/supervisor/src/build/validate.rs
  • Etemenanki/supervisor/src/build/apply.rs
  • Etemenanki/supervisor/src/build/inbound.rs
  • Etemenanki/supervisor/src/build/outbound.rs
  • Etemenanki/supervisor/src/system/listener.rs
  • Etemenanki/supervisor/src/system/handoff.rs
  • Etemenanki/supervisor/src/supervisor.rs
  • Etemenanki/supervisor/src/serve.rs
  • Etemenanki/protocols/src/transports/ws/endpoint.rs
  • Etemenanki/protocols/src/hysteria/server/config.rs
  • Etemenanki/protocols/src/hysteria/config.rs
  • Etemenanki/protocols/src/hysteria/server/masquerade.rs
  • Etemenanki/protocols/src/hysteria/server/endpoint.rs
  • Etemenanki/protocols/src/ss_2022/users.rs
  • Etemenanki/protocols/src/ss_2022/crypto.rs
  • Etemenanki/protocols/src/ss_legacy/aead.rs
  • Etemenanki/protocols/src/wireguard/config.rs
  • Etemenanki/protocols/src/helpers/address_family.rs
  • Etemenanki/protocols/src/dns/mod.rs
  • Etemenanki/protocols/src/transports/tls/config.rs
  • Etemenanki/protocols/src/transports/grpc/settings.rs
  • Etemenanki/protocols/src/transports/reality.rs
  • Etemenanki/reality/src/keys.rs
  • Etemenanki/protocols/src/vless/addons.rs
  • Etemenanki/protocols/src/anytls/padding.rs
  • Etemenanki/protocols/src/sss/server.rs

katana 4 serves nothing itself. For every [[node]] it lowers what the panel says about the node, the node’s users and the config file into one Spec<Uid>, and hands that spec to the node’s own supervisor (etemenanki-supervisor 2.1.0 at katana 6.1.0), which binds, builds and serves it. This page covers the two files that lower the listener and the upstreams. src/lower/inbound.rs turns a panel node and the node’s local settings into an InboundSpec, and gives each panel user the credential that inbound admits. src/lower/outbound.rs turns the process-wide [[outbound]] list and [dns] table into the OutboundSpec list and the DnsSpec that every node’s spec carries.

The panel node is api::Node (src/api/mod.rs), a type alias of helium_node_api::config::NodeConfig: the node config of the helium-node-api crate, the contract Helium and katana share. A helium answer is one already. The newV2board client converts a UniProxy answer into one and refuses by name, as it reads the answer, whatever katana cannot serve; a Hysteria 2 node takes what UniProxy has no field for from [node.hysteria] (src/api/hysteria.rs). So lowering reads one vocabulary whichever panel a node has, and what a panel can ask for and the kernel cannot serve never reaches it. The module doc of src/lower/inbound.rs: “the contract’s types can’t write it, and the UniProxy client refuses it by name as it reads an answer”.

Both files judge and translate, and nothing else. src/lower/inbound.rs judges this host’s part, which the contract never carries: the certificate settings, the listen address, the real-IP and handoff keys, and Hysteria 2’s credential kind and congestion control. Its module doc says each is “refused by name rather than ignored, which would leave an operator believing a control is in force that is not”. It also parses an sss node’s chains and holds a Hysteria 2 masquerade to what the kernel answers with. src/lower/outbound.rs judges the outbound keys and servers and the [[outbound]] tags. Both read the certificate, key and DNS CA files into bytes. References, the pairing of TLS settings with a stream shape and the remaining cross-checks are the supervisor’s validation, when the spec is applied or checked.

This page is for contributors who change what a panel node or an [[outbound]] entry may ask for. How the pieces become one spec (node_spec, the user set, speed limits and the route table) is on Lowering a node into a spec, and the audit#<id> outbounds are on Destination audit. The operator’s side is on Protocols and transports, Hysteria 2 nodes and Outbounds.

Function File Does
lower_inbound src/lower/inbound.rs One node’s InboundSpec: tag, bind, handoff socket, sniffing, protocol, user set, PROXY protocol, real-IP header.
handoff, handoff_file, group_id, find_gid src/lower/inbound.rs handoff_dir and handoff_group as a directory and a gid, after refusing a path that is relative or too long for the node’s socket and a group /etc/group does not list; the socket’s name in that directory, from the port and a single listen address.
real_ip, websocket src/lower/inbound.rs real_ip_header and real_ip_from as a RealIpSpec, after refusing half a setting or a typo; whether the node’s protocol runs over WebSocket, the one transport that reads it.
inbound_tag src/lower/inbound.rs The inbound’s tag, <Type>_<listen_ip>_<port>.
bind_host, dual_stack src/lower/inbound.rs The host a listener binds: 0.0.0.0 widened to :: where the host’s IPv6 sockets take IPv4 too.
stream, Under src/lower/inbound.rs A stream node’s InboundTransportSpec: TCP, TLS, WebSocket or gRPC with the certificate it serves, or REALITY, after judging the certificate settings. Under says what runs under the transport: nothing, TLS or REALITY.
reality_spec src/lower/inbound.rs A REALITY node’s RealityServerSpec: the server name, the cover site, the key and the decoded shortId.
lower_stream_protocol src/lower/inbound.rs VMess (with its clock check), VLESS (with its flow), Trojan, Shadowsocks, AnyTLS, SOCKS, HTTP or sss, from the Node variant.
lower_shadowsocks src/lower/inbound.rs A Shadowsocks node’s cipher and, for 2022, its server key, over the node’s transport.
lower_sss src/lower/inbound.rs An sss node’s SssServerSettings: its chains parsed, its datagram limit, the rest at their defaults.
lower_hysteria src/lower/inbound.rs A Hysteria 2 node’s Hysteria2InboundSpec: the node’s obfuscation, masquerade, UDP relay and rates, with this host’s credential kind, congestion control, QUIC settings and certificate.
masquerade_spec, congestion src/lower/inbound.rs The node’s masquerade, held to what the kernel answers with; the congestion control, which test_spec also judges on every node.
read_cert_key src/lower/inbound.rs The certificate and private key files, as bytes.
credentials src/lower/inbound.rs The one credential a panel user presents to the node’s protocol.
local, uniproxy, obfs src/api/hysteria.rs A Hysteria 2 node that a panel cannot describe in full: the node [node.hysteria] describes alone, or a UniProxy node completed with [node.hysteria]’s UDP relay, masquerade and rate overrides; the Salamander obfuscation, as a panel or the block names it.
lower_outbounds src/lower/outbound.rs The four built-in outbounds, then one OutboundSpec per [[outbound]].
lower_outbound and its helpers src/lower/outbound.rs One [[outbound]] entry as an OutboundProtocolSpec.
lower_dns src/lower/outbound.rs [dns] as a DnsSpec::Single resolver backend.

Every function here is synchronous and pure, apart from three things the module doc of src/lower/mod.rs names: reading the certificate, key and DNS CA files that a spec carries as bytes, reading /etc/group for a handoff socket’s group, and asking the host once whether its IPv6 sockets take IPv4 too. Nothing binds, dials or spawns.

Concern Owner Page
Reading a panel’s answer into an api::Node, and refusing what a UniProxy answer asks for that katana cannot serve src/api/newv2board.rs → parse_node_config, src/api/helium.rs, src/api/hysteria.rs Panel clients
Assembly: node_spec, shared_spec, test_spec, the user set (lower_users, which calls credentials), speed limits, lower_route src/lower/mod.rs, src/lower/route.rs Lowering a node into a spec
Audit outbounds: one blackhole per audit rule id, after the outbounds lowered here src/rule.rs → audit_routes Destination audit
Semantic rules: tags, references, TLS material against the shape, key lengths, credential collisions supervisor/src/build/validate.rs Validation and apply errors
Building inbounds: handlers, user tables, OpenSSL and rustls configurations, the REALITY server, listeners supervisor/src/build/inbound.rs, supervisor/src/system/listener.rs Listeners and the serve loop, Users, principals and sessions, Transports: REALITY
Building outbounds: proxy clients, WireGuard tunnels supervisor/src/build/outbound.rs Outbounds, UDP fan-out and balancers
The resolver built from the DnsSpec supervisor/src/build/dns.rs Name resolution and the DNS service
When a spec is lowered and applied, and which applied changes close the node’s connections src/manager/node.rs The node manager
The config-file checks and the warning about shared WireGuard outbounds src/runtime.rs Runtime and config reload

katana 3 built kernel objects itself. Everything below either became a lowering function here or moved into the supervisor:

katana 3 katana 4
src/inbound.rs → build_transport The judgement is stream here. The OpenSSL acceptor, ALPN and the WebSocket and gRPC routes are built by the supervisor (supervisor/src/build/inbound.rs → build_transport).
build_protocol, build_shadowsocks lower_stream_protocol and lower_shadowsocks choose the protocol; credentials gives each user their key. The supervisor builds the VMess, VLESS, Trojan and Shadowsocks tables (build/inbound.rs → user_table).
build_hysteria_authenticator, build_hysteria lower_hysteria. The supervisor builds the Authenticator, the QUIC configuration and the listener.
validate_hysteria test_spec in src/lower/mod.rs plus etemenanki_supervisor::check.
runtime.rs → build_outbounds: one pool per process, one shared resolver lower_outbounds and lower_dns, lowered into every node’s spec. Each node’s supervisor builds its own outbounds and resolver.
src/outbound/{mod,proxy,freedom}.rs supervisor/src/topology/outbound/ and supervisor/src/build/outbound.rs.
HY2_MAX_CONNECTIONS (4096) and MAX_LIVE_CONNECTIONS_PER_NODE (65,536): the Hysteria 2 connection cap, and the per-node live-session cap of every listener that also bounded Hysteria circuits A Hysteria 2 inbound takes the kernel defaults DEFAULT_MAX_CONNECTIONS (262,144) and DEFAULT_MAX_CIRCUITS (4,194,304). The limits of a stream inbound are the supervisor’s; see Limits, timeouts and memory.

What changes for an operator upgrading from katana 3 is on Upgrading to katana 4.

src/api/mod.rs
/// What a panel says a node serves: helium-node-api's node config.
pub type Node = helium_node_api::config::NodeConfig;
// Vmess, Vless, Trojan, Shadowsocks, Anytls, Socks(TlsProxy), Http(TlsProxy), Sss, Hysteria2
src/lower/inbound.rs
use helium_node_api::config as contract;
pub fn inbound_tag(node: &Node, listen_ip: &str) -> CompactString;
pub fn bind_host(listen_ip: &str) -> String;
pub fn dual_stack() -> bool;
pub fn lower_inbound(cfg: &NodeConfig, node: &Node) -> io::Result<InboundSpec>;
pub fn real_ip(controller: &ControllerConfig) -> io::Result<Option<RealIpSpec>>;
pub fn handoff_file(listen_ip: &str, port: u16) -> String;
pub fn handoff(controller: &ControllerConfig) -> io::Result<Option<(&Path, Option<u32>)>>;
pub fn credentials(protocol: &InboundProtocolSpec, u: &UserInfo) -> Result<Credentials, String>;
pub fn congestion(cfg: &HysteriaConfig) -> io::Result<Fallback>;
fn unsupported(feature: &str) -> io::Error; // ErrorKind::Unsupported
fn invalid(msg: impl Into<String>) -> io::Error; // ErrorKind::InvalidInput
fn read_cert_key(cert: &CertConfig) -> io::Result<ServerTlsSpec>;
fn websocket(protocol: &InboundProtocolSpec) -> bool;
fn group_id(name: &str) -> io::Result<u32>;
fn find_gid(groups: &str, name: &str) -> Option<u32>;
/// What a stream protocol runs over its transport.
enum Under<'a> {
Plain,
Tls, // with this host's certificate
Reality(&'a contract::Reality),
}
// impl From<contract::Security> for Under<'_>: None is Plain, Tls is Tls
fn stream(
transport: &contract::Transport,
under: Under<'_>,
cert: &CertConfig,
) -> io::Result<InboundTransportSpec>;
fn reality_spec(reality: &contract::Reality) -> io::Result<RealityServerSpec>;
fn lower_stream_protocol(cfg: &NodeConfig, node: &Node) -> io::Result<InboundProtocolSpec>;
fn lower_sss(sss: &contract::Sss) -> io::Result<SssServerSettings>;
fn lower_shadowsocks(
cipher: &contract::SsCipher,
transport: InboundTransportSpec,
) -> InboundProtocolSpec;
fn lower_hysteria(
node: &contract::Hysteria2,
cfg: &HysteriaConfig,
cert: &CertConfig,
) -> io::Result<Hysteria2InboundSpec>;
fn masquerade_spec(status: u16, body: &str, content_type: &str) -> io::Result<MasqueradeSpec>;
src/api/hysteria.rs
pub fn local(cfg: &HysteriaConfig, port: NonZeroU16) -> io::Result<Node>;
pub fn uniproxy(
port: NonZeroU16,
obfs_type: &str,
obfs_password: &str,
up_mbps: u64,
down_mbps: u64,
ignore_client_bandwidth: Option<bool>,
local: &HysteriaConfig,
) -> io::Result<Node>;
pub fn obfs(obfs_type: &str, password: &str) -> io::Result<Option<Obfs>>;
fn complete(/* port, obfs, the panel's rates, local */) -> io::Result<Node>; // runs Node::validate
fn udp(cfg: &HysteriaConfig) -> io::Result<Option<UdpRelay>>;
fn masquerade(cfg: &HysteriaConfig) -> Option<Masquerade>;
src/lower/outbound.rs
pub fn lower_outbounds(globals: &Globals) -> io::Result<Vec<OutboundSpec>>;
pub fn lower_dns(dns: &DnsConfig) -> io::Result<DnsSpec>;
fn outbound(tag: &str, protocol: OutboundProtocolSpec) -> OutboundSpec; // drain: None
fn invalid(msg: impl Into<String>) -> io::Error; // ErrorKind::InvalidInput
fn lower_outbound(cfg: &OutboundConfig) -> io::Result<OutboundProtocolSpec>;
fn parse_server(host: &str, port: u16) -> io::Result<Destination>;
fn account(cfg: &OutboundConfig) -> Option<Account>;
fn require_uuid(cfg: &OutboundConfig) -> io::Result<Uuid>;
fn parse_security(name: Option<&str>) -> io::Result<Security>;
fn lower_shadowsocks(cfg: &OutboundConfig, upstream: ProxyUpstream) -> io::Result<OutboundProtocolSpec>;
fn lower_wireguard(
cfg: &OutboundConfig,
endpoint: Destination,
address_family: AddressFamilyStrategy,
) -> io::Result<OutboundProtocolSpec>;
fn parse_address_family(cfg: &OutboundConfig) -> io::Result<AddressFamilyStrategy>;
fn parse_family(cfg: &OutboundConfig, raw: Option<&str>, field: &str) -> io::Result<AddressFamilyStrategy>;
fn parse_wg_key(text: Option<&str>, field: &str, cfg: &OutboundConfig) -> io::Result<[u8; 32]>;

Globals (src/config.rs) is what every node lowers besides its own settings: outbounds: Vec<OutboundConfig> and dns: DnsConfig, cloned from the config file by Config::globals.

The constants and the one piece of state these functions use:

// src/lower/mod.rs: the tag of the one user set a node's inbound admits
pub const USER_SET: &str = "users";
// src/rule.rs: what every audit outbound's tag starts with
pub const AUDIT_TAG_PREFIX: &str = "audit#";
// protocols/src/hysteria/server/config.rs
pub const DEFAULT_MAX_CONNECTIONS: usize = 262_144;
pub const DEFAULT_MAX_CIRCUITS: usize = 4_194_304;
// protocols/src/wireguard/config.rs
pub const DEFAULT_MTU: usize = 1420;
// src/lower/inbound.rs: who may hand connections over, and the longest socket path
const HANDOFF_MODE: u32 = 0o660;
const MAX_SOCKET_PATH: usize = 107;
// src/lower/inbound.rs → dual_stack: the probe's answer, once per process
static DUAL_STACK: OnceLock<bool> = OnceLock::new();

inbound.rs builds its errors with two helpers. unsupported(feature) is io::ErrorKind::Unsupported with the text node requests kernel-unsupported feature: <feature>, for a key of the config file that asks for what the kernel does not implement (cert.reject_unknown_sni and the ACME cert modes). invalid(msg) is io::ErrorKind::InvalidInput with the message as given, for a value that is wrong. src/api/hysteria.rs has its own invalid with the same meaning. The newV2board client has an unsupported of its own with the same text, which builds an anyhow::Error rather than an io::Error, for what a UniProxy answer asks for. outbound.rs has its own invalid with the same meaning, and one Unsupported error, for an unknown Shadowsocks cipher. The texts carry no prefix of their own; each caller adds one, and katana --test prints configuration error: node <node_id>: <error> (see Failure paths and cancellation).

credentials is different: its error is a String naming what is wrong with one user, which the caller logs before skipping that user. It never fails the node.

These are the supervisor’s types (supervisor/src/topology/spec_plan/), shown with the fields katana sets. The whole spec is on The spec: desired state.

supervisor/src/topology/spec_plan/inbound.rs, transport.rs and topology/inbound/mod.rs
pub struct InboundSpec {
pub tag: CompactString,
pub bind: BindSpec, // Tcp { host, port } or Udp { host, port }
pub handoff: Option<HandoffSpec>, // katana: Some on a stream node with handoff_dir set
pub sniff: bool,
pub protocol: InboundProtocolSpec, // katana: Vmess, Vless, Trojan, Shadowsocks, Ss2022, Anytls, Socks, Http, Sss, Hysteria2
pub users: Option<CompactString>, // katana: Some("users")
pub user_removal: Option<UserRemovalPolicy>, // katana: None
pub proxy_protocol: bool, // katana: true for a TCP bind
pub real_ip: Option<RealIpSpec>, // katana: Some only on a WebSocket node with real_ip_header set
}
pub struct HandoffSpec {
pub path: PathBuf, // katana: <handoff_dir>/ joined with handoff_file(listen_ip, port)
pub mode: u32, // katana: 0o660
pub gid: Option<u32>, // katana: handoff_group's gid, or None
}
pub struct RealIpSpec {
pub header: CompactString, // the upgrade request header that names the client
pub trusted: Vec<IpCidr>, // the proxies trusted to set it
}
pub struct InboundTransportSpec {
pub shape: StreamShape, // Tcp, Tls, Ws { path, host, tls }, Grpc { service, authority, tls }, Reality
pub tls: Option<ServerTlsSpec>,
pub reality: Option<RealityServerSpec>, // Some exactly when the shape is Reality
}
pub struct RealityServerSpec {
pub private_key: Secret<[u8; 32]>,
pub server_names: Vec<String>, // katana: the panel's one server name
pub short_ids: Vec<[u8; 8]>, // katana: the panel's one shortId
pub dest: Destination, // katana: server_name at the panel's port, over TCP
pub max_time_diff: Option<Duration>, // katana: None
pub min_client_version: Option<[u8; 3]>, // katana: None
pub max_client_version: Option<[u8; 3]>, // katana: None
pub require_hybrid: bool, // katana: false
}
pub struct ServerTlsSpec {
pub cert_pem: Vec<u8>,
pub key_pem: Secret<Vec<u8>>,
}
pub struct Hysteria2InboundSpec {
pub tls: ServerTlsSpec,
pub shared_password: Option<Secret<String>>,
pub masquerade: Option<MasqueradeSpec>,
pub obfs: Option<ObfsSpec>, // ObfsSpec::Salamander { psk: Secret<Vec<u8>> }
pub udp_idle_timeout: Option<Duration>,
pub max_connections: usize,
pub max_circuits: usize,
pub user_auth: Hysteria2UserAuth, // Account or Password
pub bandwidth: BandwidthConfig, // { up, down: Option<Bandwidth>, disable_loss_compensation }
pub ignore_client_bandwidth: bool,
pub congestion: Fallback, // Cubic, NewReno or Bbr
pub quic: QuicOptions, // katana: QuicOptions::server()
}
supervisor/src/topology/spec_plan/outbound.rs, transport.rs and dns.rs
pub struct OutboundSpec {
pub tag: CompactString,
pub protocol: OutboundProtocolSpec,
pub drain: Option<DrainPolicy>, // katana: None
}
pub struct ProxyUpstream {
pub server: Destination, // always addressed over TCP
pub transport: OutboundTransportSpec,
}
pub struct OutboundTransportSpec {
pub shape: StreamShape, // katana: Tcp
pub tls: Option<ClientTlsSpec>, // katana: None
pub reality: Option<RealityClientSpec>, // katana: None
pub address_family: AddressFamilyStrategy,
}
pub struct WireguardSpec {
pub private_key: Secret<[u8; 32]>,
pub peer_public_key: [u8; 32],
pub preshared_key: Option<Secret<[u8; 32]>>,
pub endpoint: Destination,
pub endpoint_address_family: AddressFamilyStrategy,
pub addresses: Vec<IpAddr>,
pub address_family: AddressFamilyStrategy,
pub mtu: usize,
pub keepalive: Option<u16>,
pub reserved: Option<[u8; 3]>,
}
pub enum DnsSpec {
Single(Backend), // katana lowers only this one
Split { /* … */ },
}

Secret<T> (spec_plan/mod.rs) is the supervisor’s wrapper for “a value that must never reach a log line: a password, a pre-shared key, a private key”. It compares and hashes as its contents, so a changed key is a changed spec, and its Debug prints Secret(..), neither the value nor its length. katana wraps these in one: the TLS private key, a REALITY node’s X25519 private key, the Salamander key, the node’s Shadowsocks 2022 PSK, the users’ passwords and Shadowsocks 2022 keys, the outbound Shadowsocks passwords and PSKs, the SOCKS and HTTP outbound passwords, and the WireGuard private and pre-shared keys.

flowchart TB
  BOOT["NodeManager::try_bootstrap"] --> NS["node_spec"]
  REC["NodeManager::reconcile"] --> NS
  TS["test_spec: --test and config checks"] --> RI["real_ip"]
  TS --> HO["handoff"]
  TS --> CG["congestion"]
  TS --> SH["shared_spec"]
  TS -->|"Hysteria 2 only"| HL["hysteria::local"]
  HL --> NS
  NS --> SH
  SH --> LO["lower_outbounds"]
  SH --> LD["lower_dns"]
  SH --> RT["audit_routes and lower_route"]
  NS --> LI["lower_inbound"]
  LI --> LH["lower_hysteria"]
  LI --> LS["lower_stream_protocol"]
  LI --> RI
  LI --> HO
  LS --> LT["stream"]
  LT --> RC["read_cert_key"]
  LH --> RC
  LH --> CG
  NS --> LU["lower_users: credentials per user"]

node_spec (in src/lower/mod.rs) calls shared_spec first, so the outbounds, DNS and route are lowered, and can fail, before the inbound. Then it lowers the inbound and the users against that inbound’s protocol. The result goes to Supervisor::start (bootstrap), Supervisor::apply_with (reconcile) or etemenanki_supervisor::check (checks), which validate it before anything is built. The node manager runs the lowering on the blocking pool, because the users make it grow.

Caller When Lowers
NodeManager::try_bootstrap (src/manager/node.rs) Each attempt to bring the node up, after the panel has answered The whole node, through NodeManager::lower_off_runtime.
NodeManager::reconcile After each panel poll; after a config edit to the panel client (panel_type, enable_mtls, [node.api], [node.hysteria]), to a setting the listener or routes are built from, or to the clock check or the policies; after a change to [[outbound]] or [dns] The whole node, through NodeManager::lower_off_runtime.
runtime::check_node via test_spec When a node is built at start or added by a reload, and when a reload changes a running node or the globals The real-IP, handoff and congestion keys, then outbounds, DNS and route; for a Hysteria 2 node of newV2board also its inbound.
runtime::test_config (katana --test) Once per [[node]] The same as check_node.

test_spec first calls real_ip(&cfg.controller), handoff(&cfg.controller) and congestion(&cfg.hysteria), for every node, and discards the results. It lowers the inbound only for a node whose node_type is Hysteria 2, because on newV2board that node type’s own settings can be judged before the panel is asked (a helium node names no node_type, so its check lowers no inbound): it lowers the node hysteria::local(&cfg.hysteria, port) builds from [node.hysteria] alone, on [node.hysteria] port, or on port 1 (NonZeroU16::MIN) when that is 0, with one placeholder user. The code comment: “A node whose panel names its port is judged on a placeholder one.” hysteria::local holds the block’s obfuscation, UDP relay and masquerade to their rules, so the check refuses them before any panel is asked. See Lowering a node into a spec for test_spec.

NodeManager::try_bootstrap and NodeManager::reconcile lower the node NodeManager::node_info last read: the panel client’s answer, or, on a newV2board Hysteria 2 node with [node.hysteria] port set, the node hysteria::local builds. The panel client’s read is where a UniProxy answer is refused for what it asks for, before lowering: parse_node_config in src/api/newv2board.rs names the reason in its error, and the node logs it as a node_info error (see Refused before lowering).

lower_inbound(cfg, node) produces one inbound per node:

Field Value From
tag inbound_tag(node, &cfg.controller.listen_ip) The node’s protocol, [node.controller] listen_ip as written, the node’s port.
bind BindSpec::Udp { host, port } for a Hysteria 2 node, BindSpec::Tcp { host, port } otherwise host = bind_host(listen_ip), port = node.port().get().
handoff HandoffSpec { path: <dir>/<handoff_file(listen_ip, port)>, mode: 0o660, gid } from handoff(&cfg.controller)?, kept only for a BindSpec::Tcp [node.controller] handoff_dir and handoff_group; see The handoff socket.
sniff !cfg.controller.disable_sniffing [node.controller] disable_sniffing.
protocol InboundProtocolSpec::Hysteria2(lower_hysteria(…)?), or lower_stream_protocol(cfg, node)? See the sections below.
users Some("users") (USER_SET) Every panel node admits exactly one user set, filled by lower_users.
user_removal None The supervisor-wide default applies; see Users, principals and sessions.
proxy_protocol true for a BindSpec::Tcp, false for Hysteria 2’s Udp Every stream node.
real_ip real_ip(&cfg.controller)?, kept only when websocket(&protocol) [node.controller] real_ip_header and real_ip_from; see The real-IP header.

The code comment on sniff gives its reason: disable_sniffing had no effect until the kernel learned to sniff, and honouring it keeps the key from being a setting that does nothing. tests/integration/sniff.rs pins both states with a real Xray client and a node whose route table drops everything except one domain rule.

proxy_protocol has the listener read a PROXY protocol v2 header at the start of each TCP connection when one is sent, and take the client’s address from it, so a relay in front can name the client it carries. The code comment: “A relay in front may name its client in a PROXY protocol header.” That address is what a session’s source is, and so what the device limit and the IP ban count and what helium’s report carries (see Lowering a node into a spec). How the listener reads the header is on Listeners and the serve loop. No panel has a say in it: the contract’s module doc lists “which PROXY headers and real-IP headers to trust” among what stays in katana’s host config.

lower_inbound computes the bind host first, before it lowers the protocol, so the dual-stack probe below and its one WARN line can run for a node whose protocol lowering then fails.

The supervisor builds the listener from bind. Its validation also checks the shape of the inbound spec; katana builds every inbound so that it meets these rules:

Supervisor text (prefixed inbound <tag>: ) Rule What katana sets
the protocol cannot be served on <bind> Hysteria 2 needs a UDP bind, the stream protocols a TCP or Unix one. Udp for Hysteria 2, Tcp for the rest.
the transport layers tls but carries no tls settings, the transport carries tls settings but does not layer tls tls is present exactly when the shape layers TLS. stream reads the certificate exactly when the node runs TLS, which is when its shape layers TLS.
the protocol has no open mode and needs a user set A VMess, VLESS, Trojan, AnyTLS or sss inbound names a user set. users: Some("users") on every inbound.
a reality transport carries no reality settings, the transport carries reality settings but its shape is not reality, reality needs at least one server name, invalid reality server name "<name>", reality needs at least one shortId, reality dest needs a non-zero port reality is present exactly with the Reality shape, and holds at least one server name (none empty, none with *), at least one shortId and a cover site with a port. stream sets reality only with the Reality shape, and reality_spec gives one server name and one shortId. The contract holds the name to a host name without a wildcard and the port to a NonZeroU16, so katana never produces these.
reality is for vless only The Reality shape carries VLESS alone. Only Node::Vless can carry REALITY, in its VlessSecurity; the newV2board client refuses REALITY on a VMess node by name.
vless vision (xtls-rprx-vision) rides only over reality A VLESS inbound with VlessFlow::Vision has the Reality shape. The contract’s validate() refuses Vision without REALITY on every panel’s node, so katana never produces this.
anytls runs over tls only; its shape must be tls, and the padding scheme’s own errors AnyTLS has the Tls shape, and its padding scheme parses (PaddingScheme::from_lines). Every AnyTLS node lowers the Tls shape: the contract’s Anytls has no transport and no security. The padding lines pass on as the contract holds them; what each line means is the supervisor’s to judge.
socks serves udp associate over plain tcp only; turn udp off to wrap it in a transport A SOCKS inbound relays UDP only on the plain Tcp shape. udp: false on every SOCKS node.
sss udp_max_datagram must be at least 1, sss flush_delay must be at most 10ms, sss header_timeout must be above zero An sss inbound’s limits. lower_sss takes udp_max_datagram, a NonZeroU16 in the contract, and the defaults for the other two, so none of the three arises.
hysteria2 needs a shared password or a user set, a shared password and a user set cannot both be set; a credential would have two answers A Hysteria 2 inbound has exactly one of the two. shared_password: None and users: Some("users").
max_connections and max_circuits must be at least 1 Both Hysteria 2 limits are positive. The kernel defaults.
only a websocket transport on a tcp listener reads a real-ip header, a real-ip header needs at least one trusted proxy, the real-ip header "<header>" is not a header name A real_ip goes with a WebSocket transport on a TCP bind, at least one trusted network and a valid header name. real_ip only on a WebSocket node, which binds TCP; real_ip has refused an empty real_ip_from and a bad name before.
only a stream inbound on a tcp listener takes a handoff socket, the handoff socket <path> must be an absolute path to a file, the handoff socket <path> is longer than 107 bytes, the handoff socket's mode <mode> holds more than permission bits A handoff socket stands beside a TCP bind, at an absolute path of at most 107 bytes (sun_path), with only permission bits for its mode. handoff only on a BindSpec::Tcp; the path is an absolute directory joined with handoff_file(listen_ip, port), which handoff has held to 107 bytes at the longest port; mode is 0o660.

The full rule list is on Validation and apply errors.

src/lower/inbound.rs
pub fn real_ip(controller: &ControllerConfig) -> io::Result<Option<RealIpSpec>>;
fn websocket(protocol: &InboundProtocolSpec) -> bool;

A reverse proxy such as nginx in front of a WebSocket node opens its own connection for every client, and can name the client in a header of the WebSocket upgrade. real_ip turns [node.controller]’s real_ip_header (Option<String>) and real_ip_from (Vec<String>) into the supervisor’s RealIpSpec. Its doc comment gives the rule and the reason: both or neither, every CIDR valid, the header a header name, because “refusing a half or a typo keeps a node from quietly taking no header, or from trusting an address no one meant”. The checks, in order:

real_ip_header real_ip_from Result
unset empty Ok(None)
unset not empty real_ip_from is set without real_ip_header
set empty real_ip_header needs real_ip_from: the proxies trusted to set it
not a header name not empty real_ip_header "X Real IP" is not a header name
a header name an entry IpCidr does not parse real_ip_from "<entry>": <error>, for example real_ip_from "127.0.0.1/33": invalid length for network: Network length 33 is too long for Ipv4 (maximum: 32) or real_ip_from "localhost": couldn't parse address in network: invalid IP address syntax
a header name every entry parses Ok(Some(RealIpSpec { header, trusted })), the networks in file order

Every refusal is InvalidInput, and the header is printed with Debug quoting. The header name is judged by the kernel’s own rule: real_ip builds a throwaway WsRoute::new("/") and calls WsRoute::real_ip_header(header) (protocols/src/transports/ws/endpoint.rs), which parses the name with http::HeaderName::from_bytes; header names compare case-insensitively. IpCidr is the cidr crate’s, as for a route rule’s cidr: a bare address is a single host, and set host bits are refused.

lower_inbound calls real_ip(&cfg.controller)? for every node, after the protocol is lowered, and keeps the result only when websocket(&protocol) holds: the protocol runs over a transport (InboundProtocolSpec::transport, which every stream protocol has), and its shape is StreamShape::Ws. The doc comment of websocket calls WebSocket “the one transport whose upgrade a reverse proxy can name the client in”. A TCP, TLS, REALITY or gRPC node and a Hysteria 2 node get real_ip: None whatever the keys say, but a half or malformed setting still fails their lowering. test_spec calls real_ip before anything else, so --test, a start and a reload refuse a bad pair before any panel has described a WebSocket node; its comment: “Local, so judged now for every node type, not only once a panel names a WebSocket node or a port.”

The supervisor’s side is on Listeners and the serve loop. In short: build_transport adds the header to the WebSocket route; the route reads it off each upgrade after the path and Host check; and the accept path takes the client from it only on a connection from an address in trusted. The client is the rightmost listed address outside trusted, or the leftmost when every one is inside, so a single address is the client either way. A trusted proxy that sends no header, or one that is not a list of at most 32 IP addresses, stays the client itself. The client the header names is checked against the IP bans and becomes the session’s source, so it is what the device limit, the IP ban and helium’s report count. An edit to either key sets rehandle in apply_static, so the node polls at once, and the apply swaps the handler and keeps live connections (The node manager).

src/lower/inbound.rs
/// Who may hand connections over: the relay's group, and no one else.
const HANDOFF_MODE: u32 = 0o660;
/// The longest path a Unix socket may have.
const MAX_SOCKET_PATH: usize = 107;
pub fn handoff_file(listen_ip: &str, port: u16) -> String;
pub fn handoff(controller: &ControllerConfig) -> io::Result<Option<(&Path, Option<u32>)>>;
fn group_id(name: &str) -> io::Result<u32>;
fn find_gid(groups: &str, name: &str) -> Option<u32>;

A relay running on the same host can hand a stream node’s TCP connections over on a Unix socket of the node’s own. handoff_file(listen_ip, port) names that socket inside handoff_dir: the port, and the listen address as well when the node listens on one address rather than all of them, so that two nodes on one port and different addresses get different paths.

listen_ip handoff_file(listen_ip, 443)
An IpAddr that is not unspecified, such as 203.0.113.5 or 2001:db8::1 <ip>-443.sock, the address as IpAddr displays it: 203.0.113.5-443.sock, 2001:db8::1-443.sock
0.0.0.0 or :: 443.sock
Empty 443.sock
Anything else that does not parse as an IpAddr, such as localhost <listen_ip>-443.sock as written: localhost-443.sock

handoff turns [node.controller]’s handoff_dir (Option<PathBuf>) and handoff_group (Option<String>) into the directory and the group’s gid. Its doc comment gives the rule and the reason: the directory absolute and short enough for any node’s socket in it, the group’s gid read from /etc/group, and “a group without a directory, or one that is not there, is refused rather than leaving a socket the relay cannot reach”. The checks, in order:

handoff_dir handoff_group Result
unset unset Ok(None)
unset set handoff_group is set without handoff_dir
not absolute, the empty path included any handoff_dir "run/katana" must be an absolute path
with a / and handoff_file(listen_ip, 65535), longer than MAX_SOCKET_PATH bytes any handoff_dir "<dir>" is too long: with "65535.sock" in it, a socket's path would pass the 107 bytes a Unix socket's path may have, naming the node’s own longest name
valid unset Ok(Some((dir, None)))
valid set, but /etc/group cannot be read handoff_group "<name>": reading /etc/group: <error>
valid set, but no line of /etc/group names it handoff_group "no-such-group" is not a group in /etc/group
valid a group /etc/group lists Ok(Some((dir, Some(gid))))

Every refusal is InvalidInput, and the path and the names are printed with Debug quoting. The length check takes the node’s own longest name, handoff_file(&controller.listen_ip, u16::MAX): the directory, a / and that name must fit in MAX_SOCKET_PATH, 107 bytes, because sun_path holds 107 bytes and a NUL. Port 65535 gives the longest name of any port, so the check holds before a panel has named the port. A node on every address may have a directory of up to 96 bytes (65535.sock is 10 bytes); a node on 203.0.113.5 or 2001:db8::1 up to 84 (203.0.113.5-65535.sock is 22). find_gid reads the text of /etc/group as one name:password:gid:members line per group: the first line whose first field is the whole name gives its third field, parsed as a u32. A name that is only part of a group’s name does not match, and a line with no number in its third field gives no gid. katana reads the file itself, without NSS, so a group that only an NSS module serves is not found.

lower_inbound calls handoff(&cfg.controller)? for every node, after the protocol and proxy_protocol and before real_ip, and keeps the result only for a BindSpec::Tcp, the bind of every stream node. It builds HandoffSpec { path: dir.join(handoff_file(&cfg.controller.listen_ip, port)), mode: HANDOFF_MODE, gid }, port being the node’s, so a node on port 443 with handoff_dir = "/run/katana/handoff" gets /run/katana/handoff/443.sock on 0.0.0.0 and /run/katana/handoff/203.0.113.5-443.sock on 203.0.113.5. The name takes listen_ip as written, not the host bind_host makes of it, so 0.0.0.0 bound as :: still gives 443.sock. A Hysteria 2 node’s UDP bind gets handoff: None, but a bad setting still fails its lowering. The group is looked up at every lowering, so every poll reads /etc/group while handoff_group is set. test_spec calls handoff right after real_ip, for every node type, so --test, a start and a reload refuse a setting the relay could not use before any panel has named a port.

The supervisor’s side is on Listeners and the serve loop. In short: the handoff socket is a second listener of the inbound and serves the same handler. It is bound in prepare, under a staging name beside its path: a missing directory is created with mode 0750 and given gid, and the socket gets mode and gid after it is bound and before it listens. The commit moves it over its path, and a refused apply removes only the staged file. The TCP listener and the handoff socket count against one set of caps, the inbound’s: its connections in their handshake and its live connections are bounded across both. Each connection on the socket carries one TCP socket, passed as SCM_RIGHTS, and a whole PROXY protocol v2 header naming its client, with nothing after it: the supervisor reads one byte more than the longest header, so a byte after even a full-length header refuses the handoff. The supervisor answers 0x00 once it takes the socket and 0x01 when it refuses it, closes that connection, and serves the TCP socket as if the TCP listener had accepted it, with the client the header names; a LOCAL header leaves the socket’s own peer. That client is checked against the IP bans and becomes the session’s source, so it is what the device limit, the IP ban and helium’s report count.

An edit to either key sets rebind in apply_static, so the node polls at once. The applied spec’s main bind is unchanged, so the plan swaps the handler on the TCP listener, binds a new handoff socket in prepare when the socket is new or its path or group changed, and stops accepting on the old one. The new socket joins the caps of the TCP listener the inbound keeps. No step of that plan closes a connection, and rebind does not set rebuild_pending, so every connection is kept, handed-over ones included (The node manager).

Input Read by Used for
The Node variant lower_inbound, inbound_tag, lower_stream_protocol The tag, the bind kind, the protocol.
Node::port(), a NonZeroU16 lower_inbound, inbound_tag The bind port and tag.
transport: Tcp, Ws { path, host } or Grpc { service_name } stream The stream shape. Trojan, Shadowsocks, SOCKS, HTTP, VMess, VLESS and sss carry one; AnyTLS and Hysteria 2 do not.
security: Security::None or Tls; VLESS’s VlessSecurity, which adds Reality(Reality) lower_stream_protocol, as an Under; reality_spec Plain, TLS or REALITY under the transport. Trojan, AnyTLS, SOCKS and HTTP have no security: they always run inside TLS.
Vless::flow lower_stream_protocol The VLESS flow: none, or Vision.
Shadowsocks::cipher lower_shadowsocks The cipher and, for Shadowsocks 2022, the server key.
Anytls::padding_scheme lower_stream_protocol An AnyTLS node’s padding scheme, passed on as its lines.
Sss::transform, Sss::udp_max_datagram lower_sss An sss node’s chains and datagram limit.
Hysteria2::obfs, up_mbps, down_mbps, ignore_client_bandwidth, udp, masquerade lower_hysteria Salamander obfuscation, the rates, the UDP relay and the masquerade.
[node.controller] listen_ip, disable_sniffing lower_inbound The bind host, the tag, sniff.
[node.controller] disable_vmess_clock_check lower_stream_protocol A VMess inbound’s clock_check.
[node.controller] real_ip_header, real_ip_from real_ip A WebSocket node’s real_ip.
[node.controller] handoff_dir, handoff_group handoff A stream node’s handoff.
[node.controller.cert] stream, lower_hysteria, read_cert_key TLS mode, files, reject_unknown_sni.
[node.hysteria] credential, congestion lower_hysteria, congestion The credential kind and the congestion control: what only this host decides. A helium node can set only congestion, and its client refuses the rest of the block.
[node.hysteria] port, obfs, obfs_password, udp, udp_idle_timeout, masquerade, up_mbps, down_mbps, ignore_client_bandwidth src/api/hysteria.rs, before lowering Folded into the Node::Hysteria2 a newV2board node lowers: the whole node when port is set (local), or the UDP relay, the masquerade and overrides of the panel’s rates (uniproxy).

The variant is the panel’s. helium’s node config names it in its protocol key: vmess, vless, trojan, shadowsocks, anytls, socks, http, sss or hysteria2. The newV2board client reads a UniProxy answer as a node of the type [node.api] node_type names, parsed by NodeType::parse (src/api/mod.rs), which lower-cases the value and accepts these names:

[node.api] node_type NodeType
v2ray, vmess, vless V2ray
trojan Trojan
shadowsocks Shadowsocks
hysteria2, hysteria, hy2 Hysteria2
anytls Anytls
socks, socks5 Socks
http Http
sss Sss

vmess and vless are aliases of V2ray: which of the two protocols a V2ray node serves is [node.api] enable_vless, which the newV2board client reads as it converts the answer, into Node::Vless when it is set and Node::Vmess otherwise; lowering reads no [node.api] key itself. An sss node type is refused when the client is built: newV2board: no UniProxy panel describes an sss node; sss is Helium's own protocol, served with panel_type = "Helium".

A Hysteria 2 node reaches lower_hysteria with everything a client meets: the port, the obfuscation, the rates, the UDP relay and the masquerade. helium’s node config says all of it. A UniProxy answer says the port, the obfuscation and the rates, and hysteria::uniproxy completes the node from [node.hysteria]; with [node.hysteria] port set, NodeManager::node_info builds the node with hysteria::local from the block alone and does not ask the panel for it (see Hysteria 2 nodes). Speed limits are the users’ (UserInfo::speed_limit), already [node.api] speed_limit where that is set, and are lowered with them; see Lowering a node into a spec.

inbound_tag formats <Type>_<listen_ip>_<port>, where <Type> is V2ray, Trojan, Shadowsocks, Hysteria2, AnyTLS, Socks, Http or Sss by the Node variant (V2ray for both Vmess and Vless, as the panels’ node type names them) and listen_ip is the configured string, not the bind host. The default node on port 443 is V2ray_0.0.0.0_443 on every host, including one where it binds ::.

The tag names the inbound in every supervisor error about it, for example building inbound Hysteria2_0.0.0.0_8443 failed: …. Because it keeps listen_ip as written, it reads the same whether the host binds :: or 0.0.0.0. the_default_listen_ip_binds_both_families_where_the_host_can asserts the tag V2ray_0.0.0.0_443.

src/lower/inbound.rs
pub fn bind_host(listen_ip: &str) -> String {
match listen_ip.parse::<Ipv4Addr>() {
Ok(ip) if ip.is_unspecified() && dual_stack() => Ipv6Addr::UNSPECIFIED.to_string(),
_ => listen_ip.to_owned(),
}
}

The default listen_ip is 0.0.0.0 (src/config.rs → default_listen_ip). The code comment gives the reason for widening it: in XrayR and Xray, whose config keys katana takes over, 0.0.0.0 means every address, IPv6 included, because Go binds it as one dual-stack [::] socket. katana binds :: wherever that socket takes IPv4 too. Where it would not, binding :: would lose every IPv4 client, so 0.0.0.0 stays.

dual_stack() answers that question once per process and caches the answer in the static DUAL_STACK: OnceLock<bool>:

  1. Create an IPv6 stream socket with socket2::Socket::new(Domain::IPV6, Type::STREAM, None). It is never bound, and is closed when the probe returns. If the socket cannot be created (no IPv6 on the host), the answer is false.

  2. Read only_v6(), the socket’s IPV6_V6ONLY default. Ok(false) means the host’s IPv6 sockets take IPv4 too, and the answer is true.

  3. Ok(true) means net.ipv6.bindv6only is set. The answer is false, and katana logs once at WARN, target katana::lower::inbound:

    IPv6 sockets here take IPv6 alone (net.ipv6.bindv6only), so listen_ip 0.0.0.0 serves IPv4 only
  4. An error from only_v6() is false, without a log line.

The probe predicts the listener the supervisor binds, because supervisor/src/system/listener.rs → bind binds with std::net::TcpListener::bind or std::net::UdpSocket::bind and leaves IPV6_V6ONLY at the host default. The one answer serves TCP and UDP listeners alike, since net.ipv6.bindv6only governs both. A host whose setting changes after the first probe keeps the first answer until katana restarts.

listen_ip Host binds :: with IPv4 too Host does not
0.0.0.0 :: 0.0.0.0
Anything else: 127.0.0.1, 192.0.2.7, ::, ::1, 2001:db8::7, localhost as written as written

Only the IPv4 wildcard is widened; an address written out, IPv6 or not, is what the operator chose to serve on (any_other_listen_ip_binds_as_written). Any other value, a host name such as localhost included, is passed to the supervisor as written; see Listeners and the serve loop. dual_stack() runs only for a listen_ip that parses as the IPv4 unspecified address, so a host that never uses 0.0.0.0 never probes.

When a node comes up, the node manager logs the address the spec binds as node <id>: listening on <addr>, which for a widened bind reads [::]:443 (src/manager/node.rs → log_listening).

lower_stream_protocol hands each stream node’s transport to stream(transport, under, cert), with an Under that says what runs under it: Plain, Tls with this host’s certificate, or Reality with the node’s settings. VMess, Shadowsocks and sss take theirs from their security (Security::None is Plain, Security::Tls is Tls), VLESS from its VlessSecurity; Trojan, SOCKS and HTTP are always Tls, and AnyTLS is Tls over Transport::Tcp. The doc comment of stream: “The certificate settings are this host’s, so their rules are judged here”. It runs its checks in a fixed order and returns at the first failure:

  1. Under::Reality(reality) returns at once with InboundTransportSpec { shape: StreamShape::Reality, tls: None, reality: Some(reality_spec(reality)?) }. The doc comment: REALITY brings a TLS 1.3 of its own and no certificate, so none of the certificate rules apply to it. The transport is not looked at: the contract runs REALITY over Transport::Tcp alone, and its validate() refuses any other with security reality runs over transport tcp only. See REALITY nodes.
  2. cert.reject_unknown_sni = true is refused: node requests kernel-unsupported feature: cert.reject_unknown_sni. The code comment gives the reason: the key asks the listener to reject a handshake whose SNI does not match the certificate, and nothing here does that; a control that is asked for and not delivered leaves the operator believing it is in force.
  3. cert.mode of "dns", "http" or "tls", the ACME modes, is refused as ACME cert mode "dns" (the mode is printed with Debug quoting). The comparison is exact.
  4. TLS with any cert.mode other than "file" is refused with InvalidInput: TLS node requires cert.mode = "file". The default mode is "none" (src/config.rs → default_cert_mode).
  5. The transport is mapped to a StreamShape (table below).
  6. With TLS, read_cert_key(cert) reads the certificate and key.

Steps 2 and 3 apply to every stream node that is not REALITY, with or without TLS, so an ACME mode or reject_unknown_sni is refused even on a plaintext node. The certificate files of a plaintext or REALITY node are never read.

contract::Transport StreamShape under Plain Under Tls
Tcp Tcp Tls
Ws { path, host } Ws { path, host, tls: false } Ws { path, host, tls: true }
Grpc { service_name } Grpc { service: service_name, authority: None, tls: false } Grpc { service: service_name, authority: None, tls: true }

The contract has these three transports and no other, and no field for TCP header obfuscation: its doc says “Only what Etemenanki serves is here”. So httpupgrade, splithttp, any other transport and a TCP header other than none never reach lowering. A UniProxy answer that asks for one is refused by name as the newV2board client reads it (Refused before lowering), and a helium config cannot say one.

  • WebSocket. path and host are the node’s, unchanged. The contract holds the path to one that starts with /, has no whitespace, control character or # in it, and no query but ?ed=N; and the host, when there is one, to a non-empty host without whitespace, control characters or a port (an IPv6 address in brackets). On a UniProxy node the client writes a path that is left out or empty as /, and an empty Host as no host, before the contract’s rules run.
  • gRPC. service is the node’s service_name, which the contract holds to a non-empty one. authority is always None: a server does not check the authority a client sends, so it has no inbound meaning (spec_plan/transport.rs).
  • The result. InboundTransportSpec { shape, tls, reality: None }, where tls is Some exactly under Tls, which is exactly when the shape layers TLS. The supervisor’s validation refuses any other pairing (the transport layers tls but carries no tls settings), which katana cannot produce.

What the supervisor makes of the shape is on Listeners and the serve loop. In short, supervisor/src/build/inbound.rs → build_transport builds an OpenSSL acceptor from the PEM bytes (protocols/src/transports/tls/config.rs → ServerConfig::from_pem) with no ALPN for Tls, ALPN http/1.1 for WebSocket over TLS, and ALPN h2 for gRPC over TLS, builds the WebSocket route from the path, the host and, with a real_ip, its header (WsRoute::new, host, real_ip_header), and serves gRPC at /<service>/Tun and /<service>/TunMulti (GrpcPaths::new). ServerConfig::from_pem takes the first certificate of the PEM bundle as the leaf and adds the rest as extra chain certificates, starts from OpenSSL’s Mozilla intermediate (v5) profile with TLS 1.2 as the minimum version, checks that the private key matches the certificate (check_private_key), and turns on OpenSSL’s read-ahead. A bundle that holds no certificate fails with no certificate in PEM bundle; every other failure carries OpenSSL’s own error text. The transports themselves are on Transports: TCP and TLS and Transports: WebSocket and gRPC.

src/lower/inbound.rs
fn reality_spec(reality: &contract::Reality) -> io::Result<RealityServerSpec>;

A REALITY node is a Node::Vless whose security is VlessSecurity::Reality(Reality): server_name, server_port (a NonZeroU16), private_key (a RealityPrivateKey, 32 bytes) and short_id (a ShortId, Xray’s hex text, lower-cased). A helium config is one as it comes; its security has the type reality and these four keys. From a UniProxy panel, the newV2board client builds one for a V2ray node with enable_vless whose answer has tls = 2, from the settings in tls_settings: it reads the key with decode_private_key (protocols/src/transports/reality.rs), which takes Xray’s format, unpadded base64url of 32 bytes, and checks that the bytes are a usable X25519 key, and the shortId with decode_short_id; neither error repeats the value (see Panel clients). The contract’s validate() then holds the node of either panel to its rules: the server name is a host name of ASCII letters, digits, -, _ and ., at most 253 bytes, with no wildcard and no trailing dot, and REALITY runs over TCP alone.

stream hands the settings to reality_spec, which takes the key’s 32 bytes as they are and decodes the shortId into its 8 bytes with decode_short_id: an even number of hex digits, at most 16, zero-padded, the empty string being the all-zero shortId. The code comment: “The contract holds a shortId to Xray’s form, which this reads.” A shortId that does not decode fails with REALITY short_id: <error>, InvalidInput, which a shortId the contract took never meets. Neither the key nor the shortId reaches the log: the contract’s Debug prints RealityPrivateKey(..) and ShortId(..), and the decoders’ errors never repeat a value. The result:

RealityServerSpec field Value
private_key The decoded key, in a Secret.
server_names [server_name]: the one SNI answered as REALITY.
short_ids [short_id], decoded.
dest server_name at server_port, over TCP: Remote::IpAddr when the name parses as an IP address, Remote::Domain otherwise.
max_time_diff, min_client_version, max_client_version None: no clock or client-version bound.
require_hybrid false. The code comment: sing-box and mihomo clients send the X25519 share alone.

The one server name is both the SNI a client must send and the cover site every other visitor is passed on to. A REALITY node needs no certificate: stream returns before the certificate checks. The supervisor checks the spec again (the rows under The InboundSpec katana builds), refuses REALITY under any protocol but VLESS, and builds the server. REALITY itself is on REALITY and Transports: REALITY.

lower_stream_protocol(cfg, node) branches on the Node variant, and lowers the transport with what runs under it:

Node InboundProtocolSpec Under the transport
Vmess Vmess { transport, clock_check }; clock_check is !disable_vmess_clock_check Its security.
Vless Vless { transport, flow }; flow is VlessFlow::None, or VlessFlow::Vision for the contract’s VlessFlow::Vision Its VlessSecurity: None, Tls, or Reality.
Trojan Trojan { transport } Tls.
Shadowsocks lower_shadowsocks(&ss.cipher, transport) Its security.
Anytls Anytls { transport, padding_scheme }, the scheme’s lines Tls, over Transport::Tcp.
Socks Socks { udp: false, udp_bind: None, transport } Tls.
Http Http { allow_transparent: false, transport } Tls.
Sss Sss { transport, settings: lower_sss(sss)? }; see sss nodes Its security. The code comment: “REALITY stays VLESS’s: the supervisor refuses sss under it.”
Hysteria2 unreachable!("lower_inbound routes hysteria2 on its own") lower_inbound never calls this function for Hysteria 2.

clock_check: true, the default, admits a VMess client only when its auth id’s timestamp is within ±120 s of the server clock. false admits a client whose clock is off by any amount, at the cost of replay protection: a handshake replayed more than four minutes after it first arrived is served again. VLESS carries no clock, so the setting changes nothing on a VLESS node (vmess_checks_the_clock_unless_the_node_turns_it_off). A change to it swaps the handler and keeps live connections; the node manager logs node <id>: VMess clock check off or on (The node manager).

The VLESS flow. Vision (xtls-rprx-vision, XTLS_RPRX_VISION in protocols/src/vless/addons.rs) is the one flow the contract has, and its validate() allows it over REALITY alone (flow xtls-rprx-vision needs security reality). The code comment: “The supervisor allows Vision over REALITY only, as the contract does.” So the supervisor’s own refusal, vless vision (xtls-rprx-vision) rides only over reality, never meets a katana spec. On a UniProxy panel the newV2board client refuses any other flow by name (…: VLESS flow "xtls-rprx-vision-udp443"), and a flow on a VMess node (…: an XTLS flow off VLESS). How the flow works is on VLESS Vision.

Trojan. A Trojan node is TLS with the node’s own certificate, over the transport the node names.

AnyTLS. A panel’s AnyTLS node is always TLS over TCP with the node’s own certificate: the contract’s Anytls has a port and a padding scheme and nothing else. It lowers the Tls shape and reads the certificate files like any TLS node. padding_scheme is the lines of the contract’s PaddingScheme, or None for the reference default every client starts with. The contract holds the lines to at least one, none empty or holding a line break, at most 2048 bytes once joined with \n; on a UniProxy node an empty or absent list is None. The supervisor parses the lines and refuses a malformed scheme. The protocol is on AnyTLS.

SOCKS and HTTP. The contract’s TlsProxy has no security: a panel’s SOCKS or HTTP node always runs inside TLS, so TLS, WebSocket over TLS and gRPC over TLS are the shapes it lowers. The newV2board client refuses a UniProxy SOCKS or HTTP node without TLS (…: socks without TLS, …: http without TLS) or over REALITY (…: socks over REALITY, …: http over REALITY). Its doc comment gives the reason: in the clear, the account and everything the node relays would cross the network readable, and a plain proxy on a public port is an open proxy’s first step. A SOCKS node sets udp: false; the code comment: its UDP would leave the transport for a socket of its own, in the clear. It relays TCP alone. An HTTP node sets allow_transparent: false.

What a panel asks for under a protocol is settled before lowering. REALITY lives in VLESS’s security alone, so a REALITY transport under VMess, Shadowsocks, SOCKS or HTTP cannot be written; a UniProxy answer that asks for one is refused by name (…: REALITY on a VMess node, newV2board: shadowsocks over REALITY is not supported, …: socks over REALITY). The supervisor’s reality is for vless only never meets a katana spec.

src/lower/inbound.rs
fn lower_sss(sss: &contract::Sss) -> io::Result<SssServerSettings>;

lower_sss turns the node’s chains and datagram limit into the supervisor’s SssServerSettings. sss is Helium’s own protocol, and only the helium client describes an sss node: the UniProxy client refuses node_type = "sss" when it is built. helium’s node config gives the chains (transform, with up and down) and udp_max_datagram, and nothing else. The doc comment: “its chains parsed, its datagram limit, and the rest at their defaults, which no panel describes.”

SssServerSettings field From When absent
up, down SssChain::parse of transform.up and transform.down The identity chain.
max_datagram udp_max_datagram 65535, from SssServerSettings::default.
header_timeout Always the default 10 s.
reject Always SssReject::Drain
flush_delay Always the default Zero.

A chain expression that does not parse is refused with InvalidInput: sss transform.up: <error> or sss transform.down: <error>. The contract has already held each chain to at most 8 expressions, none empty, none starting or ending with whitespace and none with a control character in it; what an expression means is katana’s to parse. udp_max_datagram is a NonZeroU16 in the contract and the other two keep the kernel’s defaults, so the supervisor’s checks on U, t_c and T_h (the rows under The InboundSpec katana builds) never fail on a katana spec. The chains, the wire format and the gate a refused stream meets are on sss and sss transforms.

A Shadowsocks node rides the transport the panel names, as Xray serves it: the bare socket, TLS, or WebSocket or gRPC with or without TLS. lower_shadowsocks takes the lowered transport and puts it in the spec. The code comment: a Shadowsocks node’s UDP never rides a transport (as in Xray), so a node over a transport relays TCP alone. REALITY under Shadowsocks never reaches lowering: the contract’s Shadowsocks has a plain Security, and the UniProxy client refuses tls = 2 on one.

lower_shadowsocks(cipher, transport) maps the contract’s SsCipher and refuses nothing:

  1. SsCipher::Ss2022 { cipher, server_key } is InboundProtocolSpec::Ss2022 { method, psk, transport }, with method Blake3Aes128Gcm for Aes128Gcm and Blake3Aes256Gcm for Aes256Gcm, and psk the key’s bytes in a Secret. The code comment: “The contract holds it to the cipher’s key length”, 16 or 32 bytes.
  2. SsCipher::Legacy(cipher) is InboundProtocolSpec::Shadowsocks { method, password, transport }, with Aes128Gcm, Aes256Gcm, Chacha20Poly1305 and XChacha20Poly1305 as the kernel’s methods of the same names and an empty server password. The code comment: the users’ passwords are the whole set, and the server password admits nobody; each user is admitted by their own password, their UUID (see Per-user credentials).

helium’s node config holds both. A 2022 cipher (2022-blake3-aes-128-gcm or 2022-blake3-aes-256-gcm) comes with a server_key of that cipher’s length in padded standard base64, and a legacy one (aes-128-gcm, aes-256-gcm, chacha20-ietf-poly1305 or xchacha20-ietf-poly1305) with none; a 2022 cipher without its key, or a legacy one with a key, is refused when the config is read.

A UniProxy answer names its cipher in a string, which the newV2board client reads with the kernel’s names. ss_2022::Method::from_name matches 2022-blake3-aes-128-gcm and 2022-blake3-aes-256-gcm exactly; ss_legacy::Method::from_name matches, case-insensitively, aes-128-gcm, aes-256-gcm, chacha20-poly1305 and xchacha20-poly1305, with the aliases aead_aes_128_gcm, aead_aes_256_gcm, chacha20-ietf-poly1305, aead_chacha20_poly1305 and xchacha20-ietf-poly1305. Any other name, 2022-blake3-chacha20-poly1305 included, is refused by name: node requests kernel-unsupported feature: shadowsocks cipher "rc4-md5". A 2022 node’s server_key goes through two kernel helpers from protocols/src/ss_2022/users.rs: decode_psk trims whitespace and decodes standard base64, and its error is replaced by shadowsocks server_key is not base64 (the code comment: “The decoder’s own error would quote a byte of the key.”); normalise_psk sizes the key to the cipher’s length (16 bytes for 2022-blake3-aes-128-gcm, 32 for 2022-blake3-aes-256-gcm): a key of that length is kept, a longer one is folded to the first key_len bytes of its SHA-256 (fold_key), and a shorter one fails with shadowsocks-2022: PSK too short (<n> < <key_len>). The node key is the identity PSK; each user’s key comes from credentials below.

The supervisor builds the user table (build/inbound.rs → user_table). The wire formats are on Shadowsocks AEAD and Shadowsocks 2022.

lower_hysteria(node, &cfg.hysteria, &cfg.controller.cert) builds the whole listener spec from the node, a contract::Hysteria2, and what only this host decides: [node.hysteria]’s credential kind and congestion control, and the certificate. A Hysteria 2 node skips stream and lower_stream_protocol entirely: no REALITY, PROXY protocol, transport or VLESS flow applies. Its checks run in this order:

  1. cert.mode != "file" fails with hysteria2 node requires cert.mode = "file". A Hysteria listener is a TLS server by construction, since the handshake is inside QUIC, so there is no unencrypted mode to fall back to. A Hysteria 2 node has no ACME check of its own, so cert.mode = "dns" on one is reported with this text.
  2. cert.reject_unknown_sni = true is refused as node requests kernel-unsupported feature: cert.reject_unknown_sni, as for stream nodes.
  3. Obfuscation: the node’s obfs, Obfs::Salamander { password }, becomes ObfsSpec::Salamander { psk }, the password’s UTF-8 bytes in a Secret; none is obfs: None.
  4. Masquerade: the node’s masquerade, through masquerade_spec.
  5. UDP: the node’s udp, UdpRelay { idle_timeout_secs }, becomes udp_idle_timeout: Some(<n> s); none relays no UDP.
  6. Credential kind, from [node.hysteria] credential.
  7. Rates and congestion control: the node’s rates, and the congestion control through congestion(cfg).
  8. Certificate, last: read_cert_key(cert).

The port is the node’s NonZeroU16, so a Hysteria 2 node always has one. The certificate comes last on purpose. The doc comment: every check is a judgement about the config alone and runs before the certificate is read, because “reporting a missing file instead of the typo that is actually wrong helps nobody”. The unit tests rely on this order: hy2_cert() names certificate files that do not exist, and every hysteria_refuses_* test still expects its own config error.

Where the node comes from. The module doc of src/api/hysteria.rs: “UniProxy says a node’s obfuscation and rates, and nothing of its UDP relay or its masquerade, so those come from [node.hysteria], which also overrides the rates. A helium node’s panel says all of it, and its client refuses the block, so nothing here touches one.”

Node Built by Obfuscation Rates UDP relay and masquerade
helium the panel’s config, as it comes the panel’s the panel’s the panel’s
newV2board, [node.hysteria] port unset hysteria::uniproxy, as the newV2board client reads the answer the panel’s obfs and obfs-password [node.hysteria]’s where set, else the panel’s [node.hysteria]’s
newV2board, [node.hysteria] port set hysteria::local, in NodeManager::node_info, without asking the panel [node.hysteria] obfs and obfs_password [node.hysteria]’s where set, else none [node.hysteria]’s

uniproxy and local both end in complete, which builds the node and runs the contract’s validate() on it, so a node from [node.hysteria] is held to the rules a helium config is. A refusal there is part of reading the node, not of lowering it. In uniproxy it is a UniProxy refusal, logged with parse UniProxy config response: before it (see Refused before lowering); in local it is node_info failed: <text> at bootstrap. test_spec runs local for every newV2board Hysteria 2 node, so --test and the reload check refuse the block’s own mistakes before any panel is asked.

Obfuscation. hysteria::obfs(obfs_type, password) reads the panel’s two strings or the block’s two keys, each treated as absent when empty:

obfs obfs_password Result
empty empty no obfuscation
empty set obfs_password is set but obfs is not; did you mean obfs = "salamander"?
salamander empty or fewer than 4 bytes obfs_password must be at least 4 bytes for salamander
salamander 4 bytes or more Obfs::Salamander { password }
anything else any unknown obfs "<obfs>" (expected "salamander")

The match is case-sensitive: obfs = "Salamander" is refused as unknown obfs "Salamander" (expected "salamander"). The code comment on the password-only row: a typo in obfs would otherwise silently disable the obfuscation the operator asked for. The panel’s two strings are held to the same rules (a_hysteria_node_is_completed_with_the_local_block). helium’s obfs is {"type": "salamander", "password": …}, and the contract refuses a password shorter than 4 bytes when the config is read (obfs.password must be at least 4 bytes). The supervisor’s validation checks the Salamander key length again (salamander obfs key must be at least 4 bytes); katana’s own check comes first and prints its own text.

A changed obfuscation key on a running listener is a Disrupt step in the supervisor’s plan (supervisor/src/topology/spec_plan/plan.rs → swap_disruption), with the reason the hysteria2 obfuscation changed; connected clients cannot follow the new key. An apply that does not allow disruption is refused with ApplyError::Disruptive, printed inbound <tag>: <reason>; this ends its live connections and needs allow_disruptive. katana’s reconcile applies every spec with ApplyOptions { allow_disruptive: true }, so the supervisor does not refuse the change: katana allows this Disrupt step. See Planning and applying a change and The node manager.

Masquerade. From [node.hysteria.masquerade] (hysteria::masquerade): with status, body and content_type all unset, the node has no masquerade, and the supervisor answers with Masquerade::default(), which is Go’s http.NotFound byte for byte. With any of them set, the unset fields are filled in:

Field Default
status 404
body "404 page not found\n"
content_type "text/plain; charset=utf-8"

helium’s masquerade carries status, body and content_type together; left out, the node answers as an unconfigured server does, with the same 404. Either way the contract’s validate() holds the status to 100 to 999 (masquerade.status is <n>, but must be 100 to 999) and never 233 (masquerade.status must not be 233, the Hysteria 2 authentication success status), because answering an unauthenticated request with 233 would tell it that it had authenticated. A local status of 233 is refused with that text. lower_hysteria then builds the MasqueradeSpec with masquerade_spec(status, body, content_type), which calls Masquerade::new(status, body, content_type) and discards the result; the call is there for its refusals. The doc comment: “refused as the supervisor would refuse it: judged here too so the refusal reads as it always has”. Masquerade::new (protocols/src/hysteria/server/masquerade.rs) refuses status 233 with hysteria2: 233 is the authentication success status and cannot be used for the masquerade, and a status outside 100 to 999 with hysteria2: <status> is not an HTTP status code; a node that passed the contract’s rules never meets either (a_panels_masquerade_the_kernel_cannot_answer_with_is_refused builds one that did not).

UDP. From [node.hysteria] (hysteria::udp):

udp udp_idle_timeout Hysteria2InboundSpec::udp_idle_timeout
true unset Some(60 s)
true 2 to 600 Some(<n> s)
true outside 2..=600 refused: udp_idle_timeout must be between 2 and 600 seconds
false (default) set refused: udp_idle_timeout is set but udp is not enabled
false unset None: no UDP relay

helium’s udp is {"idle_timeout_secs": <n>}, 60 when the key is left out, and the contract refuses a timeout outside 2 to 600 when the config is read (udp.idle_timeout_secs is <n>, but must be 2 to 600); udp left out relays no UDP.

The range is upstream Hysteria’s, for its reasons as the code comment gives them: below 2 seconds a busy association would be swept between packets, above 600 seconds a dead one holds its socket for ten minutes. The contract cannot express a timeout for a relay that is off, so the udp is not enabled refusal is katana’s alone, and only the local block can reach it; the supervisor checks the range again.

Credential kind.

credential user_auth What a client sends in Hysteria-Auth
"" (default) or "uuid" Hysteria2UserAuth::Password The user’s UUID.
"user_pass" Hysteria2UserAuth::Account <name>:<uuid>, upstream’s user:pass form, split on the first colon.
anything else refused unknown hysteria credential kind "<kind>" (expected "uuid" or "user_pass")

A helium node cannot set credential, so it always has the default, Password, and its clients send the UUID, written lowercase and hyphenated as the helium client writes every UUID. uuid is the default because, in the code comment’s words, panel node agents key their user map by the UUID itself, and the panel’s user list carries no password field to put in front of a colon. The comment on user_pass calls it “upstream’s convention, for a client configured against a reference server”, and adds that “the username is the user’s traffic label”: the name traffic_email gives the user, as described under Per-user credentials. The supervisor’s own default for the enum is Account; katana never relies on it. An unknown kind is refused rather than defaulted, because the kind decides whether any client can authenticate at all.

Rates and congestion control. Each rate is the node’s. On newV2board, complete takes each from [node.hysteria] when it is set there, else from the panel (a node [node.hysteria] describes alone has panel rates of 0); ignore_client_bandwidth is [node.hysteria]’s, else the panel’s, else true. A helium node cannot set them locally, and helium’s node config always has up_mbps and down_mbps (both required) and ignore_client_bandwidth (true when left out), so on helium every rate is the panel’s:

Hysteria2InboundSpec field Value
bandwidth.up Bandwidth::from_mbps(node.up_mbps): the most the node sends one client at; 0 is None, no cap
bandwidth.down Bandwidth::from_mbps(node.down_mbps): the rate answered to every client; 0 is None
bandwidth.disable_loss_compensation false
ignore_client_bandwidth The node’s
congestion congestion(cfg): "cubic" or unset: Fallback::Cubic; "bbr": Fallback::Bbr; "reno": Fallback::NewReno; anything else refused with unknown hysteria congestion "<value>" (expected "cubic", "bbr" or "reno")

The doc comment of complete on the default: “Neither saying whether to ignore a client’s figures leaves the node answering auto, as before it read rates at all”, so neither end sends at a fixed rate. With false, a client that declares its download rate is sent to at that rate, capped by up. How the server turns these into the answer it gives and the rate it sends at is on Hysteria 2: server; the congestion controllers are on Congestion control. a_panel_that_sets_rates_has_the_node_send_at_the_agreed_one, a_panel_silent_on_ignoring_client_bandwidth_keeps_the_node_on_auto and the_local_hysteria_block_overrides_the_panels_rates in tests/unit/e2e.rs pin the three cases end to end.

congestion is pub because test_spec calls it too, on every node, before any panel is asked. Its doc comment calls the key “the one key of the block that is this host’s on every panel”.

A changed rate or UDP idle timeout swaps the listener’s handler, so it reaches the connections that arrive after it; the live ones keep theirs. Any other change to the node, its masquerade, whether it relays UDP, its obfuscation and its port among them, is a change to disruptive_part (src/manager/node.rs), so the node manager closes every connection on the node after the apply. A connection held open would otherwise go on answering the old way, or relaying, or being refused, under the old setting. An edit to [node.hysteria] drops every connection too, as an edit to a local setting the listener is built from, and gives the node a new panel client, because the newV2board client keeps a copy of the block to complete its Hysteria 2 node with (The node manager).

The result.

Hysteria2InboundSpec field Value
tls read_cert_key(cert)?
shared_password None: the inbound admits the users set, never one shared password.
masquerade As above.
obfs As above.
udp_idle_timeout As above.
max_connections DEFAULT_MAX_CONNECTIONS, 262,144 concurrent QUIC connections.
max_circuits DEFAULT_MAX_CIRCUITS, 4,194,304 live proxied streams across the listener.
user_auth As above.
bandwidth, ignore_client_bandwidth, congestion As above.
quic QuicOptions::server(): upstream’s receive windows (8 MiB per stream, 20 MiB per connection) and 30 s idle timeout, no keep-alive, and up to 65,536 concurrent streams per client.

katana has no setting for the two limits or for the QUIC settings. What the listener does with them is on Hysteria 2: server and Listeners and the serve loop.

src/lower/inbound.rs
fn read_cert_key(cert: &CertConfig) -> io::Result<ServerTlsSpec> {
if cert.cert_file.is_empty() || cert.key_file.is_empty() {
return Err(invalid("TLS node requires cert.cert_file and cert.key_file"));
}
Ok(ServerTlsSpec {
cert_pem: std::fs::read(&cert.cert_file)?,
key_pem: Secret::new(std::fs::read(&cert.key_file)?),
})
}
  • Bytes, not parsed. Lowering carries the PEM as bytes and never parses it. hysteria_accepts_both_credential_kinds writes cert.pem and key.pem holding the bytes cert and key, and the lowering succeeds. The supervisor parses them when it builds the handler: OpenSSL for a stream node (ServerConfig::from_pem, described under Stream transports), rustls for Hysteria 2. A bad file is an ApplyError::Build, printed building inbound <tag> failed: <error>. For a Hysteria 2 node --test shows it:

    configuration error: node 1: building inbound Hysteria2_0.0.0.0_8443 failed: hysteria2: the certificate file contains no certificates
    configuration error: node 1: building inbound Hysteria2_0.0.0.0_8443 failed: hysteria2: the key file contains no private key

    The Hysteria 2 texts come from protocols/src/hysteria/server/endpoint.rs → tls_config and server_config, which build a TLS 1.3 rustls configuration with ALPN h3 and turn it into a QUIC one:

    Text When
    hysteria2: could not read the certificate: <error> The certificate PEM does not parse.
    hysteria2: the certificate file contains no certificates It parses and holds no certificate.
    hysteria2: could not read the private key: <error> The key PEM does not parse.
    hysteria2: the key file contains no private key It parses and holds no private key.
    hysteria2 tls setup failed: <error> rustls refuses the protocol version setup.
    hysteria2: certificate and key do not match: <error> rustls refuses the certificate and key as a pair.
    hysteria2 quic tls setup failed: <error> The rustls configuration cannot serve QUIC.
  • Read on every lowering. read_cert_key reads both files each time a Hysteria 2 node, or a stream node whose shape layers TLS, is lowered: at each bootstrap attempt, at each reconcile and, for a Hysteria 2 node of newV2board, at each check (a helium node’s check lowers no inbound). A file that cannot be read refuses the node. A certificate renewed in place therefore changes the lowered spec at the next reconcile. The bind is unchanged, so the supervisor’s plan builds a new handler on the running listener (Step::SwapHandler, see Planning and applying a change). The node manager’s rule for closing every connection compares the node (disruptive_part) and local settings, not file contents, so a renewed certificate is applied as an ordinary change.

  • Secrecy. The private key goes straight into a Secret, so the spec’s Debug prints Secret(..) in its place.

credentials(protocol, u) gives one panel user the credential the node’s protocol admits. lower_users (src/lower/mod.rs) calls it for each user with the lowered inbound’s protocol, and logs an error as skipping user <uid>: <why> at WARN before leaving that user out. It also skips, with skipping user <uid>: listed twice and skipping user <uid>: shares its credential with user <first>, a uid it has already taken and a user whose credential an earlier user presents; see Lowering a node into a spec. The checks in credentials, in order:

Protocol Credential set From Refusal (why)
any none an empty uuid uuid is empty
Vless, Vmess, Sss uuid: Some(Uuid) Uuid::parse_str(&u.uuid) uuid is not a valid UUID
Trojan, Anytls, Shadowsocks password: Some(Secret) the UUID string, the XrayR convention
Socks, Http account: Some(Account { user, pass }) the UUID string as both user and pass
Ss2022 { method, .. } ss2022_psk: Some(Secret) the first method.key_len() bytes of the UUID’s text shadowsocks-2022 key too short (< <key_len>)
Hysteria2 with Password password: Some(Secret) the UUID string
Hysteria2 with Account account: Some(Account { user, pass }) user = traffic_email(u), pass = the UUID string its name holds ':'
Tun none the inbound admits no panel users
  • Shadowsocks 2022 user keys are the leading bytes of the UUID’s text, cut rather than folded: the ASCII characters themselves, not the 16 bytes the UUID parses to. A 36-character UUID always has 16 or 32 bytes to give. This is the panel convention, in which a client’s password is the server key, a colon, and the base64 of the first key_len characters of its UUID. ss2022_builds asserts that the key is &uuid.as_bytes()[..16] for 2022-blake3-aes-128-gcm.
  • Hysteria 2 account names are traffic_email(u) (src/api/mod.rs): the panel’s email, or the uid in decimal when the email is empty. The wire form is user:pass split on the first colon, so a name holding : could never be presented. The supervisor’s validation refuses the whole spec over the same case (below); katana skips the one user, so the rest of the node still comes up.
  • SOCKS and HTTP accounts use the UUID for both name and password: the code comment says the panel’s users carry nothing but their UUID, and the UUID is unique, so no two accounts collide.
  • The last row is never reached. A panel node is never TUN.
  • On helium every user’s uuid is the text helium::user_infos writes from the answer’s UUID, in its lowercase hyphenated form, so each credential above is that text (or, for VLESS, VMess and sss, the UUID it parses back to). The first two refusals cannot arise there: a users answer with an empty or malformed UUID does not parse at all (parse helium users response). The row for a Hysteria 2 Account does not apply either: a helium node cannot set [node.hysteria] credential.
  • No credential in any error. The texts are fixed strings plus a key length; none contains the UUID. The code comment: the reason a user cannot be admitted names no credential, because the value is a secret.

The supervisor re-checks the user set on apply (supervisor/src/build/validate.rs → validate_admission). Its texts are prefixed inbound <tag>: and name a user by Uid::name, the uid in decimal, for example inbound Hysteria2_0.0.0.0_8443: user 7: a hysteria2 account needs a name without ':' and a password or user 7: a hysteria2 password must not be empty. Two users presenting one credential are reported as users <a> and <b> present the same credential (username for the accounts of SOCKS, HTTP and Hysteria 2 nodes, compared case-insensitively on Hysteria 2). The rules are on Validation and apply errors and Users, principals and sessions.

Every refusal in src/lower/inbound.rs with its own text, in the order each function checks it. A certificate or key file that cannot be read also refuses the node. Unsupported texts carry the prefix node requests kernel-unsupported feature: , shown here as …: . Each is reported as a lowering error: katana --test prints it as configuration error: node <node_id>: <error>, and a node logs it in initial start failed: … at bootstrap and cannot build the node, keeping the running one: … on a later cycle (The node manager).

Function Condition Kind Text
stream cert.reject_unknown_sni Unsupported …: cert.reject_unknown_sni
stream cert.mode is dns, http or tls Unsupported …: ACME cert mode "dns"
stream TLS and cert.mode != "file" InvalidInput TLS node requires cert.mode = "file"
read_cert_key empty cert_file or key_file InvalidInput TLS node requires cert.cert_file and cert.key_file
reality_spec a shortId decode_short_id refuses, which a shortId the contract took never is InvalidInput REALITY short_id: <error>
lower_sss a chain expression that does not parse InvalidInput sss transform.up: <error>, sss transform.down: <error>
real_ip real_ip_from without real_ip_header InvalidInput real_ip_from is set without real_ip_header
real_ip real_ip_header without real_ip_from InvalidInput real_ip_header needs real_ip_from: the proxies trusted to set it
real_ip a header that is not a header name InvalidInput real_ip_header "X Real IP" is not a header name
real_ip an entry that is not a CIDR InvalidInput real_ip_from "127.0.0.1/33": <error>
handoff handoff_group without handoff_dir InvalidInput handoff_group is set without handoff_dir
handoff a relative or empty handoff_dir InvalidInput handoff_dir "run/katana" must be an absolute path
handoff a handoff_dir too long for the node’s socket name at port 65535 InvalidInput handoff_dir "<dir>" is too long: with "65535.sock" in it, a socket's path would pass the 107 bytes a Unix socket's path may have
group_id /etc/group cannot be read InvalidInput handoff_group "<name>": reading /etc/group: <error>
group_id no line of /etc/group names the group InvalidInput handoff_group "no-such-group-here" is not a group in /etc/group
lower_hysteria cert.mode != "file" InvalidInput hysteria2 node requires cert.mode = "file"
lower_hysteria cert.reject_unknown_sni Unsupported …: cert.reject_unknown_sni
masquerade_spec a masquerade status the kernel refuses, which a node that passed the contract’s rules never has InvalidInput hysteria2: 233 is the authentication success status and cannot be used for the masquerade, hysteria2: <status> is not an HTTP status code
lower_hysteria unknown credential InvalidInput unknown hysteria credential kind "totp" (expected "uuid" or "user_pass")
congestion, from lower_hysteria and test_spec unknown congestion InvalidInput unknown hysteria congestion "vegas" (expected "cubic", "bbr" or "reno")
lower_hysteria empty cert_file or key_file InvalidInput TLS node requires cert.cert_file and cert.key_file (from read_cert_key)

What a panel asks for that katana cannot serve is refused as the node is read, so lowering never sees it. A helium answer is held to the contract when it is deserialized, and one that breaks a rule fails as parse helium config response: <reason>. A UniProxy answer is refused by the newV2board client’s parse_node_config (src/api/newv2board.rs) and its helpers, which then run the contract’s validate() on the node they built; the client’s error is parse UniProxy config response: <reason>. The code comment gives the reason for writing the reason into the message itself: “a node logs a panel error’s outermost message alone.” A node logs a UniProxy refusal as a node_info error, at bootstrap at ERROR and on a poll at WARN:

node 1: node_info failed: parse UniProxy config response: node requests kernel-unsupported feature: tcp header type "http"; retrying in 1s
node 1: node_info: parse UniProxy config response: node requests kernel-unsupported feature: httpupgrade transport

katana --test does not ask the panel, so it shows none of these; it does show the refusals of [node.hysteria] that hysteria::local makes, and the sss row, which comes from building the client. Here …: is again node requests kernel-unsupported feature: .

Where Condition Text
parse_node_config a body that is not JSON serde’s own text, with its line and column
parse_node_config a value of the wrong type; serde’s own text could quote it, a key or a password among them a value of the wrong type at line <l>, column <c>
parse_node_config server_port outside 1 to 65535 server_port <n> is not a port (1 to 65535), never truncated into another port
check_protocol the panel’s protocol tag names another node type, or one katana does not serve the panel's node is protocol "<tag>", but this node is configured as <type>, the panel's node is protocol "<tag>", which katana does not serve
transport network of httpupgrade …: httpupgrade transport
transport splithttp or xhttp …: splithttp transport
transport any other network but TCP, WebSocket and gRPC, lower-cased …: transport "quic"
plain_tcp_header on TCP, REALITY’s included, a header whose type is a string other than none (any case) …: tcp header type "http"; an empty type reads tcp header type ""
plain_tcp_header a header that is neither an object nor null tcp header is not an object
plain_tcp_header a header whose type is neither a string nor null tcp header type is not a string
v2ray a flow on a VMess node …: an XTLS flow off VLESS
v2ray a flow other than empty or xtls-rprx-vision …: VLESS flow "xtls-rprx-vision-udp443"
v2ray tls = 2 on a VMess node …: REALITY on a VMess node
reality tls = 2 and no tls_settings, or settings of another shape a REALITY node (tls = 2) carries no tls_settings, the REALITY tls_settings: <why>
reality an empty server_name, a server_port of 0 REALITY needs a server_name, REALITY needs the cover site's port
reality a key or shortId the kernel’s decoders refuse REALITY private_key: <error>, REALITY short_id: <error>, neither repeating the value
shadowsocks obfs other than empty, plain or none newV2board: shadowsocks obfs "http" is not supported
shadowsocks tls = 2 newV2board: shadowsocks over REALITY is not supported
shadowsocks a cipher neither kernel table names, or 2022-blake3-chacha20-poly1305 …: shadowsocks cipher "rc4-md5"
shadowsocks a 2022 server_key that is not standard base64, or shorter than the cipher’s key shadowsocks server_key is not base64, shadowsocks-2022: PSK too short (<n> < <key_len>)
proxy a SOCKS or HTTP node without TLS …: socks without TLS, …: http without TLS
proxy a SOCKS or HTTP node with tls = 2 …: socks over REALITY, …: http over REALITY
PaddingScheme::new an AnyTLS padding line that is empty or holds a line break, or lines longer than 2048 bytes joined padding_scheme[<i>] is empty, padding_scheme[<i>] has a line break; give each line on its own, padding_scheme is <n> bytes joined with \n, more than 2048
hysteria::obfs Hysteria 2 obfuscation, the panel’s or the block’s see the obfuscation table under Hysteria 2 nodes
hysteria::udp [node.hysteria] udp and udp_idle_timeout see the UDP table
Client::new node_type = "sss" newV2board: no UniProxy panel describes an sss node; sss is Helium's own protocol, served with panel_type = "Helium"
The contract’s validate(), on both panels’ nodes REALITY over a transport other than TCP security reality runs over transport tcp only
validate() Vision without REALITY flow xtls-rprx-vision needs security reality
validate() a REALITY server name that is not a plain host name security.server_name must be a host name of ASCII letters, digits, -, _ and ., at most 253 bytes, with no wildcard and not ending in a dot
validate() a WebSocket path that does not start with /, or has whitespace, a control character or # in it, or a query but ?ed=N transport.path must start with /, transport.path must not have whitespace, a control character or # in it, transport.path must have no query but ?ed=N; a node matches the path of an upgrade without one
validate() a WebSocket host that is empty, or has whitespace, a control character or a port transport.host must not be empty; leave it out instead, transport.host must not have whitespace or a control character in it, transport.host must not have a port; a node matches it against the Host of an upgrade without one
validate() an empty gRPC service name transport.service_name must not be empty
validate() an sss chain of more than 8 expressions, or an expression that is empty, has whitespace around it or holds a control character transform.up has <n> expressions, more than 8, transform.up[<i>] must be a non-empty expression without control characters or whitespace around it (or down)
validate() a Salamander password shorter than 4 bytes, or a UDP idle timeout outside 2 to 600 seconds; on a newV2board node hysteria::obfs and hysteria::udp refuse these first obfs.password must be at least 4 bytes, udp.idle_timeout_secs is <n>, but must be 2 to 600
validate() a masquerade status outside 100 to 999, or 233 masquerade.status is <n>, but must be 100 to 999, masquerade.status must not be 233, the Hysteria 2 authentication success status

What each panel’s answer may hold is on Panel clients.

lower_outbounds(globals) returns the outbounds every node’s route table may name:

  1. Seed the four built-in outbounds, in this order: direct (Freedom { address_family: Auto }), block (Blackhole), freedom (Freedom { address_family: Auto }) and blackhole (Blackhole). freedom and blackhole are Xray’s names for the first two.
  2. For each [[outbound]] in file order, refuse a tag that starts with AUDIT_TAG_PREFIX ("audit#") or equals any tag already in the list, built-in or earlier entry, with duplicate/reserved outbound tag <tag>.
  3. Push OutboundSpec { tag, protocol: lower_outbound(entry)?, drain: None }.

The first error aborts the whole list. shared_spec then appends one audit#<id> blackhole per audit rule id, so the final order in a node’s spec is the built-ins, the [[outbound]] entries, then the audit outbounds. Because no entry may start with audit#, an audit outbound can never collide with a configured one (an_audit_tag_is_reserved in tests/unit/lower/spec.rs). Tag comparison is exact: Direct is a new tag, not a duplicate.

An empty tag is not refused here; the supervisor’s validation refuses it (see Validation and apply errors).

drain: None leaves each outbound on the supervisor-wide Policies::drain, whose default is DrainPolicy::Keep; what that means for a changed or removed outbound is on Outbounds, UDP fan-out and balancers and The plane: routing each flow. What the node manager itself does to open connections when [[outbound]] or [dns] changes is on The node manager.

One copy per node. Every node lowers the same Globals into its own spec, and every node runs its own supervisor, so every node builds its own proxy clients, its own WireGuard tunnels and its own resolver with its own cache. For WireGuard that matters: a peer keeps one session per key, so two nodes routing to one WireGuard outbound run two tunnels on one key and keep taking the session from each other. runtime::warn_shared_wireguard logs a WARN line, target katana::runtime, naming each WireGuard outbound it finds routed to by more than one node and the nodes that route to it. It runs at start, under --test and on each reload that passes its checks:

wireguard outbound wg is routed to by 2 nodes (newv2board@https://panel.example.com#1/v2ray, newv2board@https://panel.example.com#2/v2ray): each brings up its own tunnel with the same key, and the peer keeps only one of them at a time

A node counts when its [node.route] default or any rule names the tag. Each node is shown by its display identity, never by its panel key. See Runtime and config reload.

flowchart TB
  A["lower_outbound(cfg)"] --> P["protocol = cfg.protocol, ASCII-lowercased"]
  P --> F["parse_address_family"]
  F --> D{"direct or freedom?"}
  D -->|"yes"| FR["Freedom with address_family"]
  D -->|"no"| S["parse_server(server, port)"]
  S --> M{"protocol"}
  M --> PX["socks, socks5, http, vmess, vless"]
  M --> SS["shadowsocks, ss: lower_shadowsocks"]
  M --> WG["wireguard, wg: lower_wireguard"]
  M --> X["anything else: unknown outbound protocol"]

lower_outbound(cfg) runs these steps in order:

  1. Protocol name. cfg.protocol is ASCII-lowercased, so SOCKS5, VMess and socks5 are all accepted.
  2. Address family. parse_address_family parses address_family for every protocol, direct included. Unset means AddressFamilyStrategy::Auto; a bad value fails with outbound <tag> invalid address_family "<value>".
  3. Direct. direct and freedom return OutboundProtocolSpec::Freedom { address_family } at once. They carry no upstream, so they are the only protocols that need no server and port.
  4. Server. parse_server(&cfg.server, cfg.port) fails with outbound needs a non-empty server and non-zero port (got "<server>":<port>). A server in brackets must be an IPv6 literal, as in a URL or a wg-quick Endpoint, and becomes that address; brackets around anything else, or a stray ], fail with outbound server "<server>": brackets hold only an IPv6 literal rather than being looked up at dial time as a name that can never resolve. Otherwise a server that parses as an IP address becomes Remote::IpAddr, and any other value is a domain name, Remote::Domain. The Destination’s network is DialNetwork::Tcp.
  5. Upstream. Every proxy reaches its upstream over plain TCP: ProxyUpstream { server, transport: OutboundTransportSpec { shape: StreamShape::Tcp, tls: None, reality: None, address_family } }. The module doc: TLS, WebSocket and gRPC toward an upstream are out of scope.
  6. Protocol. One arm per protocol. Any other name fails with unknown outbound protocol "<protocol>", printed lower-cased. The step order means an entry with an unknown protocol and no server is reported for the server.
protocol OutboundProtocolSpec Required besides server and port
direct, freedom Freedom { address_family } nothing, not even server and port
socks, socks5 Socks { upstream, account } nothing
http Http { upstream, account } nothing
vmess Vmess { upstream, id, security } uuid
vless Vless { upstream, id, flow: VlessFlow::None } uuid
shadowsocks, ss Ss2022 { upstream, method, identity_psks, psk } or Shadowsocks { upstream, method, password } password, and a known method
wireguard, wg Wireguard(WireguardSpec) private_key, public_key, one local_address

The supervisor also has Trojan, Hysteria2, Anytls and Sss outbounds. katana’s [[outbound]] does not lower to them, so protocol = "trojan" is refused as unknown outbound protocol "trojan". A VLESS outbound carries no flow.

What the supervisor builds from each variant, and how it dials, is on Outbounds, UDP fan-out and balancers.

parse_family(cfg, raw, field) serves both address_family and WireGuard’s endpoint_address_family. Unset is AddressFamilyStrategy::Auto. A set value goes through AddressFamilyStrategy::from_str (protocols/src/helpers/address_family.rs), which trims it, lower-cases it and replaces - with _:

Accepted Strategy
"", auto Auto
ipv4, v4, 4, ipv4_only, ipv4only Ipv4Only
ipv6, v6, 6, ipv6_only, ipv6only Ipv6Only
prefer_ipv4, prefer_v4, ipv4_prefer, v4_prefer PreferIpv4
prefer_ipv6, prefer_v6, ipv6_prefer, v6_prefer PreferIpv6

Anything else fails with outbound <tag> invalid <field> "<value>", the value as written.

address_family means something different per protocol, but it is lowered for all of them:

Protocol Where address_family goes What it selects
direct, freedom Freedom { address_family } Which of the destination’s addresses are dialed.
socks, http, vmess, vless, shadowsocks upstream.transport.address_family Which of the upstream server’s addresses are dialed.
wireguard WireguardSpec::address_family Which family is used inside the tunnel.
wireguard endpoint_address_family (its own key) Which of a domain server’s addresses the peer is dialed on.

When both username and password are set, account(cfg) returns Some(Account { user: username, pass: Secret::new(password) }), and the client authenticates to the upstream with them. SOCKS UDP ASSOCIATE and the HTTP CONNECT client are the supervisor’s; see Outbounds, UDP fan-out and balancers, SOCKS and HTTP proxy.

require_uuid fails with outbound <tag> needs a uuid when uuid is unset, and with outbound <tag>: uuid is not a valid UUID when it does not parse. The doc comment gives the reason for naming only the tag: the value is a credential for the upstream, and the error ends up in a log. a_malformed_uuid_is_refused_without_echoing_it passes not-a-uuid-but-a-secret and asserts that the error does not contain it.

parse_security maps VMess security, ASCII-lowercased, after the UUID has been checked:

security Security
unset, auto, aes-128-gcm, aes128gcm Aes128Gcm
chacha20-poly1305, chacha20poly1305 ChaCha20Poly1305
anything else refused: unsupported vmess security "<value>", lower-cased

global_padding (a bool, default false) is accepted and has no effect; the code comment: “the kernel’s VMess client always pads”. The supervisor builds every VMess stream and datagram codec with global padding on (supervisor/src/build/outbound.rs passes true), so the setting cannot turn it off.

lower_shadowsocks(cfg, upstream):

  1. password is required first: shadowsocks outbound <tag> needs a password, even when the method is also wrong.
  2. method is looked up as for the inbound. An unset method is the empty string.
  3. Shadowsocks 2022 (exact match). password is split on :. Each part goes through decode_psk and normalise_psk into a Secret. The last key is the user’s PSK (psk), and the keys before it, in the order written, form identity_psks, the iPSK:…:uPSK chain. An empty part fails normalise_psk, so an empty password prints shadowsocks-2022: PSK too short (0 < 16) for a 16-byte method. The has an empty password branch cannot be reached, because splitting always yields at least one part.
  4. Legacy AEAD (case-insensitive, with the aliases). Shadowsocks { upstream, method, password }. The supervisor derives the master key.
  5. Anything else fails with Unsupported: unsupported shadowsocks cipher "<method>", which reads unsupported shadowsocks cipher "" for an unset method.

Both key helpers print their own texts: decode PSK: <error> and shadowsocks-2022: PSK too short (<n> < <key_len>). The supervisor re-checks the outbound keys on apply; see Validation and apply errors.

lower_wireguard(cfg, server, address_family) builds a WireguardSpec in this order:

  1. Endpoint. The parsed server with its network switched to DialNetwork::Udp.
  2. Keys. private_key, then public_key, through parse_wg_key. A missing key fails with wireguard outbound <tag> needs a <field>. The value goes to protocols/src/wireguard/config.rs → parse_key, which trims it and accepts standard base64 or hex of exactly 32 bytes; anything else fails with wireguard outbound <tag> <field>: invalid WireGuard key: expected base64 or hex encoding of 32 bytes.
  3. Local addresses. Each local_address is cut at the first /, trimmed and parsed as an IpAddr. The prefix length is dropped. A bad address fails with wireguard outbound <tag> invalid local_address "<value>": <error>, for example invalid IP address syntax. An empty list fails with wireguard outbound <tag> needs at least one local_address.
  4. Pre-shared key. Optional, parsed as the other keys, under the field name pre_shared_key.
  5. Reserved. Optional. reserved is a TOML array of integers, deserialised into Vec<u8> (src/config.rs → OutboundConfig), so a value above 255 is a TOML parse error. <[u8; 3]>::try_from then needs exactly 3 bytes: wireguard outbound <tag> reserved must be exactly 3 bytes.
  6. Endpoint address family. endpoint_address_family, through parse_family: outbound <tag> invalid endpoint_address_family "<value>".
WireguardSpec field From Default
private_key private_key, in a Secret required
peer_public_key public_key required
preshared_key pre_shared_key, in a Secret None
endpoint server, port over UDP required
endpoint_address_family endpoint_address_family Auto
addresses local_address, prefixes dropped at least one required
address_family address_family Auto
mtu mtu DEFAULT_MTU, 1420
keepalive keepalive, a u16 of seconds, passed through unchanged None
reserved reserved None

endpoint_address_family was added in katana 4.1.0. It chooses which of a domain server’s addresses the peer is dialed on, and it is separate from address_family, which only covers destinations inside the tunnel. a_wireguard_endpoint_address_family_is_lowered sets endpoint_address_family = "ipv4_only" and address_family = "ipv6_only" on one entry and checks that the endpoint stays Ipv4Only.

The supervisor’s validation adds one rule for WireGuard: with address_family ipv4_only or ipv6_only, one of addresses must be of that family. --test prints:

configuration error: node 1: outbound wg@v0: wireguard address_family ipv6_only needs an IPv6 address

The other strategies are not checked. The tunnel itself is on WireGuard and Outbounds, UDP fan-out and balancers.

Every refusal in src/lower/outbound.rs, in check order. All are InvalidInput except the unknown Shadowsocks cipher, which is Unsupported.

Function Condition Text
lower_outbounds tag starts with audit#, or repeats a built-in or earlier tag duplicate/reserved outbound tag <tag>
parse_address_family bad address_family outbound <tag> invalid address_family "<value>"
parse_server empty server or port = 0 outbound needs a non-empty server and non-zero port (got "<server>":<port>)
parse_server brackets around anything but an IPv6 literal, or a stray ] outbound server "<server>": brackets hold only an IPv6 literal
require_uuid no uuid outbound <tag> needs a uuid
require_uuid bad uuid outbound <tag>: uuid is not a valid UUID
parse_security unknown security unsupported vmess security "<value>"
lower_shadowsocks no password shadowsocks outbound <tag> needs a password
lower_shadowsocks bad base64 in a 2022 key decode PSK: <error>
lower_shadowsocks a 2022 key shorter than key_len shadowsocks-2022: PSK too short (<n> < <key_len>)
lower_shadowsocks unknown method unsupported shadowsocks cipher "<method>"
lower_wireguard missing key wireguard outbound <tag> needs a private_key (or public_key)
lower_wireguard bad key wireguard outbound <tag> <field>: invalid WireGuard key: expected base64 or hex encoding of 32 bytes
lower_wireguard bad local_address wireguard outbound <tag> invalid local_address "<value>": <error>
lower_wireguard no local_address wireguard outbound <tag> needs at least one local_address
lower_wireguard reserved not 3 bytes wireguard outbound <tag> reserved must be exactly 3 bytes
lower_wireguard bad endpoint_address_family outbound <tag> invalid endpoint_address_family "<value>"
lower_outbound unknown protocol unknown outbound protocol "<protocol>"
src/lower/outbound.rs
pub fn lower_dns(dns: &DnsConfig) -> io::Result<DnsSpec> {
let ca_pem = match &dns.ca_file {
Some(path) => Some(std::fs::read(path)?),
None => None,
};
Ok(DnsSpec::Single(Backend::from_spec(ResolverSpec {
backend: dns.backend.as_deref(),
server: dns.server.as_deref(),
server_name: dns.server_name.as_deref(),
url: dns.url.as_deref(),
ca_pem: ca_pem.as_deref(),
})?))
}
  • One resolver. katana lowers only DnsSpec::Single: one backend resolves the proxy servers the outbounds dial and the destinations the node reaches itself. A client’s own DNS queries are ordinary UDP or TCP flows, routed by the node’s route table. Split and the supervisor’s DNS service are never lowered. See Name resolution and the DNS service.
  • The default backend is "system", the host resolver. The DnsConfig doc (src/config.rs) gives the reason: it is the only backend that honours /etc/hosts, nsswitch.conf and search domains. The cache in front of it is always on, which is what a node relaying for many users feels, since the same names are resolved over and over.
  • The server. The udp, tls and https backends each need server, a socket address (IP:port), not a name. For https the DnsConfig doc explains why the address is not taken from the URL: that “would mean resolving the resolver”. Backend::from_spec (protocols/src/dns/mod.rs) checks server before server_name or url, so a tls or https block missing both reports the server first.
  • The CA file. When ca_file is set, lower_dns reads it into bytes on every lowering and passes them to Backend::from_spec, and the tls and https backends verify the resolver against it instead of the system roots. The DnsConfig doc: a private resolver is trusted this way “without widening trust to all of Web PKI”. A file that cannot be read refuses the node. The supervisor parses the bytes when it builds the resolver.
  • The URL of an https backend must start with https://. Its authority is host, host:port, [v6] or [v6]:port, and a URL with no path gets the path /dns-query (split_https_url, split_host_port). The resolver itself is on DNS resolver.
  • Per node. Every node builds its own resolver and cache from the same [dns] (the DnsConfig doc: each node keeps a cache of its own).

The errors, as --test prints them after configuration error: node 1: . The url rows also set backend = "https" and server = "192.0.2.53:443":

[dns] Text
backend = "doh" dns: unknown backend "doh" (expected "system", "udp", "tls" or "https")
backend = "udp", no server dns: the udp backend needs a server address
backend = "tls", no server dns: the tls backend needs a server address
backend = "https", no server dns: the https backend needs a server address
backend = "udp", server = "dns.example.com:53" dns: invalid server address: invalid socket address syntax
backend = "tls", server = "192.0.2.53:853", no server_name dns: the tls backend needs a server name to verify against
backend = "https", server = "192.0.2.53:443", no url dns: the https backend needs the resolver's url
url = "http://dns.example.com/dns-query" dns: "…" is not an https:// url
url = "https:///dns-query" dns: "…" has no usable host
url = "https://[2001:db8::1/dns-query" dns: "…" has an unclosed [
url = "https://[2001:db8::1]x/dns-query" dns: "…" has junk after ]
url = "https://:443/dns-query" dns: "…" has no host
url = "https://dns.example.com:99999/dns-query" dns: "…" has an invalid port
ca_file with no certificate (supervisor) building dns failed: no certificate in CA PEM bundle
Invariant Enforced by Pinned by
A local key that asks for what the kernel cannot do is refused by name as Unsupported unsupported() in stream and lower_hysteria acme_cert_mode_rejected pins the refusal (is_err()), not its text or kind; reject_unknown_sni_is_refused_rather_than_ignored pins the kind and the key in the text
What a UniProxy answer asks for and katana cannot serve is refused by name as the answer is read, with the reason in the error’s own message, never served as something else parse_node_config and its helpers in src/api/newv2board.rs a_transport_katana_cannot_serve_is_refused, a_tcp_header_other_than_none_is_refused, only_vision_and_only_on_vless, shadowsocks_ciphers_and_keys, parse_socks_and_http_read_their_transport_over_tls, an_sss_node_is_refused (tests/unit/api/newv2board.rs)
A TCP node, REALITY included, is served as bare TCP only when its panel asks for no header obfuscation; any other header type is refused by name plain_tcp_header, called by the newV2board client’s transport for every TCP node; the contract has no field for a header a_tcp_header_other_than_none_is_refused (tests/unit/api/newv2board.rs)
A port is 1 to 65535, never truncated into another NonZeroU16 in the contract; parse_node_config refuses any other server_port a_port_outside_one_to_65535_is_refused (tests/unit/api/newv2board.rs)
A REALITY node lowers to the Reality shape with no certificate: its one server name as SNI and cover site at the panel’s port, one decoded shortId stream, reality_spec a_reality_node_lowers_to_its_server_spec
A REALITY key or shortId that does not decode is refused without the value in the error; settings missing, REALITY over another transport or on VMess, are refused The newV2board client’s reality and v2ray, the kernel’s decoders, the contract’s validate() a_reality_node_with_bad_settings_is_refused_without_repeating_them, a_reality_node_without_its_settings_is_refused (tests/unit/api/newv2board.rs)
Vision is the one XTLS flow, only on VLESS, and only over REALITY The contract’s VlessFlow and validate(); the newV2board client’s v2ray only_vision_and_only_on_vless (tests/unit/api/newv2board.rs)
Every new node kind lowers to a spec the supervisor’s own validation accepts node_spec the_new_node_kinds_pass_the_supervisors_validation (tests/unit/lower/spec.rs): REALITY with Vision, AnyTLS, SOCKS, HTTP, legacy Shadowsocks and sss over WebSocket and TLS, Shadowsocks 2022, and a Hysteria 2 node as helium describes it
A SOCKS or HTTP node is served over TLS only, and a SOCKS node relays no UDP Under::Tls for every Socks and Http node, udp: false; on UniProxy the newV2board client’s proxy socks_and_http_nodes_are_tls_and_relay_no_udp; parse_socks_and_http_read_their_transport_over_tls (tests/unit/api/newv2board.rs)
An AnyTLS node is TLS with the panel’s padding scheme The Anytls arm: Transport::Tcp under Tls an_anytls_node_is_tls_with_its_padding_scheme
AnyTLS users present their UUID as password; SOCKS and HTTP users as account name and password credentials anytls_socks_and_http_users_are_their_uuid
An sss node lowers its chains and datagram limit, keeps the defaults for the rest, and refuses a chain it cannot parse by naming it lower_sss an_sss_node_lowers_its_chains_and_limits, an_sss_node_defaults_to_identity_and_draining, an_sss_node_refuses_a_chain_it_cannot_parse
sss users present their UUID credentials sss_users_are_their_uuid
reject_unknown_sni = true is refused as Unsupported naming the key; false lowers stream, lower_hysteria reject_unknown_sni_is_refused_rather_than_ignored for a stream node; the lower_hysteria path is shown by katana --test on a Hysteria 2 node, not by a unit test
A TLS stream node needs cert.mode = "file" stream step 4 tls_without_cert_file_errors
Shadowsocks rides the transport the panel names, legacy or 2022 lower_shadowsocks takes the lowered transport shadowsocks_rides_the_panels_transport
Each legacy cipher lowers to the kernel’s of the same name lower_shadowsocks every_legacy_cipher_lowers_to_the_kernels
tls is Some exactly when the shape layers TLS stream reads the certificate exactly under Tls, the shapes that layer it Structural; the supervisor’s validation refuses any other pairing
Lowering carries PEM as bytes and never parses it read_cert_key hysteria_accepts_both_credential_kinds lowers files holding cert and key
0.0.0.0 binds both families where the host allows; any other value binds as written; the tag keeps listen_ip bind_host, dual_stack, inbound_tag the_default_listen_ip_binds_both_families_where_the_host_can, any_other_listen_ip_binds_as_written, a_node_on_0_0_0_0_serves_ipv4_and_ipv6_clients, a_hysteria_node_on_0_0_0_0_serves_ipv4_and_ipv6_clients
disable_sniffing is honoured sniff: !disable_sniffing a_sniffed_host_reaches_a_domain_rule, disable_sniffing_stops_the_domain_rule_matching
A Node::Vless lowers VLESS lower_stream_protocol a_vless_node_lowers_vless
A VMess inbound checks the clock unless disable_vmess_clock_check is set lower_stream_protocol vmess_checks_the_clock_unless_the_node_turns_it_off
A stream inbound reads PROXY protocol v2 headers; a Hysteria 2 inbound does not proxy_protocol from the bind kind in lower_inbound without_enable_device_limit_no_limit_holds_and_no_ip_is_banned (tests/unit/lower/spec.rs)
Only a WebSocket node reads a real-IP header, and only with both keys set; half a setting or a typo in one is refused on every node, by the node check too real_ip, websocket in lower_inbound; real_ip first in test_spec a_websocket_node_takes_its_client_from_a_trusted_proxys_header, half_a_real_ip_setting_or_a_typo_in_one_is_refused, the_node_check_refuses_a_half_real_ip_setting (tests/unit/lower/spec.rs)
A stream node with handoff_dir set takes handed-over connections on <handoff_dir>/<port>.sock, or <handoff_dir>/<ip>-<port>.sock on one address, mode 0660, with handoff_group’s gid; a Hysteria 2 node takes none; unset, none is bound handoff, handoff_file and the filter in lower_inbound a_stream_node_takes_handed_over_connections_on_a_socket_named_for_its_port, a_node_on_one_address_names_its_handoff_socket_for_it, a_hysteria_node_takes_no_handed_over_connections
A handoff setting the relay could not use is refused on every node, by the node check too: a group without a directory, a relative directory or one too long for the node’s own socket name, a group /etc/group does not list handoff, called by lower_inbound and test_spec a_handoff_setting_the_relay_could_not_use_is_refused, the_node_check_refuses_a_handoff_setting_the_relay_could_not_use (tests/unit/lower/spec.rs)
A group is found by its whole name find_gid a_group_is_found_by_its_whole_name
A Shadowsocks 2022 user’s key is the leading key_len bytes of their UUID’s text credentials ss2022_builds
Hysteria config errors are reported before a missing certificate [node.hysteria]’s rules run as the node is read; read_cert_key runs last in lower_hysteria Every hysteria_refuses_* test uses hy2_cert(), whose files do not exist
Obfuscation cannot be silently disabled or weakened, whether the panel or the block names it hysteria::obfs hysteria_refuses_an_obfs_password_with_no_obfs, hysteria_refuses_an_unknown_obfs_rather_than_disabling_it, hysteria_refuses_a_short_obfs_password; for the panel’s, a_hysteria_node_is_completed_with_the_local_block (tests/unit/api/newv2board.rs)
The panel’s obfuscation reaches the listener Hysteria2::obfs feeds lower_hysteria a_panel_described_hysteria_node_serves_obfuscated_traffic
The masquerade never answers with the auth-success status The contract’s validate(), then Masquerade::new through masquerade_spec hysteria_refuses_a_masquerade_that_says_authenticated, a_panels_masquerade_the_kernel_cannot_answer_with_is_refused
The UDP idle timeout is in range, and set only with UDP hysteria::udp hysteria_refuses_an_out_of_range_udp_idle_timeout, hysteria_refuses_an_idle_timeout_without_udp
The node’s UDP relay and masquerade reach the listener whatever [node.hysteria] says; a UniProxy node’s are [node.hysteria]’s lower_hysteria reading Hysteria2::udp and masquerade; hysteria::uniproxy the_nodes_hysteria_udp_and_masquerade_reach_the_spec (tests/unit/lower/spec.rs), a_hysteria_node_is_completed_with_the_local_block
No certificate, no Hysteria node The cert.mode check hysteria_requires_a_certificate
An unknown credential kind is refused; "", uuid and user_pass give Password, Password and Account The credential match hysteria_refuses_an_unknown_credential_kind, hysteria_accepts_both_credential_kinds
The panel’s Hysteria 2 rates reach the listener, [node.hysteria] overrides them, and a panel silent on ignore_client_bandwidth leaves the node on auto hysteria::complete, then the rate block of lower_hysteria a_panel_that_sets_rates_has_the_node_send_at_the_agreed_one, the_local_hysteria_block_overrides_the_panels_rates, a_panel_silent_on_ignoring_client_bandwidth_keeps_the_node_on_auto (tests/unit/e2e.rs)
A change to the node drops every connection unless the supervisor applies it to new connections alone: an AnyTLS padding scheme, Hysteria 2’s rates and UDP idle timeout disruptive_part (src/manager/node.rs) only_a_disruptive_change_drops_every_connection (tests/unit/manager/node.rs)
An unknown congestion control is refused, by the node check on every node too congestion, called by lower_hysteria and test_spec hysteria_refuses_an_unknown_congestion_control, a_helium_nodes_check_judges_its_congestion_control (tests/unit/lower/spec.rs)
A Hysteria client authenticates with its panel UUID by default Hysteria2UserAuth::Password plus credentials a_real_client_proxies_through_a_katana_hysteria_node, a_hysteria_node_relays_and_meters
A Hysteria 2 node refuses a UUID the panel never issued Hysteria2UserAuth::Password plus the users’ UUIDs from credentials a_hysteria_node_refuses_an_unknown_credential
Stream transports interoperate with an independent client stream mapping The ten tests in tests/integration/xray_interop.rs
Built-in and audit tags cannot be redefined, and tags are unique lower_outbounds an_audit_tag_is_reserved; no unit test pins the duplicate case, and katana --test shows it
address_family applies to every proxy protocol parse_address_family before the protocol switch address_family_applies_to_every_protocol
An invalid address_family is refused for every protocol parse_family an_invalid_address_family_is_rejected_for_every_protocol
endpoint_address_family is lowered on its own, and refused when invalid parse_family a_wireguard_endpoint_address_family_is_lowered, an_invalid_wireguard_endpoint_address_family_is_rejected
direct needs no server The early return before parse_server direct_is_configurable_as_an_outbound
A bracketed server is an IPv6 literal, and brackets around anything else are refused parse_server a_bracketed_ipv6_server_is_an_address, a_wireguard_endpoint_takes_a_bracketed_ipv6_server
A WireGuard single-family strategy has a local address of that family The supervisor’s validate_outbound wireguard_ipv4_only_builds_with_ipv4_address, wireguard_ipv6_only_requires_ipv6_address, both through check(cfg) and so etemenanki_supervisor::check
An outbound UUID is never echoed in an error require_uuid names the tag only a_malformed_uuid_is_refused_without_echoing_it
The Shadowsocks generation follows the cipher lower_shadowsocks shadowsocks_builds_both_generations
A lowered proxy outbound relays lower_outbound for vless proxy_outbound_relays_and_meters
The shared-WireGuard warning names the outbound and the nodes, never the panel key runtime::shared_wireguard, display_id a_wireguard_outbound_several_nodes_route_to_is_reported
  • First error wins. Every function returns at its first error, and the caller receives no spec at all. Nothing is half-lowered, and nothing outside the process has changed, since lowering binds and dials nothing.

  • How the errors print. The texts carry no prefix of their own. katana --test (src/main.rs) prints configuration error: node <node_id>: <error> on stderr and exits with failure, or Configuration OK on stdout. Captured with the pinned binary:

    configuration error: node 1: duplicate/reserved outbound tag audit#1
    configuration error: node 1: unknown obfs "Salamander" (expected "salamander")
    configuration error: node 1: hysteria2 node requires cert.mode = "file"
    configuration error: node 1: wireguard outbound wg invalid local_address "10.0.0.300/32": invalid IP address syntax

    How the node manager and a config reload report the same errors is on The node manager and Runtime and config reload.

  • Refusals before lowering. What a UniProxy answer asks for and katana cannot serve fails the panel client’s read, not the lowering, so the node logs it as a node_info error with the reason in it, and --test, which never asks the panel, cannot show it; see Refused before lowering. A newV2board node whose [node.hysteria] does not hold to its rules is refused by --test all the same, through hysteria::local in test_spec.

  • Errors after lowering. A spec that lowers can still be refused by the supervisor. Those texts are the supervisor’s ApplyError: Invalid prints <resource>: <reason>, for example outbound wg@v0: wireguard address_family ipv6_only needs an IPv6 address, and Build prints building <resource> failed: <error>, for example building inbound Hysteria2_0.0.0.0_8443 failed: hysteria2: the certificate file contains no certificates or building dns failed: no certificate in CA PEM bundle. See Validation and apply errors.

  • Per-user errors never fail the node. credentials returns a reason, and lower_users logs skipping user <uid>: <why> and continues with the other users.

  • Cancellation. There is nothing to cancel. The functions are synchronous: they spawn no task, hold nothing across an .await, and take no lock apart from the OnceLock that the dual-stack probe initialises once. OnceLock::get_or_init runs the probe once even when two nodes lower at the same time; a caller that arrives during the first probe waits for its answer. The file reads use std::fs::read on the calling task and block it while they run. dual_stack creates one socket, never binds it, and drops it before returning.

Constant or rule Value Where Meaning
USER_SET "users" src/lower/mod.rs The one user set each inbound admits.
AUDIT_TAG_PREFIX "audit#" src/rule.rs Reserved prefix; no [[outbound]] tag may start with it.
Built-in outbounds direct, block, freedom, blackhole lower_outbounds Always present, never redefinable.
DEFAULT_MAX_CONNECTIONS 262,144 protocols/src/hysteria/server/config.rs Concurrent QUIC connections per Hysteria 2 node.
DEFAULT_MAX_CIRCUITS 4,194,304 protocols/src/hysteria/server/config.rs Live proxied streams per Hysteria 2 listener.
udp_idle_timeout 2 to 600 s, default 60 src/api/hysteria.rs → udp, the contract’s UdpRelay Idle time before a Hysteria 2 UDP association is retired. helium’s node config has the same range and default.
Salamander key at least 4 bytes src/api/hysteria.rs → obfs, the contract’s SalamanderPassword Minimum obfs_password length.
Hysteria 2 congestion control cubic (default), bbr, reno congestion Used when no fixed rate is agreed.
QuicOptions::server() 8 MiB stream and 20 MiB connection receive windows, 30 s idle timeout, no keep-alive, 65,536 streams per client protocols/src/hysteria/config.rs The QUIC settings of every client connection.
Masquerade defaults 404, 404 page not found\n, text/plain; charset=utf-8 src/api/hysteria.rs → masquerade Used for any field of [node.hysteria.masquerade] left unset when another is set.
Masquerade status 100 to 999, never 233 The contract’s validate(), Masquerade::new
key_len() 16 or 32 bytes ss_2022::Method Shadowsocks 2022 server, user and chain key length.
WireGuard keys 32 bytes, base64 or hex parse_key Private, public and pre-shared keys.
DEFAULT_MTU 1420 protocols/src/wireguard/config.rs WireGuard tunnel MTU when mtu is unset.
reserved exactly 3 bytes lower_wireguard Xray’s WireGuard reserved header bytes.
Dual-stack probe once per process dual_stack The answer is cached in a OnceLock.
MAX_SOCKET_PATH 107 bytes src/lower/inbound.rs The longest Unix socket path: handoff_dir, a / and handoff_file(listen_ip, 65535) must fit, so 96 bytes of directory on every address and less on one.
HANDOFF_MODE 0o660 src/lower/inbound.rs The handoff socket’s permission bits: its owner and its group may connect.

The unit tests live next to the code through #[path] attributes and run with cargo test.

tests/unit/lower/inbound.rs (36 tests). The nodes are the contract’s, built in the test: stream nodes start from base_node(), VMess over plain TCP on port 443, with an empty config parsed from "". A Hysteria 2 node is hy2_node(cfg), the node hysteria::local builds from a [node.hysteria] on port 8443; the doc comment of lower_hy2: “the block’s refusals are the reading’s, the certificate’s the lowering’s”.

Test Pins
a_vless_node_lowers_vless A Node::Vless without security lowers Vless.
vmess_checks_the_clock_unless_the_node_turns_it_off A VMess inbound’s clock_check is on by default and off with disable_vmess_clock_check; a VLESS node lowers Vless either way.
a_reality_node_lowers_to_its_server_spec A VLESS node with REALITY settings (RFC 7748’s test key in Xray’s format, the empty shortId) lowers Vless with VlessFlow::Vision over the Reality shape, no TLS material, server_names ["www.example.com"], the all-zero shortId, the cover site www.example.com at port 443 and require_hybrid off; with no flow it lowers VlessFlow::None.
ss2022_builds A 2022-blake3-aes-128-gcm node with a 16-byte key lowers, and a user’s key is the first 16 bytes of their UUID’s text.
shadowsocks_rides_the_panels_transport aes-128-gcm over WebSocket lowers Shadowsocks over Ws { path: "/ss", tls: false }; a 2022 cipher over gRPC with TLS lowers Ss2022 over Grpc { tls: true } with the certificate read.
every_legacy_cipher_lowers_to_the_kernels Each of the four SsLegacyCiphers lowers Shadowsocks with the kernel’s method of the same name, and ss_legacy::Method::from_name reads the cipher’s wire name back to that method.
an_anytls_node_is_tls_with_its_padding_scheme An AnyTLS node lowers the tag AnyTLS_0.0.0.0_443, the Tls shape and the panel’s padding lines; without a certificate it is refused.
socks_and_http_nodes_are_tls_and_relay_no_udp A SOCKS or HTTP node over WebSocket is refused without a certificate, and with one lowers Socks { udp: false, udp_bind: None } or Http { allow_transparent: false } over Ws { tls: true }.
anytls_socks_and_http_users_are_their_uuid An AnyTLS user’s password, and a SOCKS or HTTP user’s account name and password, are the UUID.
acme_cert_mode_rejected cert.mode = "dns" is refused.
tls_without_cert_file_errors A VMess node over TLS with the default cert.mode = "none" is refused.
reject_unknown_sni_is_refused_rather_than_ignored Unsupported, the text names the key; the default lowers.
the_default_listen_ip_binds_both_families_where_the_host_can 0.0.0.0 binds :: when dual_stack(), else 0.0.0.0; the tag is V2ray_0.0.0.0_443.
any_other_listen_ip_binds_as_written 127.0.0.1, 192.0.2.7, ::, ::1, 2001:db8::7 and localhost pass through.
hysteria_requires_a_certificate cert.mode = "none" is refused with a text naming cert.mode.
hysteria_refuses_an_obfs_password_with_no_obfs The password-without-type text.
hysteria_refuses_an_unknown_obfs_rather_than_disabling_it obfs = "gecko" is refused.
hysteria_refuses_a_short_obfs_password A 2-byte Salamander key is refused.
hysteria_refuses_an_out_of_range_udp_idle_timeout 1 and 601 seconds are refused.
hysteria_refuses_an_idle_timeout_without_udp A timeout without udp is refused.
hysteria_refuses_a_masquerade_that_says_authenticated Masquerade status 233 in [node.hysteria.masquerade] is refused with a text naming 233.
a_panels_masquerade_the_kernel_cannot_answer_with_is_refused A Hysteria 2 node built without the contract’s checks, with masquerade status 99, is refused by lowering with not an HTTP status code, before the certificate is read.
hysteria_refuses_an_unknown_credential_kind credential = "totp" is refused.
hysteria_refuses_an_unknown_congestion_control congestion = "vegas" is refused with unknown hysteria congestion.
hysteria_accepts_both_credential_kinds "", uuid and user_pass lower to Password, Password and Account, over cert.pem and key.pem holding the bytes cert and key in a per-process temporary directory.
a_websocket_node_takes_its_client_from_a_trusted_proxys_header With real_ip_header = "X-Real-IP" and real_ip_from = ["127.0.0.1/32", "::1/128"], a WebSocket node on /ws lowers RealIpSpec { header: "X-Real-IP", trusted: [127.0.0.1/32, ::1/128] }; the same keys on a TCP and a gRPC node, and no keys on the WebSocket node, give None.
half_a_real_ip_setting_or_a_typo_in_one_is_refused A header without networks, networks without a header, 127.0.0.1/33, localhost and the header X Real IP each fail lower_inbound with InvalidInput and a text containing real_ip_.
a_stream_node_takes_handed_over_connections_on_a_socket_named_for_its_port With handoff_dir = "/run/katana/handoff" and handoff_group = "root", the port-443 node lowers HandoffSpec { path: "/run/katana/handoff/443.sock", mode: 0o660, gid: Some(0) }; without a group the gid is None; without either key handoff is None.
a_hysteria_node_takes_no_handed_over_connections A Hysteria 2 node with handoff_dir set lowers handoff: None.
a_node_on_one_address_names_its_handoff_socket_for_it Under /run/katana/handoff, 0.0.0.0 and :: give 443.sock, 203.0.113.5 gives 203.0.113.5-443.sock and 2001:db8::1 gives 2001:db8::1-443.sock; 203.0.113.5 and 203.0.113.6 give different paths.
a_handoff_setting_the_relay_could_not_use_is_refused A group without a directory, run/katana, the empty path, a 97-byte directory and an unknown group each fail with InvalidInput and the expected text; a 96-byte directory lowers on the default listen_ip, and its socket path is 96 + /443.sock bytes long; the same directory on 2001:db8::1 is refused with a text naming 2001:db8::1-65535.sock.
a_group_is_found_by_its_whole_name Over a sample /etc/group text that starts with a comment line, find_gid finds root and a group whose name begins another group’s name, each by its whole name; a name that is only the start of a group’s gives None, and so does a line without a gid.
an_sss_node_lowers_its_chains_and_limits An sss node over WebSocket lowers the tag Sss_0.0.0.0_443, both chains and max_datagram 1500, and keeps the default flush_delay, header_timeout and SssReject::Drain.
an_sss_node_defaults_to_identity_and_draining An sss node with empty chains and no datagram limit lowers SssServerSettings::default().
an_sss_node_refuses_a_chain_it_cannot_parse The chain expression gzip is refused with a text naming transform.up.
sss_users_are_their_uuid An sss user presents the UUID, and no password.

tests/unit/lower/outbound.rs (11 tests). The two WireGuard family tests go through check(cfg), which lowers one entry with lower_outbounds, adds lower_dns of the default [dns] and a route to direct, and runs etemenanki_supervisor::check, so they see the supervisor’s rules too. The others call lower_outbound or parse_server directly.

Test Pins
wireguard_ipv4_only_builds_with_ipv4_address ipv4_only with 10.0.0.2/32 passes the supervisor check.
wireguard_ipv6_only_requires_ipv6_address ipv6_only with only an IPv4 address fails with a text naming IPv6.
a_wireguard_endpoint_address_family_is_lowered Unset is Auto; ipv4_only is kept even when address_family is ipv6_only.
an_invalid_wireguard_endpoint_address_family_is_rejected ipv7 fails with invalid endpoint_address_family.
address_family_applies_to_every_protocol socks, http, vmess and vless carry ipv6_only into the upstream transport.
an_invalid_address_family_is_rejected_for_every_protocol ipv7 fails with invalid address_family for socks, http, vmess, vless and wireguard.
direct_is_configurable_as_an_outbound direct with no server and port lowers to Freedom { address_family: Ipv4Only }.
a_malformed_uuid_is_refused_without_echoing_it The VMess and VLESS UUID errors do not contain the value.
shadowsocks_builds_both_generations aes-256-gcm lowers legacy; a 2022 method lowers from one PSK (no chain) and from iPSK:uPSK (a chain of one); rc4-md5 fails.
a_bracketed_ipv6_server_is_an_address [2001:db8::10] and 2001:db8::10 are the same address, an IPv4 literal and a domain parse as before, and [not-an-ip], [192.0.2.1], an unbalanced bracket or [2001:db8::10]:443 fail with a text naming the brackets.
a_wireguard_endpoint_takes_a_bracketed_ipv6_server A WireGuard server = "[2001:db8::10]" lowers to that address, dialed over UDP.

Other unit tests.

Test File Pins
an_audit_tag_is_reserved tests/unit/lower/spec.rs An [[outbound]] tagged audit#1 fails node_spec with a text containing reserved.
the_new_node_kinds_pass_the_supervisors_validation tests/unit/lower/spec.rs A REALITY node with Vision, an AnyTLS node with a padding scheme, a SOCKS and an HTTP node over TLS, a legacy Shadowsocks node and an sss node over WebSocket with TLS, a Shadowsocks 2022 node, and a Hysteria 2 node as helium describes it (obfuscated, relaying UDP, with a masquerade of its own) each lower to one inbound that etemenanki_supervisor::build::validate::validate accepts.
the_nodes_hysteria_udp_and_masquerade_reach_the_spec tests/unit/lower/spec.rs A node’s 90 s idle timeout and 502 masquerade reach the Hysteria 2 spec; a node that has neither leaves both off whatever [node.hysteria] says; a UniProxy node hysteria::uniproxy completes takes both from [node.hysteria] (60 s, status 403).
a_helium_nodes_check_judges_its_congestion_control tests/unit/lower/spec.rs test_spec on a helium node lowers no inbound, accepts bbr and refuses vegas.
the_node_check_refuses_a_half_real_ip_setting tests/unit/lower/spec.rs test_spec refuses real_ip_header alone on a node no panel has described, and accepts it with real_ip_from = ["127.0.0.1/32"].
the_node_check_refuses_a_handoff_setting_the_relay_could_not_use tests/unit/lower/spec.rs test_spec refuses a relative handoff_dir and a handoff_group alone, and accepts /run/katana/handoff with the group root.
a_tcp_header_other_than_none_is_refused tests/unit/api/newv2board.rs A UniProxy TCP body of a VMess, a VLESS and a Shadowsocks node whose header is null, {}, or of type null, none or None, is plain TCP; a type http or "" is refused naming tcp header type, a type 1 and a header that is the string "http" with their own texts; a REALITY node with a type http header is refused too.
a_transport_katana_cannot_serve_is_refused tests/unit/api/newv2board.rs httpupgrade, splithttp, xhttp and quic are refused, each starting node requests kernel-unsupported feature.
only_vision_and_only_on_vless tests/unit/api/newv2board.rs xtls-rprx-vision-udp443 is refused by name, Vision on VMess with off VLESS, Vision over TLS with needs security reality; Vision over REALITY reads.
a_reality_node_with_bad_settings_is_refused_without_repeating_them tests/unit/api/newv2board.rs A bad shortId or key is refused without the value; an empty server name, a cover-site port of 0, a key of the wrong type and missing settings are refused; REALITY over WebSocket is refused with reality runs over transport tcp only, and on VMess with REALITY on a VMess node.
shadowsocks_reads_its_transport, shadowsocks_ciphers_and_keys tests/unit/api/newv2board.rs A Shadowsocks node reads its transport and TLS from either spelling of the settings, and tls = 2 is refused; each legacy name and alias reads as its cipher, a 2022 key reads as given and a longer one is folded to 16 bytes; rc4-md5, 2022-blake3-chacha20-poly1305, a key that is not base64, a key too short for 2022-blake3-aes-256-gcm and obfs = "http" are refused.
parse_socks_and_http_read_their_transport_over_tls tests/unit/api/newv2board.rs A SOCKS or HTTP node reads its WebSocket transport over TLS, and is refused with without TLS for tls = 0 and over REALITY for tls = 2.
a_hysteria_node_is_completed_with_the_local_block tests/unit/api/newv2board.rs A UniProxy Hysteria 2 node keeps the panel’s obfuscation, takes [node.hysteria] up_mbps over the panel’s, the panel’s down_mbps and ignore_client_bandwidth, and the block’s UDP relay (60 s) and masquerade (403); the panel’s obfuscation is refused by the block’s rules.
only_a_disruptive_change_drops_every_connection tests/unit/manager/node.rs A new AnyTLS padding scheme, a new Hysteria 2 rate and a new UDP idle timeout keep every connection; turning the UDP relay off, a new obfuscation password, a new port, a new transport, a new masquerade or none, and a new sss chain drop every one.
the_real_ip_keys_parse_and_a_typo_in_them_is_refused tests/unit/runtime.rs Both keys parse from an inline controller table; set_real_ip_from is refused as an unknown key.
the_handoff_keys_parse_and_a_typo_in_them_is_refused tests/unit/runtime.rs Both keys parse from an inline controller table; handoff_directory is refused as an unknown key.
a_reload_of_the_real_ip_keys_alone_applies_at_once, a_reload_of_the_handoff_keys_alone_applies_at_once tests/unit/manager/node.rs A StaticUpdate::Config that changes only these keys is applied by the poll it runs at once: the applied inbound gains its real_ip, and gains a handoff socket whose file exists, then loses it again (The node manager).
a_wireguard_outbound_several_nodes_route_to_is_reported tests/unit/runtime.rs Only a WireGuard outbound that two nodes route to is reported, and the report never contains the panel key.
proxy_outbound_relays_and_meters tests/unit/e2e.rs A node whose default route is a lowered vless outbound relays 50,000 bytes through an upstream VLESS server.
a_node_on_0_0_0_0_serves_ipv4_and_ipv6_clients tests/unit/e2e.rs A stream node on 0.0.0.0 relays for 127.0.0.1 and ::1 clients on one port. Skipped, with a message, where dual_stack() is false.
a_hysteria_node_on_0_0_0_0_serves_ipv4_and_ipv6_clients tests/unit/e2e.rs The same for a Hysteria 2 node’s UDP socket.
a_hysteria_node_relays_and_meters tests/unit/e2e.rs A client authenticates with its panel UUID over the certificate block’s certificate and relays 50,000 bytes.
a_hysteria_node_refuses_an_unknown_credential tests/unit/e2e.rs A UUID the panel never issued does not connect.
a_panel_described_hysteria_node_serves_obfuscated_traffic tests/unit/e2e.rs The panel’s obfs and obfs-password reach the listener: a client with the same Salamander key relays.
an_sss_node_relays_through_its_chains_and_meters tests/unit/e2e.rs An sss node that the fake helium panel describes, with a chain each way, relays 50,000 bytes for a real sss client using the same chains, and the helium reports carry them for uid 1001.

Integration tests. These start the real katana binary against a fake panel and drive it with independent clients built from reference sources. Each one skips itself when go or the reference checkout is missing. See Testing.

Test File Pins
vmess_tcp_plain, vmess_ws_plain, vmess_grpc_plain, vmess_tcp_tls, vless_ws_tls, vless_grpc_tls, trojan_tcp_tls tests/integration/xray_interop.rs Xray as the client against a katana node over TCP, WebSocket (path /katanaws) and gRPC (service GunService), with and without TLS. Xray verifies katana’s certificate by pinning its hash.
vmess_tcp_plain_mux, vless_ws_tls_mux, trojan_tcp_tls_mux tests/integration/xray_interop.rs The same with mux.cool enabled.
a_real_client_proxies_through_a_katana_hysteria_node tests/integration/hysteria_interop.rs The upstream Hysteria client authenticates with only the panel UUID and proxies two streams on one connection.
a_sniffed_host_reaches_a_domain_rule, disable_sniffing_stops_the_domain_rule_matching tests/integration/sniff.rs disable_sniffing = false lets a flow addressed by IP match a domain rule; true does not.
  1. A feature a panel describes is a field of the contract’s node config in the helium-node-api crate, which Helium and katana share, so it is added there first. The newV2board client converts a UniProxy answer into it (parse_node_config in src/api/newv2board.rs). A local feature goes into NodeConfig in src/config.rs; every config struct is deny_unknown_fields, so a key that is not declared is a parse error.
  2. Lower it in src/lower/inbound.rs into a field the supervisor’s spec already has. If the spec has no such field, the feature belongs in the supervisor first; see The spec: desired state.
  3. If the kernel cannot do it, refuse it by name with unsupported("<feature>"): in the newV2board client for what a UniProxy answer asks for, so the node logs the reason, and in lowering for a local key, in the order that reports the most useful error first: judgements about the config before any file is read.
  4. If it changes the wire, check whether the node manager must close connections when it changes. A field of the node does unless disruptive_part clears it, which it does only for what the supervisor applies to new connections alone; a local setting does when it is in apply_static’s rebuild list. See The node manager.
  5. Add a test to tests/unit/lower/inbound.rs, a test of the UniProxy reading to tests/unit/api/newv2board.rs, and an interop case when a real client can exercise it.
  1. Add the protocol’s fields to OutboundConfig in src/config.rs.
  2. Add an arm to lower_outbound that returns an OutboundProtocolSpec variant. The variant must exist in the supervisor; adding one is described on Outbounds, UDP fan-out and balancers.
  3. Make every error name cfg.tag and never a credential, and put every key or password in a Secret.
  4. If the protocol holds a tunnel keyed by a credential, as WireGuard does, add it to runtime::shared_wireguard’s protocol match.
  5. Add tests to tests/unit/lower/outbound.rs, and add the protocol to the lists in a_malformed_uuid_is_refused_without_echoing_it and an_invalid_address_family_is_rejected_for_every_protocol where it applies.
  6. Document the keys in the katana/outbound field table and on the Outbounds guide page.