配置¶
配置文件位置¶
默认情况下,slidgeqq 会使用在 /etc/slidge/conf.d/* 中找到的所有配置文件。你可以使用 SLIDGE_CONF_DIR 环境变量来更改此设置,例如 SLIDGE_CONF_DIR=/path/dir1:/path/dir2:/path/dir3。
建议使用 /etc/slidge/conf.d/ 来存储所有 slidge 组件通用的配置选项(例如,附件处理、日志选项等),并在启动时指定一个插件特定的文件,例如:
slidge -c /etc/slidge/superduper.conf
slidgeqq 特定配置¶
slidgeqq 提供下表所示的组件级选项。它们可以:
在 配置文件 中作为
key=value使用;作为命令行参数使用,前面加上
--,例如--some-option=value;作为环境变量使用,大写,前面加上
SLIDGEQQ_,并且将短横线替换为下划线,例如SLIDGEQQ_SOME_OPTION=value。
通用 slidge 配置¶
警告
由于一个糟糕的混乱(将很快™修复),无法使用配置文件来关闭默认值为 true 的布尔参数。作为变通方法,请改用 CLI 参数,例如 --some-opt=false。
可以使用以下选项:
在 配置文件 中作为
key=value使用;作为命令行参数使用,前面加上
--,例如--some-option=value;作为环境变量,大写,前面加上
SLIDGE_,并且将短横线替换为下划线,例如SLIDGE_SOME_OPTION=value。
备注
以下选项适用于 slidge 版本 0.3.5。根据你安装 slidgeqq 的方式,你可能拥有不同版本的 slidge。请使用 slidgeqq --help 来获取你可以使用的确切选项列表。
必需设置¶
| name | default | help |
|---|---|---|
| secret | unset | The gateway component's secret (required to connect to the XMPP server) |
| jid | unset | The gateway component's JID |
基本配置¶
| name | default | help |
|---|---|---|
| admins | () | JIDs of the gateway admins |
| mam-max-days | 7 | Maximum number of days for group archive retention. |
| port | 5347 | The XMPP server's port for incoming component connections |
| server | localhost | The XMPP server's host name. Defaults to localhost, which is the standard way of running slidge, on the same host as the XMPP server. The 'Jabber Component Protocol' (XEP-0114) does not mention encryption, so you *should* provide encryption another way, eg via port forwarding, if you change this. |
| legacy-module | unset | Importable python module containing (at least) a BaseGateway and a LegacySession subclass. NB: this is not needed if you use a gateway-specific entrypoint, e.g., `slidgram` or `python -m slidgram`. |
| home-dir | inferred | Directory where slidge will writes it persistent data and cache. Defaults to /var/lib/slidge/${SLIDGE_JID}. |
| user-jid-validator | inferred | Regular expression to restrict users that can register to the gateway, by JID. Defaults to .*@${INFERRED_SERVER}. INFERRED_SERVER is derived for the gateway JID, by removing whatever is before the first encountered dot in it. Example: if slidge's JID=slidge.example.org, INFERRED_SERVER=example.org. |
附件¶
| name | default | help |
|---|---|---|
| attachment-maximum-file-name-length | 200 | Some legacy network provide ridiculously long filenames, strip above this limit, preserving suffix. |
| convert-stickers | False | Convert lottie vector stickers (from the legacy side) to webp animations. |
| fix-filename-suffix-mime-type | False | Fix the Filename suffix based on the Mime Type of the file. Some clients (eg Conversations) may not inline files that have a wrong suffix for the MIME Type. Therefore the MIME Type of the file is checked, if the suffix is not valid for that MIME Type, a valid one will be picked. |
| no-upload-file-read-others | False | After writing a file in NO_UPLOAD_PATH, change its permission so that 'others' can read it. |
| no-upload-method | copy | Whether to 'copy', 'move', 'hardlink' or 'symlink' the files in no-upload-path. |
| no-upload-path | None | Instead of using the XMPP server's HTTP upload component, copy files to this dir. You need to set NO_UPLOAD_URL_PREFIX too if you use this option, and configure an web server to serve files in this dir. |
| no-upload-url-prefix | None | Base URL that servers files in the dir set in the no-upload-path option, eg https://example.com:666/slidge-attachments/ |
| upload-requester | None | Set which JID should request the upload slots. Defaults to the user's JID if IQ/get privileges granted for the 'urn:xmpp:http:upload:0' namespace; the component JID otherwise. |
| upload-service | None | JID of an HTTP upload service the gateway can use. This is optional, as it should be automatically determined via servicediscovery. |
| upload-url-prefix | None | This is an optional setting to make sure the URL of your upload service is never leaked to the legacy network in bodies of messages. This can happen under rare circumstances and/or bugs,when replying to an attachment. Set this to the common prefix of the public URL your attachments get, eg https://upload.example.org:5281/ |
| use-attachment-original-urls | False | For legacy plugins in which attachments are publicly downloadable URLs, let XMPP clients directly download them from this URL. Note that this will probably leak your client IP to the legacy network. |
日志¶
| name | default | help |
|---|---|---|
| log-file | None | Log to a file instead of stdout/err |
| log-format | %(levelname)s:%(name)s:%(message)s | Optionally, a format string for logging messages. Refer to https://docs.python.org/3/library/logging.html#logrecord-attributes for available options. |
高级设置¶
| name | default | help |
|---|---|---|
| avatar-resampling-threads | 2 | Number of additional threads to use for avatar resampling. Even in a single-core context, this makes avatar resampling non-blocking. |
| avatar-size | 200 | Maximum image size (width and height), image ratio will be preserved |
| component-name | None | Overrides the default component name with a custom one. This is seen in service discovery and as the nickname of the component in chat windows. |
| dev-mode | False | Enables an interactive python shell via chat commands, for admins.Not safe to use in prod, but great during dev. |
| ignore-delay-threshold | 300 | Threshold, in seconds, below which the <delay> information is stripped out of emitted stanzas. |
| partial-registration-timeout | 3600 | Timeout before registration and login. Only useful for legacy networks where a single step registration process is not enough. |
| qr-timeout | 60 | Timeout for QR code flashing confirmation. |
| strip-leading-emoji-adhoc | False | Strip the leading emoji in ad-hoc command names, if present, in case you are a emoji-hater. |
| welcome-message | None | Overrides the default welcome message received by newly registered users. |
| db-url | inferred | Database URL, see <https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls>. Defaults to sqlite:///${HOME_DIR}/slidge.sqlite |
高级日志配置¶
要自定义 slidge 的输出,你可以使用命令行参数 --log-config 来指定一个 日志配置文件。