Skip to content

Commit

Permalink
prefix node builtin deps with node:
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 14, 2024
1 parent bb7ab9c commit 4b82d0f
Show file tree
Hide file tree
Showing 29 changed files with 74 additions and 78 deletions.
12 changes: 6 additions & 6 deletions bin/haraka
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// this script takes inspiration from:
// https://github.com/tnantoka/LooseLeaf/blob/master/bin/looseleaf

const child = require('child_process');
const fs = require('fs');
const net = require('net');
const nopt = require('nopt');
const path = require('path');
const os = require('os');
const child = require('node:child_process');
const fs = require('node:fs');
const net = require('node:net');
const path = require('node:path');
const os = require('node:os');

const nopt = require('nopt');
const utils = require('haraka-utils');
const sprintf = require('sprintf-js').sprintf;
const base = path.join(__dirname, '..');
Expand Down
7 changes: 3 additions & 4 deletions connection.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';
// a single connection

// node.js built-in libs
const dns = require('dns');
const net = require('net');
const os = require('os');
const dns = require('node:dns');
const net = require('node:net');
const os = require('node:os');

// npm libs
const ipaddr = require('ipaddr.js');
Expand Down
2 changes: 1 addition & 1 deletion host_pool.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const net = require('net');
const net = require('node:net');
const utils = require('haraka-utils');

