Skip to content

Inbounds

An inbound is a listener that accepts connections from clients in one protocol and hands every flow it decodes to routing. Each [[inbound]] table in the config file creates one. A config can have as many inbounds as you need, in any mix of protocols, and each is identified by its tag.

This page covers the keys every inbound shares, what each protocol can carry, how listen and port decide what gets bound, Unix-socket listeners, and the fixed limits on every listener. The protocol-specific [inbound.settings] keys are on each protocol’s own page.

katana does not read [[inbound]] tables: there, the panel decides each node’s protocol, port and transport. Everything below is about etemenanki-app.

A SOCKS proxy for programs on the same machine:

config.toml
[[inbound]]
tag = "socks-in"
protocol = "socks"
port = 1080 # listen defaults to 127.0.0.1
[[outbound]]
tag = "direct"
protocol = "freedom"

Because listen is not set, this binds 127.0.0.1:1080 and is reachable only from the local host. At startup the log says so:

INFO etemenanki_supervisor::system::listener: inbound socks-in listening on 127.0.0.1:1080

A server usually carries more than one inbound. This config serves a local SOCKS proxy, a public VLESS endpoint over WebSocket and TLS, and an HTTP proxy on a Unix socket for a local service:

config.toml
[[inbound]]
tag = "local-socks"
protocol = "socks"
port = 1080 # 127.0.0.1 only
[[inbound]]
tag = "public-vless"
protocol = "vless"
listen = "0.0.0.0" # every IPv4 interface
port = 443
[inbound.stream]
network = "ws"
security = "tls"
[inbound.stream.ws]
path = "/ray"
[inbound.stream.tls]
cert_file = "/etc/etemenanki/cert.pem"
key_file = "/etc/etemenanki/key.pem"
[inbound.settings]
users = [{ id = "11111111-2222-3333-4444-555555555555", email = "alice@example.com" }]
[[inbound]]
tag = "app-http"
protocol = "http"
listen = "/run/etemenanki/http.sock" # a Unix socket: no port
[[outbound]]
tag = "direct"
protocol = "freedom"

Check a config with etemenanki-app --test -c config.toml before you start it. --test builds every inbound and reads its certificate and key files, but it binds nothing (see what --test cannot catch).

These keys sit directly in each [[inbound]] table. Unknown keys are errors, so a misspelt listen stops the config instead of silently falling back to the default.

KeyTypeRequiredDefaultDescription
tagstringyes—Name of the inbound. It must be unique among inbounds (duplicate inbound tag …) and not empty. Routing rules match it with inbound_tag, and log lines use it. Inbound and outbound tags are separate namespaces.
protocolstring (enum)yes—The protocol clients speak: socks, http, trojan, vless, vmess, shadowsocks, anytls, sss, hysteria2 (aliases hysteria and hy2) or tun. Values are case-sensitive. wireguard is refused with wireguard cannot be used as an inbound (no server implementation); anything else fails with unknown protocol.
listenstringno"127.0.0.1"Address to bind. Defaults to loopback on purpose; write 0.0.0.0 or :: to accept connections from the network. Write IPv6 addresses bare (::, not [::]). A value starting with / is a Unix socket path, refused on Windows (unix sockets are not served on windows); a value starting with @ (abstract socket) is refused. hysteria2 and anytls cannot listen on a Unix socket. Must be absent for tun. Two inbounds cannot bind the same address and port (… is bound by another inbound).
portu16depends—Port to bind, from 0 to 65535. Required when listen is absent or an address (port is required). Must be absent for a Unix socket (a unix socket listen has no port; remove port) and for tun. For hysteria2 this is a UDP port.
streamtableno—Transport under the protocol: network (tcp, tls, ws, grpc), security and the tls, ws, grpc and reality subtables. socks, http, trojan, vless, vmess, shadowsocks, anytls and sss on an IP listener use it; anytls needs network = "tls", only vless takes security = "reality", and a socks inbound over anything but plain TCP needs udp = false. For hysteria2 and tun, and on a Unix socket, a network other than tcp or a security other than none is refused.
sniffingboolnotrueRead a TLS SNI or HTTP Host from the first bytes of a flow whose destination is a bare IP, so that domain rules can match it. Flows addressed by domain are never inspected.
settingstabledepends{}Protocol-specific settings, described on each protocol page. Required for shadowsocks and hysteria2, which have mandatory keys. Unknown keys are refused with inbound <tag>: invalid settings: …. These errors carry no line number.

