|
| 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 | +| / | `/unix/%2F` | |
| 21 | +| /file.socket | `/unix/%2Ffile.socket` | |
| 22 | +| /dir/file.socket | `/unix/%2Fdir%2Ffile.socket` | |
| 23 | +| /dir/file.socket/p2p/12D... | `/unix/%2Fdir%2Ffile.socket/p2p/12D...` | |
| 24 | +| /tmp/foo/../bar | `/unix/%2Ftmp%2Ffoo%2F..%2Fbar` | |
| 25 | +| /%2F | `/unix/%252F` | |
| 26 | +| /a%20space | `/unix/%2Fa%2520space` | |
| 27 | +| /a%2Fslash | `/unix/%2Fa%252Fslash` | |
| 28 | +| socket | `/unix/socket` | |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +`/unix` would typically be found at the start of a multiaddr, however it may |
| 33 | +appear anywhere, for example in the case where we route through some sort of |
| 34 | +proxy server or SSH tunnel. |
| 35 | + |
| 36 | +The absence of a `/` character at the start of the decoded address indicates a |
| 37 | +relative path, otherwise the path is absolute. |
0 commit comments