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

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

Add pass to bouncer network attributes

File size: 7.8 KB
RevLine 
[532]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
45### `RPL_ISUPPORT` token
46
47The server can advertise a `BOUNCER_NETID` token in its `RPL_ISUPPORT` message.
48Its optional value is the network ID bound for the current connection.
49
50### `bouncer-networks` batch
51
52The `bouncer-networks` batch does not take any parameter and can only contain
53`BOUNCER NETWORK` messages.
54
55### `BOUNCER` command
56
57A new `BOUNCER` command is introduced. It has a case-insensitive subcommand:
58
59 BOUNCER <subcommand> <params...>
60
61#### `BIND` subcommand
62
63The `BIND` subcommand selects an upstream network to bind to for the lifetime
64of the current connection. Clients can only send it after authentication but
65before the registration completes.
66
67 BOUNCER BIND <netid>
68
69#### `LISTNETWORKS` subcommand
70
71The `LISTNETWORKS` subcommand queries the list of upstream networks.
72
73 BOUNCER LISTNETWORKS
74
75The server replies with a `bouncer-networks` batch, containing any number of
76`BOUNCER NETWORK` messages:
77
78 BOUNCER NETWORK <netid> <attributes>
79
80#### `ADDNETWORK` subcommand
81
82The `ADDNETWORK` subcommand registers a new upstream network in the bouncer.
83
84 BOUNCER ADDNETWORK <attributes>
85
86The bouncer MAY reject this new network for any reason, in this case it MUST
87reply with an error. If the request is accepted, the bouncer MUST generate a
88new unique network ID. The bouncer MAY populate unspecified attributes with
89implementation-defined defaults.
90
91Clients MUST specify at least the `host` attribute.
92
93If the client doesn't specify the `tls` attribute, the server SHOULD use the
94default `1`. If the client doesn't specify the `port` attribute, the server
95SHOULD use the default `6697` if `tls=1` or `6667` if `tls=0`.
96
97On success, the server replies with:
98
99 BOUNCER ADDNETWORK <netid>
100
101#### `CHANGENETWORK` subcommand
102
103The `CHANGENETWORK` subcommand changes attributes of an existing upstream
104network.
105
106 BOUNCER CHANGENETWORK <netid> <attributes>
107
108The bouncer MAY reject the change for any reason, in this case it MUST reply
109with an error. At least one attribute MUST be specified by the client.
110
111On success, the server replies with:
112
113 BOUNCER CHANGENETWORK <netid>
114
115#### `DELNETWORK` subcommand
116
117The `DELNETWORK` subcommand removes an existing upstream network.
118
119 BOUNCER DELNETWORK <netid>
120
121The bouncer MAY reject the change for any reason, in this case it MUST reply
122with an error.
123
124On success, the server replies with:
125
126 BOUNCER DELNETWORK <netid>
127
128### Network notifications
129
130When a network attributes are updated, the bouncer MUST broadcast a
131`BOUNCER NETWORK` message to all connected clients with the updated attributes:
132
133 BOUNCER NETWORK <netid> <attributes>
134
135When a network is removed, the bouncer MUST broadcast a `BOUNCER NETWORK`
136message to all connected clients:
137
138 BOUNCER NETWORK <netid> *
139
140### Errors
141
142Errors are returned using the standard replies syntax. The general syntax is:
143
144 FAIL BOUNCER <code> <subcommand> [context...] <description>
145
146If a client sends an unknown subcommand, the server MUST reply with:
147
148 FAIL BOUNCER UNKNOWN_COMMAND <subcommand> :Unknown subcommand
149
150#### `ACCOUNT_REQUIRED` error
151
152If a client sends a `BIND` subcommand before authentication, the server MAY
153reply with:
154
155 FAIL BOUNCER ACCOUNT_REQUIRED BIND :Authentication required
156
157#### `REGISTRATION_IS_COMPLETED` error
158
159If a client sends a `BIND` subcommand after registration, the server MAY reply
160with:
161
162 FAIL BOUNCER REGISTRATION_IS_COMPLETED BIND :Cannot bind to a network after registration
163
164#### `INVALID_NETID` error
165
166If a client sends a subcommand with an invalid network ID, the server MUST
167reply with:
168
169 FAIL BOUNCER INVALID_NETID <subcommand> <netid> :Network not found
170
171#### `INVALID_ATTRIBUTE` error
172
173If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
174invalid attribute, the server MUST reply with:
175
176 FAIL BOUNCER INVALID_ATTRIBUTE <subcommand> <netid> <attribute> :Invalid attribute value
177
178If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
179value.
180
181#### `READ_ONLY_ATTRIBUTE` error
182
183If a client attempts to change a read-only network attribute using the
184`ADDNETWORK` or `CHANGENETWORK` subcommand, the server MUST reply with:
185
186 FAIL BOUNCER READ_ONLY_ATTRIBUTE <subcommand> <netid> <attribute> :Read-only attribute
187
188If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
189value.
190
191#### `UNKNOWN_ATTRIBUTE` error
192
193If a client sends an `ADDNETWORK` or a `CHANGENETWORK` subcommand with an
194unknown attribute, the server MUST reply with:
195
196 FAIL BOUNCER UNKNOWN_ATTRIBUTE <subcommand> <netid> <attribute> :Unknown attribute
197
198If the `subcommand` is `ADDNETWORK`, `netid` MUST be set to the special `*`
199value.
200
201#### `NEED_ATTRIBUTE` error
202
203If a client sends an `ADDNETWORK` subcommand without a mandatory attribute, the
204server MUST reply with:
205
206 FAIL BOUNCER NEED_ATTRIBUTE ADDNETWORK <attribute> :Missing required attribute
207
208TODO: more errors
209
210### Standard network attributes
211
212Bouncers MUST recognise the following network attributes:
213
214* `name`: the human-readable name for the network.
215* `state` (read-only): one of `connected`, `connecting` or `disconnected`.
216 Indicates the current state of the connection to the upstream network.
217* `host`: the hostname or literal IP address to connect to.
218* `port`: the TCP port to connect to.
219* `tls`: `1` to use a TLS connection, `0` to use a cleartext connection.
220* `nickname`: the nickname to use during registration.
221* `username`: the username to use during registration.
222* `realname`: the realname to use during registration.
[533]223* `pass`: the server password (PASS) to use during registration.
[532]224
225TODO: more attributes
226
227### Examples
228
229Binding to a network:
230
231 C: CAP LS 302
232 C: NICK emersion
233 C: USER emersion 0 0 :Simon
234 S: CAP * LS :sasl=PLAIN bouncer-networks
235 C: CAP REQ :sasl bouncer-networks
236 [SASL authentication]
237 C: BOUNCER BIND 42
238 C: CAP END
239
240Listing networks:
241
242 C: BOUNCER LISTNETWORKS
243 S: BATCH +asdf bouncer-networks
244 S: @batch=asdf BOUNCER NETWORK 42 name=Freenode;state=connected
245 S: @batch=asdf BOUNCER NETWORK 43 name=My\sAwesome\sNetwork;state=disconnected
246 S: BATCH -asdf
247
248Adding a new network:
249
250 C: BOUNCER ADDNETWORK name=OFTC;host=irc.oftc.net
251 S: BOUNCER NETWORK 44 status=connecting
252 S: BOUNCER ADDNETWORK 44
253 S: BOUNCER NETWORK 44 status=connected
254
255Changing an existing network:
256
257 C: BOUNCER CHANGENETWORK 44 realname=Simon
258 S: BOUNCER NETWORK 44 realname=Simon
259 S: BOUNCER CHANGENETWORK 44
260
261Removing an existing network:
262
263 C: BOUNCER DELNETWORK 44
264 S: BOUNCER NETWORK 44 *
265 S: BOUNCER DELNETWORK 44
Note: See TracBrowser for help on using the repository browser.