A misspelt key is reported with its line:

configuration invalid: TOML parse error at line 4, column 1
protocol Listens on [inbound.stream] UDP mux.cool / XUDP Client authentication Unix socket
socks TCP tcp, tls, ws, grpc SOCKS5 UDP ASSOCIATE, on by default (udp = true), over plain TCP only No None, or username and password Yes, with udp_bind or udp = false
http TCP tcp, tls, ws, grpc No No Basic auth when accounts is set, otherwise open Yes
trojan TCP tcp, tls, ws, grpc Yes Yes Password per user Yes
vless TCP tcp, tls, ws, grpc, and REALITY over tcp Yes Yes UUID per user Yes
vmess TCP tcp, tls, ws, grpc Yes Yes UUID per user Yes
shadowsocks TCP tcp, tls, ws, grpc No, TCP only No Cipher and password, optionally one password per user Yes
anytls TCP tls only Yes, as UDP-over-TCP streams No; AnyTLS multiplexes streams of its own Password per user No
sss TCP tcp, tls, ws, grpc Yes, always on No UUID per user Yes
hysteria2, hysteria, hy2 UDP (QUIC) No When udp = true (off by default) No; every circuit is its own QUIC stream One shared password, or a user name and password per user No
tun A network interface No When udp = true (on by default) No None; the device is local Not applicable

Notes on the table:

  • Listens on is what etemenanki-app binds. hysteria2 binds a UDP socket, so it can share a port number with a TCP inbound, for example Trojan over TLS and Hysteria 2 both on port 443.
  • mux.cool / XUDP is the server side of Xray’s multiplexing. Trojan, VLESS and VMess inbounds accept it automatically; there is no key to turn it on or off. One carrier connection holds at most 256 sub-flows. An AnyTLS connection carries many streams by its own framing, also at most 256 at a time.
  • UDP means the inbound relays datagrams, not just streams. HTTP and Shadowsocks inbounds carry TCP only.
  • REALITY is a security of its own, security = "reality" with network = "tcp", and only VLESS takes it. See REALITY.
  • wireguard exists only as an outbound; see WireGuard. As an inbound it is refused with inbound <tag>: wireguard cannot be used as an inbound (no server implementation).

Inbounds that check credentials give every user a name. The name never goes on the wire; it is what the REST API shows as a connection’s user, and what keeps a user apart from the others in the configuration.

Protocol A user is named by
trojan, vless, vmess, anytls, sss email, required for every user
shadowsocks with users email, required for every user
hysteria2 with users email when it is set, otherwise user
socks with auth = "password", http with accounts user

Three rules apply within one inbound:

  • Every user has a name: an empty or missing one is refused (inbound TAG: users[N] has no email; a user of this inbound is named by its email, or inbound TAG: accounts[N] has no user).
  • No two users share a name (inbound TAG: users[0] and users[1] are both named "NAME").
  • No two users present the same credential: the same password, UUID or key, or, for Hysteria 2, the same user name in any letter case (inbound TAG: users A and B present the same credential, or … present the same username).

The email need not be an e-mail address. Any string that tells your users apart will do.

etemenanki-app decides what to bind while it builds the config, so --test refuses the same shapes a start would.

flowchart TB
  A["[[inbound]]"] --> B{"protocol = tun?"}
  B -- yes --> T["TUN device: listen and port must be absent"]
  B -- no --> C{"listen starts with / ?"}
  C -- yes --> U["Unix socket: port must be absent"]
  C -- no --> D{"listen starts with @ ?"}
  D -- yes --> E["error: abstract sockets not supported"]
  D -- no --> F{"port set?"}
  F -- no --> G["error: port is required"]
  F -- yes --> H{"protocol"}
  H -- "hysteria2, hysteria, hy2" --> UDP["UDP socket on listen:port"]
  H -- "socks, http, trojan, vless, vmess, shadowsocks, anytls, sss" --> TCP["TCP listener on listen:port"]
  H -- "anything else" --> X["error: unknown protocol, or wireguard refused"]

Apart from the tun check, the listen and port checks run before the protocol is looked at. An inbound with an unknown protocol and no port therefore reports port is required, not unknown protocol.

