diff --git a/README.md b/README.md index 36f0085..c10a4d9 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,8 @@ TODO: most of these are way underspecified - /ipcidr - /dns4, /dns6 - [/dnsaddr](protocols/DNSADDR.md) +- [/unix](protocols/unix.md) +- [/unix-abstract](protocols/unix.md) - /tcp - /udp - /utp diff --git a/protocols.csv b/protocols.csv index 2b6eed9..b0eebea 100644 --- a/protocols.csv +++ b/protocols.csv @@ -2,6 +2,9 @@ code, size, name, comment 4, 32, ip4, 6, 16, tcp, 273, 16, udp, +403, 0, stream, +404, 0, seqpacket, +405, 0, dgram, 33, 16, dccp, 41, 128, ip6, 42, V, ip6zone, rfc4007 IPv6 zone @@ -13,7 +16,8 @@ code, size, name, comment 132, 16, sctp, 301, 0, udt, 302, 0, utp, -400, V, unix, Percent-encoded path to a Unix domain socket +400, V, unix, Percent-encoded path to a unix-domain socket +401, V, unix-abstract, Percent-encoded address of a linux abstract unix-domain socket 421, V, p2p, preferred over /ipfs 421, V, ipfs, backwards compatibility; equivalent to /p2p 444, 96, onion, diff --git a/protocols/unix.md b/protocols/unix.md index a37d18b..47aedf4 100644 --- a/protocols/unix.md +++ b/protocols/unix.md @@ -1,6 +1,6 @@ # `unix` -This protocol encodes a Unix domain socket path to a resource. In the string +This protocol encodes a UNIX-domain socket path to a resource. In the string representation, the path is encoded in a way consistent with a single URI Path segment per [RFC 3986 Section 3.3](https://datatracker.ietf.org/doc/html/rfc3986#autoid-23). @@ -12,7 +12,7 @@ representation to avoid ambiguities over which characters were escaped. ## Examples -The following is a table of examples converting some common Unix paths to their +The following is a table of examples converting some common UNIX paths to their Multiaddr string form. | Unix Path | Multiaddr string form | @@ -33,5 +33,29 @@ Multiaddr string form. appear anywhere, for example in the case where we route through some sort of proxy server or SSH tunnel. -The absence of a `/` character at the start of the decoded address indicates a -relative path, otherwise the path is absolute. +# `unix-abstract` + +This protocol encodes a Linux UNIX-domain abstract socket address, +which are distinguished by their first byte being 0. +It is encoded the same way as `unix`; +the marker byte is not part of the path. + +## Examples + +In the following table, the address column follows the userspace convention +of 0 bytes in the address being rendered as an `@` for abstract addresses +for display only. + +| Rendered Address | multiaddr string form | +| -------------------------------------------- | ------------------------------------------------------------------ | +| @f87a1c847a4ecaf3/bus/systemd/bus-api-system | `/unix-abstract/f87a1c847a4ecaf3%2Fbus%2Fsystemd%2Fbus-api-system` | +| @/run/fsid.sock@@@@@@@@@@@@@@@@@@@@@@@@@@... | `/unix-abstract/%2Frun%2Ffsid.sock%00%00%00%00%00%00%00%00%00...` | + +# `stream`, `seqpacket`, `dgram` + +These correspond to the *type* of UNIX-domain socket: +`SOCK_STREAM`, `SOCK_SEQPACKET`, `SOCK_DGRAM`. + +Previous versions of this specification did not contain these types; +for compatibility, their absence should not indicate an error, +if a default makes sense when decoding.