Skip to content

Commit eb8e465

Browse files
Specify /unix. Add /unix-abstract. Add /stream, /seqpacket, /dgram
Based on #174
1 parent 9b7b3fa commit eb8e465

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ TODO: most of these are way underspecified
152152
- /ipcidr
153153
- /dns4, /dns6
154154
- [/dnsaddr](protocols/DNSADDR.md)
155+
- [/unix](protocols/unix.md)
156+
- [/unix-abstract](protocols/unix.md)
155157
- /tcp
156158
- /udp
157159
- /utp

protocols.csv

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ code, size, name, comment
22
4, 32, ip4,
33
6, 16, tcp,
44
273, 16, udp,
5+
403, 0, stream,
6+
404, 0, seqpacket,
7+
405, 0, dgram,
58
33, 16, dccp,
69
41, 128, ip6,
710
42, V, ip6zone, rfc4007 IPv6 zone
@@ -13,7 +16,8 @@ code, size, name, comment
1316
132, 16, sctp,
1417
301, 0, udt,
1518
302, 0, utp,
16-
400, V, unix,
19+
400, V, unix, Percent-encoded path to a unix-domain socket
20+
401, V, unix-abstract, Percent-encoded address of a linux abstract unix-domain socket
1721
421, V, p2p, preferred over /ipfs
1822
421, V, ipfs, backwards compatibility; equivalent to /p2p
1923
444, 96, onion,
@@ -39,4 +43,4 @@ code, size, name, comment
3943
280, 0, webrtc-direct, ICE-lite webrtc transport with SDP munging during connection establishment and without use of a STUN server
4044
281, 0, webrtc, webrtc transport where connection establishment is according to w3c spec
4145
290, 0, p2p-circuit,
42-
777, V, memory, in memory transport for self-dialing and testing; arbitrary
46+
777, V, memory, in memory transport for self-dialing and testing; arbitrary

protocols/unix.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# `unix`
2+
3+
This protocol encodes a UNIX-domain socket path to a resource. In the string
4+
representation, the path is encoded in a way consistent with a single URI Path
5+
segment per [RFC 3986 Section 3.3](https://datatracker.ietf.org/doc/html/rfc3986#autoid-23).
6+
7+
Specifically following the grammar of a single `segment-nz`. In the binary
8+
representation, no encoding is needed as the value is length prefixed.
9+
10+
When comparing multiaddrs, implementations should compare their binary
11+
representation to avoid ambiguities over which characters were escaped.
12+
13+
## Examples
14+
15+
The following is a table of examples converting some common UNIX paths to their
16+
Multiaddr string form.
17+
18+
| Unix Path | Multiaddr string form |
19+
| --------------------------- | --------------------------------------- |
20+
| socket | `/unix/socket` |
21+
| /run/unbound.ctl | `/unix/%2Frun%2Funbound.ctl` |
22+
| /run/user/1000/gnupg/S.g... | `/unix/%2Frun%2Fuser%2F1000%2Fgnupg...` |
23+
| real space | `/unix/fake%20space` |
24+
| real/slash | `/unix/real%2Fslash` |
25+
| fake%20space | `/unix/fake%2520space` |
26+
| fake%2Fslash | `/unix/fake%252Fslash` |
27+
28+
## Usage
29+
30+
`/unix` would typically be found at the start of a multiaddr, however it may
31+
appear anywhere, for example in the case where we route through some sort of
32+
proxy server or SSH tunnel.
33+
34+
# `unix-abstract`
35+
36+
This protocol encodes a Linux UNIX-domain abstract socket address,
37+
which are distinguished by their first byte being 0.
38+
It is encoded the same way as `unix`;
39+
the marker byte is not part of the path.
40+
41+
## Examples
42+
43+
In the following table, the address column follows the userspace convention
44+
of 0 bytes in the address being rendered as an `@` for abstract addresses
45+
for display only.
46+
47+
| Rendered Address | multiaddr string form |
48+
| -------------------------------------------- | ------------------------------------------------------------------ |
49+
| @f87a1c847a4ecaf3/bus/systemd/bus-api-system | `/unix-abstract/f87a1c847a4ecaf3%2Fbus%2Fsystemd%2Fbus-api-system` |
50+
| @/run/fsid.sock@@@@@@@@@@@@@@@@@@@@@@@@@@... | `/unix-abstract/%2Frun%2Ffsid.sock%00%00%00%00%00%00%00%00%00...` |
51+
52+
# `stream`, `seqpacket`, `dgram`
53+
54+
These correspond to the *type* of UNIX-domain socket:
55+
`SOCK_STREAM`, `SOCK_SEQPACKET`, `SOCK_DGRAM`.
56+
57+
Previous versions of this specification did not contain these types;
58+
for compatibility, their absence should not indicate an error,
59+
if a default makes sense when decoding.

0 commit comments

Comments
 (0)