When listen is absent, the inbound binds 127.0.0.1. This is deliberate: a proxy that was meant to stay local must never end up on the network because of a typo or a wrongly nested key. A server that should accept connections from other machines says so explicitly:

listen = "0.0.0.0"
port = 443
  • Write IPv6 addresses bare, without brackets: "::" or "2001:db8::10".
  • port is a 16-bit number, so 70000 is a parse error.
  • port = 0 lets the kernel choose a free port. The startup log prints the configured value (127.0.0.1:0), not the port the kernel chose, so the log does not tell you which port is in use.
  • Two inbounds cannot have the same listen and port: inbound <tag>: 127.0.0.1:1080 is bound by another inbound. A hysteria2 inbound binds UDP, so it may share a port number with a TCP inbound.
  • Ports below 1024 need root or the CAP_NET_BIND_SERVICE capability. That is enforced by the kernel when the listener binds.

A tun inbound creates a network interface instead of binding a socket. It refuses both keys with tun owns a network interface and has no listener; remove listen/port. The device’s name, addresses and routes are in its [inbound.settings]; see TUN.

A listen value that starts with / makes the inbound listen on a Unix-domain socket at that path instead of on TCP. Use it when a local program, or a web server on the same host, talks to the proxy without going through the network stack.

[[inbound]]
tag = "socks-unix"
protocol = "socks"
listen = "/run/etemenanki/socks.sock"
[inbound.settings]
udp = true
udp_bind = "127.0.0.1" # a Unix socket has no local IP for the UDP relay
Rule Error when broken
The path is absolute. A relative path such as run/x.sock is read as a host name. inbound TAG: port is required
No port. inbound TAG: a unix socket listen has no port; remove port
No abstract sockets (@name). inbound TAG: abstract unix sockets are not supported; use a filesystem path
No transport: in [inbound.stream], network may only be tcp and security only none. inbound TAG: protocol vless over a unix socket does not support stream network "ws" (or stream security "tls")
Not hysteria2, which needs UDP. inbound TAG: hysteria2 listens on UDP and cannot use a unix socket
Not anytls, which runs over TLS only. inbound TAG: anytls runs over tls only; its shape must be tls
socks with udp = true (the default) also sets udp_bind, or turns UDP off. inbound TAG: socks over a unix socket has no local IP for UDP associate; set udp_bind or turn udp off

Every other stream protocol works on a Unix socket: socks, http, trojan, vless, vmess, shadowsocks and sss. The protocol runs directly on the socket, with no TLS, WebSocket or gRPC layer, because there is nothing on a local socket to disguise it from.

  • Across reloads the socket file is kept, and keeps serving, as long as the inbound’s listen does not change.
  • When the listener stops, because the inbound was removed or moved, or the process is shutting down (SIGINT or SIGTERM), it removes its socket file, but only while the path still holds the socket it created.
  • A file that is not a socket at the path is left alone, and the bind fails with PATH exists and is not a socket.
  • The parent directory must exist. etemenanki-app does not create it.
  • The path length is limited by the operating system (about 107 bytes on Linux).
  • Permissions come from the process’s umask. etemenanki-app does not change the socket’s mode or owner, so control who may connect with the permissions of the directory that holds it.

Give every process its own socket path.

A connection over a Unix socket has no client IP address. Routing rules that match source_cidr never match flows from a Unix-socket inbound, and a SOCKS inbound has no local IP on which to place its UDP relay, which is why it needs udp_bind.

A SOCKS UDP relay accepts datagrams from one client only. Over TCP, that client is the IP address the control connection came from. A Unix socket has no such address, so the client has to name its source itself: in its UDP ASSOCIATE request, it must give the exact IP address and port its datagrams will come from, and the address must be in a family that udp_bind hears: IPv4 for an IPv4 or IPv4-mapped udp_bind (such as ::ffff:192.0.2.10), IPv6 for any other IPv6 one, and either for ::. With udp_bind = "127.0.0.1", for example, that means an IPv4 address such as 127.0.0.1:5000. The relay then accepts datagrams from that address and port only.

The inbound refuses a request that leaves the address or the port unspecified or zero, names a domain instead of an IP address, or names an address in a family the relay cannot receive. It answers with SOCKS5 reply code 0x02 (“connection not allowed by ruleset”) and closes the control connection. RFC 1928 lets a client send all zeros when it does not know its source address, and many clients do. Such a client can use CONNECT over a Unix socket, but not UDP ASSOCIATE. --test cannot catch this, and the table above does not list it, because the inbound refuses the request at run time and the config itself is valid. The SOCKS page covers the UDP relay in full.

