source: code/trunk/doc/ext/bouncer-networks.md@ 536

Last change on this file since 536 was 535, checked in by contact, 4 years ago

Introduce the soju.im/bouncer-networks-notify capability

File size: 8.8 KB
Line 
1---
2title: Bouncer networks extension
3layout: spec
4work-in-progress: true
5copyrights:
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
18This is an experimental specification for a vendored extension.
19
20No guarantees are made regarding the stability of this extension.
21Backwards-incompatible changes can be made at any time without prior notice.
22
23Software implementing this work-in-progress specification MUST NOT use the
24unprefixed `bouncer-networks` CAP names. Instead, implementations SHOULD use
25the `soju.im/bouncer-networks` CAP names to be interoperable with other software
26implementing a compatible work-in-progress version.
27
28## Description
29
30This document describes the `bouncer-networks` extension. This enables clients
31to discover servers that are bouncers, list and edit upstream networks the
32bouncer is connected to.
33
34Each network has a unique per-user ID called "netid". It MUST NOT change during
35the lifetime of the network. TODO: character restrictions for network IDs.
36
37Networks also have attributes. Attributes are encoded in the message-tag
38format. Clients MUST ignore unknown attributes.
39
40## Implementation
41
42The `bouncer-networks` extension defines a new `RPL_ISUPPORT` token and a new
43`BOUNCER` command.
44
45The `bouncer-networks` capability MUST be negociated. This allows the server and
46client to behave differently when the client is aware of the bouncer networks.
47
48The `bouncer-networks-notify` capability MAY be negociated. This allows the
49client to signal that it is capable of receiving and correctly processing
50bouncer network notifications.
51
52### `RPL_ISUPPORT` token
53
54The server can advertise a `BOUNCER_NETID` token in its `RPL_ISUPPORT` message.
55Its optional value is the network ID bound for the current connection.
56
57### `bouncer-networks` batch
58
59The `bouncer-networks` batch does not take any parameter and can only contain
60`BOUNCER NETWORK` messages.
61
62### `BOUNCER` command
63
64A new `BOUNCER` command is introduced. It has a case-insensitive subcommand:
65
66 BOUNCER <subcommand> <params...>
67
68#### `BIND` subcommand
69
70The `BIND` subcommand selects an upstream network to bind to for the lifetime
71of the current connection. Clients can only send it after authentication but
72before the registration completes.
73
74 BOUNCER BIND <netid>
75
76#### `LISTNETWORKS` subcommand
77
78The `LISTNETWORKS` subcommand queries the list of upstream networks.
79
80 BOUNCER LISTNETWORKS
81
82The 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
89The `ADDNETWORK` subcommand registers a new upstream network in the bouncer.
90
91 BOUNCER ADDNETWORK <attributes>
92
93The bouncer MAY reject this new network for any reason, in this case it MUST
94reply with an error. If the request is accepted, the bouncer MUST generate a
95new unique network ID. The bouncer MAY populate unspecified attributes with
96implementation-defined defaults.
97
98Clients MUST specify at least the `host` attribute.
99
100If the client doesn't specify the `tls` attribute, the server SHOULD use the
101default `1`. If the client doesn't specify the `port` attribute, the server
102SHOULD use the default `6697` if `tls=1` or `6667` if `tls=0`.
103
104On success, the server replies with:
105
106 BOUNCER ADDNETWORK <netid>
107
108#### `CHANGENETWORK` subcommand
109
110The `CHANGENETWORK` subcommand changes attributes of an existing upstream
111network.
112
113 BOUNCER CHANGENETWORK <netid> <attributes>
114
115The bouncer MAY reject the change for any reason, in this case it MUST reply
116with an error. At least one attribute MUST be specified by the client.
117
118On success, the server replies with:
119
120 BOUNCER CHANGENETWORK <netid>
121
122#### `DELNETWORK` subcommand
123
124The `DELNETWORK` subcommand removes an existing upstream network.
125
126 BOUNCER DELNETWORK <netid>
127
128The bouncer MAY reject the change for any reason, in this case it MUST reply
129with an error.
130
131On success, the server replies with:
132
133 BOUNCER DELNETWORK <netid>
134
135### Network notifications
136
137If the client has negociated the `bouncer-networks-notify` capability, the
138server MUST send an initial batch of `BOUNCER NETWORK` messages with the current
139list of network, and MUST send notification messages whenever a network is
140added, updated or removed.
141
142If the client has not negociated the `bouncer-networks-notify` capability, the
143server MUST NOT send implicit `BOUNCER NETWORK` messages.
144
145When network attributes are updated, the bouncer MUST broadcast a
146`BOUNCER NETWORK` message with the updated attributes to all connected clients
147with the `bouncer-networks-notify` capability enabled:
148
149 BOUNCER NETWORK <netid> <attributes>
150
151The notification SHOULD NOT contain attributes that haven't been updated.
152
153When a network is removed, the bouncer MUST broadcast a `BOUNCER NETWORK`
154message 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
161Errors are returned using the standard replies syntax. The general syntax is:
162
163 FAIL BOUNCER <code> <subcommand> [context...] <description>
164
165If 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
171If a client sends a `BIND` subcommand before authentication, the server MAY
172reply with:
173
174 FAIL BOUNCER ACCOUNT_REQUIRED BIND :Authentication required
175
176#### `REGISTRATION_IS_COMPLETED` error
177
178If a client sends a `BIND` subcommand after registration, the server MAY reply
179with:
180
181 FAIL BOUNCER REGISTRATION_IS_COMPLETED BIND :Cannot bind to a network after registration
182
183#### `INVALID_NETID` error
184
185If a client sends a subcommand with an invalid network ID, the server MUST
186reply with:
187
188 FAIL BOUNCER INVALID_NETID <subcommand> <netid> :Network not found
189
190#### `INVALID_ATTRIBUTE` error
191
192If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
193invalid attribute, the server MUST reply with:
194
195 FAIL BOUNCER INVALID_ATTRIBUTE <subcommand> <netid> <attribute> :Invalid attribute value
196
197If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
198value.
199
200#### `READ_ONLY_ATTRIBUTE` error
201
202If 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
207If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
208value.
209
210#### `UNKNOWN_ATTRIBUTE` error
211
212If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
213unknown attribute, the server MUST reply with:
214
215 FAIL BOUNCER UNKNOWN_ATTRIBUTE <subcommand> <netid> <attribute> :Unknown attribute
216
217If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
218value.
219
220#### `NEED_ATTRIBUTE` error
221
222If a client sends an `ADDNETWORK` subcommand without a mandatory attribute, the
223server MUST reply with:
224
225 FAIL BOUNCER NEED_ATTRIBUTE ADDNETWORK <attribute> :Missing required attribute
226
227TODO: more errors
228
229### Standard network attributes
230
231Bouncers 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
244TODO: more attributes
245
246### Examples
247
248Binding 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
259Listing 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
267Adding 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
274Changing an existing network:
275
276 C: BOUNCER CHANGENETWORK 44 realname=Simon
277 S: BOUNCER NETWORK 44 realname=Simon
278 S: BOUNCER CHANGENETWORK 44
279
280Removing an existing network:
281
282 C: BOUNCER DELNETWORK 44
283 S: BOUNCER NETWORK 44 *
284 S: BOUNCER DELNETWORK 44
Note: See TracBrowser for help on using the repository browser.