/* HostPool:
Expand Down
2 changes: 1 addition & 1 deletion line_socket.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
// A subclass of Socket which reads data by line

const net = require('net');
const net = require('node:net');
const utils = require('haraka-utils');

const tls_socket = require('./tls_socket');
Expand Down
4 changes: 2 additions & 2 deletions logger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
// Log class

const util = require('util');
const tty = require('tty');
const util = require('node:util');
const tty = require('node:tty');

const config = require('haraka-config');
const constants = require('haraka-constants');
Expand Down
2 changes: 1 addition & 1 deletion outbound/fsync_writestream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const fs = require('fs');
const fs = require('node:fs');

class FsyncWriteStream extends fs.WriteStream {
constructor (path, options) {
Expand Down
8 changes: 4 additions & 4 deletions outbound/hmail.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const events = require('events');
const fs = require('fs');
const dns = require('dns');
const path = require('path');
const events = require('node:events');
const fs = require('node:fs');
const dns = require('node:dns');
const path = require('node:path');

const { Address } = require('address-rfc2821');
const config = require('haraka-config');
Expand Down
4 changes: 2 additions & 2 deletions outbound/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');

const async = require('async');
const { Address } = require('address-rfc2821');
Expand Down
2 changes: 1 addition & 1 deletion outbound/qfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const os = require('os');
const os = require('node:os');
const platform_dot = `${(['win32','win64'].includes(process.platform)) ? '' : '__tmp__'}.`;

let QFILECOUNTER = 0;
Expand Down
6 changes: 3 additions & 3 deletions outbound/queue.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const child_process = require('node:child_process');
const fs = require('node:fs');
const path = require('node:path');

const async = require('async');
const { Address } = require('address-rfc2821');
Expand Down
7 changes: 4 additions & 3 deletions outbound/tls.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';

const net = require('net')
const net = require('node:net')

const logger = require('../logger');
const tls_socket = require('../tls_socket');
const config = require('haraka-config');
const hkredis = require('haraka-plugin-redis');

const logger = require('../logger');
const tls_socket = require('../tls_socket');

const inheritable_opts = [
'key', 'cert', 'ciphers', 'minVersion', 'dhparam',
'requestCert', 'honorCipherOrder', 'rejectUnauthorized',
Expand Down
6 changes: 3 additions & 3 deletions plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// load all defined plugins

// node built-ins
const fs = require('fs');
const path = require('path');
const vm = require('vm');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');

// npm modules
exports.config = require('haraka-config');
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth/auth_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Note: You can disable setting `connection.notes.auth_passwd` by `plugin.blankout_password = true`

const crypto = require('crypto');
const crypto = require('node:crypto');

const tlds = require('haraka-tld')
const utils = require('haraka-utils');
Expand Down
2 changes: 1 addition & 1 deletion plugins/auth/auth_vpopmaild.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Auth against vpopmaild

const net = require('net');
const net = require('node:net');

exports.register = function () {
this.inherits('auth/auth_base');
Expand Down
2 changes: 1 addition & 1 deletion plugins/block_me.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// in the mail_from.blocklist file. You need to be running the
// mail_from.blocklist plugin for this to work fully.

const fs = require('fs');
const fs = require('node:fs');
const utils = require('haraka-utils');

exports.hook_data = (next, connection) => {
Expand Down
6 changes: 2 additions & 4 deletions plugins/data.signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

exports.hook_data = (next, connection) => {
// enable mail body parsing
if (!connection?.transaction) return next();

connection.transaction.parse_body = true;
if (connection?.transaction) connection.transaction.parse_body = true;
next();
}

Expand All @@ -17,7 +15,7 @@ exports.hook_data_post = function (next, connection) {
if (check_sigs(sigs, connection.transaction.body)) {
return next(DENY, "Mail matches a known spam signature");
}
return next();
next();
}

function check_sigs (sigs, body) {
Expand Down
3 changes: 2 additions & 1 deletion plugins/early_talker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// This plugin checks for clients that talk before we sent a response

const { isIPv6 } = require('node:net');

const ipaddr = require('ipaddr.js');
const { isIPv6 } = require('net');

exports.register = function () {
this.load_config();
Expand Down
2 changes: 1 addition & 1 deletion plugins/mail_from.is_resolvable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// Check MAIL FROM domain is resolvable to an MX
const net = require('net');
const net = require('node:net');

const net_utils = require('haraka-net-utils');

Expand Down
4 changes: 2 additions & 2 deletions plugins/queue/qmail-queue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Queue to qmail-queue

const childproc = require('child_process');
const fs = require('fs');
const childproc = require('node:child_process');
const fs = require('node:fs');

exports.register = function () {

Expand Down
4 changes: 2 additions & 2 deletions plugins/queue/quarantine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// quarantine

const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');

exports.register = function () {

Expand Down
2 changes: 1 addition & 1 deletion plugins/queue/smtp_forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// and passes back any errors seen on the ongoing server to the
// originating server.

const url = require('url');
const url = require('node:url');

const smtp_client_mod = require('./smtp_client');

Expand Down
4 changes: 2 additions & 2 deletions plugins/queue/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const os = require('os');
const fs = require('node:fs');
const os = require('node:os');

const tempDir = os.tmpdir();

Expand Down
13 changes: 6 additions & 7 deletions plugins/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
//
// documentation via: haraka -h relay

const net = require('node:net');

const ipaddr = require('ipaddr.js');
const net = require('net');

exports.register = function () {

Expand Down Expand Up @@ -89,11 +90,9 @@ exports.acl = function (next, connection) {
}

exports.pass_relaying = (next, connection) => {
if (connection.relaying) {
return next(OK);
}
if (connection.relaying) return next(OK);

return next();
next();
}

exports.is_acl_allowed = function (connection) {
Expand Down Expand Up @@ -172,7 +171,7 @@ exports.dest_domains = function (next, connection, params) {
}

transaction.results.add(this, {fail: 'relay_dest_domain'});
return next(DENY, "Mail for that recipient is not accepted here.");
next(DENY, "Mail for that recipient is not accepted here.");
}

exports.force_routing = function (next, hmail, domain) {
Expand All @@ -196,7 +195,7 @@ exports.force_routing = function (next, hmail, domain) {
}

this.logdebug(this, `using ${nexthop} for: ${domain}`);
return next(OK, nexthop);
next(OK, nexthop);
}

exports.all = function (next, connection, params) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/reseed_rng.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const crypto = require('crypto');
const crypto = require('node:crypto');

exports.hook_init_child = function (next) {
Math.seedrandom(crypto.randomBytes(256).toString('hex'));
Expand Down
5 changes: 3 additions & 2 deletions plugins/status.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');

const async = require('async');

exports.register = function () {
Expand Down
5 changes: 3 additions & 2 deletions plugins/xclient.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Implementation of XCLIENT protocol
// See http://www.postfix.org/XCLIENT_README.html

const net = require('node:net');

const utils = require('haraka-utils');
const DSN = require('haraka-dsn');
const net = require('net');
let allowed_hosts = {};

exports.register = function () {
Expand Down Expand Up @@ -119,5 +120,5 @@ exports.hook_unrecognized_command = function (next, connection, params) {
connection.xclient = true;
if (!xclient.name) return next(NEXT_HOOK, 'lookup_rdns');

return next(NEXT_HOOK, 'connect');
next(NEXT_HOOK, 'connect');
}
17 changes: 8 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
'use strict';
// smtp network server

const daemon = require('daemon');
const fs = require('fs');
const os = require('os');
const path = require('path');
const tls = require('tls');
const cluster = require('node:cluster');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const tls = require('node:tls');

// let log = require('why-is-node-running');
const async = require('async');
const daemon = require('daemon');
const tls_socket = require('./tls_socket');
const conn = require('./connection');
const outbound = require('./outbound');
const async = require('async');
const cluster = require('cluster');
const constants = require('haraka-constants');
const endpoint = require('./endpoint');
const constants = require('haraka-constants');

const Server = exports;
Server.logger = require('./logger');
Expand Down
15 changes: 6 additions & 9 deletions smtp_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
// than a bunch of connections to a single host from the configuration values
// in "host" and "port" (see host_pool.js).

// node.js builtins
const events = require('events');
const events = require('node:events');

// npm deps
const ipaddr = require('ipaddr.js');
const net_utils = require('haraka-net-utils');
const utils = require('haraka-utils');
const ipaddr = require('ipaddr.js');
const net_utils = require('haraka-net-utils');
const utils = require('haraka-utils');

// haraka libs
const tls_socket = require('./tls_socket')
const logger = require('./logger');
const HostPool = require('./host_pool');
const logger = require('./logger');
const HostPool = require('./host_pool');

const smtp_regexp = /^(\d{3})([ -])(.*)/;
const STATE = {
Expand Down
2 changes: 1 addition & 1 deletion transaction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
// An SMTP Transaction

const util = require('util');
const util = require('node:util');

const Notes = require('haraka-notes');
const utils = require('haraka-utils');
Expand Down

0 comments on commit 4b82d0f

Please sign in to comment.