New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zone-mta

Package Overview
Dependencies
Maintainers
1
Versions
335
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone-mta - npm Package Compare versions

Comparing version

to
0.1.0-alpha.77

57

lib/mail-queue.js

@@ -400,19 +400,10 @@ 'use strict';

let domain = options.domain || false;
let index, end;
let lockOwner = options.lockOwner || false;
let getDomainConfig = options.getDomainConfig;
let iteratorName;
let iteratorName = 'zone ' + zone;
if (!domain) {
// index by zone
index = 'delivery-zone ' + encodeURIComponent(zone) + ' ';
end = 'delivery-zone ' + encodeURIComponent(zone) + ' ~';
iteratorName = 'zone ' + zone;
} else {
// index by zone + domain
index = 'delivery-domain ' + encodeURIComponent(domain) + ' ' + encodeURIComponent(zone) + ' ';
end = 'delivery-domain ' + encodeURIComponent(domain) + ' ' + encodeURIComponent(zone) + ' ~';
iteratorName = 'domain ' + domain + ' ' + zone;
}
// index by zone
index = 'delivery-zone ' + encodeURIComponent(zone) + ' ';
end = 'delivery-zone ' + encodeURIComponent(zone) + ' ~';

@@ -427,3 +418,3 @@ let iterator = this.getSharedIterator(iteratorName, {

valueAsBuffer: false,
limit: 100
limit: 1000
});

@@ -441,25 +432,4 @@

if (!key) {
if (domain && !options.toDomainOnly) {
// Retry without domain
domain = false;
// create new iterator
index = 'delivery-zone ' + encodeURIComponent(zone) + ' ';
end = 'delivery-zone ' + encodeURIComponent(zone) + ' ~';
iteratorName = 'zone ' + zone;
iterator = this.getSharedIterator(iteratorName, {
gt: index,
lt: end,
keys: true,
values: false,
fillCache: true,
keyAsBuffer: false,
valueAsBuffer: false,
limit: 100
});
// start over
return setImmediate(tryNext);
} else {
// We only end up here if we scanned through all keys and found nothing
return callback(null, false);
}
// We only end up here if we scanned through all keys and found nothing
return callback(null, false);
}

@@ -476,13 +446,4 @@

let zoneKey;
let domainKey;
let zoneKey = key;
if (domain) {
domainKey = key;
zoneKey = key.replace(/^delivery\-domain [^\s]+/, 'delivery-zone');
} else {
zoneKey = key;
domainKey = key.replace(/^delivery\-zone /, 'delivery-domain ' + key.split('%40').pop() + ' ');
}
// check if the key is already locked

@@ -527,2 +488,4 @@ if (!this.locks.lock(lockKey, zone, deliveryDomain, lockOwner, maxConnections)) {

let domainKey = zoneKey.replace(/^delivery\-zone /, 'delivery-domain ' + key.split('%40').pop() + ' ');
// zone key was found. probably a deferred recovery race, delete all

@@ -529,0 +492,0 @@ return this.releaseDelivery({

11

lib/queue-server.js

@@ -237,2 +237,13 @@ 'use strict';

break;
case 'CLEARCACHE':
// clears a key from shared cache
if (data.key) {
this.queue.cache.remove(data.key);
}
client.send({
req: data.req,
response: true
});
break;
}

@@ -239,0 +250,0 @@ };

@@ -272,5 +272,8 @@ 'use strict';

this.getConnection(delivery, (err, connection) => {
let domainData = {};
let ttl = 60 * 100;
let cmd;
if (err) {
let ttl;
let domainData = {};
// if we were not able to successfully connect to a server then store error result

@@ -289,5 +292,14 @@ domainData.error = err.message;

}
cmd = {
cmd: 'SETCACHE',
key: this.zone.name + ':' + cacheKey,
value: domainData,
ttl
};
} else {
// if the server was blocked then this update would release it
domainData.success = true;
cmd = {
cmd: 'CLEARCACHE',
key: this.zone.name + ':' + cacheKey
};
}

@@ -297,8 +309,3 @@

this.sendCommand({
cmd: 'SETCACHE',
key: this.zone.name + ':' + cacheKey,
value: domainData,
ttl
}, () => false);
this.sendCommand(cmd, () => false);
});

