Support Pantalaimon for encryption support

Requires a special build of the bot-sdk and pantalaimon currently
This commit is contained in:
Travis Ralston 2019-10-02 22:20:37 -06:00
parent a2595652b8
commit 517025b6c2
4 changed files with 37 additions and 10 deletions

View File

@ -12,7 +12,7 @@ Phase 1:
* [x] Update lists with new bans/ACLs
Phase 2:
* [ ] Pantalaimon support
* [x] Pantalaimon support
* [ ] Redact messages on ban (optionally)
* [ ] Less spam in management room
* [ ] Vet rooms on startup option

View File

@ -1,9 +1,23 @@
# Where the homeserver is located (client-server URL)
# Where the homeserver is located (client-server URL). This should point at
# pantalaimon if you're using that.
homeserverUrl: "https://matrix.org"
# The access token for the bot to use
# The access token for the bot to use. Do not populate if using Pantalaimon.
accessToken: "YOUR_TOKEN_HERE"
# Pantalaimon options (https://github.com/matrix-org/pantalaimon)
pantalaimon:
# If true, accessToken above is ignored and the username/password below will be
# used instead. The access token of the bot will be stored in the dataPath.
use: false
# The username to login with.
username: mjolnir
# The password to login with. Can be removed after the bot has logged in once and
# stored the access token.
password: your_password
# The directory the bot should store various bits of information in
dataPath: "/data/storage"

View File

@ -19,6 +19,11 @@ import * as config from "config";
interface IConfig {
homeserverUrl: string;
accessToken: string;
pantalaimon: {
use: boolean;
username: string;
password: string;
};
dataPath: string;
autojoin: boolean;
managementRoom: string;

View File

@ -19,6 +19,7 @@ import {
AutojoinRoomsMixin,
LogService,
MatrixClient,
PantalaimonClient,
Permalinks,
RichConsoleLogger,
SimpleFsStorageProvider
@ -29,14 +30,21 @@ import { Mjolnir } from "./Mjolnir";
LogService.setLogger(new RichConsoleLogger());
const storage = new SimpleFsStorageProvider(path.join(config.dataPath, "bot.json"));
const client = new MatrixClient(config.homeserverUrl, config.accessToken, storage);
if (config.autojoin) {
AutojoinRoomsMixin.setupOnClient(client);
}
(async function () {
const storage = new SimpleFsStorageProvider(path.join(config.dataPath, "bot.json"));
let client: MatrixClient;
if (config.pantalaimon.use) {
const pantalaimon = new PantalaimonClient(config.homeserverUrl, storage);
client = await pantalaimon.createClientWithCredentials(config.pantalaimon.username, config.pantalaimon.password);
} else {
client = new MatrixClient(config.homeserverUrl, config.accessToken, storage);
}
if (config.autojoin) {
AutojoinRoomsMixin.setupOnClient(client);
}
const banLists: BanList[] = [];
const protectedRooms: { [roomId: string]: string } = {};