Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion protocols.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
32 changes: 28 additions & 4 deletions protocols/unix.md
Original file line number Diff line number Diff line change
@@ -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).

Expand All @@ -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 |
Expand All @@ -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.