@@ -305,0 +312,0 @@ });

@@ -50,5 +50,2 @@ 'use strict';

// which domain to prefer when fetching new messages
this.lastDomain = false;
// If throttling is configured then calculate required parameters

@@ -140,4 +137,2 @@ if (zone.throttling) {

this.lastDomain = false;
// Respawn after 5 seconds

@@ -159,18 +154,5 @@ setTimeout(() => this.spawnSender(), 5 * 1000).unref();

this.queue.shift(this.name, {
domain: this.lastDomain,
lockOwner,
getDomainConfig: domain => this.domainConfig(domain)
}, (err, delivery) => {
if (err) {
return callback(err);
}
if (delivery) {
this.lastDomain = delivery.domain;
} else {
this.lastDomain = false;
}
return callback(null, delivery);
});
}, callback);
}

@@ -177,0 +159,0 @@

@@ -16,7 +16,7 @@ 'use strict';

this.closing = false;
this.timeout = false;
this.idleTimeout = false;
}
close() {
clearTimeout(this.timeout);
clearTimeout(this.idleTimeout);
clearTimeout(this.resetTimeout);

@@ -35,20 +35,19 @@ this.resetTimeout = false;

// function to run once the iterator has finished
let removeIterator = () => {
clearTimeout(this.resetTimeout);
if (this.iterator) {
this.iterator.end(() => false);
this.iterator = false;
this.iterators.delete(this.name);
}
};
if (this.inProgress) {
// in the middle of current iteration, wait until it finishes
this.nextQueue.push(removeIterator);
this.nextQueue.push(() => this.removeIterator());
} else {
removeIterator();
this.removeIterator();
}
}
removeIterator() {
clearTimeout(this.resetTimeout);
if (this.iterator) {
this.iterator.end(() => false);
this.iterator = false;
this.iterators.delete(this.name);
}
}
getNext(callback) {

@@ -70,12 +69,11 @@ if (!this.iterator) {

if (!this.resetTimeout) {
// keep this iterator alive for a second, this is needed to prevent creating a separate
// empty iterator for every client
this.resetTimeout = setTimeout(() => {
this.resetTimeout = false;
if (this.iterator) {
this.iterator.end(() => false);
this.iterator = false;
this.iterators.delete(this.name);
}
}, 1000);
if (!this.iterator.itemCount) {
// keep this iterator alive for a second, this is needed to prevent creating a separate
// empty iterator for every client if there's nothing to iterate on
this.resetTimeout = setTimeout(() => this.removeIterator(), 1000);
} else {
// we reached to an end of an iterator that had some data in it
// maybe there's more, so we do not wait until we can create a new one
this.removeIterator();
}
}

@@ -92,3 +90,3 @@

next(callback) {
clearTimeout(this.timeout);
clearTimeout(this.idleTimeout);
if (this.closing) {

@@ -111,9 +109,7 @@ // already closing, skip

// If this iterator is not needed in 3 seconds, delete it
// Not so important for Zone queues but for the domain queues
this.timeout = setTimeout(() => {
if (this.iterator) {
this.iterator.end(() => false);
this.iterator = false;
this.iterators.delete(this.name);
}
// Most probably there's a stalling send so no point continuing,
// just start over once it's done
this.idleTimeout = setTimeout(() => {
clearTimeout(this.idleTimeout);
this.removeIterator();
}, 3 * 1000);

@@ -120,0 +116,0 @@ return;

{
"name": "zone-mta",
"private": false,
"version": "0.1.0-alpha.76",
"version": "0.1.0-alpha.77",
"description": "Tiny outbound MTA",

@@ -6,0 +6,0 @@ "main": "app.js",