Skip to content

Commit

Permalink
Add support JPRS whois (#1)
Browse files Browse the repository at this point in the history
* Update lock file

* Update test conditions

* Add support JPRS whois

* Revert package-lock.json

* Fix tests

---------

Co-authored-by: MattIPv4 <[email protected]>
  • Loading branch information
nekok500 and MattIPv4 authored Sep 16, 2024
1 parent 538f50e commit b4be578
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/whois.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const parseWhois = text => {
// RegExp parts
const reLinebreak = '\\r\\n';
const reWhitespace = `[^\\S${reLinebreak}]`;
const reKey = '([a-zA-Z\\-\\s]+):';
const reKeyColon = '([a-zA-Z\\-\\s]+):';
const reKeyBrackets = '\\[([a-zA-Z\\-\\s登録年月日有効期限]+)\\]';
const reKey = `(${reKeyColon}|${reKeyBrackets})`;
const reText = `([^\\s${reLinebreak}][^${reLinebreak}]*)`;
const reLineStart = `^${reWhitespace}*${reKey}`;
const reLineEnd = `${reWhitespace}+${reText}$`;
Expand All @@ -30,8 +32,8 @@ const parseWhois = text => {
for (const rawMatch of singleLineMatches) {
const match = rawMatch.trim().match(regExpSingleLine);
matches.push({
key: normalizeKey(match[1]),
value: normalizeValue(match[2]),
key: normalizeKey(match[2] || match[3]),
value: normalizeValue(match[4]),
});
}

Expand All @@ -42,8 +44,8 @@ const parseWhois = text => {

const match = rawMatch.trim().match(regExpSplitLine);
matches.push({
key: normalizeKey(match[1]),
value: normalizeValue(match[2]),
key: normalizeKey(match[2] || match[3]),
value: normalizeValue(match[4]),
});
}

Expand Down Expand Up @@ -83,8 +85,8 @@ module.exports = async query => {
const result = consistentResultObj({
registrant: findAttribute(['registrant'], data),
registrar: findAttribute(['registrar', 'organisation'], data),
registration: findAttributeDate(['creation date', 'created', 'registered on'], data),
expiration: findAttributeDate(['registry expiry date', 'expiry date'], data),
registration: findAttributeDate(['creation date', 'created', 'registered on', '登録年月日'], data),
expiration: findAttributeDate(['registry expiry date', 'expiry date', '有効期限'], data),
abuse: findAttribute(['registrar abuse contact email'], data),
});

Expand Down
2 changes: 1 addition & 1 deletion test/src/cfwho.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = async () => {
// Data here is potentially fragile
const resultIp = await cfwhoLookup('104.16.181.15');
assert.deepEqual(resultIp, {
name: 'CLOUDFLARENET, US',
name: 'Cloudflare, Inc.',
registrant: undefined,
asn: '13335',
registrar: undefined,
Expand Down
4 changes: 2 additions & 2 deletions test/src/rdap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module.exports = async () => {
asn: undefined,
registrar: 'Network Solutions, LLC',
registration: new Date('2000-04-12T10:36:48.000Z'),
expiration: new Date('2023-04-12T10:36:48.000Z'),
expiration: new Date('2028-04-12T10:36:48.000Z'),
cidr: undefined,
abuse: 'abuse@web.com',
abuse: 'domain.operations@web.com',
});

// Data here is potentially fragile
Expand Down
16 changes: 14 additions & 2 deletions test/src/whois.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ module.exports = async () => {
asn: undefined,
registrar: 'Network Solutions, LLC',
registration: new Date('2000-04-12T10:36:48.000Z'),
expiration: new Date('2023-04-12T10:36:48.000Z'),
expiration: new Date('2028-04-12T10:36:48.000Z'),
cidr: undefined,
abuse: '[email protected]',
abuse: '[email protected]',
});

const resultJpDomain = await whoisLookup('jprs.jp');
assert.deepEqual(resultJpDomain, {
name: undefined,
registrant: 'Japan Registry Services Co.,Ltd.',
asn: undefined,
registrar: undefined,
registration: new Date('2001-02-02T00:00:00.000Z'),
expiration: new Date('2025-02-28T00:00:00.000Z'),
cidr: undefined,
abuse: undefined,
});

// WHOISJS does not support IPs
Expand Down

0 comments on commit b4be578

Please sign in to comment.