How to use haraka-config - 10 common examples

To help you get started, we’ve selected a few haraka-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github haraka / Haraka / tests / server.js View on Github external
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();
    })
}
github haraka / Haraka / transaction.js View on Github external
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;
}
github haraka / Haraka / outbound / config.js View on Github external
'+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;
    }
github haraka / Haraka / logger.js View on Github external
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);
}
github haraka / Haraka / outbound / config.js View on Github external
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;
github haraka / Haraka / connection.js View on Github external
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;
github haraka / Haraka / connection.js View on Github external
};
        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,
github haraka / Haraka / connection.js View on Github external
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) {
github haraka / Haraka / connection.js View on Github external
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;
github haraka / Haraka / outbound / queue.js View on Github external
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);

haraka-config

Haraka's config file loader

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis

Popular haraka-config functions

Similar packages