Merge pull request #7907 from is-a-dev/feat/support-aaaa-records

feat(script): adds support for aaaa records
This commit is contained in:
Akshay Nair
2023-09-22 22:37:42 +05:30
committed by GitHub
7 changed files with 20 additions and 3 deletions
+1 -1
View File
@@ -11,6 +11,6 @@ jobs:
fetch-depth: 0
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.0
bun-version: 1.0.3
- run: bun install
- run: bun test
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.0
bun-version: 1.0.3
- run: bun install
- run: bun test
- name: Publishing records
BIN
View File
Binary file not shown.
+1
View File
@@ -16,6 +16,7 @@
"author": "Akshay Nair <phenax5@gmail.com>",
"license": "GPL-3.0",
"dependencies": {
"ip-regex": "^5.0.0",
"ramda": "^0.27.1"
},
"devDependencies": {
+6
View File
@@ -59,6 +59,10 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: 'help.baa' },
{ ...defaultDomain, name: '_github-pages-challenge-is-a-dev' },
{ ...defaultDomain, name: '_github-challenge-is-a-dev' },
{ ...defaultDomain, record: { AAAA: [] } },
{ ...defaultDomain, record: { AAAA: ['182.22.222.22', '::1'] } },
{ ...defaultDomain, record: { AAAA: '182.22.222.22' } },
{ ...defaultDomain, record: { A: '::1' } },
];
const validCases = [
@@ -86,6 +90,8 @@ describe('validateDomainData', () => {
{ ...defaultDomain, name: '_github-challenge-hello01-ga' },
{ ...defaultDomain, name: '_github-challenge-hello01_ga' },
{ ...defaultDomain, record: { TXT: ['foobar wow nice!!!', 'more text'] } },
{ ...defaultDomain, record: { AAAA: ['::1', '2001:db8:3333:4444:5555:6666:7777:8888'] } },
{ ...defaultDomain, record: { A: ['122.222.222.222'] } },
];
it('should return false for invalid data', () => {
+1 -1
View File
@@ -18,7 +18,7 @@ const DOMAINS_PATH = path.resolve('domains');
module.exports = {
ENV,
IS_TEST,
VALID_RECORD_TYPES: ['CNAME', 'A', 'URL', 'MX', 'TXT'],
VALID_RECORD_TYPES: ['CNAME', 'A', 'URL', 'MX', 'TXT', 'AAAA'],
DOMAIN_DOMAIN: DOMAIN_DOMAIN || 'booboo.xyz',
DOMAIN_USER: IS_TEST ? 'testuser' : DOMAIN_USER,
DOMAIN_API_KEY: IS_TEST ? 'testkey' : DOMAIN_API_KEY,
+10
View File
@@ -2,6 +2,8 @@ const R = require('ramda');
const { VALID_RECORD_TYPES } = require('./constants');
const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers');
const INVALID_NAMES = require('./invalid-domains.json');
const ipRegex_ = require('ip-regex');
const ipRegex = ipRegex_.default ?? ipRegex_;
const isValidURL = and([R.is(String), testRegex(/^https?:\/\//ig)]);
@@ -17,6 +19,7 @@ const validateCnameRecord = type => and([
const validateARecord = type => and([
R.propIs(Array, type),
R.propSatisfies(withLengthGte(1), type),
R.all(testRegex(ipRegex.v4({ exact: true }))),
]);
const validateMXRecord = type => and([
@@ -25,6 +28,12 @@ const validateMXRecord = type => and([
R.propSatisfies(R.all(isValidDomain), type),
]);
const validateAAAARecord = R.propSatisfies(and([
R.is(Array),
withLengthGte(1),
R.all(testRegex(ipRegex.v6({ exact: true }))),
]))
const checkRestrictedNames = R.complement(R.includes(R.__, INVALID_NAMES))
const validateDomainData = validate({
@@ -75,6 +84,7 @@ const validateDomainData = validate({
[R.has('URL'), R.propSatisfies(isValidURL, 'URL')],
[R.has('MX'), validateMXRecord('MX')],
[R.has('TXT'), R.propSatisfies(or([ R.is(String), R.is(Array) ]), 'TXT')],
[R.has('AAAA'), validateAAAARecord('AAAA')],
[R.T, R.T],
]),
]),