[inbound.stream] puts a transport under the protocol: TLS, WebSocket or gRPC, optionally with TLS under WebSocket or gRPC. Every inbound that listens on TCP takes it, on an IP listener: socks, http, trojan, vless, vmess, shadowsocks, anytls and sss.

[inbound.stream]
network = "grpc"
security = "tls"
[inbound.stream.grpc]
service_name = "example"
[inbound.stream.tls]
cert_file = "/etc/etemenanki/cert.pem"
key_file = "/etc/etemenanki/key.pem"

Some protocols narrow the choice:

  • anytls runs over TLS only, so it needs network = "tls". Anything else fails with inbound TAG: anytls runs over tls only; its shape must be tls.
  • vless alone also takes security = "reality" with network = "tcp"; see REALITY. Every other protocol refuses it with inbound TAG: reality is for vless only.
  • socks over anything but plain TCP must set udp = false. A SOCKS UDP relay is a separate UDP socket beside the listener, and its datagrams travel in the clear: under TLS they would name every target the TLS hides, and behind a WebSocket or gRPC front the client reaches the front, not the relay. With UDP left on, the inbound fails with inbound TAG: socks serves udp associate over plain tcp only; turn udp off to wrap it in a transport.
  • shadowsocks carries TCP only, with or without a transport.

hysteria2 and tun refuse a transport instead of silently dropping it, so an operator does not end up with a bare port while believing it is disguised. For these two, and for any inbound on a Unix socket, a network other than tcp or a security other than none is an error:

inbound hy2-in: protocol hysteria2 does not support stream network "ws"

hysteria2 carries its own TLS: its certificate and key go in [inbound.settings], not in [inbound.stream.tls]. Every network and security value, the ws, grpc and tls keys, and the errors they produce are on the transports page.

With sniffing = true, the default, an inbound reads a domain name out of the opening bytes of a flow whose destination is a bare IP address: the SNI of a TLS ClientHello, or the Host header of an HTTP request. Routing then matches domain and geosite rules against that name as well as the address. The destination the flow is dialled to does not change.

  • Only flows addressed by IP are inspected. A flow that already names a domain is routed on that name immediately.
  • The inbound waits at most 300 milliseconds and reads at most 4 KiB. A client that sends nothing first, as in SSH or SMTP, is routed on its IP once the wait expires.
  • Malformed or unrecognised bytes never fail a connection; the flow is routed on its address.
  • A mux.cool sub-flow is sniffed only from the data that arrived with its opening frame, and an AnyTLS stream only from the data that came with its address: sniffing either never waits for more data.

For SOCKS, HTTP CONNECT and Hysteria 2, sniffing changes when the client gets its answer. Normally the inbound dials the outbound first and replies “connected” only once the dial succeeds, or replies with a refusal. When it has to sniff a request addressed by IP, it must reply first, because the client sends no data until it has the reply. Such a client then learns of an unreachable target when the connection closes, not from the reply.

Set sniffing = false on an inbound whose clients always send domains, or whose traffic you route only by IP, port or inbound tag. The routing page explains how sniffed names meet the rules.

Every inbound that accepts sockets (all protocols except hysteria2 and tun, on TCP or on a Unix socket) has these fixed limits. They are not configurable.

Limit Value What happens at the limit
Live connections per inbound 4,194,304 A new connection is closed as soon as it is accepted. A connection counts from accept until it closes.
Concurrent handshakes per inbound 204,800 A new connection is closed as soon as it is accepted.
Handshake time 10 seconds A client that has not completed its protocol request in time is disconnected. The transport step before it (TLS, the WebSocket upgrade, the gRPC connection preface, the REALITY handshake) has its own 10 seconds. An sss inbound gives the request header header_timeout instead, 10 seconds by default.
mux.cool sub-flows per carrier connection 256 A further sub-flow is declined; the carrier and its other sub-flows carry on.
AnyTLS streams per connection 256 A further stream is closed at once; the connection and its other streams carry on.
Sniffing wait / bytes 300 ms / 4 KiB The flow is routed on its address.

Connections dropped at a limit are logged at debug level only. The limits of the other two inbound types are settings:

