Skip to content

Commit

Permalink
style: prefix node libs, arrow fns (#3359)
Browse files Browse the repository at this point in the history
- prefix node libs with `node:`
- conn: replace a fn with arrow function
- contrib/plugin2npm.sh: fix path to package.json
- config/plugins: consistent formatting
- fix(mf.resolv): this -> plugin, fixes #3361
  • Loading branch information
msimerson authored May 15, 2024
1 parent f4cc2a6 commit 027b1ba
Show file tree
Hide file tree
Showing 43 changed files with 156 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@

#### Changed

- prefix node libs with 'node:' #3359
- .gitignore: add config/me and config/*.pem
- auth_base: enable disabling constrain_sender at runtime #3298
- auth_base: skip constrain_sender when auth user has no domain #3319
- avg: repackaged as NPM module #3347
- bounce: repackaged plugin as NPM module #3341
- clamd: repackaged plugin as NPM module
- config/plugins: consistent formatting #3359
- connection: check remote is connected before queue #3338
- improve log message for queue* hooks, fixes #2998
- support IPv6 when setting remote.is_private #3295
- in setTLS, replace forEach with for...of
- NOTE: remove a handful of 3.0 sunset property names #3315
- contrib/plugin2npm.sh: fix path to package.json #3359
- deps: bump all versions to latest #3303, #3344
- dkim: repackaged as NPM module #3311
- esets: repackaged as NPM module #3353
Expand Down
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
71 changes: 36 additions & 35 deletions config/plugins
Original file line number Diff line number Diff line change
@@ -1,71 +1,72 @@
# This file lists plugins that Haraka will run
#
# Plugin ordering often matters, run 'haraka -o -c /path/to/haraka/config'
# to see the order plugins (and their hooks) will run in.
# to see the order plugins (and their hooks) will run.
#
# To see a list of all plugins, run 'haraka -l'
# To see a list of installed plugins, run 'haraka -l'
#
# To see the help docs for a particular plugin, run 'haraka -h plugin.name'
# The plugin registry: https://github.com/haraka/Haraka/blob/master/Plugins.md
#
# To see the docs for a plugin, run 'haraka -h plugin.name'

#status
#process_title
# Log to syslog (see 'haraka -h syslog')
# status
# process_title
# syslog
# watch

# CONNECT
#toobusy
#karma
#relay
# control which IPs, rDNS hostnames, HELO hostnames, MAIL FROM addresses, and
# RCPT TO address you accept mail from. See 'haraka -h access'.
# ----------
# toobusy
# karma
# relay
# access
# p0f
# geoip
# asn
# fcrdns
# block & allow lists (see config/dns-list.ini)
dns-list
# dns-list

# HELO
#early_talker
# see config/helo.checks.ini for configuration
helo.checks
# see 'haraka -h tls' for config instructions before enabling!
# ----------
# early_talker
# helo.checks
# see 'haraka -h tls' before enabling!
# tls
#
# AUTH plugins require TLS before AUTH is advertised, see
# https://github.com/haraka/Haraka/wiki/Require-SSL-TLS
# ----------
# auth/flat_file
# auth/auth_proxy
# auth/auth_ldap

# MAIL FROM
# Only accept mail where the MAIL FROM domain is resolvable to an MX record
# ----------
mail_from.is_resolvable
#spf
# spf

# RCPT TO
# At least one rcpt_to plugin is REQUIRED for inbound email. The simplest
# plugin is in_host_list, see 'haraka -h rcpt_to.in_host_list' to configure.
# ----------
# At least one rcpt_to plugin is REQUIRED for inbound email.
rcpt_to.in_host_list
#qmail-deliverable
#rcpt_to.ldap
#rcpt_to.routes
# qmail-deliverable
# rcpt_to.ldap
# rcpt_to.routes

# DATA
#bounce
# Check mail headers are valid
headers
#uribl
#attachment
#clamd
#spamassassin
#dkim
#limit
# ----------
# attachment
# bounce
# clamd
# dkim
# headers
# limit
# rspamd
# spamassassin
# uribl

# QUEUE
# ----------
# queues: discard qmail-queue quarantine smtp_forward smtp_proxy
# Queue mail via smtp - see config/smtp_forward.ini for where your mail goes
queue/smtp_forward

#watch
20 changes: 9 additions & 11 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 Expand Up @@ -959,7 +958,6 @@ class Connection {
})
}
mail_respond (retval, msg) {
const self = this;
if (!this.transaction) {
this.logerror("mail_respond found no transaction!");
return;
Expand All @@ -974,12 +972,12 @@ class Connection {
}
);

function store_results (action) {
const store_results = (action) => {
let addr = sender.format();
if (addr.length > 2) { // all but null sender
addr = addr.substr(1, addr.length -2); // trim off < >
}
self.transaction.results.add({name: 'mail_from'}, {
this.transaction.results.add({name: 'mail_from'}, {
action,
code: constants.translate(retval),
address: addr,
Expand All @@ -990,25 +988,25 @@ class Connection {
case constants.deny:
this.respond(550, msg || `${dmsg} denied`, () => {
store_results('reject');
self.reset_transaction();
this.reset_transaction();
});
break;
case constants.denydisconnect:
this.respond(550, msg || `${dmsg} denied`, () => {
store_results('reject');
self.disconnect();
this.disconnect();
});
break;
case constants.denysoft:
this.respond(450, msg || `${dmsg} denied`, () => {
store_results('tempfail');
self.reset_transaction();
this.reset_transaction();
});
break;
case constants.denysoftdisconnect:
this.respond(450, msg || `${dmsg} denied`, () => {
store_results('tempfail');
self.disconnect();
this.disconnect();
});
break;
default:
Expand Down
3 changes: 2 additions & 1 deletion contrib/plugin2npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ if grep template "$PLUGIN_REPO/README.md"; then
-e "s/template\.ini/$1.ini/" \
"$PLUGIN_REPO/test/index.js"

sed -i '' -e "s/template/${1}/g" package.json
sed -i '' -e "s/template/${1}/g" "$PLUGIN_REPO/package.json"

sed -i '' \
-e "s/_template/_${1}/g" \
-e "s/template\.ini/$1.ini/" \
Expand Down
2 changes: 1 addition & 1 deletion endpoint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
// Socket address parser/formatter and server binding helper

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

module.exports = function endpoint (addr, defaultPort) {
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
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"address-rfc2822": "^2.2.2",
"async": "^3.2.5",
"daemon": "~1.1.0",
"haraka-config": "^1.3.0",
"haraka-constants": "^1.0.6",
"haraka-dsn": "^1.0.5",
"haraka-config": "^1.4.0",
"haraka-constants": "^1.0.7",
"haraka-dsn": "^1.1.0",
"haraka-email-message": "^1.2.3",
"haraka-message-stream": "^1.2.1",
"haraka-net-utils": "^1.7.0",
Expand All @@ -37,17 +37,17 @@
"haraka-utils": "^1.1.3",
"ipaddr.js": "~2.2.0",
"node-gyp": "^10.1.0",
"nopt": "~7.2.0",
"nopt": "^7.2.1",
"npid": "~0.4.0",
"redis": "~4.6.13",
"semver": "^7.6.0",
"semver": "^7.6.2",
"sockaddr": "^1.0.1",
"sprintf-js": "~1.1.3"
},
"optionalDependencies": {
"haraka-plugin-access": "^1.1.6",
"haraka-plugin-aliases": "^1.0.2",
"haraka-plugin-asn": "^2.0.2",
"haraka-plugin-asn": "^2.0.3",
"haraka-plugin-attachment": "^1.1.2",
"haraka-plugin-auth-ldap": "^1.1.0",
"haraka-plugin-avg": "^1.1.0",
Expand Down
Loading

0 comments on commit 027b1ba

Please sign in to comment.