Skip to content

Commit

Permalink
Do not use wild-config directly in imap-core
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Aug 31, 2023
1 parent 77adb92 commit 1bc4bbc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
32 changes: 16 additions & 16 deletions config/imap.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# If enabled then WildDuck exposes an IMAP interface for listing and fetching emails
enabled=true
port=9993
host="0.0.0.0"
enabled = true
port = 9993
host = "0.0.0.0"

# Use `true` for port 993 and `false` for 143. If connection is not secured
# on connection then WildDuck enables STARTTLS extension
secure=true
secure = true

# Max size for messages uploaded via APPEND
maxMB=25
maxMB = 25

# delete messages from \Trash and \Junk after retention days
retention=30
retention = 30

# Default max donwload bandwith per day in megabytes
# Replaced by 'const:max:imap:download' setting
maxDownloadMB=10240
maxDownloadMB = 10240

# Default max upload bandwith per day in megabytes
# Replaced by 'const:max:imap:upload' setting
maxUploadMB=10240
maxUploadMB = 10240

# Default max concurrent connections per service per client
maxConnections=15
maxConnections = 15

# if `true` then do not autodelete expired messages
disableRetention=false
disableRetention = false

# If true, then disables STARTTLS support
disableSTARTTLS=false
disableSTARTTLS = false

# If true, then advertises COMPRESS=DEFLATE capability
enableCompression=false
enableCompression = false

# If true, then expect HAProxy PROXY header as the first line of data
useProxy=false
useProxy = false
# useProxy=true # expect PROXY from all conections
# useProxy=['*'] # expect PROXY from all conections
# useProxy=['1.2.3.4', '1.2.3.5'] # expect PROXY only from connections from listed IP addresses

# an array of IP addresses to ignore (not logged)
ignoredHosts=[]
ignoredHosts = []

#name="WildDuck IMAP"
#version="1.0.0"
Expand All @@ -56,8 +56,8 @@ ignoredHosts=[]

[setup]
# Public configuration for IMAP
hostname="localhost"
secure=true
hostname = "localhost"
secure = true
# port defaults to imap.port
#port=9993

Expand Down
10 changes: 8 additions & 2 deletions imap-core/lib/commands/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const config = require('wild-config');

Check failure on line 3 in imap-core/lib/commands/logout.js

View workflow job for this annotation

GitHub Actions / test (16.x, ubuntu-20.04)

'config' is assigned a value but never used

Check failure on line 3 in imap-core/lib/commands/logout.js

View workflow job for this annotation

GitHub Actions / test (18.x, ubuntu-20.04)

'config' is assigned a value but never used

Check failure on line 3 in imap-core/lib/commands/logout.js

View workflow job for this annotation

GitHub Actions / test (20.x, ubuntu-20.04)

'config' is assigned a value but never used

const quotes = config.imap.quotes || [
const DEFAULT_QUOTES = [
'All dreams are but another reality. Never forget...',
'Oh boy, oh boy, oh boy...',
'Cut the dramatics, would yeh, and follow me!',
Expand Down Expand Up @@ -34,7 +34,13 @@ module.exports = {

this.clearNotificationListener();
this.send('* BYE Logout requested');
this.send(command.tag + ' OK ' + quotes[Math.floor(Math.random() * quotes.length)]);

let logoutMessages = [].concat(this._server.options.logoutMessages || []).filter(msg => typeof msg === 'string');
if (!logoutMessages || !logoutMessages.length) {
logoutMessages = DEFAULT_QUOTES;
}

this.send(command.tag + ' OK ' + logoutMessages[Math.floor(Math.random() * logoutMessages.length)]);
setImmediate(() => this.close());
}
};
2 changes: 2 additions & 0 deletions imap.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ let createInterface = (ifaceOptions, callback) => {

certs.loadTLSOptions(serverOptions, 'imap');

serverOptions.logoutMessages = config.imap.quotes;

const server = new IMAPServer(serverOptions);

certs.registerReload(server, 'imap');
Expand Down

0 comments on commit 1bc4bbc

Please sign in to comment.