Skip to content

Commit

Permalink
Move mediaProxy configuration to the top level
Browse files Browse the repository at this point in the history
This bypasses its weird interactions with ApplyConfig which would
sometimes cause it to not be initialized properly.
  • Loading branch information
tadzik committed Sep 6, 2024
1 parent 29d3d93 commit dda35d0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
21 changes: 11 additions & 10 deletions config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ bridge:
appservicePort: 9555
# Config for the media proxy
# required to serve publically accessible URLs to authenticated Matrix media
mediaProxy:
# To generate a .jwk file:
# $ node src/generate-signing-key.js > signingkey.jwk
signingKeyPath: "signingkey.jwk"
# How long should the generated URLs be valid for
ttlSeconds: 3600
# The port for the media proxy to listen on
bindPort: 11111
# The publically accessible URL to the media proxy
publicUrl: "https://bifrost.bridge/media"

mediaProxy:
# To generate a .jwk file:
# $ node src/generate-signing-key.js > signingkey.jwk
signingKeyPath: "signingkey.jwk"
# How long should the generated URLs be valid for
ttlSeconds: 3600
# The port for the media proxy to listen on
bindPort: 11111
# The publically accessible URL to the media proxy
publicUrl: "https://bifrost.bridge/media"

roomRules: []
# - room: "#badroom:example.com"
Expand Down
28 changes: 14 additions & 14 deletions config/config.schema.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"$schema": "http://json-schema.org/draft-07/schema#"
"$id": "http://matrix.org/bifrost/schema"
type: object
required: ["bridge", "datastore", "purple", "portals"]
required: ["bridge", "mediaProxy", "datastore", "purple", "portals"]
properties:
bridge:
type: object
required: ["domain", "homeserverUrl", "userPrefix", "mediaProxy"]
required: ["domain", "homeserverUrl", "userPrefix"]
properties:
domain:
type: string
Expand All @@ -15,18 +15,18 @@ properties:
type: string
appservicePort:
type: number
mediaProxy:
type: "object"
properties:
signingKeyPath:
type: "string"
ttlSeconds:
type: "integer"
bindPort:
type: "integer"
publicUrl:
type: "string"
required: ["signingKeyPath", "ttlSeconds", "bindPort", "publicUrl"]
mediaProxy:
type: "object"
properties:
signingKeyPath:
type: "string"
ttlSeconds:
type: "integer"
bindPort:
type: "integer"
publicUrl:
type: "string"
required: ["signingKeyPath", "ttlSeconds", "bindPort", "publicUrl"]
datastore:
required: ["engine"]
type: "object"
Expand Down
21 changes: 9 additions & 12 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ export class Config {
homeserverUrl: "",
userPrefix: "_bifrost_",
appservicePort: 9555,
mediaProxy: {
signingKeyPath: "",
ttlSeconds: 0,
bindPort: 0,
publicUrl: ""
},
};

public readonly mediaProxy: IMediaProxy;

public readonly roomRules: IConfigRoomRule[] = [];

public readonly datastore: IConfigDatastore = {
Expand Down Expand Up @@ -109,12 +105,13 @@ export interface IConfigBridge {
homeserverUrl: string;
userPrefix: string;
appservicePort?: number;
mediaProxy: {
signingKeyPath: string;
ttlSeconds: number;
bindPort: number;
publicUrl: string;
},
}

export interface IMediaProxy {
signingKeyPath: string;
ttlSeconds: number;
bindPort: number;
publicUrl: string;
}

export interface IConfigPurple {
Expand Down
2 changes: 1 addition & 1 deletion src/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Program {
}

private async initialiseMediaProxy(): Promise<MediaProxy> {
const config = this.config.bridge.mediaProxy;
const config = this.config.mediaProxy;
const jwk = JSON.parse(fs.readFileSync(config.signingKeyPath, "utf8").toString());
const signingKey = await webcrypto.subtle.importKey('jwk', jwk, {
name: 'HMAC',
Expand Down

0 comments on commit dda35d0

Please sign in to comment.