How to use the haraka-tld.top_level_tlds function in haraka-tld

To help you get started, we’ve selected a few haraka-tld 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 / data.uribl.js View on Github external
}
    if (!hosts || !hosts.length) {
        connection.logdebug(plugin, `(${type}) no items found for lookup`);
        results.add(plugin, {skip: type});
        return next();
    }
    connection.logdebug(plugin, `(${type}) found ${hosts.length} items for lookup` );
    utils.shuffle(hosts);

    let j;
    const queries = {};
    for (let i=0; i < hosts.length; i++) {
        let host = hosts[i].toLowerCase();
        connection.logdebug(plugin, `(${type}) checking: ${host}`);
        // Make sure we have a valid TLD
        if (!net.isIPv4(host) && !net.isIPv6(host) && !tlds.top_level_tlds[(host.split('.').reverse())[0]]) {
            continue;
        }
        // Check the exclusion list
        if (check_excludes_list(host)) {
            results.add(plugin, {skip: `excluded domain:${host}`});
            continue;
        }
        // Loop through the zones
        for (j=0; j < zones.length; j++) {
            const zone = zones[j];
            if (zone === 'main') continue;  // skip config
            if (!lists[zone] || (lists[zone] && !/^(?:1|true|yes|enabled|on)$/i.test(lists[zone][type]))) {
                results.add(plugin, {skip: `${type} unsupported for ${zone}` });
                continue;
            }
            // Convert in-addr.arpa into bare IPv4/v6 lookup
github haraka / Haraka / plugins / data.uribl.js View on Github external
exports.register = function () {
    // Override regexps if top_level_tlds file is present
    if (!tlds.top_level_tlds) return;
    if (!Object.keys(tlds.top_level_tlds).length) return;

    this.logdebug('Building new regexps from TLD file');
    const re_schemeless = `(?:%(?:25)?(?:2F|3D|40))?((?:www\\.)?[a-zA-Z0-9][a-zA-Z0-9\\-.]{0,250}\\.(?:${Object.keys(tlds.top_level_tlds).join('|')}))(?!\\w)`;
    schemeless = new RegExp(re_schemeless, 'gi');
    const re_schemed = `(\\w{3,16}:\\/+(?:\\S+@)?([a-zA-Z0-9][a-zA-Z0-9\\-.]+\\.(?:${Object.keys(tlds.top_level_tlds).join('|')})))(?!\\w)`;
    schemed = new RegExp(re_schemed, 'gi');
}
github haraka / Haraka / plugins / data.uribl.js View on Github external
exports.register = function () {
    // Override regexps if top_level_tlds file is present
    if (!tlds.top_level_tlds) return;
    if (!Object.keys(tlds.top_level_tlds).length) return;

    this.logdebug('Building new regexps from TLD file');
    const re_schemeless = `(?:%(?:25)?(?:2F|3D|40))?((?:www\\.)?[a-zA-Z0-9][a-zA-Z0-9\\-.]{0,250}\\.(?:${Object.keys(tlds.top_level_tlds).join('|')}))(?!\\w)`;
    schemeless = new RegExp(re_schemeless, 'gi');
    const re_schemed = `(\\w{3,16}:\\/+(?:\\S+@)?([a-zA-Z0-9][a-zA-Z0-9\\-.]+\\.(?:${Object.keys(tlds.top_level_tlds).join('|')})))(?!\\w)`;
    schemed = new RegExp(re_schemed, 'gi');
}

haraka-tld

Haraka TLD utilities

MIT
Latest version published 1 month ago

Package Health Score

76 / 100
Full package analysis