|
| 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 | + |
| 46 | +| Rendered Address | multiaddr string form | |
| 47 | +| -------------------------------------------- | ------------------------------------------------------------------ | |
| 48 | +| @f87a1c847a4ecaf3/bus/systemd/bus-api-system | `/unix-abstract/f87a1c847a4ecaf3%2Fbus%2Fsystemd%2Fbus-api-system` | |
| 49 | +| @/run/fsid.sock@@@@@@@@@@@@@@@@@@@@@@@@@@... | `/unix-abstract/%2Frun%2Ffsid.sock%00%00%00%00%00%00%00%00%00...` | |
| 50 | + |
| 51 | +# `stream`, `seqpacket`, `dgram` |
| 52 | + |
| 53 | +These correspond to the *type* of UNIX-domain socket: |
| 54 | +`SOCK_STREAM`, `SOCK_SEQPACKET`, `SOCK_DGRAM`. |
| 55 | + |
| 56 | +Previous versions of this specification did not contain these types; |
| 57 | +for compatibility, their absence should not indicate an error, |
| 58 | +if a default makes sense when decoding. |
0 commit comments