1.2.1 • Published 20 days ago

haraka-tld v1.2.1

Weekly downloads
718
License
MIT
Repository
github
Last release
20 days ago

Build Status Code Coverage Code Climate

NPM

haraka-tld

Haraka TLD utilities

Installation

npm install haraka-tld

Usage

const tlds = require('haraka-tld');
if (tlds.get_organizational_domain('mail.example.com') === 'example.com') {
    // do something
}

Functions exported

get_organizational_domain

Reduces a hostname to an Organizational Domain.

The O.D. is the portion of a domain name immediately delegated by a registrar and the portion that is no longer 'Public'

com               <-- TLD (or Public Suffix)
example.com       <-- Organizational Domain
mail.example.com  <-- hostmame

get_organizational_domain('mail.example.com'); // -> example.com

Haraka usage example:

const tlds = require('haraka-tld');
const from_dom = tlds.get_organizational_domain(connection.transaction.mail_from.host);
const to_dom = tlds.get_organizational_domain(connection.transaction.rcpt_to.host);
if (from_dom == to_dom) {
    // the envelope sender domain matches the envelope receiver domain
    // eg: root@mail.example.com would match sysadmin@example.com
}

split_hostname

Split FQDN to host and domain

const split = tlds.split_hostname('host.sub1.sub2.domain.com');
// split[0] = 'host.sub1.sub2';
// split[1] = 'domain.com';

is_public_suffix

if (tlds.is_public_suffix('com')) {
    // true
}
if (tlds.is_public_suffix('wikipedia.org')) {
    // false
}

Directly access lists

Check for a TLD

if (tlds.top_level_tlds['com']) {
    // true
}

The following files are included

  • public-suffix-list

A list of all Public Suffixes (the parts of a domain name exactly one level below the registrar). Includes punycoded international domains, is maintained by the Mozilla project, and accomplishes roughly the same task as the *-tlds files.

  • top-level-tlds

The list of TLDs valid on the internet. Update URL

  • two-level-tlds

A list of 2nd level TLDs. Update URL

  • three-level-tlds

A list of 3rd level TLDs. Update URL

  • extra-tlds

This allows for additional 2nd and 3rd level TLDs from a single file. Used for site customizations or for the URIBL hosters.txt. Update URL

Updating

  • update the TLD files with ./update_tld_files
  • use the .release scripts to roll a new release. If the .release dir is empty (first time), populate it with git submodule update --init --recursive.
.release/start.sh patch
$edit CHANGELOG.md
git add . && git commit
.release/submit.sh
1.2.1

20 days ago

1.2.0

4 months ago

1.1.2

4 months ago

1.1.1

10 months ago

1.1.0

2 years ago

1.0.33

2 years ago

1.0.30

2 years ago

1.0.34

2 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

4 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.22

5 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.99

8 years ago