1 | ---
|
---|
2 | title: Bouncer networks extension
|
---|
3 | layout: spec
|
---|
4 | work-in-progress: true
|
---|
5 | copyrights:
|
---|
6 | -
|
---|
7 | name: "Darren Whitlen"
|
---|
8 | period: "2020"
|
---|
9 | email: "darren@kiwiirc.com"
|
---|
10 | -
|
---|
11 | name: "Simon Ser"
|
---|
12 | period: "2021"
|
---|
13 | email: "contact@emersion.fr"
|
---|
14 | ---
|
---|
15 |
|
---|
16 | ## Notes for implementing experimental vendor extension
|
---|
17 |
|
---|
18 | This is an experimental specification for a vendored extension.
|
---|
19 |
|
---|
20 | No guarantees are made regarding the stability of this extension.
|
---|
21 | Backwards-incompatible changes can be made at any time without prior notice.
|
---|
22 |
|
---|
23 | Software implementing this work-in-progress specification MUST NOT use the
|
---|
24 | unprefixed `bouncer-networks` CAP names. Instead, implementations SHOULD use
|
---|
25 | the `soju.im/bouncer-networks` CAP names to be interoperable with other software
|
---|
26 | implementing a compatible work-in-progress version.
|
---|
27 |
|
---|
28 | ## Description
|
---|
29 |
|
---|
30 | This document describes the `bouncer-networks` extension. This enables clients
|
---|
31 | to discover servers that are bouncers, list and edit upstream networks the
|
---|
32 | bouncer is connected to.
|
---|
33 |
|
---|
34 | Each network has a unique per-user ID called "netid". It MUST NOT change during
|
---|
35 | the lifetime of the network. TODO: character restrictions for network IDs.
|
---|
36 |
|
---|
37 | Networks also have attributes. Attributes are encoded in the message-tag
|
---|
38 | format. Clients MUST ignore unknown attributes.
|
---|
39 |
|
---|
40 | ## Implementation
|
---|
41 |
|
---|
42 | The `bouncer-networks` extension defines a new `RPL_ISUPPORT` token and a new
|
---|
43 | `BOUNCER` command.
|
---|
44 |
|
---|
45 | The `bouncer-networks` capability MUST be negociated. This allows the server and
|
---|
46 | client to behave differently when the client is aware of the bouncer networks.
|
---|
47 |
|
---|
48 | The `bouncer-networks-notify` capability MAY be negociated. This allows the
|
---|
49 | client to signal that it is capable of receiving and correctly processing
|
---|
50 | bouncer network notifications.
|
---|
51 |
|
---|
52 | ### `RPL_ISUPPORT` token
|
---|
53 |
|
---|
54 | The server can advertise a `BOUNCER_NETID` token in its `RPL_ISUPPORT` message.
|
---|
55 | Its optional value is the network ID bound for the current connection.
|
---|
56 |
|
---|
57 | ### `bouncer-networks` batch
|
---|
58 |
|
---|
59 | The `bouncer-networks` batch does not take any parameter and can only contain
|
---|
60 | `BOUNCER NETWORK` messages.
|
---|
61 |
|
---|
62 | ### `BOUNCER` command
|
---|
63 |
|
---|
64 | A new `BOUNCER` command is introduced. It has a case-insensitive subcommand:
|
---|
65 |
|
---|
66 | BOUNCER <subcommand> <params...>
|
---|
67 |
|
---|
68 | #### `BIND` subcommand
|
---|
69 |
|
---|
70 | The `BIND` subcommand selects an upstream network to bind to for the lifetime
|
---|
71 | of the current connection. Clients can only send it after authentication but
|
---|
72 | before the registration completes.
|
---|
73 |
|
---|
74 | BOUNCER BIND <netid>
|
---|
75 |
|
---|
76 | #### `LISTNETWORKS` subcommand
|
---|
77 |
|
---|
78 | The `LISTNETWORKS` subcommand queries the list of upstream networks.
|
---|
79 |
|
---|
80 | BOUNCER LISTNETWORKS
|
---|
81 |
|
---|
82 | The server replies with a `bouncer-networks` batch, containing any number of
|
---|
83 | `BOUNCER NETWORK` messages:
|
---|
84 |
|
---|
85 | BOUNCER NETWORK <netid> <attributes>
|
---|
86 |
|
---|
87 | #### `ADDNETWORK` subcommand
|
---|
88 |
|
---|
89 | The `ADDNETWORK` subcommand registers a new upstream network in the bouncer.
|
---|
90 |
|
---|
91 | BOUNCER ADDNETWORK <attributes>
|
---|
92 |
|
---|
93 | The bouncer MAY reject this new network for any reason, in this case it MUST
|
---|
94 | reply with an error. If the request is accepted, the bouncer MUST generate a
|
---|
95 | new unique network ID. The bouncer MAY populate unspecified attributes with
|
---|
96 | implementation-defined defaults.
|
---|
97 |
|
---|
98 | Clients MUST specify at least the `host` attribute.
|
---|
99 |
|
---|
100 | If the client doesn't specify the `tls` attribute, the server SHOULD use the
|
---|
101 | default `1`. If the client doesn't specify the `port` attribute, the server
|
---|
102 | SHOULD use the default `6697` if `tls=1` or `6667` if `tls=0`.
|
---|
103 |
|
---|
104 | On success, the server replies with:
|
---|
105 |
|
---|
106 | BOUNCER ADDNETWORK <netid>
|
---|
107 |
|
---|
108 | #### `CHANGENETWORK` subcommand
|
---|
109 |
|
---|
110 | The `CHANGENETWORK` subcommand changes attributes of an existing upstream
|
---|
111 | network.
|
---|
112 |
|
---|
113 | BOUNCER CHANGENETWORK <netid> <attributes>
|
---|
114 |
|
---|
115 | The bouncer MAY reject the change for any reason, in this case it MUST reply
|
---|
116 | with an error. At least one attribute MUST be specified by the client.
|
---|
117 |
|
---|
118 | On success, the server replies with:
|
---|
119 |
|
---|
120 | BOUNCER CHANGENETWORK <netid>
|
---|
121 |
|
---|
122 | #### `DELNETWORK` subcommand
|
---|
123 |
|
---|
124 | The `DELNETWORK` subcommand removes an existing upstream network.
|
---|
125 |
|
---|
126 | BOUNCER DELNETWORK <netid>
|
---|
127 |
|
---|
128 | The bouncer MAY reject the change for any reason, in this case it MUST reply
|
---|
129 | with an error.
|
---|
130 |
|
---|
131 | On success, the server replies with:
|
---|
132 |
|
---|
133 | BOUNCER DELNETWORK <netid>
|
---|
134 |
|
---|
135 | ### Network notifications
|
---|
136 |
|
---|
137 | If the client has negociated the `bouncer-networks-notify` capability, the
|
---|
138 | server MUST send an initial batch of `BOUNCER NETWORK` messages with the current
|
---|
139 | list of network, and MUST send notification messages whenever a network is
|
---|
140 | added, updated or removed.
|
---|
141 |
|
---|
142 | If the client has not negociated the `bouncer-networks-notify` capability, the
|
---|
143 | server MUST NOT send implicit `BOUNCER NETWORK` messages.
|
---|
144 |
|
---|
145 | When network attributes are updated, the bouncer MUST broadcast a
|
---|
146 | `BOUNCER NETWORK` message with the updated attributes to all connected clients
|
---|
147 | with the `bouncer-networks-notify` capability enabled:
|
---|
148 |
|
---|
149 | BOUNCER NETWORK <netid> <attributes>
|
---|
150 |
|
---|
151 | The notification SHOULD NOT contain attributes that haven't been updated.
|
---|
152 |
|
---|
153 | When a network is removed, the bouncer MUST broadcast a `BOUNCER NETWORK`
|
---|
154 | message with the special argument `*` to all connected clients with the
|
---|
155 | `bouncer-networks-notify` capability enabled:
|
---|
156 |
|
---|
157 | BOUNCER NETWORK <netid> *
|
---|
158 |
|
---|
159 | ### Errors
|
---|
160 |
|
---|
161 | Errors are returned using the standard replies syntax. The general syntax is:
|
---|
162 |
|
---|
163 | FAIL BOUNCER <code> <subcommand> [context...] <description>
|
---|
164 |
|
---|
165 | If a client sends an unknown subcommand, the server MUST reply with:
|
---|
166 |
|
---|
167 | FAIL BOUNCER UNKNOWN_COMMAND <subcommand> :Unknown subcommand
|
---|
168 |
|
---|
169 | #### `ACCOUNT_REQUIRED` error
|
---|
170 |
|
---|
171 | If a client sends a `BIND` subcommand before authentication, the server MAY
|
---|
172 | reply with:
|
---|
173 |
|
---|
174 | FAIL BOUNCER ACCOUNT_REQUIRED BIND :Authentication required
|
---|
175 |
|
---|
176 | #### `REGISTRATION_IS_COMPLETED` error
|
---|
177 |
|
---|
178 | If a client sends a `BIND` subcommand after registration, the server MAY reply
|
---|
179 | with:
|
---|
180 |
|
---|
181 | FAIL BOUNCER REGISTRATION_IS_COMPLETED BIND :Cannot bind to a network after registration
|
---|
182 |
|
---|
183 | #### `INVALID_NETID` error
|
---|
184 |
|
---|
185 | If a client sends a subcommand with an invalid network ID, the server MUST
|
---|
186 | reply with:
|
---|
187 |
|
---|
188 | FAIL BOUNCER INVALID_NETID <subcommand> <netid> :Network not found
|
---|
189 |
|
---|
190 | #### `INVALID_ATTRIBUTE` error
|
---|
191 |
|
---|
192 | If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
|
---|
193 | invalid attribute, the server MUST reply with:
|
---|
194 |
|
---|
195 | FAIL BOUNCER INVALID_ATTRIBUTE <subcommand> <netid> <attribute> :Invalid attribute value
|
---|
196 |
|
---|
197 | If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
|
---|
198 | value.
|
---|
199 |
|
---|
200 | #### `READ_ONLY_ATTRIBUTE` error
|
---|
201 |
|
---|
202 | If a client attempts to change a read-only network attribute using the
|
---|
203 | `ADDNETWORK` or `CHANGENETWORK` subcommand, the server MUST reply with:
|
---|
204 |
|
---|
205 | FAIL BOUNCER READ_ONLY_ATTRIBUTE <subcommand> <netid> <attribute> :Read-only attribute
|
---|
206 |
|
---|
207 | If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
|
---|
208 | value.
|
---|
209 |
|
---|
210 | #### `UNKNOWN_ATTRIBUTE` error
|
---|
211 |
|
---|
212 | If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
|
---|
213 | unknown attribute, the server MUST reply with:
|
---|
214 |
|
---|
215 | FAIL BOUNCER UNKNOWN_ATTRIBUTE <subcommand> <netid> <attribute> :Unknown attribute
|
---|
216 |
|
---|
217 | If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
|
---|
218 | value.
|
---|
219 |
|
---|
220 | #### `NEED_ATTRIBUTE` error
|
---|
221 |
|
---|
222 | If a client sends an `ADDNETWORK` subcommand without a mandatory attribute, the
|
---|
223 | server MUST reply with:
|
---|
224 |
|
---|
225 | FAIL BOUNCER NEED_ATTRIBUTE ADDNETWORK <attribute> :Missing required attribute
|
---|
226 |
|
---|
227 | TODO: more errors
|
---|
228 |
|
---|
229 | ### Standard network attributes
|
---|
230 |
|
---|
231 | Bouncers MUST recognise the following network attributes:
|
---|
232 |
|
---|
233 | * `name`: the human-readable name for the network.
|
---|
234 | * `state` (read-only): one of `connected`, `connecting` or `disconnected`.
|
---|
235 | Indicates the current state of the connection to the upstream network.
|
---|
236 | * `host`: the hostname or literal IP address to connect to.
|
---|
237 | * `port`: the TCP port to connect to.
|
---|
238 | * `tls`: `1` to use a TLS connection, `0` to use a cleartext connection.
|
---|
239 | * `nickname`: the nickname to use during registration.
|
---|
240 | * `username`: the username to use during registration.
|
---|
241 | * `realname`: the realname to use during registration.
|
---|
242 | * `pass`: the server password (PASS) to use during registration.
|
---|
243 |
|
---|
244 | TODO: more attributes
|
---|
245 |
|
---|
246 | ### Examples
|
---|
247 |
|
---|
248 | Binding to a network:
|
---|
249 |
|
---|
250 | C: CAP LS 302
|
---|
251 | C: NICK emersion
|
---|
252 | C: USER emersion 0 0 :Simon
|
---|
253 | S: CAP * LS :sasl=PLAIN bouncer-networks bouncer-networks-notify
|
---|
254 | C: CAP REQ :sasl bouncer-networks
|
---|
255 | [SASL authentication]
|
---|
256 | C: BOUNCER BIND 42
|
---|
257 | C: CAP END
|
---|
258 |
|
---|
259 | Listing networks:
|
---|
260 |
|
---|
261 | C: BOUNCER LISTNETWORKS
|
---|
262 | S: BATCH +asdf bouncer-networks
|
---|
263 | S: @batch=asdf BOUNCER NETWORK 42 name=Freenode;state=connected
|
---|
264 | S: @batch=asdf BOUNCER NETWORK 43 name=My\sAwesome\sNetwork;state=disconnected
|
---|
265 | S: BATCH -asdf
|
---|
266 |
|
---|
267 | Adding a new network:
|
---|
268 |
|
---|
269 | C: BOUNCER ADDNETWORK name=OFTC;host=irc.oftc.net
|
---|
270 | S: BOUNCER NETWORK 44 name=OFTC;host=irc.oftc.net;status=connecting
|
---|
271 | S: BOUNCER ADDNETWORK 44
|
---|
272 | S: BOUNCER NETWORK 44 status=connected
|
---|
273 |
|
---|
274 | Changing an existing network:
|
---|
275 |
|
---|
276 | C: BOUNCER CHANGENETWORK 44 realname=Simon
|
---|
277 | S: BOUNCER NETWORK 44 realname=Simon
|
---|
278 | S: BOUNCER CHANGENETWORK 44
|
---|
279 |
|
---|
280 | Removing an existing network:
|
---|
281 |
|
---|
282 | C: BOUNCER DELNETWORK 44
|
---|
283 | S: BOUNCER NETWORK 44 *
|
---|
284 | S: BOUNCER DELNETWORK 44
|
---|