Skip to content

Commit

Permalink
Merge pull request #1376 from matrix-org/hs/additional-addresses-excl…
Browse files Browse the repository at this point in the history
…usive

Exclusively allow additional addresses when connecting to IRC
  • Loading branch information
Half-Shot committed Jun 9, 2021
2 parents 0bea1ce + 898a551 commit 67f83b9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/1376.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow only using the `additionalAddresses` field when connecting to IRC.
7 changes: 6 additions & 1 deletion config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ ircService:
# It is also used in the Third Party Lookup API as the instance `desc`
# property, where each server is an instance.
name: "ExampleNet"

# Additional addresses to connect to, used for load balancing between IRCDs.
additionalAddresses: [ "irc2.example.com" ]
# Typically additionalAddresses would be in addition to the address key given above,
# but some configurations wish to exclusively use additional addresses while reserving
# the top key for identification purposes. Set this to true to exclusively use the
# additionalAddresses array when connecting to servers.
onlyAdditionalAddresses: false
#
# [DEPRECATED] Use `name`, above, instead.
# A human-readable description string
Expand Down
2 changes: 2 additions & 0 deletions config.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ properties:
type: "array"
items:
type: "string"
onlyAdditionalAddresses:
type: "boolean"
ssl:
type: "boolean"
ca:
Expand Down
9 changes: 8 additions & 1 deletion src/irc/IrcServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IrcServerConfig {
password?: string;
allowExpiredCerts?: boolean;
additionalAddresses?: string[];
onlyAdditionalAddresses: boolean;
dynamicChannels: {
enabled: boolean;
published: boolean;
Expand Down Expand Up @@ -686,6 +687,7 @@ export class IrcServer {
public static get DEFAULT_CONFIG(): IrcServerConfig {
return {
sendConnectionMessages: true,
onlyAdditionalAddresses: false,
quitDebounce: {
enabled: false,
quitsPerSecond: 5,
Expand Down Expand Up @@ -797,7 +799,12 @@ export class IrcServer {
}

this.addresses = config.additionalAddresses || [];
this.addresses.push(this.domain);
// Don't include the original domain if not configured to.
if (!config.onlyAdditionalAddresses) {
this.addresses.push(this.domain);
} else if (this.addresses.length === 0) {
throw Error("onlyAdditionalAddresses is true, but no additional addresses are provided in the config");
}
this.excludedUsers = config.excludedUsers.map((excluded) => {
return {
...excluded,
Expand Down

0 comments on commit 67f83b9

Please sign in to comment.