How to use the haraka-net-utils.is_ip_literal function in haraka-net-utils

To help you get started, we’ve selected a few haraka-net-utils 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 / plugins / spf.js View on Github external
// bypass auth'ed or relay'ing hosts if told to
    const skip_reason = exports.skip_hosts(connection);
    if (skip_reason) {
        connection.results.add(plugin, {skip: `helo(${skip_reason})`});
        return next();
    }

    // Bypass private IPs
    if (connection.remote.is_private) {
        connection.results.add(plugin, {skip: 'helo(private_ip)'});
        return next();
    }

    // RFC 4408, 2.1: "SPF clients must be prepared for the "HELO"
    //           identity to be malformed or an IP address literal.
    if (net_utils.is_ip_literal(helo)) {
        connection.results.add(plugin, {skip: 'helo(ip_literal)'});
        return next();
    }

    // avoid 2nd EHLO evaluation if EHLO host is identical
    const results = connection.results.get(plugin);
    if (results && results.domain === helo) return next();

    let timeout = false;
    const spf = new SPF();
    const timer = setTimeout(() => {
        timeout = true;
        connection.loginfo(plugin, 'timeout');
        return next();
    }, plugin.cfg.lookup_timeout * 1000);
github haraka / Haraka / plugins / access.js View on Github external
exports.get_domain = function (hook, connection, params) {

    switch (hook) {
        case 'connect':
            if (!connection.remote.host) return;
            if (connection.remote.host === 'DNSERROR') return;
            if (connection.remote.host === 'Unknown') return;
            return connection.remote.host;
        case 'helo':
        case 'ehlo':
            if (net_utils.is_ip_literal(params)) return;
            return params;
        case 'mail':
        case 'rcpt':
            if (params && params[0]) {
                return params[0].host;
            }
    }
    return;
};
github haraka / Haraka / plugins / helo.checks.js View on Github external
exports.big_company = function (next, connection, helo) {
    const plugin = this;

    if (plugin.should_skip(connection, 'big_company')) { return next(); }

    if (net_utils.is_ip_literal(helo)) {
        connection.results.add(plugin, {skip: 'big_co(literal)'});
        return next();
    }

    if (!plugin.cfg.bigco) {
        connection.results.add(plugin, {err: 'big_co(config missing)'});
        return next();
    }

    if (!plugin.cfg.bigco[helo]) {
        connection.results.add(plugin, {pass: 'big_co(not)'});
        return next();
    }

    const rdns = connection.remote.host;
    if (!rdns || rdns === 'Unknown' || rdns === 'DNSERROR') {