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

ZMS-167 #740

Merged
merged 1 commit into from
Oct 14, 2024
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
2 changes: 1 addition & 1 deletion api.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ server.use(async (req, res) => {
req.role = tokenData.role;
req.user = tokenData.user;

// make a reference to original method, otherwise might be overrided
// make a reference to original method, otherwise might be overridden
let setAuthToken = userHandler.setAuthToken.bind(userHandler);

req.accessToken = {
Expand Down
10 changes: 5 additions & 5 deletions config/imap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ maxMB = 25
# delete messages from \Trash and \Junk after retention days
retention = 30

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

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

Expand All @@ -35,8 +35,8 @@ enableCompression = false

# If true, then expect HAProxy PROXY header as the first line of data
useProxy = false
# useProxy=true # expect PROXY from all conections
# useProxy=['*'] # expect PROXY from all conections
# useProxy=true # expect PROXY from all connections
# useProxy=['*'] # expect PROXY from all connections
# 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)
Expand All @@ -54,7 +54,7 @@ ignoredHosts = []
#secure=false
#ignoreSTARTTLS=true

# Apple push notificiations
# Apple push notifications
# TODO: missing actual implementation for Apple Push Service
[aps]
enabled = false
Expand Down
24 changes: 12 additions & 12 deletions config/pop3.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# If enabled then WildDuck exposes a limited POP3 interface for listing and fetching emails
enabled=true
port=9995
enabled = true
port = 9995
# by default bind to localhost only
host="0.0.0.0"
host = "0.0.0.0"

# Use `true` for port 995 and `false` for 110
secure=true
secure = true

# If true, then do not show server info in CAPA response
disableVersionString=false
disableVersionString = false

# How many latest messages to list for LIST and UIDL
# POP3 server never lists all messages but only a limited length list
maxMessages=250
maxMessages = 250

# Max donwload bandwith per day in megabytes
# Max download bandwidth per day in megabytes
# Replaced by 'const:max:pop3:download' setting
maxDownloadMB=10240
maxDownloadMB = 10240

# If true, then expect HAProxy PROXY header as the first line of data
useProxy=false
useProxy = false

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

#name="WildDuck POP3"
#version="1.0.0"
Expand All @@ -34,7 +34,7 @@ ignoredHosts=[]

[setup]
# Public configuration for POP3
hostname="localhost"
secure=true
hostname = "localhost"
secure = true
# port defaults to pop3.port
#port=9995
4 changes: 2 additions & 2 deletions config/tls.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default TLS keys (can be overriden by individual services)
# Default TLS keys (can be overridden by individual services)
#key="/path/to/server/key.pem"
#ca=["/path/to/server/ca1.pem", "/path/to/server/ca2.pem"]
#cert="/path/to/server/cert.pem"
#dhparam="/path/to/server/dhparam.pem"
#dhparam="/path/to/server/dhparam.pem"
2 changes: 1 addition & 1 deletion docs/api-error-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- `FileNotFound`: This file does not exist
- `InsecurePasswordError`: Provided password was found from breached passwords list
- `ERRCOMPOSE`: Could not queue message for delivery
- `KeyGenereateError`: Failed to generate private or public key
- `KeyGenerateError`: Failed to generate private or public key
- `InternalConfigError`: Invalid encryption settings
- `HashError`
- `UserUpdateFail`: Could not update user
Expand Down
2 changes: 1 addition & 1 deletion docs/api/openapidocs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/in-depth/command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ wduck-users() {
}
```

### Query user informations
### Query user information

```
curl -i http://localhost:8080/users/$USERID
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
_user: this.session.user.id.toString(),
_mailbox: this.selected.mailbox,
_sess: this.id,
_message_count: messages.lentgh
_message_count: messages.length
};

this._server.onCopy(
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module.exports = {
let specialUseFlag = folder.specialUse;
if (specialUseFlag) {
if (isXlist && XlistTags.has(specialUseFlag)) {
// rewite flag to XLIST tag which is a bit different
// rewrite flag to XLIST tag which is a bit different
specialUseFlag = XlistTags.get(specialUseFlag);
}
flags.push(specialUseFlag);
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
_user: this.session.user.id.toString(),
_mailbox: this.selected.mailbox,
_sess: this.id,
_message_count: messages.lentgh
_message_count: messages.length
};

this._server.onMove(
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
state: ['Authenticated', 'Selected'],

handler(command, callback) {
// fixed structre
// fixed structure
this.send('* NAMESPACE (("" "/")) NIL NIL');

callback(null, {
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function parseQueryTerms(terms, uidList) {
break;

case 'or':
// ensure that value is alwas an array
// ensure that value is always an array
response.value = [].concat(curTerm.slice(1) || []);
break;

Expand Down
20 changes: 11 additions & 9 deletions imap-core/lib/commands/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
let type = 'flags'; // currently hard coded, in the future might support other values as well, eg. X-GM-LABELS
let range = (command.attributes[0] && command.attributes[0].value) || '';

// if arguments include extenstions at index 1, then length is 4, otherwise 3
// if arguments include extensions at index 1, then length is 4, otherwise 3
let pos = command.attributes.length === 4 ? 1 : 0;

let action = ((command.attributes[pos + 1] && command.attributes[pos + 1].value) || '').toString().toUpperCase();
Expand Down Expand Up @@ -124,7 +124,7 @@ module.exports = {
_user: this.session.user.id.toString(),
_mailbox: this.selected.mailbox,
_sess: this.id,
_message_count: messages.lentgh,
_message_count: messages.length,
_flags: flags.join(', '),
_store_action: action,
_silent: silent ? 'yes' : '',
Expand Down Expand Up @@ -157,11 +157,13 @@ module.exports = {
// STORE returns MODIFIED as sequence numbers, so convert UIDs to sequence list
if (modified && modified.length) {
logdata._modified = modified.length;
modified = modified.map(uid => this.selected.uidList.indexOf(uid) + 1).filter(
seq =>
// ensure that deleted items (eg seq=0) do not end up in the list
seq > 0
);
modified = modified
.map(uid => this.selected.uidList.indexOf(uid) + 1)
.filter(
seq =>
// ensure that deleted items (eg seq=0) do not end up in the list
seq > 0
);
}

let message = success === true ? 'STORE completed' : false;
Expand All @@ -181,8 +183,8 @@ module.exports = {
typeof success === 'string'
? success.toUpperCase()
: modified && modified.length
? 'MODIFIED ' + imapTools.packMessageRange(modified)
: false,
? 'MODIFIED ' + imapTools.packMessageRange(modified)
: false,
message
};

Expand Down
8 changes: 4 additions & 4 deletions imap-core/lib/commands/uid-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
let type = 'flags'; // currently hard coded, in the future might support other values as well, eg. X-GM-LABELS
let range = (command.attributes[0] && command.attributes[0].value) || '';

// if arguments include extenstions at index 1, then length is 4, otherwise 3
// if arguments include extensions at index 1, then length is 4, otherwise 3
let pos = command.attributes.length === 4 ? 1 : 0;

let action = ((command.attributes[pos + 1] && command.attributes[pos + 1].value) || '').toString().toUpperCase();
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = {
_user: this.session.user.id.toString(),
_mailbox: this.selected.mailbox,
_sess: this.id,
_message_count: messages.lentgh,
_message_count: messages.length,
_flags: flags.join(', '),
_store_action: action,
_silent: silent ? 'yes' : '',
Expand Down Expand Up @@ -160,8 +160,8 @@ module.exports = {
typeof success === 'string'
? success.toUpperCase()
: modified && modified.length
? 'MODIFIED ' + imapTools.packMessageRange(modified)
: false,
? 'MODIFIED ' + imapTools.packMessageRange(modified)
: false,
message
});
}
Expand Down
2 changes: 1 addition & 1 deletion imap-core/lib/commands/xapplepushservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {
}
}

// Make sure all required keys (exept mailboxes) are present
// Make sure all required keys (except mailboxes) are present
for (let requiredKey of requiredKeys) {
if (!data[requiredKey] && requiredKey !== 'mailboxes') {
return callback(null, {
Expand Down
22 changes: 8 additions & 14 deletions imap-core/lib/handler/imap-compile-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ module.exports = (response, isLogging) => {
if (stream.isLimited) {
// stream is already limited
let limiter = new LengthLimiter(expectedLength - startFrom, ' ', 0);
stream.pipe(limiter).pipe(
output,
{
end: false
}
);
stream.pipe(limiter).pipe(output, {
end: false
});
limiter.once('end', () => resolve());
} else {
// force limites
let limiter = new LengthLimiter(expectedLength, ' ', startFrom);
stream.pipe(limiter).pipe(
output,
{
end: false
}
);
stream.pipe(limiter).pipe(output, {
end: false
});
limiter.once('end', () => resolve());
}

Expand Down Expand Up @@ -106,7 +100,7 @@ module.exports = (response, isLogging) => {
// (...)
resp.push(LEFT_PARENTHESIS);

// Check if we need to skip separtor WS between two arrays
// Check if we need to skip separator WS between two arrays
let isSubArray = node.length > 1 && Array.isArray(node[0]);

for (let child of node) {
Expand Down Expand Up @@ -190,7 +184,7 @@ module.exports = (response, isLogging) => {
if (isLogging && node.value.length > 20) {
resp.push(Buffer.from('"(* ' + node.value.length + 'B string *)"'));
} else {
// JSON.stringify conveniently adds enclosing quotes and escapes any "\ occurences
// JSON.stringify conveniently adds enclosing quotes and escapes any "\ occurrences
resp.push(Buffer.from(JSON.stringify((node.value || '').toString('binary')), 'binary'));
}
break;
Expand Down
6 changes: 3 additions & 3 deletions imap-core/lib/handler/imap-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const imapFormalSyntax = require('./imap-formal-syntax');
/**
* Compiles an input object into
*/
module.exports = function(response, asArray, isLogging) {
module.exports = function (response, asArray, isLogging) {
let respParts = [];
let resp = (response.tag || '') + (response.command ? ' ' + response.command : '');
let val;
let lastType;
let walk = function(node, options) {
let walk = function (node, options) {
options = options || {};

if (lastType === 'LITERAL' || (!['(', '<', '['].includes(resp.substr(-1)) && resp.length)) {
Expand All @@ -32,7 +32,7 @@ module.exports = function(response, asArray, isLogging) {
lastType = 'LIST';
resp += '(';

// check if we need to skip separtor WS between two arrays
// check if we need to skip separator WS between two arrays
let subArray = node.length > 1 && Array.isArray(node[0]);

node.forEach(child => {
Expand Down
4 changes: 2 additions & 2 deletions imap-core/lib/imap-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class IMAPConnection extends EventEmitter {
return this.close();
}
if (this.compression) {
// make sure we transmit the message immediatelly
// make sure we transmit the message immediately
this._deflate.flush();
}
this.logger.debug(
Expand Down Expand Up @@ -621,7 +621,7 @@ class IMAPConnection extends EventEmitter {
// append received notifications to the list
conn.selected.notifications = conn.selected.notifications.concat(updates);
if (conn.idling) {
// when idling emit notifications immediatelly
// when idling emit notifications immediately
conn.emitNotifications();
}
});
Expand Down
4 changes: 2 additions & 2 deletions imap-core/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const queryHandlers = {
return callback(null, true);
},

// matches if the message object includes (exists:true) or does not include (exists:false) specifiec flag
// matches if the message object includes (exists:true) or does not include (exists:false) specific flag
flag(message, query, callback) {
let pos = [].concat(message.flags || []).indexOf(query.value);
return callback(null, query.exists ? pos >= 0 : pos < 0);
Expand Down Expand Up @@ -290,7 +290,7 @@ function matchSearchTerm(message, query, callback) {
}

/**
* Traverses query tree and checks if all query terms match or not. Stops on first false match occurence
* Traverses query tree and checks if all query terms match or not. Stops on first false match occurrence
*
* @param {Object} message Stored message object
* @param {Object} query Query term object
Expand Down
Loading