@honeybbq/teamspeak 0.0.1 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +726 -2
- package/dist/client/abort.d.ts +5 -0
- package/dist/client/abort.d.ts.map +1 -0
- package/dist/client/abort.js +23 -0
- package/dist/client/abort.js.map +1 -0
- package/dist/client/address.d.ts +17 -0
- package/dist/client/address.d.ts.map +1 -0
- package/dist/client/address.js +66 -0
- package/dist/client/address.js.map +1 -0
- package/dist/client/api/voice.d.ts +24 -0
- package/dist/client/api/voice.d.ts.map +1 -0
- package/dist/client/api/voice.js +33 -0
- package/dist/client/api/voice.js.map +1 -0
- package/dist/client/capabilities.d.ts +68 -0
- package/dist/client/capabilities.d.ts.map +1 -0
- package/dist/client/capabilities.js +59 -0
- package/dist/client/capabilities.js.map +1 -0
- package/dist/client/client.d.ts +196 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +1523 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/commands.d.ts +66 -0
- package/dist/client/commands.d.ts.map +1 -0
- package/dist/client/commands.js +162 -0
- package/dist/client/commands.js.map +1 -0
- package/dist/client/crypto/crypt-ops.d.ts +7 -0
- package/dist/client/crypto/crypt-ops.d.ts.map +1 -0
- package/dist/client/crypto/crypt-ops.js +2 -0
- package/dist/client/crypto/crypt-ops.js.map +1 -0
- package/dist/client/crypto/crypt.d.ts +37 -0
- package/dist/client/crypto/crypt.d.ts.map +1 -0
- package/dist/client/crypto/crypt.js +203 -0
- package/dist/client/crypto/crypt.js.map +1 -0
- package/dist/client/crypto/eax.d.ts +12 -0
- package/dist/client/crypto/eax.d.ts.map +1 -0
- package/dist/client/crypto/eax.js +118 -0
- package/dist/client/crypto/eax.js.map +1 -0
- package/dist/client/crypto/identity.d.ts +97 -0
- package/dist/client/crypto/identity.d.ts.map +1 -0
- package/dist/client/crypto/identity.js +412 -0
- package/dist/client/crypto/identity.js.map +1 -0
- package/dist/client/crypto/index.d.ts +7 -0
- package/dist/client/crypto/index.d.ts.map +1 -0
- package/dist/client/crypto/index.js +5 -0
- package/dist/client/crypto/index.js.map +1 -0
- package/dist/client/crypto/primitives.d.ts +43 -0
- package/dist/client/crypto/primitives.d.ts.map +1 -0
- package/dist/client/crypto/primitives.js +116 -0
- package/dist/client/crypto/primitives.js.map +1 -0
- package/dist/client/diagnostics.d.ts +45 -0
- package/dist/client/diagnostics.d.ts.map +1 -0
- package/dist/client/diagnostics.js +30 -0
- package/dist/client/diagnostics.js.map +1 -0
- package/dist/client/discovery/index.d.ts +2 -0
- package/dist/client/discovery/index.d.ts.map +1 -0
- package/dist/client/discovery/index.js +2 -0
- package/dist/client/discovery/index.js.map +1 -0
- package/dist/client/discovery/resolver.d.ts +26 -0
- package/dist/client/discovery/resolver.d.ts.map +1 -0
- package/dist/client/discovery/resolver.js +275 -0
- package/dist/client/discovery/resolver.js.map +1 -0
- package/dist/client/errors.d.ts +82 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +201 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/events.d.ts +3 -0
- package/dist/client/events.d.ts.map +1 -0
- package/dist/client/events.js +8 -0
- package/dist/client/events.js.map +1 -0
- package/dist/client/handshake/crypt-handshake.d.ts +17 -0
- package/dist/client/handshake/crypt-handshake.d.ts.map +1 -0
- package/dist/client/handshake/crypt-handshake.js +128 -0
- package/dist/client/handshake/crypt-handshake.js.map +1 -0
- package/dist/client/handshake/crypt-init2.d.ts +7 -0
- package/dist/client/handshake/crypt-init2.d.ts.map +1 -0
- package/dist/client/handshake/crypt-init2.js +37 -0
- package/dist/client/handshake/crypt-init2.js.map +1 -0
- package/dist/client/handshake/index.d.ts +4 -0
- package/dist/client/handshake/index.d.ts.map +1 -0
- package/dist/client/handshake/index.js +4 -0
- package/dist/client/handshake/index.js.map +1 -0
- package/dist/client/handshake/license.d.ts +35 -0
- package/dist/client/handshake/license.d.ts.map +1 -0
- package/dist/client/handshake/license.js +169 -0
- package/dist/client/handshake/license.js.map +1 -0
- package/dist/client/handshake.d.ts +27 -0
- package/dist/client/handshake.d.ts.map +1 -0
- package/dist/client/handshake.js +126 -0
- package/dist/client/handshake.js.map +1 -0
- package/dist/client/helpers.d.ts +6 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +13 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/hooks.d.ts +7 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +28 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +28 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/reconnect.d.ts +12 -0
- package/dist/client/reconnect.d.ts.map +1 -0
- package/dist/client/reconnect.js +44 -0
- package/dist/client/reconnect.js.map +1 -0
- package/dist/client/throttle.d.ts +20 -0
- package/dist/client/throttle.d.ts.map +1 -0
- package/dist/client/throttle.js +83 -0
- package/dist/client/throttle.js.map +1 -0
- package/dist/client/trace.d.ts +223 -0
- package/dist/client/trace.d.ts.map +1 -0
- package/dist/client/trace.js +13 -0
- package/dist/client/trace.js.map +1 -0
- package/dist/client/transfer.d.ts +111 -0
- package/dist/client/transfer.d.ts.map +1 -0
- package/dist/client/transfer.js +243 -0
- package/dist/client/transfer.js.map +1 -0
- package/dist/client/transport/generation-window.d.ts +30 -0
- package/dist/client/transport/generation-window.d.ts.map +1 -0
- package/dist/client/transport/generation-window.js +97 -0
- package/dist/client/transport/generation-window.js.map +1 -0
- package/dist/client/transport/handler.d.ts +61 -0
- package/dist/client/transport/handler.d.ts.map +1 -0
- package/dist/client/transport/handler.js +793 -0
- package/dist/client/transport/handler.js.map +1 -0
- package/dist/client/transport/index.d.ts +6 -0
- package/dist/client/transport/index.d.ts.map +1 -0
- package/dist/client/transport/index.js +5 -0
- package/dist/client/transport/index.js.map +1 -0
- package/dist/client/transport/packet.d.ts +36 -0
- package/dist/client/transport/packet.d.ts.map +1 -0
- package/dist/client/transport/packet.js +55 -0
- package/dist/client/transport/packet.js.map +1 -0
- package/dist/client/transport/quicklz.d.ts +24 -0
- package/dist/client/transport/quicklz.d.ts.map +1 -0
- package/dist/client/transport/quicklz.js +179 -0
- package/dist/client/transport/quicklz.js.map +1 -0
- package/dist/client/types.d.ts +226 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +39 -0
- package/dist/client/types.js.map +1 -0
- package/dist/core/api/channels.d.ts +182 -0
- package/dist/core/api/channels.d.ts.map +1 -0
- package/dist/core/api/channels.js +155 -0
- package/dist/core/api/channels.js.map +1 -0
- package/dist/core/api/clients.d.ts +304 -0
- package/dist/core/api/clients.d.ts.map +1 -0
- package/dist/core/api/clients.js +260 -0
- package/dist/core/api/clients.js.map +1 -0
- package/dist/core/api/command.d.ts +305 -0
- package/dist/core/api/command.d.ts.map +1 -0
- package/dist/core/api/command.js +363 -0
- package/dist/core/api/command.js.map +1 -0
- package/dist/core/api/files.d.ts +153 -0
- package/dist/core/api/files.d.ts.map +1 -0
- package/dist/core/api/files.js +181 -0
- package/dist/core/api/files.js.map +1 -0
- package/dist/core/api/groups.d.ts +248 -0
- package/dist/core/api/groups.d.ts.map +1 -0
- package/dist/core/api/groups.js +271 -0
- package/dist/core/api/groups.js.map +1 -0
- package/dist/core/api/moderation.d.ts +205 -0
- package/dist/core/api/moderation.d.ts.map +1 -0
- package/dist/core/api/moderation.js +209 -0
- package/dist/core/api/moderation.js.map +1 -0
- package/dist/core/api/parse.d.ts +16 -0
- package/dist/core/api/parse.d.ts.map +1 -0
- package/dist/core/api/parse.js +40 -0
- package/dist/core/api/parse.js.map +1 -0
- package/dist/core/api/server.d.ts +310 -0
- package/dist/core/api/server.d.ts.map +1 -0
- package/dist/core/api/server.js +290 -0
- package/dist/core/api/server.js.map +1 -0
- package/dist/core/command/command.d.ts +20 -0
- package/dist/core/command/command.d.ts.map +1 -0
- package/dist/core/command/command.js +112 -0
- package/dist/core/command/command.js.map +1 -0
- package/dist/core/command/ids.d.ts +125 -0
- package/dist/core/command/ids.d.ts.map +1 -0
- package/dist/core/command/ids.js +85 -0
- package/dist/core/command/ids.js.map +1 -0
- package/dist/core/command/parser.d.ts +17 -0
- package/dist/core/command/parser.d.ts.map +1 -0
- package/dist/core/command/parser.js +65 -0
- package/dist/core/command/parser.js.map +1 -0
- package/dist/core/command/request.d.ts +61 -0
- package/dist/core/command/request.d.ts.map +1 -0
- package/dist/core/command/request.js +64 -0
- package/dist/core/command/request.js.map +1 -0
- package/dist/core/command/responses.d.ts +59 -0
- package/dist/core/command/responses.d.ts.map +1 -0
- package/dist/core/command/responses.js +74 -0
- package/dist/core/command/responses.js.map +1 -0
- package/dist/core/command-name.d.ts +333 -0
- package/dist/core/command-name.d.ts.map +1 -0
- package/dist/core/command-name.js +331 -0
- package/dist/core/command-name.js.map +1 -0
- package/dist/core/enums.d.ts +146 -0
- package/dist/core/enums.d.ts.map +1 -0
- package/dist/core/enums.js +132 -0
- package/dist/core/enums.js.map +1 -0
- package/dist/core/errorcode.d.ts +413 -0
- package/dist/core/errorcode.d.ts.map +1 -0
- package/dist/core/errorcode.js +410 -0
- package/dist/core/errorcode.js.map +1 -0
- package/dist/core/errors.d.ts +111 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +233 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events.d.ts +207 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +6 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/helpers.d.ts +42 -0
- package/dist/core/helpers.d.ts.map +1 -0
- package/dist/core/helpers.js +156 -0
- package/dist/core/helpers.js.map +1 -0
- package/dist/core/index.d.ts +35 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +23 -0
- package/dist/core/internal.d.ts.map +1 -0
- package/dist/core/internal.js +20 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/middleware.d.ts +14 -0
- package/dist/core/middleware.d.ts.map +1 -0
- package/dist/core/middleware.js +18 -0
- package/dist/core/middleware.js.map +1 -0
- package/dist/core/notification-name.d.ts +154 -0
- package/dist/core/notification-name.d.ts.map +1 -0
- package/dist/core/notification-name.js +152 -0
- package/dist/core/notification-name.js.map +1 -0
- package/dist/core/notifications.d.ts +43 -0
- package/dist/core/notifications.d.ts.map +1 -0
- package/dist/core/notifications.js +116 -0
- package/dist/core/notifications.js.map +1 -0
- package/dist/core/permission-name.d.ts +533 -0
- package/dist/core/permission-name.d.ts.map +1 -0
- package/dist/core/permission-name.js +531 -0
- package/dist/core/permission-name.js.map +1 -0
- package/dist/core/permission.d.ts +31 -0
- package/dist/core/permission.d.ts.map +1 -0
- package/dist/core/permission.js +20 -0
- package/dist/core/permission.js.map +1 -0
- package/dist/core/property-name.d.ts +403 -0
- package/dist/core/property-name.d.ts.map +1 -0
- package/dist/core/property-name.js +405 -0
- package/dist/core/property-name.js.map +1 -0
- package/dist/core/reason.d.ts +39 -0
- package/dist/core/reason.d.ts.map +1 -0
- package/dist/core/reason.js +36 -0
- package/dist/core/reason.js.map +1 -0
- package/dist/core/reconnect.d.ts +59 -0
- package/dist/core/reconnect.d.ts.map +1 -0
- package/dist/core/reconnect.js +55 -0
- package/dist/core/reconnect.js.map +1 -0
- package/dist/core/types.d.ts +110 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +27 -0
- package/dist/core/types.js.map +1 -0
- package/dist/query/client.d.ts +194 -0
- package/dist/query/client.d.ts.map +1 -0
- package/dist/query/client.js +969 -0
- package/dist/query/client.js.map +1 -0
- package/dist/query/errors.d.ts +61 -0
- package/dist/query/errors.d.ts.map +1 -0
- package/dist/query/errors.js +100 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/index.d.ts +36 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +34 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/knownhosts.d.ts +61 -0
- package/dist/query/knownhosts.d.ts.map +1 -0
- package/dist/query/knownhosts.js +223 -0
- package/dist/query/knownhosts.js.map +1 -0
- package/dist/query/lines.d.ts +14 -0
- package/dist/query/lines.d.ts.map +1 -0
- package/dist/query/lines.js +29 -0
- package/dist/query/lines.js.map +1 -0
- package/dist/query/options.d.ts +187 -0
- package/dist/query/options.d.ts.map +1 -0
- package/dist/query/options.js +213 -0
- package/dist/query/options.js.map +1 -0
- package/dist/query/reconnect.d.ts +29 -0
- package/dist/query/reconnect.d.ts.map +1 -0
- package/dist/query/reconnect.js +87 -0
- package/dist/query/reconnect.js.map +1 -0
- package/dist/query/ssh.d.ts +345 -0
- package/dist/query/ssh.d.ts.map +1 -0
- package/dist/query/ssh.js +241 -0
- package/dist/query/ssh.js.map +1 -0
- package/dist/query/stream.d.ts +38 -0
- package/dist/query/stream.d.ts.map +1 -0
- package/dist/query/stream.js +70 -0
- package/dist/query/stream.js.map +1 -0
- package/dist/query/tcp.d.ts +38 -0
- package/dist/query/tcp.d.ts.map +1 -0
- package/dist/query/tcp.js +53 -0
- package/dist/query/tcp.js.map +1 -0
- package/dist/query/transport.d.ts +36 -0
- package/dist/query/transport.d.ts.map +1 -0
- package/dist/query/transport.js +2 -0
- package/dist/query/transport.js.map +1 -0
- package/dist/query/web.d.ts +54 -0
- package/dist/query/web.d.ts.map +1 -0
- package/dist/query/web.js +146 -0
- package/dist/query/web.js.map +1 -0
- package/dist/versions/index.d.ts +3094 -0
- package/dist/versions/index.d.ts.map +1 -0
- package/dist/versions/index.js +9237 -0
- package/dist/versions/index.js.map +1 -0
- package/package.json +118 -4
- package/src/client/abort.ts +24 -0
- package/src/client/address.ts +74 -0
- package/src/client/api/voice.ts +61 -0
- package/src/client/capabilities.ts +106 -0
- package/src/client/client.ts +1809 -0
- package/src/client/commands.ts +193 -0
- package/src/client/crypto/crypt-ops.ts +6 -0
- package/src/client/crypto/crypt.ts +275 -0
- package/src/client/crypto/eax.ts +152 -0
- package/src/client/crypto/identity.ts +484 -0
- package/src/client/crypto/index.ts +21 -0
- package/src/client/crypto/primitives.ts +141 -0
- package/src/client/diagnostics.ts +58 -0
- package/src/client/discovery/index.ts +1 -0
- package/src/client/discovery/resolver.ts +325 -0
- package/src/client/errors.ts +217 -0
- package/src/client/events.ts +12 -0
- package/src/client/handshake/crypt-handshake.ts +157 -0
- package/src/client/handshake/crypt-init2.ts +48 -0
- package/src/client/handshake/index.ts +3 -0
- package/src/client/handshake/license.ts +208 -0
- package/src/client/handshake.ts +150 -0
- package/src/client/helpers.ts +10 -0
- package/src/client/hooks.ts +30 -0
- package/src/client/index.ts +93 -0
- package/src/client/reconnect.ts +43 -0
- package/src/client/throttle.ts +92 -0
- package/src/client/trace.ts +237 -0
- package/src/client/transfer.ts +436 -0
- package/src/client/transport/generation-window.ts +108 -0
- package/src/client/transport/handler.ts +926 -0
- package/src/client/transport/index.ts +14 -0
- package/src/client/transport/packet.ts +69 -0
- package/src/client/transport/quicklz.ts +209 -0
- package/src/client/types.ts +268 -0
- package/src/core/api/channels.ts +396 -0
- package/src/core/api/clients.ts +654 -0
- package/src/core/api/command.ts +563 -0
- package/src/core/api/files.ts +405 -0
- package/src/core/api/groups.ts +622 -0
- package/src/core/api/moderation.ts +525 -0
- package/src/core/api/parse.ts +52 -0
- package/src/core/api/server.ts +709 -0
- package/src/core/command/command.ts +125 -0
- package/src/core/command/ids.ts +149 -0
- package/src/core/command/parser.ts +68 -0
- package/src/core/command/request.ts +119 -0
- package/src/core/command/responses.ts +114 -0
- package/src/core/command-name.ts +334 -0
- package/src/core/enums.ts +167 -0
- package/src/core/errorcode.ts +412 -0
- package/src/core/errors.ts +258 -0
- package/src/core/events.ts +219 -0
- package/src/core/helpers.ts +161 -0
- package/src/core/index.ts +126 -0
- package/src/core/internal.ts +23 -0
- package/src/core/middleware.ts +24 -0
- package/src/core/notification-name.ts +155 -0
- package/src/core/notifications.ts +157 -0
- package/src/core/permission-name.ts +538 -0
- package/src/core/permission.ts +34 -0
- package/src/core/property-name.ts +411 -0
- package/src/core/reason.ts +38 -0
- package/src/core/reconnect.ts +98 -0
- package/src/core/types.ts +138 -0
- package/src/query/client.ts +1129 -0
- package/src/query/errors.ts +108 -0
- package/src/query/index.ts +65 -0
- package/src/query/knownhosts.ts +257 -0
- package/src/query/lines.ts +28 -0
- package/src/query/options.ts +388 -0
- package/src/query/reconnect.ts +84 -0
- package/src/query/ssh.ts +614 -0
- package/src/query/stream.ts +91 -0
- package/src/query/tcp.ts +85 -0
- package/src/query/transport.ts +35 -0
- package/src/query/web.ts +195 -0
- package/src/versions/index.ts +10774 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server and instance commands.
|
|
3
|
+
*
|
|
4
|
+
* "Server" here means the virtual server a client is connected to; "instance"
|
|
5
|
+
* means the process hosting it. The distinction matters because the setting
|
|
6
|
+
* names differ (`virtualserver_*` versus `serverinstance_*`) and the two are
|
|
7
|
+
* easy to mix up.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
nonEmpty,
|
|
12
|
+
uint,
|
|
13
|
+
U16,
|
|
14
|
+
firstRow,
|
|
15
|
+
exec,
|
|
16
|
+
query,
|
|
17
|
+
list,
|
|
18
|
+
encodeFields,
|
|
19
|
+
inSeconds,
|
|
20
|
+
parsePermission,
|
|
21
|
+
permissionParam,
|
|
22
|
+
createdGroupID,
|
|
23
|
+
str,
|
|
24
|
+
big,
|
|
25
|
+
num,
|
|
26
|
+
bool,
|
|
27
|
+
icon,
|
|
28
|
+
date,
|
|
29
|
+
durationMs,
|
|
30
|
+
SECOND,
|
|
31
|
+
} from "./command.js";
|
|
32
|
+
import type { Params, PermissionEntry, WireNames } from "./command.js";
|
|
33
|
+
import type { CommandExecutor, CommandOptions } from "../command/request.js";
|
|
34
|
+
import type {
|
|
35
|
+
ChannelID,
|
|
36
|
+
ClientDBID,
|
|
37
|
+
ClientID,
|
|
38
|
+
IconID,
|
|
39
|
+
ServerGroupID,
|
|
40
|
+
ServerID,
|
|
41
|
+
UID,
|
|
42
|
+
} from "../command/ids.js";
|
|
43
|
+
import {
|
|
44
|
+
asChannelID,
|
|
45
|
+
asClientDBID,
|
|
46
|
+
asClientID,
|
|
47
|
+
asServerGroupID,
|
|
48
|
+
asServerID,
|
|
49
|
+
asUID,
|
|
50
|
+
} from "../command/ids.js";
|
|
51
|
+
import type { GroupType } from "../enums.js";
|
|
52
|
+
import type { GroupDeleteOptions } from "./groups.js";
|
|
53
|
+
import type { Permission } from "../permission.js";
|
|
54
|
+
|
|
55
|
+
/** A server group as `servergrouplist` reports it. */
|
|
56
|
+
export interface ServerGroup {
|
|
57
|
+
/** The group's id. */
|
|
58
|
+
readonly id: ServerGroupID;
|
|
59
|
+
/** The group's name. */
|
|
60
|
+
readonly name: string;
|
|
61
|
+
/** What kind of group this is, one of {@link GroupType}. */
|
|
62
|
+
readonly type: number;
|
|
63
|
+
/** The group's icon, or undefined for none. */
|
|
64
|
+
readonly iconID: IconID | undefined;
|
|
65
|
+
/** Whether membership is stored, rather than lost when the server restarts. */
|
|
66
|
+
readonly savedInDatabase: boolean;
|
|
67
|
+
/** Where the group sorts among the others; a 32-bit value. */
|
|
68
|
+
readonly sortID: number;
|
|
69
|
+
/** Where the group's name shows beside a member's nickname, one of {@link GroupNameMode}. */
|
|
70
|
+
readonly nameMode: number;
|
|
71
|
+
/** The power needed to modify the group. */
|
|
72
|
+
readonly modifyPower: number;
|
|
73
|
+
/** The power needed to add a member. */
|
|
74
|
+
readonly memberAddPower: number;
|
|
75
|
+
/** The power needed to remove a member. */
|
|
76
|
+
readonly memberRemovePower: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const parseServerGroup = (row: Record<string, string>): ServerGroup => ({
|
|
80
|
+
id: asServerGroupID(big(row, "sgid")),
|
|
81
|
+
name: str(row, "name"),
|
|
82
|
+
type: num(row, "type"),
|
|
83
|
+
iconID: icon(row, "iconid"),
|
|
84
|
+
savedInDatabase: bool(row, "savedb"),
|
|
85
|
+
sortID: num(row, "sortid"),
|
|
86
|
+
nameMode: num(row, "namemode"),
|
|
87
|
+
modifyPower: num(row, "n_modifyp"),
|
|
88
|
+
memberAddPower: num(row, "n_member_addp"),
|
|
89
|
+
memberRemovePower: num(row, "n_member_removep"),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/** Every server group. */
|
|
93
|
+
export async function listServerGroups(
|
|
94
|
+
client: CommandExecutor,
|
|
95
|
+
options?: CommandOptions,
|
|
96
|
+
): Promise<ServerGroup[]> {
|
|
97
|
+
return (await list(client, "servergrouplist", [], options)).map(parseServerGroup);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The virtual server's settings, as `serverinfo` reports them.
|
|
102
|
+
*
|
|
103
|
+
* Raw rather than parsed: `serverinfo` carries well over a hundred
|
|
104
|
+
* `virtualserver_*` fields, which ones appear depends on the server version and
|
|
105
|
+
* on the caller's permissions, and a typed subset would drop the rest. The
|
|
106
|
+
* keys are named in `PropertyName`.
|
|
107
|
+
*/
|
|
108
|
+
export async function getServerInfo(
|
|
109
|
+
client: CommandExecutor,
|
|
110
|
+
options?: CommandOptions,
|
|
111
|
+
): Promise<Readonly<Record<string, string>>> {
|
|
112
|
+
return firstRow(await query(client, "serverinfo", [], options), "serverinfo");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Raw wire properties, sent as given. */
|
|
116
|
+
const rawProperties = (settings: Readonly<Record<string, string>>): Params =>
|
|
117
|
+
Object.entries(settings).filter(
|
|
118
|
+
(entry): entry is [string, string] => typeof entry[1] === "string",
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Change the virtual server's settings. Only the properties you pass are sent.
|
|
123
|
+
*
|
|
124
|
+
* Unlike every other options object, these are the raw `virtualserver_*`
|
|
125
|
+
* wire properties from `serverinfo`, passed through as given rather than
|
|
126
|
+
* enumerated: there are well over a hundred, they are version-dependent, and a
|
|
127
|
+
* value read back from {@link getServerInfo} should be writable straight back.
|
|
128
|
+
* The values are strings, as `getServerInfo` returns them. The editable keys
|
|
129
|
+
* are marked in `PropertyName`.
|
|
130
|
+
*/
|
|
131
|
+
export async function editServer(
|
|
132
|
+
client: CommandExecutor,
|
|
133
|
+
settings: Readonly<Record<string, string>>,
|
|
134
|
+
options?: CommandOptions,
|
|
135
|
+
): Promise<void> {
|
|
136
|
+
await exec(client, "serveredit", rawProperties(settings), options);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The host process's settings, as `hostinfo` reports them, raw.
|
|
141
|
+
*
|
|
142
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
143
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
144
|
+
* Granted, it works over the voice protocol like any other query. The keys are
|
|
145
|
+
* named in `PropertyName`.
|
|
146
|
+
*/
|
|
147
|
+
export async function getHostInfo(
|
|
148
|
+
client: CommandExecutor,
|
|
149
|
+
options?: CommandOptions,
|
|
150
|
+
): Promise<Readonly<Record<string, string>>> {
|
|
151
|
+
return firstRow(await query(client, "hostinfo", [], options), "hostinfo");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The server instance's settings, as `instanceinfo` reports them, raw.
|
|
156
|
+
*
|
|
157
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
158
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
159
|
+
* Granted, it works over the voice protocol like any other query. The keys are
|
|
160
|
+
* named in `PropertyName`.
|
|
161
|
+
*/
|
|
162
|
+
export async function getInstanceInfo(
|
|
163
|
+
client: CommandExecutor,
|
|
164
|
+
options?: CommandOptions,
|
|
165
|
+
): Promise<Readonly<Record<string, string>>> {
|
|
166
|
+
return firstRow(await query(client, "instanceinfo", [], options), "instanceinfo");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Change the server instance's settings: raw `serverinstance_*` properties,
|
|
171
|
+
* passed through as given, for the same reasons as {@link editServer}. The
|
|
172
|
+
* editable keys are marked in `PropertyName`.
|
|
173
|
+
*/
|
|
174
|
+
export async function editInstance(
|
|
175
|
+
client: CommandExecutor,
|
|
176
|
+
settings: Readonly<Record<string, string>>,
|
|
177
|
+
options?: CommandOptions,
|
|
178
|
+
): Promise<void> {
|
|
179
|
+
await exec(client, "instanceedit", rawProperties(settings), options);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** An address the instance listens on. */
|
|
183
|
+
export interface Binding {
|
|
184
|
+
/**
|
|
185
|
+
* What listens there: `voice`, `query` or `filetransfer`. The server does not
|
|
186
|
+
* name it in each row, so it is the subsystem asked for, or `voice` when none
|
|
187
|
+
* was.
|
|
188
|
+
*/
|
|
189
|
+
readonly subsystem: string;
|
|
190
|
+
/** The address. */
|
|
191
|
+
readonly ip: string;
|
|
192
|
+
/** The port; undefined when the server does not report one. */
|
|
193
|
+
readonly port: number | undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Which bindings {@link listBindings} reports. */
|
|
197
|
+
export interface BindingListOptions extends CommandOptions {
|
|
198
|
+
/** Only this subsystem's: `voice`, `query` or `filetransfer`; unset for all (`subsystem`). */
|
|
199
|
+
readonly subsystem?: string | undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Active IP bindings, when the instance is multi-homed.
|
|
204
|
+
*
|
|
205
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
206
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
207
|
+
* Granted, it works over the voice protocol like any other query.
|
|
208
|
+
*/
|
|
209
|
+
export async function listBindings(
|
|
210
|
+
client: CommandExecutor,
|
|
211
|
+
options: BindingListOptions = {},
|
|
212
|
+
): Promise<Binding[]> {
|
|
213
|
+
const subsystem = options.subsystem || "voice";
|
|
214
|
+
const rows = await list(
|
|
215
|
+
client,
|
|
216
|
+
"bindinglist",
|
|
217
|
+
[["subsystem", nonEmpty(options.subsystem ?? "")]],
|
|
218
|
+
options,
|
|
219
|
+
);
|
|
220
|
+
return rows.map((row) => ({
|
|
221
|
+
subsystem: str(row, "subsystem") || subsystem,
|
|
222
|
+
ip: str(row, "ip"),
|
|
223
|
+
port: row["port"] === undefined ? undefined : num(row, "port"),
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The server's build, as `version` reports it. */
|
|
228
|
+
export interface ServerVersion {
|
|
229
|
+
/** The version, such as "3.13.7". */
|
|
230
|
+
readonly version: string;
|
|
231
|
+
/** The build number. */
|
|
232
|
+
readonly build: number;
|
|
233
|
+
/** The platform the server runs on, such as "Linux". */
|
|
234
|
+
readonly platform: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** The server's build version. */
|
|
238
|
+
export async function getVersion(
|
|
239
|
+
client: CommandExecutor,
|
|
240
|
+
options?: CommandOptions,
|
|
241
|
+
): Promise<ServerVersion> {
|
|
242
|
+
const row = firstRow(await query(client, "version", [], options), "version");
|
|
243
|
+
return { version: str(row, "version"), build: num(row, "build"), platform: str(row, "platform") };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Which server and client a connection is, as `whoami` reports it. */
|
|
247
|
+
export interface WhoAmI {
|
|
248
|
+
/** The virtual server's state, such as "online" (`virtualserver_status`). */
|
|
249
|
+
readonly serverStatus: string;
|
|
250
|
+
/** The virtual server's id, 0 when none is selected (`virtualserver_id`). */
|
|
251
|
+
readonly serverID: ServerID;
|
|
252
|
+
/** The virtual server's unique identifier (`virtualserver_unique_identifier`). */
|
|
253
|
+
readonly serverUID: string;
|
|
254
|
+
/** The virtual server's voice port (`virtualserver_port`). */
|
|
255
|
+
readonly serverPort: number;
|
|
256
|
+
/** This connection's client id (`client_id`). */
|
|
257
|
+
readonly clientID: ClientID;
|
|
258
|
+
/** The channel this connection is in (`client_channel_id`). */
|
|
259
|
+
readonly channelID: ChannelID;
|
|
260
|
+
/** This connection's nickname (`client_nickname`). */
|
|
261
|
+
readonly nickname: string;
|
|
262
|
+
/** This connection's database id (`client_database_id`). */
|
|
263
|
+
readonly databaseID: ClientDBID;
|
|
264
|
+
/** The ServerQuery login name, "" for a voice client (`client_login_name`). */
|
|
265
|
+
readonly loginName: string;
|
|
266
|
+
/**
|
|
267
|
+
* This connection's unique identifier (`client_unique_identifier`). The voice
|
|
268
|
+
* protocol sends the field empty; the voice client's `uid` has
|
|
269
|
+
* it.
|
|
270
|
+
*/
|
|
271
|
+
readonly uid: UID;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Which server and client this connection is, as the server sees it. */
|
|
275
|
+
export async function whoAmI(client: CommandExecutor, options?: CommandOptions): Promise<WhoAmI> {
|
|
276
|
+
const row = firstRow(await query(client, "whoami", [], options), "whoami");
|
|
277
|
+
return {
|
|
278
|
+
serverStatus: str(row, "virtualserver_status"),
|
|
279
|
+
serverID: asServerID(big(row, "virtualserver_id")),
|
|
280
|
+
serverUID: str(row, "virtualserver_unique_identifier"),
|
|
281
|
+
serverPort: num(row, "virtualserver_port"),
|
|
282
|
+
clientID: asClientID(uint(row, "client_id", U16)),
|
|
283
|
+
channelID: asChannelID(big(row, "client_channel_id")),
|
|
284
|
+
nickname: str(row, "client_nickname"),
|
|
285
|
+
databaseID: asClientDBID(big(row, "client_database_id")),
|
|
286
|
+
loginName: str(row, "client_login_name"),
|
|
287
|
+
uid: asUID(str(row, "client_unique_identifier")),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The virtual server's traffic, as `serverrequestconnectioninfo` reports it.
|
|
293
|
+
* Byte counts are bytes; bandwidths are bytes per second.
|
|
294
|
+
*/
|
|
295
|
+
export interface ServerConnectionInfo {
|
|
296
|
+
/** File transfer bandwidth out (`connection_filetransfer_bandwidth_sent`). */
|
|
297
|
+
readonly fileTransferBandwidthSent: number;
|
|
298
|
+
/** File transfer bandwidth in (`connection_filetransfer_bandwidth_received`). */
|
|
299
|
+
readonly fileTransferBandwidthReceived: number;
|
|
300
|
+
/** File transfer bytes sent (`connection_filetransfer_bytes_sent_total`). */
|
|
301
|
+
readonly fileTransferBytesSent: number;
|
|
302
|
+
/** File transfer bytes received (`connection_filetransfer_bytes_received_total`). */
|
|
303
|
+
readonly fileTransferBytesReceived: number;
|
|
304
|
+
/** Packets sent (`connection_packets_sent_total`). */
|
|
305
|
+
readonly packetsSent: number;
|
|
306
|
+
/** Bytes sent (`connection_bytes_sent_total`). */
|
|
307
|
+
readonly bytesSent: number;
|
|
308
|
+
/** Packets received (`connection_packets_received_total`). */
|
|
309
|
+
readonly packetsReceived: number;
|
|
310
|
+
/** Bytes received (`connection_bytes_received_total`). */
|
|
311
|
+
readonly bytesReceived: number;
|
|
312
|
+
/** Bandwidth out over the last second (`connection_bandwidth_sent_last_second_total`). */
|
|
313
|
+
readonly bandwidthSentLastSecond: number;
|
|
314
|
+
/** Bandwidth out over the last minute (`connection_bandwidth_sent_last_minute_total`). */
|
|
315
|
+
readonly bandwidthSentLastMinute: number;
|
|
316
|
+
/** Bandwidth in over the last second (`connection_bandwidth_received_last_second_total`). */
|
|
317
|
+
readonly bandwidthReceivedLastSecond: number;
|
|
318
|
+
/** Bandwidth in over the last minute (`connection_bandwidth_received_last_minute_total`). */
|
|
319
|
+
readonly bandwidthReceivedLastMinute: number;
|
|
320
|
+
/**
|
|
321
|
+
* How long the virtual server has been running, in milliseconds
|
|
322
|
+
* (`connection_connected_time`). Sent in seconds here — unlike the field of
|
|
323
|
+
* the same name in `clientinfo`, which is in milliseconds.
|
|
324
|
+
*/
|
|
325
|
+
readonly connectedTimeMs: number;
|
|
326
|
+
/** The share of packets lost, 0 to 1 (`connection_packetloss_total`). */
|
|
327
|
+
readonly packetLoss: number;
|
|
328
|
+
/** The average ping, in milliseconds (`connection_ping`). */
|
|
329
|
+
readonly pingMs: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The virtual server's traffic statistics — not this connection's, as the
|
|
334
|
+
* command's name suggests.
|
|
335
|
+
*/
|
|
336
|
+
export async function getConnectionInfo(
|
|
337
|
+
client: CommandExecutor,
|
|
338
|
+
options?: CommandOptions,
|
|
339
|
+
): Promise<ServerConnectionInfo> {
|
|
340
|
+
const row = firstRow(
|
|
341
|
+
await query(client, "serverrequestconnectioninfo", [], options),
|
|
342
|
+
"serverrequestconnectioninfo",
|
|
343
|
+
);
|
|
344
|
+
return {
|
|
345
|
+
fileTransferBandwidthSent: num(row, "connection_filetransfer_bandwidth_sent"),
|
|
346
|
+
fileTransferBandwidthReceived: num(row, "connection_filetransfer_bandwidth_received"),
|
|
347
|
+
fileTransferBytesSent: num(row, "connection_filetransfer_bytes_sent_total"),
|
|
348
|
+
fileTransferBytesReceived: num(row, "connection_filetransfer_bytes_received_total"),
|
|
349
|
+
packetsSent: num(row, "connection_packets_sent_total"),
|
|
350
|
+
bytesSent: num(row, "connection_bytes_sent_total"),
|
|
351
|
+
packetsReceived: num(row, "connection_packets_received_total"),
|
|
352
|
+
bytesReceived: num(row, "connection_bytes_received_total"),
|
|
353
|
+
bandwidthSentLastSecond: num(row, "connection_bandwidth_sent_last_second_total"),
|
|
354
|
+
bandwidthSentLastMinute: num(row, "connection_bandwidth_sent_last_minute_total"),
|
|
355
|
+
bandwidthReceivedLastSecond: num(row, "connection_bandwidth_received_last_second_total"),
|
|
356
|
+
bandwidthReceivedLastMinute: num(row, "connection_bandwidth_received_last_minute_total"),
|
|
357
|
+
connectedTimeMs: durationMs(row, "connection_connected_time", SECOND),
|
|
358
|
+
packetLoss: num(row, "connection_packetloss_total"),
|
|
359
|
+
pingMs: num(row, "connection_ping"),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* The numeric id of the virtual server listening on `port`.
|
|
365
|
+
*
|
|
366
|
+
* Needs an instance-level permission (`b_serverinstance_*`), which not even the
|
|
367
|
+
* Server Admin group holds by default — expect error 2568 until it is granted.
|
|
368
|
+
* Granted, it works over the voice protocol like any other query.
|
|
369
|
+
*/
|
|
370
|
+
export async function getServerIDByPort(
|
|
371
|
+
client: CommandExecutor,
|
|
372
|
+
port: number,
|
|
373
|
+
options?: CommandOptions,
|
|
374
|
+
): Promise<ServerID> {
|
|
375
|
+
const rows = await query(client, "serveridgetbyport", [["virtualserver_port", port]], options);
|
|
376
|
+
return asServerID(big(firstRow(rows, "serveridgetbyport", "server_id"), "server_id"));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// ---- Server groups ----------------------------------------------------------
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Create a server group.
|
|
383
|
+
*
|
|
384
|
+
* `type` is required, and always sent: the server's own default is
|
|
385
|
+
* `GroupType.Regular`, while the type's first value is `Template`, so leaving
|
|
386
|
+
* it to a default on either side is a trap.
|
|
387
|
+
*/
|
|
388
|
+
export async function createServerGroup(
|
|
389
|
+
client: CommandExecutor,
|
|
390
|
+
name: string,
|
|
391
|
+
type: GroupType,
|
|
392
|
+
options?: CommandOptions,
|
|
393
|
+
): Promise<ServerGroupID> {
|
|
394
|
+
const rows = await query(
|
|
395
|
+
client,
|
|
396
|
+
"servergroupadd",
|
|
397
|
+
[
|
|
398
|
+
["name", name],
|
|
399
|
+
["type", type],
|
|
400
|
+
],
|
|
401
|
+
options,
|
|
402
|
+
);
|
|
403
|
+
return asServerGroupID(createdGroupID(rows, "sgid", name, "servergroupadd"));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/** Delete a server group. */
|
|
407
|
+
export async function deleteServerGroup(
|
|
408
|
+
client: CommandExecutor,
|
|
409
|
+
sgid: ServerGroupID,
|
|
410
|
+
options: GroupDeleteOptions = {},
|
|
411
|
+
): Promise<void> {
|
|
412
|
+
await exec(
|
|
413
|
+
client,
|
|
414
|
+
"servergroupdel",
|
|
415
|
+
[
|
|
416
|
+
["sgid", sgid],
|
|
417
|
+
["force", options.force ?? false],
|
|
418
|
+
],
|
|
419
|
+
options,
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Rename a server group. */
|
|
424
|
+
export async function renameServerGroup(
|
|
425
|
+
client: CommandExecutor,
|
|
426
|
+
sgid: ServerGroupID,
|
|
427
|
+
name: string,
|
|
428
|
+
options?: CommandOptions,
|
|
429
|
+
): Promise<void> {
|
|
430
|
+
await exec(
|
|
431
|
+
client,
|
|
432
|
+
"servergrouprename",
|
|
433
|
+
[
|
|
434
|
+
["sgid", sgid],
|
|
435
|
+
["name", name],
|
|
436
|
+
],
|
|
437
|
+
options,
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Copy a server group's permissions onto another; a `targetGroupID` of 0 makes
|
|
443
|
+
* the server create a new group named `name`, of `type`.
|
|
444
|
+
*/
|
|
445
|
+
export async function copyServerGroup(
|
|
446
|
+
client: CommandExecutor,
|
|
447
|
+
sourceGroupID: ServerGroupID,
|
|
448
|
+
targetGroupID: ServerGroupID,
|
|
449
|
+
name: string,
|
|
450
|
+
type: GroupType,
|
|
451
|
+
options?: CommandOptions,
|
|
452
|
+
): Promise<ServerGroupID> {
|
|
453
|
+
const rows = await query(
|
|
454
|
+
client,
|
|
455
|
+
"servergroupcopy",
|
|
456
|
+
[
|
|
457
|
+
["ssgid", sourceGroupID],
|
|
458
|
+
["tsgid", targetGroupID],
|
|
459
|
+
["name", name],
|
|
460
|
+
["type", type],
|
|
461
|
+
],
|
|
462
|
+
options,
|
|
463
|
+
);
|
|
464
|
+
// Copying onto an existing group keeps that group's id.
|
|
465
|
+
if (targetGroupID !== 0n) return targetGroupID;
|
|
466
|
+
return asServerGroupID(createdGroupID(rows, "sgid", name, "servergroupcopy"));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Add a client to a server group. */
|
|
470
|
+
export async function addClientToServerGroup(
|
|
471
|
+
client: CommandExecutor,
|
|
472
|
+
sgid: ServerGroupID,
|
|
473
|
+
cldbid: ClientDBID,
|
|
474
|
+
options?: CommandOptions,
|
|
475
|
+
): Promise<void> {
|
|
476
|
+
await exec(
|
|
477
|
+
client,
|
|
478
|
+
"servergroupaddclient",
|
|
479
|
+
[
|
|
480
|
+
["sgid", sgid],
|
|
481
|
+
["cldbid", cldbid],
|
|
482
|
+
],
|
|
483
|
+
options,
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/** Remove a client from a server group. */
|
|
488
|
+
export async function removeClientFromServerGroup(
|
|
489
|
+
client: CommandExecutor,
|
|
490
|
+
sgid: ServerGroupID,
|
|
491
|
+
cldbid: ClientDBID,
|
|
492
|
+
options?: CommandOptions,
|
|
493
|
+
): Promise<void> {
|
|
494
|
+
await exec(
|
|
495
|
+
client,
|
|
496
|
+
"servergroupdelclient",
|
|
497
|
+
[
|
|
498
|
+
["sgid", sgid],
|
|
499
|
+
["cldbid", cldbid],
|
|
500
|
+
],
|
|
501
|
+
options,
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Which optional fields `servergroupclientlist` should include. */
|
|
506
|
+
export interface ServerGroupClientListOptions extends CommandOptions {
|
|
507
|
+
/** Each member's nickname (`-names`). */
|
|
508
|
+
readonly names?: boolean | undefined;
|
|
509
|
+
/** Each member's unique identifier (`-uid`). */
|
|
510
|
+
readonly uids?: boolean | undefined;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const memberFlags: WireNames<ServerGroupClientListOptions> = { names: "-names", uids: "-uid" };
|
|
514
|
+
|
|
515
|
+
/** A member of a server group. */
|
|
516
|
+
export interface ServerGroupMember {
|
|
517
|
+
/** The member's database id. */
|
|
518
|
+
readonly databaseID: ClientDBID;
|
|
519
|
+
/** The member's nickname, with `names`; "" otherwise. */
|
|
520
|
+
readonly nickname: string;
|
|
521
|
+
/** The member's unique identifier, with `uids`; "" otherwise. */
|
|
522
|
+
readonly uid: UID;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** Members of a server group, optionally with their nicknames and uids. */
|
|
526
|
+
export async function listServerGroupClients(
|
|
527
|
+
client: CommandExecutor,
|
|
528
|
+
sgid: ServerGroupID,
|
|
529
|
+
options: ServerGroupClientListOptions = {},
|
|
530
|
+
): Promise<ServerGroupMember[]> {
|
|
531
|
+
const rows = await list(
|
|
532
|
+
client,
|
|
533
|
+
"servergroupclientlist",
|
|
534
|
+
[["sgid", sgid], ...encodeFields(options, memberFlags)],
|
|
535
|
+
options,
|
|
536
|
+
);
|
|
537
|
+
return rows.map((row) => ({
|
|
538
|
+
databaseID: asClientDBID(big(row, "cldbid")),
|
|
539
|
+
nickname: str(row, "client_nickname"),
|
|
540
|
+
uid: asUID(str(row, "client_unique_identifier")),
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** A server group a client belongs to. */
|
|
545
|
+
export interface ServerGroupRef {
|
|
546
|
+
/** The group's id. */
|
|
547
|
+
readonly id: ServerGroupID;
|
|
548
|
+
/** The group's name. */
|
|
549
|
+
readonly name: string;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/** Server groups a client belongs to. */
|
|
553
|
+
export async function getServerGroupsByClient(
|
|
554
|
+
client: CommandExecutor,
|
|
555
|
+
cldbid: ClientDBID,
|
|
556
|
+
options?: CommandOptions,
|
|
557
|
+
): Promise<ServerGroupRef[]> {
|
|
558
|
+
const rows = await list(client, "servergroupsbyclientid", [["cldbid", cldbid]], options);
|
|
559
|
+
return rows.map((row) => ({ id: asServerGroupID(big(row, "sgid")), name: str(row, "name") }));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/** Permissions set on a server group. */
|
|
563
|
+
export async function listServerGroupPermissions(
|
|
564
|
+
client: CommandExecutor,
|
|
565
|
+
sgid: ServerGroupID,
|
|
566
|
+
options?: CommandOptions,
|
|
567
|
+
): Promise<PermissionEntry[]> {
|
|
568
|
+
return (await list(client, "servergrouppermlist", [["sgid", sgid]], options)).map(
|
|
569
|
+
parsePermission,
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/** How {@link addServerGroupPermission} sets the permission. */
|
|
574
|
+
export interface ServerGroupPermissionOptions extends CommandOptions {
|
|
575
|
+
/** Whether the value is negated, so the lowest wins; false by default (`permnegated`). */
|
|
576
|
+
readonly negated?: boolean | undefined;
|
|
577
|
+
/** Whether it skips channel and client overrides; false by default (`permskip`). */
|
|
578
|
+
readonly skip?: boolean | undefined;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** Set a permission on a server group. */
|
|
582
|
+
export async function addServerGroupPermission(
|
|
583
|
+
client: CommandExecutor,
|
|
584
|
+
sgid: ServerGroupID,
|
|
585
|
+
permission: Permission,
|
|
586
|
+
value: number,
|
|
587
|
+
options: ServerGroupPermissionOptions = {},
|
|
588
|
+
): Promise<void> {
|
|
589
|
+
await exec(
|
|
590
|
+
client,
|
|
591
|
+
"servergroupaddperm",
|
|
592
|
+
[
|
|
593
|
+
["sgid", sgid],
|
|
594
|
+
permissionParam(permission),
|
|
595
|
+
["permvalue", value],
|
|
596
|
+
["permnegated", options.negated ?? false],
|
|
597
|
+
["permskip", options.skip ?? false],
|
|
598
|
+
],
|
|
599
|
+
options,
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/** Remove a permission from a server group. */
|
|
604
|
+
export async function deleteServerGroupPermission(
|
|
605
|
+
client: CommandExecutor,
|
|
606
|
+
sgid: ServerGroupID,
|
|
607
|
+
permission: Permission,
|
|
608
|
+
options?: CommandOptions,
|
|
609
|
+
): Promise<void> {
|
|
610
|
+
await exec(client, "servergroupdelperm", [["sgid", sgid], permissionParam(permission)], options);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// ---- Temporary passwords ----------------------------------------------------
|
|
614
|
+
|
|
615
|
+
/** A temporary server password. */
|
|
616
|
+
export interface TempPassword {
|
|
617
|
+
/** The password itself (`pw_clear`). */
|
|
618
|
+
readonly password: string;
|
|
619
|
+
/** What it is for (`desc`). */
|
|
620
|
+
readonly description: string;
|
|
621
|
+
/** Who created it (`nickname`). */
|
|
622
|
+
readonly creatorNickname: string;
|
|
623
|
+
/** The creator's unique identifier (`uid`). */
|
|
624
|
+
readonly creatorUID: UID;
|
|
625
|
+
/** When it became valid (`start`). */
|
|
626
|
+
readonly startsAt: Date | undefined;
|
|
627
|
+
/** When it stops being valid (`end`). */
|
|
628
|
+
readonly endsAt: Date | undefined;
|
|
629
|
+
/** The channel a client joining with it lands in, or 0 for the default channel. */
|
|
630
|
+
readonly targetChannelID: ChannelID;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** The server's temporary passwords. */
|
|
634
|
+
export async function listTempPasswords(
|
|
635
|
+
client: CommandExecutor,
|
|
636
|
+
options?: CommandOptions,
|
|
637
|
+
): Promise<TempPassword[]> {
|
|
638
|
+
const rows = await list(client, "servertemppasswordlist", [], options);
|
|
639
|
+
return rows.map((row) => ({
|
|
640
|
+
password: str(row, "pw_clear"),
|
|
641
|
+
description: str(row, "desc"),
|
|
642
|
+
creatorNickname: str(row, "nickname"),
|
|
643
|
+
creatorUID: asUID(str(row, "uid")),
|
|
644
|
+
startsAt: date(row, "start"),
|
|
645
|
+
endsAt: date(row, "end"),
|
|
646
|
+
targetChannelID: asChannelID(big(row, "tcid")),
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** A temporary password to create. */
|
|
651
|
+
export interface TempPasswordOptions {
|
|
652
|
+
/**
|
|
653
|
+
* The password (`pw`). The caller chooses it; the server does not generate
|
|
654
|
+
* one, and an empty one is refused here rather than created.
|
|
655
|
+
*/
|
|
656
|
+
readonly password: string;
|
|
657
|
+
/** What it is for, shown in the list (`desc`). */
|
|
658
|
+
readonly description: string;
|
|
659
|
+
/**
|
|
660
|
+
* How long it stays valid, in milliseconds (`duration`). Sent in whole
|
|
661
|
+
* seconds; a positive duration under a second is sent as one.
|
|
662
|
+
*/
|
|
663
|
+
readonly durationMs: number;
|
|
664
|
+
/** The channel a client joining with it lands in; unset or 0 is the default channel (`tcid`). */
|
|
665
|
+
readonly targetChannelID?: ChannelID | undefined;
|
|
666
|
+
/** That channel's password, in cleartext; unset or "" for none (`tcpw`). */
|
|
667
|
+
readonly targetChannelPassword?: string | undefined;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const tempPasswordNames: WireNames<TempPasswordOptions> = {
|
|
671
|
+
password: "pw",
|
|
672
|
+
description: "desc",
|
|
673
|
+
durationMs: ["duration", inSeconds],
|
|
674
|
+
targetChannelID: "tcid",
|
|
675
|
+
targetChannelPassword: "tcpw",
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Create a temporary server password.
|
|
680
|
+
*
|
|
681
|
+
* The server reports nothing back — the password is the one passed in.
|
|
682
|
+
*/
|
|
683
|
+
export async function addTempPassword(
|
|
684
|
+
client: CommandExecutor,
|
|
685
|
+
temp: TempPasswordOptions,
|
|
686
|
+
options?: CommandOptions,
|
|
687
|
+
): Promise<void> {
|
|
688
|
+
if (typeof temp.password !== "string" || temp.password === "") {
|
|
689
|
+
throw new TypeError("a temporary password cannot be empty");
|
|
690
|
+
}
|
|
691
|
+
// tcid and tcpw are required on the wire, even for the default channel.
|
|
692
|
+
const fields: TempPasswordOptions = {
|
|
693
|
+
...temp,
|
|
694
|
+
targetChannelID: temp.targetChannelID ?? asChannelID(0),
|
|
695
|
+
targetChannelPassword: temp.targetChannelPassword ?? "",
|
|
696
|
+
};
|
|
697
|
+
await exec(client, "servertemppasswordadd", encodeFields(fields, tempPasswordNames), options, [
|
|
698
|
+
"tcpw",
|
|
699
|
+
]);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Delete a temporary password. */
|
|
703
|
+
export async function deleteTempPassword(
|
|
704
|
+
client: CommandExecutor,
|
|
705
|
+
password: string,
|
|
706
|
+
options?: CommandOptions,
|
|
707
|
+
): Promise<void> {
|
|
708
|
+
await exec(client, "servertemppassworddel", [["pw", password]], options);
|
|
709
|
+
}
|