Compare commits
5 Commits
58351275d0
...
c0f5e0cb17
Author | SHA1 | Date |
---|---|---|
AJ ONeal | c0f5e0cb17 | |
AJ ONeal | 6093d772fc | |
AJ ONeal | 6352cf4b51 | |
AJ ONeal | afd8b6fb90 | |
AJ ONeal | 3b65560818 |
|
@ -0,0 +1,3 @@
|
|||
v1.2.10 - Tested with dig.js, deployed to production with digd.js
|
||||
* Parses and packs common record types including:
|
||||
* A,AAAA,CAA,CNAME,MX,NS,PTR,SOA,SRV,TXT
|
|
@ -0,0 +1,41 @@
|
|||
Copyright 2017 AJ ONeal
|
||||
|
||||
This is open source software; you can redistribute it and/or modify it under the
|
||||
terms of either:
|
||||
|
||||
a) the "MIT License"
|
||||
b) the "Apache-2.0 License"
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
Apache-2.0 License Summary
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -49,8 +49,8 @@ var types = exports.DNS_TYPES = {
|
|||
};
|
||||
|
||||
// and in reverse
|
||||
for (var key in types) {
|
||||
Object.keys(types).forEach(function (key) {
|
||||
types[types[key]] = key;
|
||||
}
|
||||
});
|
||||
|
||||
}('undefined' !== typeof window ? window : exports));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dns-suite",
|
||||
"version": "1.2.9",
|
||||
"version": "1.2.10",
|
||||
"description": "testing dns",
|
||||
"main": "dns.js",
|
||||
"homepage": "https://git.coolaj86.com/coolaj86/dns-suite.js",
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
// RFC 6844
|
||||
// Explanation: https://tools.ietf.org/html/rfc6844#section-3
|
||||
// Binary Format: https://tools.ietf.org/html/rfc6844#section-5
|
||||
// Real-world Usage: https://support.dnsimple.com/articles/caa-record/
|
||||
|
||||
// A Certification Authority Authorization (CAA) record is used to specify which
|
||||
// certificate authorities (CAs) are allowed to issue certificates for a domain.
|
||||
|
||||
// Value Meaning/Use
|
||||
//
|
||||
// Flag An unsigned integer between 0-255.
|
||||
// It is currently used to represent the critical flag, that has a
|
||||
// specific meaning per RFC 6844
|
||||
// Tag An ASCII string that represents the identifier of the property
|
||||
// represented by the record.
|
||||
// Value The value associated with the tag.
|
||||
|
||||
// The RFC currently defines 3 available tags:
|
||||
//
|
||||
// - issue: explicity authorizes a single certificate authority to issue a
|
||||
// certificate (any type) for the hostname.
|
||||
// - issuewild: explicity authorizes a single certificate authority to issue a
|
||||
// wildcard certificate (and only wildcard) for the hostname.
|
||||
// - iodef: specifies an URL to which a certificate authority may report
|
||||
// policy violations.
|
||||
|
||||
exports.DNS_PACKER_TYPE_CAA = function (ab, dv, total, record) {
|
||||
if ('number' !== typeof record.flag || isNaN(record.flag) || record.flag < 0 || record.flag > 255) {
|
||||
console.log(record);
|
||||
throw new Error("bad CAA flag:", record.flag);
|
||||
}
|
||||
if ('string' !== typeof record.tag || !record.tag || record.tag.length > 255) {
|
||||
throw new Error("bad CAA tag:", record.tag);
|
||||
}
|
||||
if ('string' !== typeof record.value || !record.value) {
|
||||
throw new Error("bad CAA value:", record.value);
|
||||
}
|
||||
|
||||
// RDLEN = flag (1 byte) + taglen (1 byte) + tagstr (taglen bytes) + valuestr (valuelen bytes)
|
||||
dv.setUint16(total, 1 + 1 + record.tag.length + record.value.length, false);
|
||||
total += 2;
|
||||
|
||||
// FLAG
|
||||
dv.setUint8(total, record.flag, false);
|
||||
total += 1;
|
||||
|
||||
// TAG LENGTH
|
||||
dv.setUint8(total, record.tag.length, false);
|
||||
total += 1;
|
||||
|
||||
// TAG
|
||||
record.tag.split('').forEach(function (ch) {
|
||||
dv.setUint8(total, ch.charCodeAt(0), false);
|
||||
total += 1;
|
||||
});
|
||||
|
||||
// VALUE
|
||||
record.value.split('').forEach(function (ch) {
|
||||
dv.setUint8(total, ch.charCodeAt(0), false);
|
||||
total += 1;
|
||||
});
|
||||
|
||||
return total;
|
||||
};
|
||||
|
||||
}('undefined' !== typeof window ? window : exports));
|
|
@ -1,6 +1,9 @@
|
|||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
// RFC 6844 https://tools.ietf.org/html/rfc6844#section-3
|
||||
// https://support.dnsimple.com/articles/caa-record/
|
||||
|
||||
// A Certification Authority Authorization (CAA) record is used to specify which
|
||||
// certificate authorities (CAs) are allowed to issue certificates for a domain.
|
||||
|
||||
|
@ -26,13 +29,23 @@ exports.DNS_PARSER_TYPE_CAA = function (ab, packet, record) {
|
|||
|
||||
var data = new Uint8Array(ab);
|
||||
var i = record.rdstart;
|
||||
var flag = data[i++];
|
||||
var mid = data[i++];
|
||||
var flag = data[i];
|
||||
var mid = data[i + 1];
|
||||
i += 2;
|
||||
mid += i;
|
||||
var end = record.rdstart + record.rdlength;
|
||||
var tag = '', value = '';
|
||||
while (i < mid) { tag += String.fromCharCode(data[i++]); }
|
||||
while (i < end) { value += String.fromCharCode(data[i++]); }
|
||||
var tag = '';
|
||||
var value = '';
|
||||
|
||||
while (i < mid) {
|
||||
tag += String.fromCharCode(data[i]);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
while (i < end) {
|
||||
value += String.fromCharCode(data[i]);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
record.flag = flag;
|
||||
record.tag = tag;
|
||||
|
|
Loading…
Reference in New Issue