Inbound Setting Default
hysteria2 max_connections (QUIC connections) 262,144
hysteria2 max_circuits (live circuits across the listener) 4,194,304
tun max_flows (live flows across the device) 65,536

Every limit in etemenanki-app is collected on the limits page.

When the config file changes, etemenanki-app checks the new config completely before it touches the running one. If the new config is refused, everything keeps running as it was. If it is applied, each inbound is handled on its own:

Change What happens
None The inbound keeps running as it is.
Settings, users, transport or sniffing, with the same listen and port The listener keeps its socket. New connections are served with the new settings; connections already open keep the settings they were accepted with.
Another port The inbound is bound on the new port. The connections it accepted on the old one stay open.
Inbound removed Its listener stops, and its open connections are closed.
Anything about a tun inbound, or a Hysteria 2 inbound’s obfs The reload is refused, because the change would end every live connection of that inbound: reload refused, keeping the running config: inbound TAG: <reason>, which would end its live connections; restart to apply it. Restart the process to apply it.

Binding behaves differently at start and on reload:

  • At start, the first inbound that fails to bind stops the process: failed to start: inbound TAG: binding 127.0.0.1:1080 failed: Address already in use (os error 98).
  • On a reload, a listener that fails to bind refuses the whole reload: reload: inbound TAG: binding ADDRESS failed: …; keeping the running config. The running config, with all of its listeners, stays in place.

The hot reload page covers what a reload keeps.

--test builds every inbound and reads every certificate, but it binds nothing. These problems only appear when the listener binds, at start or on a reload:

  • the port is already in use by another process;
  • a port below 1024 without the privilege to bind it;
  • a Unix-socket path whose directory is missing, that is too long, or where a file that is not a socket already exists;
  • creating a tun device, which needs the privileges to do so;
  • binding the REST API’s listen address.

Build errors are printed as configuration invalid: ... by --test and as failed to start: ... at start. Most carry the inbound’s tag.

Error Cause Fix
inbound TAG: port is required An IP listen, or a missing or relative listen, without port. Add port, or give an absolute socket path.
inbound TAG: unknown protocol "SOCKS" Protocol names are lowercase and case-sensitive. Use one of the values in the table above.
inbound TAG: wireguard cannot be used as an inbound (no server implementation) protocol = "wireguard" in an [[inbound]]. Use WireGuard as an outbound only.
duplicate inbound tag TAG Two inbounds share a tag. Rename one.
inbound TAG: users[N] has no email; a user of this inbound is named by its email A Trojan, VLESS, VMess, Shadowsocks, AnyTLS or sss user without email. Give every user a unique email.
inbound TAG: users[0] and users[1] are both named "NAME" Two users of one inbound share a name. Give each user its own email (or user).
inbound TAG: users A and B present the same credential Two users share a password, UUID or key. Give each user its own credential.
inbound TAG: ADDRESS is bound by another inbound Two inbounds have the same listen and port. Change one of them.
inbound TAG: a unix socket listen has no port; remove port A socket path together with port. Remove port.
inbound TAG: tun owns a network interface and has no listener; remove listen/port listen or port on a tun inbound. Remove both.
inbound TAG: protocol hysteria2 does not support stream network "ws" A transport on hysteria2 or tun, which cannot carry one. Remove [inbound.stream]. Hysteria 2 takes its TLS settings in [inbound.settings].
inbound TAG: socks serves udp associate over plain tcp only; turn udp off to wrap it in a transport A SOCKS inbound inside TLS, WebSocket or gRPC with udp on, the default. Set udp = false, or drop the transport.
inbound TAG: anytls runs over tls only; its shape must be tls An AnyTLS inbound without network = "tls", or on a Unix socket. Set network = "tls" and a certificate, on an IP listener.
inbound TAG: reality is for vless only security = "reality" on a protocol other than VLESS. Use TLS, or serve VLESS.
inbound TAG: tls stream needs tls.cert_file TLS requested without a certificate. Set cert_file and key_file under [inbound.stream.tls].
inbound TAG: invalid settings: unknown field ... A misspelt key in [inbound.settings]. These errors have no line number. Compare against the protocol page.
inbound TAG: binding unix:PATH failed: PATH exists and is not a socket A file that is not a socket sits at the Unix-socket path. Move the file, or choose another path.

The gotchas page lists more surprises that are not errors.