Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'haraka-config' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
function _setupServer (test, ip_port, done) {
process.env.YES_REALLY_DO_DISCARD=1; // for queue/discard plugin
process.env.HARAKA_TEST_DIR=path.resolve('tests');
// test sets the default path for plugin instances to the test dir
const test_cfg_path=path.resolve('tests');
test.server = require('../server');
test.config = require('haraka-config').module_config(test_cfg_path);
test.server.logger.loglevel = 6; // INFO
// set the default path for the plugin loader
test.server.config = test.config.module_config(test_cfg_path);
test.server.plugins.config = test.config.module_config(test_cfg_path);
// test.server.outbound.config = test.config.module_config(test_cfg_path);
test.server.load_smtp_ini();
test.server.cfg.main.listen = ip_port;
test.server.cfg.main.smtps_port = 2465;
// console.log(test.server.cfg);
test.server.load_default_tls_config(() => {
test.server.createServer({});
done();
})
}
exports.createTransaction = uuid => {
const t = new Transaction();
t.uuid = uuid || utils.uuid();
// Initialize MessageStream here to pass in the UUID
t.message_stream = new MessageStream(
config.get('smtp.ini'), t.uuid, t.header.header_list);
return t;
}
'+enable_tls',
'-ipv6_enabled',
],
}, () => {
load_config();
}).main;
// legacy config file support. Remove in Haraka 4.0
if (!cfg.disabled && config.get('outbound.disabled')) {
cfg.disabled = true;
}
if (!cfg.enable_tls && config.get('outbound.enable_tls')) {
cfg.enable_tls = true;
}
if (!cfg.maxTempFailures) {
cfg.maxTempFailures = config.get('outbound.maxTempFailures') || 13;
}
if (!cfg.concurrency_max) {
cfg.concurrency_max = config.get('outbound.concurrency_max') || 10000;
}
if (!cfg.connect_timeout) {
cfg.connect_timeout = 30;
}
if (cfg.pool_timeout === undefined) {
cfg.pool_timeout = 50;
}
if (cfg.pool_concurrency_max === undefined) {
cfg.pool_concurrency_max = 10;
}
if (!cfg.ipv6_enabled && config.get('outbound.ipv6_enabled')) {
cfg.ipv6_enabled = true;
}
logger._init_timestamps = function () {
const self = this;
const _timestamps = config.get('log_timestamps', 'value', () => {
self._init_timestamps();
});
// If we've already been toggled to true by the cfg, we should respect
// this.
self.set_timestamps(logger.timestamps || _timestamps);
}
cfg = config.get('outbound.ini', {
booleans: [
'-disabled',
'-always_split',
'+enable_tls',
'-ipv6_enabled',
],
}, () => {
load_config();
}).main;
// legacy config file support. Remove in Haraka 4.0
if (!cfg.disabled && config.get('outbound.disabled')) {
cfg.disabled = true;
}
if (!cfg.enable_tls && config.get('outbound.enable_tls')) {
cfg.enable_tls = true;
}
if (!cfg.maxTempFailures) {
cfg.maxTempFailures = config.get('outbound.maxTempFailures') || 13;
}
if (!cfg.concurrency_max) {
cfg.concurrency_max = config.get('outbound.concurrency_max') || 10000;
}
if (!cfg.connect_timeout) {
cfg.connect_timeout = 30;
}
if (cfg.pool_timeout === undefined) {
cfg.pool_timeout = 50;
}
if (cfg.pool_concurrency_max === undefined) {
cfg.pool_concurrency_max = 10;
this.transaction = null;
this.tran_count = 0;
this.capabilities = null;
this.ehlo_hello_message = config.get('ehlo_hello_message') || 'Haraka is at your service.';
this.connection_close_message = config.get('connection_close_message') || 'closing connection. Have a jolly good day.';
this.banner_includes_uuid = !!config.get('banner_includes_uuid');
this.deny_includes_uuid = config.get('deny_includes_uuid') || null;
this.early_talker = false;
this.pipelining = false;
this._relaying = false;
this.esmtp = false;
this.last_response = null;
this.hooks_to_run = [];
this.start_time = Date.now();
this.last_reject = '';
this.max_bytes = parseInt(config.get('databytes')) || 0;
this.max_mime_parts = parseInt(config.get('max_mime_parts')) || 1000;
this.totalbytes = 0;
this.rcpt_count = {
accept: 0,
tempfail: 0,
reject: 0,
};
this.msg_count = {
accept: 0,
tempfail: 0,
reject: 0,
};
this.max_line_length = parseInt(config.get('max_line_length')) || 512;
this.max_data_line_length = parseInt(config.get('max_data_line_length')) || 992;
this.results = new ResultStore(this);
this.errors = 0;
};
this.set('tls', 'enabled', (!!server.has_tls));
this.current_data = null;
this.current_line = null;
this.state = states.PAUSE;
this.encoding = 'utf8';
this.prev_state = null;
this.loop_code = null;
this.loop_msg = null;
this.uuid = utils.uuid();
this.notes = new Notes();
this.transaction = null;
this.tran_count = 0;
this.capabilities = null;
this.ehlo_hello_message = config.get('ehlo_hello_message') || 'Haraka is at your service.';
this.connection_close_message = config.get('connection_close_message') || 'closing connection. Have a jolly good day.';
this.banner_includes_uuid = !!config.get('banner_includes_uuid');
this.deny_includes_uuid = config.get('deny_includes_uuid') || null;
this.early_talker = false;
this.pipelining = false;
this._relaying = false;
this.esmtp = false;
this.last_response = null;
this.hooks_to_run = [];
this.start_time = Date.now();
this.last_reject = '';
this.max_bytes = parseInt(config.get('databytes')) || 0;
this.max_mime_parts = parseInt(config.get('max_mime_parts')) || 1000;
this.totalbytes = 0;
this.rcpt_count = {
accept: 0,
accept: 0,
tempfail: 0,
reject: 0,
};
this.msg_count = {
accept: 0,
tempfail: 0,
reject: 0,
};
this.max_line_length = parseInt(config.get('max_line_length')) || 512;
this.max_data_line_length = parseInt(config.get('max_data_line_length')) || 992;
this.results = new ResultStore(this);
this.errors = 0;
this.last_rcpt_msg = null;
this.hook = null;
this.header_hide_version = !!config.get('header_hide_version');
if (!this.header_hide_version) {
this.local.info += `/${JSON.parse(hpj).version}`;
}
Connection.setupClient(this);
}
static setupClient (self) {
this.tran_count = 0;
this.capabilities = null;
this.ehlo_hello_message = config.get('ehlo_hello_message') || 'Haraka is at your service.';
this.connection_close_message = config.get('connection_close_message') || 'closing connection. Have a jolly good day.';
this.banner_includes_uuid = !!config.get('banner_includes_uuid');
this.deny_includes_uuid = config.get('deny_includes_uuid') || null;
this.early_talker = false;
this.pipelining = false;
this._relaying = false;
this.esmtp = false;
this.last_response = null;
this.hooks_to_run = [];
this.start_time = Date.now();
this.last_reject = '';
this.max_bytes = parseInt(config.get('databytes')) || 0;
this.max_mime_parts = parseInt(config.get('max_mime_parts')) || 1000;
this.totalbytes = 0;
this.rcpt_count = {
accept: 0,
tempfail: 0,
reject: 0,
};
this.msg_count = {
accept: 0,
tempfail: 0,
reject: 0,
};
this.max_line_length = parseInt(config.get('max_line_length')) || 512;
this.max_data_line_length = parseInt(config.get('max_data_line_length')) || 992;
this.results = new ResultStore(this);
this.errors = 0;
this.last_rcpt_msg = null;
const async = require('async');
const fs = require('fs');
const path = require('path');
const Address = require('address-rfc2821').Address;
const config = require('haraka-config');
const logger = require('../logger');
const TimerQueue = require('./timer_queue');
const HMailItem = require('./hmail');
const cfg = require('./config');
const _qfile = require('./qfile');
const obtls = require('./tls');
let queue_dir;
if (config.get('queue_dir')) {
queue_dir = path.resolve(config.get('queue_dir'));
}
else if (process.env.HARAKA) {
queue_dir = path.resolve(process.env.HARAKA, 'queue');
}
else {
queue_dir = path.resolve('tests', 'test-queue');
}
exports.queue_dir = queue_dir;
const load_queue = async.queue((file, cb) => {
const hmail = new HMailItem(file, path.join(queue_dir, file));
exports._add_hmail(hmail);
hmail.once('ready', cb);
}, cfg.concurrency_max);