Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclusively allow additional addresses when connecting to IRC #1376

Merged
merged 3 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
sslselfsign:
Expand Down
9 changes: 8 additions & 1 deletion src/irc/IrcServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface IrcServerConfig {
password?: string;
allowExpiredCerts?: boolean;
additionalAddresses?: string[];
onlyAdditionalAddresses: boolean;
dynamicChannels: {
enabled: boolean;
published: boolean;
Expand Down Expand Up @@ -678,6 +679,7 @@ export class IrcServer {
public static get DEFAULT_CONFIG(): IrcServerConfig {
return {
sendConnectionMessages: true,
onlyAdditionalAddresses: false,
quitDebounce: {
enabled: false,
quitsPerSecond: 5,
Expand Down Expand Up @@ -770,7 +772,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");
}
Half-Shot marked this conversation as resolved.
Show resolved Hide resolved
this.excludedUsers = config.excludedUsers.map((excluded) => {
return {
...excluded,
Expand Down