xasdd6 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/xasdd6.js +2 -2
- package/xasdd6.mjs +80 -77
package/package.json
CHANGED
package/xasdd6.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),t=/^(\d{1,3}\.){3,3}\d{1,3}$/,n=4,r=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:`v4`,size:n,isFormat:e=>t.test(e),encode(e,t,r){r=~~r,t||=new Uint8Array(r+n);let i=e.length,a=0;for(let n=0;n<i;){let i=e.charCodeAt(n++);i===46?(t[r++]=a,a=0):a=a*10+(i-48)}return t[r]=a,t},decode(e,t){return t=~~t,`${e[t++]}.${e[t++]}.${e[t++]}.${e[t]}`}},o={name:`v6`,size:i,isFormat:e=>e.length>0&&r.test(e),encode(e,t,n){n=~~n;let r=n+i,a=-1,o=0,s=0,c=!0,l=!1;t||=new Uint8Array(n+i);for(let i=0;i<e.length;i++){let u=e.charCodeAt(i);u===58?(c?a===-1?n<r&&(a=n):(n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2):(l===!0?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=o>>8),n<r-1&&(t[n+1]=o&255),n+=2),o=0,s=0),c=!0,l=!1):u===46?(n<r&&(t[n]=s),n++,s=0,o=0,c=!1,l=!0):(c=!1,u>=97?u-=87:u>=65?u-=55:(u-=48,s=s*10+u),o=(o<<4)+u)}if(c===!1)l===!0?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=o>>8),n<r-1&&(t[n+1]=o&255),n+=2);else if(a===0)n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2;else if(a!==-1){n+=2;for(let e=Math.min(n-1,r-1);e>=a+2;e--)t[e]=t[e-2];t[a]=0,t[a+1]=0,a=n}if(a!==n&&a!==-1)for(n>r-2&&(n=r-2);r>a;)t[--r]=n<r&&n>a?t[--n]:0;else for(;n<r;)t[n++]=0;return t},decode(e,t){t=~~t;let n=``;for(let r=0;r<i;r+=2)r!==0&&(n+=`:`),n+=(e[t+r]<<8|e[t+r+1]).toString(16);return n.replace(/(^|:)0(:0)*:0(:|$)/,`$1::$3`).replace(/:{3,4}/,`::`)}};function s(e){if(a.isFormat(e))return a.size;if(o.isFormat(e))return o.size;throw Error(`Invalid ip address: ${e}`)}function c(e){return s(e)===a.size?1:2}function l(e,t,n){n=~~n;let r=s(e);return typeof t==`function`&&(t=t(n+r)),r===a.size?a.encode(e,t,n):o.encode(e,t,n)}function u(e,t,n){if(t=~~t,n||=e.length-t,n===a.size)return a.decode(e,t,n);if(n===o.size)return o.decode(e,t,n);throw Error(`Invalid buffer size needs to be ${a.size} for v4 or ${o.size} for v6.`)}function d(e){switch(e){case 1:return`A`;case 10:return`NULL`;case 28:return`AAAA`;case 18:return`AFSDB`;case 42:return`APL`;case 257:return`CAA`;case 60:return`CDNSKEY`;case 59:return`CDS`;case 37:return`CERT`;case 5:return`CNAME`;case 49:return`DHCID`;case 32769:return`DLV`;case 39:return`DNAME`;case 48:return`DNSKEY`;case 43:return`DS`;case 55:return`HIP`;case 13:return`HINFO`;case 45:return`IPSECKEY`;case 25:return`KEY`;case 36:return`KX`;case 29:return`LOC`;case 15:return`MX`;case 35:return`NAPTR`;case 2:return`NS`;case 47:return`NSEC`;case 50:return`NSEC3`;case 51:return`NSEC3PARAM`;case 12:return`PTR`;case 46:return`RRSIG`;case 17:return`RP`;case 24:return`SIG`;case 6:return`SOA`;case 99:return`SPF`;case 33:return`SRV`;case 44:return`SSHFP`;case 32768:return`TA`;case 249:return`TKEY`;case 52:return`TLSA`;case 250:return`TSIG`;case 16:return`TXT`;case 252:return`AXFR`;case 251:return`IXFR`;case 41:return`OPT`;case 255:return`ANY`}return`UNKNOWN_`+e}function f(e){switch(e.toUpperCase()){case`A`:return 1;case`NULL`:return 10;case`AAAA`:return 28;case`AFSDB`:return 18;case`APL`:return 42;case`CAA`:return 257;case`CDNSKEY`:return 60;case`CDS`:return 59;case`CERT`:return 37;case`CNAME`:return 5;case`DHCID`:return 49;case`DLV`:return 32769;case`DNAME`:return 39;case`DNSKEY`:return 48;case`DS`:return 43;case`HIP`:return 55;case`HINFO`:return 13;case`IPSECKEY`:return 45;case`KEY`:return 25;case`KX`:return 36;case`LOC`:return 29;case`MX`:return 15;case`NAPTR`:return 35;case`NS`:return 2;case`NSEC`:return 47;case`NSEC3`:return 50;case`NSEC3PARAM`:return 51;case`PTR`:return 12;case`RRSIG`:return 46;case`RP`:return 17;case`SIG`:return 24;case`SOA`:return 6;case`SPF`:return 99;case`SRV`:return 33;case`SSHFP`:return 44;case`TA`:return 32768;case`TKEY`:return 249;case`TLSA`:return 52;case`TSIG`:return 250;case`TXT`:return 16;case`AXFR`:return 252;case`IXFR`:return 251;case`OPT`:return 41;case`ANY`:return 255;case`*`:return 255}return e.toUpperCase().startsWith(`UNKNOWN_`)?parseInt(e.slice(8)):0}function p(e){switch(e){case 0:return`NOERROR`;case 1:return`FORMERR`;case 2:return`SERVFAIL`;case 3:return`NXDOMAIN`;case 4:return`NOTIMP`;case 5:return`REFUSED`;case 6:return`YXDOMAIN`;case 7:return`YXRRSET`;case 8:return`NXRRSET`;case 9:return`NOTAUTH`;case 10:return`NOTZONE`;case 11:return`RCODE_11`;case 12:return`RCODE_12`;case 13:return`RCODE_13`;case 14:return`RCODE_14`;case 15:return`RCODE_15`}return`RCODE_`+e}function ee(e){switch(e.toUpperCase()){case`NOERROR`:return 0;case`FORMERR`:return 1;case`SERVFAIL`:return 2;case`NXDOMAIN`:return 3;case`NOTIMP`:return 4;case`REFUSED`:return 5;case`YXDOMAIN`:return 6;case`YXRRSET`:return 7;case`NXRRSET`:return 8;case`NOTAUTH`:return 9;case`NOTZONE`:return 10;case`RCODE_11`:return 11;case`RCODE_12`:return 12;case`RCODE_13`:return 13;case`RCODE_14`:return 14;case`RCODE_15`:return 15}return 0}function te(e){switch(e){case 0:return`QUERY`;case 1:return`IQUERY`;case 2:return`STATUS`;case 3:return`OPCODE_3`;case 4:return`NOTIFY`;case 5:return`UPDATE`;case 6:return`OPCODE_6`;case 7:return`OPCODE_7`;case 8:return`OPCODE_8`;case 9:return`OPCODE_9`;case 10:return`OPCODE_10`;case 11:return`OPCODE_11`;case 12:return`OPCODE_12`;case 13:return`OPCODE_13`;case 14:return`OPCODE_14`;case 15:return`OPCODE_15`}return`OPCODE_`+e}function ne(e){switch(e){case 1:return`IN`;case 2:return`CS`;case 3:return`CH`;case 4:return`HS`;case 255:return`ANY`}return`UNKNOWN_`+e}function re(e){switch(e.toUpperCase()){case`IN`:return 1;case`CS`:return 2;case`CH`:return 3;case`HS`:return 4;case`ANY`:return 255}return 0}function ie(e){switch(e){case 1:return`LLQ`;case 2:return`UL`;case 3:return`NSID`;case 5:return`DAU`;case 6:return`DHU`;case 7:return`N3U`;case 8:return`CLIENT_SUBNET`;case 9:return`EXPIRE`;case 10:return`COOKIE`;case 11:return`TCP_KEEPALIVE`;case 12:return`PADDING`;case 13:return`CHAIN`;case 14:return`KEY_TAG`;case 26946:return`DEVICEID`}return e<0?null:`OPTION_${e}`}function ae(e){if(typeof e==`number`)return e;if(!e)return-1;switch(e.toUpperCase()){case`OPTION_0`:return 0;case`LLQ`:return 1;case`UL`:return 2;case`NSID`:return 3;case`OPTION_4`:return 4;case`DAU`:return 5;case`DHU`:return 6;case`N3U`:return 7;case`CLIENT_SUBNET`:return 8;case`EXPIRE`:return 9;case`COOKIE`:return 10;case`TCP_KEEPALIVE`:return 11;case`PADDING`:return 12;case`CHAIN`:return 13;case`KEY_TAG`:return 14;case`DEVICEID`:return 26946;case`OPTION_65535`:return 65535}let t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}var oe=55296,m=56320;function se(e){let t=0,n=e.length;for(let r=0;r<n;r+=1){let i=e.charCodeAt(r);if(i<=127)t+=1;else if(i<=2047)t+=2;else if((i&63488)!==oe)t+=3;else{let a=r+1;a===n||i>=m?t+=3:(e.charCodeAt(a)&64512)===m?(r=a,t+=4):t+=3}}return t}function h(e,t,n){let r=e.length;n??=0,t===void 0&&(t=new Uint8Array(se(e)+n));let i=n;for(let n=0;n<r;n+=1){let a=e.charCodeAt(n);if(a<=127)t[i++]=a;else if(a<=2047)t[i++]=192|(a&1984)>>6,t[i++]=128|a&63;else if((a&63488)!==oe)t[i++]=224|(a&61440)>>12,t[i++]=128|(a&4032)>>6,t[i++]=128|a&63;else{let o=n+1;if(o===r||a>=m)t[i++]=239,t[i++]=191,t[i++]=189;else{let r=e.charCodeAt(o);(r&64512)===m?(n=o,a=65536|(a&1023)<<10|r&1023,t[i++]=240|(a&1835008)>>18,t[i++]=128|(a&258048)>>12,t[i++]=128|(a&4032)>>6,t[i++]=128|a&63):(t[i++]=239,t[i++]=191,t[i++]=189)}}}return h.bytes=i-n,t}h.bytes=0;function g(e,t,n){let r=``;t??=0,n??=e.length;for(let i=t;i<n;){let t=e[i++],n;if(t<=128)n=t;else if(t>191&&t<224)n=(t&31)<<6|e[i++]&63;else if(t>239&&t<365){n=((t&7)<<18|(e[i++]&63)<<12|(e[i++]&63)<<6|e[i++]&63)-65536;let a=oe|n>>10&1023;r+=String.fromCharCode(a),n=m|n&1023}else n=(t&15)<<12|(e[i++]&63)<<6|e[i++]&63;r+=String.fromCharCode(n)}return g.bytes=n-t,r}g.bytes=0;var _=e=>e instanceof Uint8Array;function v(e){return typeof e==`string`?se(e):e.byteLength}function ce(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):h(e)}function le(e,t,n){if(typeof t!=`string`)throw Error(`unknown input type`);return h(t,e,n),h.bytes}var ue=2**24,de=2**16,fe=256,y=(e,t)=>e[t]*ue+e[t+1]*de+e[t+2]*fe+e[t+3],b=(e,t)=>e[t]<<8|e[t+1],x=(e,t,n)=>(t=+t,e[n+3]=t,t>>>=8,e[n+2]=t,t>>>=8,e[n+1]=t,t>>>=8,e[n]=t,n+4),S=(e,t,n)=>(e[n]=t>>8,e[n+1]=t&255,n+2);function C(e,t,n,r,i){return n<0&&(r-=n,n=0),r<0&&(r=0),i<0?new Uint8Array:n>=t.length||r>=i?0:pe(e,t,n,r,i)}function pe(e,t,n,r,i){i-r>t.length-n&&(i=r+t.length-n);let a=i-r,o=e.length-r;return a>o&&(a=o),(r!==0||i<e.length)&&(e=new Uint8Array(e.buffer,e.byteOffset+r,a)),t.set(e,n),a}var me=0,he=32768,ge=32768,_e=-32769,ve=32768,ye=-32769;function w({bytes:e=0,encode:t,decode:n,encodingLength:r}){return t.bytes=e,n.bytes=e,{encode:t,decode:n,encodingLength:r||(()=>e)}}var T=w({encode(e,t,n){t||=new Uint8Array(T.encodingLength(e)),n||=0;let r=n,i=e.replace(/^\.|\.$/gm,``);if(i.length){let e=i.split(`.`);for(let r=0;r<e.length;r++){let i=le(t,e[r],n+1);t[n]=i,n+=i+1}}return t[n++]=0,T.encode.bytes=n-r,t},decode(e,t){t||=0;let n=[],r=t,i=0,a=0,o=!1;for(;;){if(t>=e.length)throw Error(`Cannot decode name (buffer overflow)`);let s=e[t++];if(a+=+!o,s===0)break;if(!(s&192)){if(t+s>e.length)throw Error(`Cannot decode name (buffer overflow)`);if(i+=s+1,i>254)throw Error(`Cannot decode name (name too long)`);n.push(g(e,t,t+s)),t+=s,a+=o?0:s}else if((s&192)==192){if(t+1>e.length)throw Error(`Cannot decode name (buffer overflow)`);let n=b(e,t-1)-49152;if(n>=r)throw Error(`Cannot decode name (bad pointer)`);t=n,r=n,a+=+!o,o=!0}else throw Error(`Cannot decode name (bad label)`)}return T.decode.bytes=a,n.length===0?`.`:n.join(`.`)},encodingLength(e){return e===`.`||e===`..`?1:v(e.replace(/^\.|\.$/gm,``))+2}}),E=w({encode(e,t,n){t||=new Uint8Array(E.encodingLength(e)),n||=0;let r=le(t,e,n+1);return t[n]=r,E.encode.bytes=r+1,t},decode(e,t){t||=0;let n=e[t],r=g(e,t+1,t+1+n);return E.decode.bytes=n+1,r},encodingLength(e){return v(e)+1}}),D=w({bytes:12,encode(e,t,n){t||=new Uint8Array(D.encodingLength(e)),n||=0;let r=(e.flags||0)&32767,i=e.type===`response`?he:me;return S(t,e.id||0,n),S(t,r|i,n+2),S(t,e.questions.length,n+4),S(t,e.answers.length,n+6),S(t,e.authorities.length,n+8),S(t,e.additionals.length,n+10),t},decode(e,t){if(t||=0,e.length<12)throw Error(`Header must be 12 bytes`);let n=b(e,t+2);return{id:b(e,t),type:n&he?`response`:`query`,flags:n&32767,flag_qr:(n>>15&1)==1,opcode:te(n>>11&15),flag_aa:(n>>10&1)==1,flag_tc:(n>>9&1)==1,flag_rd:(n>>8&1)==1,flag_ra:(n>>7&1)==1,flag_z:(n>>6&1)==1,flag_ad:(n>>5&1)==1,flag_cd:(n>>4&1)==1,rcode:p(n&15),questions:Array(b(e,t+4)),answers:Array(b(e,t+6)),authorities:Array(b(e,t+8)),additionals:Array(b(e,t+10))}},encodingLength(){return 12}}),O=w({encode(e,t,n){t||=new Uint8Array(O.encodingLength(e)),n||=0;let r=e.length;return S(t,r,n),C(e,t,n+2,0,r),O.encode.bytes=r+2,t},decode(e,t){t||=0;let n=b(e,t),r=e.slice(t+2,t+2+n);return O.decode.bytes=n+2,r},encodingLength(e){return e.length+2}}),k=w({encode(e,t,n){return t||=new Uint8Array(k.encodingLength(e)),n||=0,T.encode(e,t,n+2),S(t,T.encode.bytes,n),k.encode.bytes=T.encode.bytes+2,t},decode(e,t){t||=0;let n=b(e,t),r=T.decode(e,t+2);return k.decode.bytes=n+2,r},encodingLength(e){return T.encodingLength(e)+2}}),A=w({encode(e,t,n){t||=new Uint8Array(A.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.mname,t,n),n+=T.encode.bytes,T.encode(e.rname,t,n),n+=T.encode.bytes,x(t,e.serial||0,n),n+=4,x(t,e.refresh||0,n),n+=4,x(t,e.retry||0,n),n+=4,x(t,e.expire||0,n),n+=4,x(t,e.minimum||0,n),n+=4,S(t,n-r-2,r),A.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.mname=T.decode(e,t),t+=T.decode.bytes,r.rname=T.decode(e,t),t+=T.decode.bytes,r.serial=y(e,t),t+=4,r.refresh=y(e,t),t+=4,r.retry=y(e,t),t+=4,r.expire=y(e,t),t+=4,r.minimum=y(e,t),t+=4,A.decode.bytes=t-n,r},encodingLength(e){return 22+T.encodingLength(e.mname)+T.encodingLength(e.rname)}}),j=w({encode(e,t,n){Array.isArray(e)||(e=[e]);for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&(e[t]=ce(e[t])),!_(e[t]))throw Error(`Must be a Buffer`);t||=new Uint8Array(j.encodingLength(e)),n||=0;let r=n;return n+=2,e.forEach(function(e){t[n++]=e.length,C(e,t,n,0,e.length),n+=e.length}),S(t,n-r-2,r),j.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=b(e,t);t+=2;let i=[];for(;r>0;){let n=e[t++];if(--r,r<n)throw Error(`Buffer overflow`);i.push(e.slice(t,t+n)),t+=n,r-=n}return j.decode.bytes=t-n,i},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach(function(e){t+=typeof e==`string`?v(e)+1:e.length+1}),t}}),M=w({encode(e,t,n){t||=new Uint8Array(M.encodingLength(e)),n||=0,typeof e==`string`&&(e=ce(e)),e||=new Uint8Array;let r=n;n+=2;let i=e.length;return C(e,t,n,0,i),n+=i,S(t,n-r-2,r),M.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=b(e,t);t+=2;let i=e.slice(t,t+r);return t+=r,M.decode.bytes=t-n,i},encodingLength(e){return e?(_(e)?e.length:v(e))+2:2}}),N=w({encode(e,t,n){t||=new Uint8Array(N.encodingLength(e)),n||=0;let r=n;return n+=2,E.encode(e.cpu,t,n),n+=E.encode.bytes,E.encode(e.os,t,n),n+=E.encode.bytes,S(t,n-r-2,r),N.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.cpu=E.decode(e,t),t+=E.decode.bytes,r.os=E.decode(e,t),t+=E.decode.bytes,N.decode.bytes=t-n,r},encodingLength(e){return E.encodingLength(e.cpu)+E.encodingLength(e.os)+2}}),P=w({encode(e,t,n){return t||=new Uint8Array(P.encodingLength(e)),n||=0,T.encode(e,t,n+2),S(t,T.encode.bytes,n),P.encode.bytes=T.encode.bytes+2,t},decode(e,t){t||=0;let n=T.decode(e,t+2);return P.decode.bytes=T.decode.bytes+2,n},encodingLength(e){return T.encodingLength(e)+2}}),F=w({encode(e,t,n){t||=new Uint8Array(F.encodingLength(e)),n||=0,S(t,e.priority||0,n+2),S(t,e.weight||0,n+4),S(t,e.port||0,n+6),T.encode(e.target,t,n+8);let r=T.encode.bytes+6;return S(t,r,n),F.encode.bytes=r+2,t},decode(e,t){t||=0;let n=b(e,t),r={};return r.priority=b(e,t+2),r.weight=b(e,t+4),r.port=b(e,t+6),r.target=T.decode(e,t+8),F.decode.bytes=n+2,r},encodingLength(e){return 8+T.encodingLength(e.target)}}),I=w({encode(e,t,n){let r=I.encodingLength(e);return t||=new Uint8Array(I.encodingLength(e)),n||=0,e.issuerCritical&&(e.flags=I.ISSUER_CRITICAL),S(t,r-2,n),n+=2,t[n]=e.flags||0,n+=1,E.encode(e.tag,t,n),n+=E.encode.bytes,le(t,e.value,n),n+=v(e.value),I.encode.bytes=r,t},decode(e,t){t||=0;let n=b(e,t);t+=2;let r=t,i={};return i.flags=e[t],t+=1,i.tag=E.decode(e,t),t+=E.decode.bytes,i.value=g(e,t,r+n),i.issuerCritical=!!(i.flags&I.ISSUER_CRITICAL),I.decode.bytes=n+2,i},encodingLength(e){return E.encodingLength(e.tag)+E.encodingLength(e.value)+2}});I.ISSUER_CRITICAL=128;var be=w({encode(e,t,n){t||=new Uint8Array(be.encodingLength(e)),n||=0;let r=n;return n+=2,S(t,e.preference||0,n),n+=2,T.encode(e.exchange,t,n),n+=T.encode.bytes,S(t,n-r-2,r),be.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.preference=b(e,t),t+=2,r.exchange=T.decode(e,t),t+=T.decode.bytes,be.decode.bytes=t-n,r},encodingLength(e){return 4+T.encodingLength(e.exchange)}}),xe=w({encode(e,t,n){return t||=new Uint8Array(xe.encodingLength(e)),n||=0,S(t,4,n),n+=2,a.encode(e,t,n),t},decode(e,t){return t||=0,t+=2,a.decode(e,t)},bytes:6}),Se=w({encode(e,t,n){return t||=new Uint8Array(Se.encodingLength(e)),n||=0,S(t,16,n),n+=2,o.encode(e,t,n),Se.encode.bytes=18,t},decode(e,t){t||=0,t+=2;let n=o.decode(e,t);return Se.decode.bytes=18,n},bytes:18}),Ce=e=>new Uint8Array(e),L=w({encode(e,t,n){t||=new Uint8Array(L.encodingLength(e)),n||=0;let r=n,i=ae(e.code);if(S(t,i,n),n+=2,e.data)S(t,e.data.length,n),n+=2,C(e.data,t,n),n+=e.data.length;else switch(i){case 8:{let r=e.sourcePrefixLength||0,i=e.family||c(e.ip,Ce),a=l(e.ip,Ce),o=Math.ceil(r/8);S(t,o+4,n),n+=2,S(t,i,n),n+=2,t[n++]=r,t[n++]=e.scopePrefixLength||0,C(a,t,n,0,o),n+=o}break;case 11:e.timeout?(S(t,2,n),n+=2,S(t,e.timeout,n),n+=2):(S(t,0,n),n+=2);break;case 12:{let r=e.length||0;S(t,r,n),n+=2,t.fill(0,n,n+r),n+=r}break;case 14:{let r=e.tags.length*2;S(t,r,n),n+=2;for(let r of e.tags)S(t,r,n),n+=2}break;default:throw Error(`Unknown roption code: ${e.code}`)}return L.encode.bytes=n-r,t},decode(e,t){t||=0;let n={};n.code=b(e,t),n.type=ie(n.code),t+=2;let r=b(e,t);switch(t+=2,n.data=e.slice(t,t+r),n.code){case 8:n.family=b(e,t),t+=2,n.sourcePrefixLength=e[t++],n.scopePrefixLength=e[t++];{let i=new Uint8Array(n.family===1?4:16);C(e,i,0,t,t+r-4),n.ip=u(i)}break;case 11:r>0&&(n.timeout=b(e,t),t+=2);break;case 14:n.tags=[];for(let i=0;i<r;i+=2)n.tags.push(b(e,t)),t+=2}return L.decode.bytes=r+4,n},encodingLength(e){if(e.data)return e.data.length+4;switch(ae(e.code)){case 8:{let t=e.sourcePrefixLength||0;return Math.ceil(t/8)+8}case 11:return typeof e.timeout==`number`?6:4;case 12:return e.length+4;case 14:return 4+e.tags.length*2}throw Error(`Unknown roption code: ${e.code}`)}}),R=w({encode(e,t,n){t||=new Uint8Array(R.encodingLength(e)),n||=0;let r=n,i=Y(e,L);return S(t,i,n),n=X(e,L,t,n+2),R.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=[],i=b(e,t);t+=2;let a=0;for(;i>0;)r[a++]=L.decode(e,t),t+=L.decode.bytes,i-=L.decode.bytes;return R.decode.bytes=t-n,r},encodingLength(e){return 2+Y(e||[],L)}}),z=w({encode(e,t,n){t||=new Uint8Array(z.encodingLength(e)),n||=0;let r=n,i=e.key;if(!_(i))throw Error(`Key must be a Buffer`);return n+=2,S(t,e.flags,n),n+=2,t[n]=z.PROTOCOL_DNSSEC,n+=1,t[n]=e.algorithm,n+=1,C(i,t,n,0,i.length),n+=i.length,z.encode.bytes=n-r,S(t,z.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);if(t+=2,r.flags=b(e,t),t+=2,e[t]!==z.PROTOCOL_DNSSEC)throw Error(`Protocol must be 3`);return t+=1,r.algorithm=e[t],t+=1,r.key=e.slice(t,n+i+2),t+=r.key.length,z.decode.bytes=t-n,r},encodingLength(e){return 6+v(e.key)}});z.PROTOCOL_DNSSEC=3,z.ZONE_KEY=128,z.SECURE_ENTRYPOINT=32768;var B=w({encode(e,t,n){t||=new Uint8Array(B.encodingLength(e)),n||=0;let r=n,i=e.signature;if(!_(i))throw Error(`Signature must be a Buffer`);return n+=2,S(t,f(e.typeCovered),n),n+=2,t[n]=e.algorithm,n+=1,t[n]=e.labels,n+=1,x(t,e.originalTTL,n),n+=4,x(t,e.expiration,n),n+=4,x(t,e.inception,n),n+=4,S(t,e.keyTag,n),n+=2,T.encode(e.signersName,t,n),n+=T.encode.bytes,C(i,t,n,0,i.length),n+=i.length,B.encode.bytes=n-r,S(t,B.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.typeCovered=d(b(e,t)),t+=2,r.algorithm=e[t],t+=1,r.labels=e[t],t+=1,r.originalTTL=y(e,t),t+=4,r.expiration=y(e,t),t+=4,r.inception=y(e,t),t+=4,r.keyTag=b(e,t),t+=2,r.signersName=T.decode(e,t),t+=T.decode.bytes,r.signature=e.slice(t,n+i+2),t+=r.signature.length,B.decode.bytes=t-n,r},encodingLength(e){return 20+T.encodingLength(e.signersName)+v(e.signature)}}),V=w({encode(e,t,n){t||=new Uint8Array(V.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.mbox||`.`,t,n),n+=T.encode.bytes,T.encode(e.txt||`.`,t,n),n+=T.encode.bytes,V.encode.bytes=n-r,S(t,V.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.mbox=T.decode(e,t)||`.`,t+=T.decode.bytes,r.txt=T.decode(e,t)||`.`,t+=T.decode.bytes,V.decode.bytes=t-n,r},encodingLength(e){return 2+T.encodingLength(e.mbox||`.`)+T.encodingLength(e.txt||`.`)}}),H=w({encode(e,t,n){t||=new Uint8Array(H.encodingLength(e)),n||=0;let r=n,i=[];for(let t=0;t<e.length;t++){let n=f(e[t]);i[n>>8]===void 0&&(i[n>>8]=[]),i[n>>8][n>>3&31]|=1<<7-(n&7)}for(let e=0;e<i.length;e++)if(i[e]!==void 0){let r=ce(i[e]);t[n]=e,n+=1,t[n]=r.length,n+=1,C(r,t,n,0,r.length),n+=r.length}return H.encode.bytes=n-r,t},decode(e,t,n){t||=0;let r=t,i=[];for(;t-r<n;){let n=e[t];t+=1;let r=e[t];t+=1;for(let a=0;a<r;a++){let r=e[t+a];for(let e=0;e<8;e++)if(r&1<<7-e){let t=d(n<<8|a<<3|e);i.push(t)}}t+=r}return H.decode.bytes=t-r,i},encodingLength(e){let t=[];for(let n=0;n<e.length;n++){let r=f(e[n]);t[r>>8]=Math.max(t[r>>8]||0,r&255)}let n=0;for(let e=0;e<t.length;e++)t[e]!==void 0&&(n+=2+Math.ceil((t[e]+1)/8));return n}}),U=w({encode(e,t,n){t||=new Uint8Array(U.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.nextDomain,t,n),n+=T.encode.bytes,H.encode(e.rrtypes,t,n),n+=H.encode.bytes,U.encode.bytes=n-r,S(t,U.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.nextDomain=T.decode(e,t),t+=T.decode.bytes,r.rrtypes=H.decode(e,t,i-(t-n)),t+=H.decode.bytes,U.decode.bytes=t-n,r},encodingLength(e){return 2+T.encodingLength(e.nextDomain)+H.encodingLength(e.rrtypes)}}),W=w({encode(e,t,n){t||=new Uint8Array(W.encodingLength(e)),n||=0;let r=n,i=e.salt;if(!_(i))throw Error(`salt must be a Buffer`);let a=e.nextDomain;if(!_(a))throw Error(`nextDomain must be a Buffer`);return n+=2,t[n]=e.algorithm,n+=1,t[n]=e.flags,n+=1,S(t,e.iterations,n),n+=2,t[n]=i.length,n+=1,C(i,t,n,0,i.length),n+=i.length,t[n]=a.length,n+=1,C(a,t,n,0,a.length),n+=a.length,H.encode(e.rrtypes,t,n),n+=H.encode.bytes,W.encode.bytes=n-r,S(t,W.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);t+=2,r.algorithm=e[t],t+=1,r.flags=e[t],t+=1,r.iterations=b(e,t),t+=2;let a=e[t];t+=1,r.salt=e.slice(t,t+a),t+=a;let o=e[t];return t+=1,r.nextDomain=e.slice(t,t+o),t+=o,r.rrtypes=H.decode(e,t,i-(t-n)),t+=H.decode.bytes,W.decode.bytes=t-n,r},encodingLength(e){return 8+e.salt.length+e.nextDomain.length+H.encodingLength(e.rrtypes)}}),G=w({encode(e,t,n){t||=new Uint8Array(G.encodingLength(e)),n||=0;let r=n,i=e.digest;if(!_(i))throw Error(`Digest must be a Buffer`);return n+=2,S(t,e.keyTag,n),n+=2,t[n]=e.algorithm,n+=1,t[n]=e.digestType,n+=1,C(i,t,n,0,i.length),n+=i.length,G.encode.bytes=n-r,S(t,G.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.keyTag=b(e,t),t+=2,r.algorithm=e[t],t+=1,r.digestType=e[t],t+=1,r.digest=e.slice(t,n+i+2),t+=r.digest.length,G.decode.bytes=t-n,r},encodingLength(e){return 6+v(e.digest)}});function we(e){switch(e.toUpperCase()){case`A`:return xe;case`PTR`:return P;case`CNAME`:return P;case`DNAME`:return P;case`TXT`:return j;case`NULL`:return M;case`AAAA`:return Se;case`SRV`:return F;case`HINFO`:return N;case`CAA`:return I;case`NS`:return k;case`SOA`:return A;case`MX`:return be;case`OPT`:return R;case`DNSKEY`:return z;case`RRSIG`:return B;case`RP`:return V;case`NSEC`:return U;case`NSEC3`:return W;case`DS`:return G}return O}var K=w({encode(e,t,n){t||=new Uint8Array(K.encodingLength(e)),n||=0;let r=n;if(T.encode(e.name,t,n),n+=T.encode.bytes,S(t,f(e.type),n),e.type.toUpperCase()===`OPT`){if(e.name!==`.`)throw Error(`OPT name must be root.`);S(t,e.udpPayloadSize||4096,n+2),t[n+4]=e.extendedRcode||0,t[n+5]=e.ednsVersion||0,S(t,e.flags||0,n+6),n+=8,R.encode(e.options||[],t,n),n+=R.encode.bytes}else{let r=re(e.class===void 0?`IN`:e.class);e.flush&&(r|=ge),S(t,r,n+2),x(t,e.ttl||0,n+4),n+=8;let i=we(e.type);i.encode(e.data,t,n),n+=i.encode.bytes}return K.encode.bytes=n-r,t},decode(e,t){t||=0;let n={},r=t;if(n.name=T.decode(e,t),t+=T.decode.bytes,n.type=d(b(e,t)),n.type===`OPT`)n.udpPayloadSize=b(e,t+2),n.extendedRcode=e[t+4],n.ednsVersion=e[t+5],n.flags=b(e,t+6),n.flag_do=(n.flags>>15&1)==1,n.options=R.decode(e,t+8),t+=8+R.decode.bytes;else{let r=b(e,t+2);n.ttl=y(e,t+4),n.class=ne(r&_e),n.flush=!!(r&ge);let i=we(n.type);n.data=i.decode(e,t+8),t+=8+i.decode.bytes}return K.decode.bytes=t-r,n},encodingLength(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return T.encodingLength(e.name)+8+we(e.type).encodingLength(t)}}),q=w({encode(e,t,n){t||=new Uint8Array(q.encodingLength(e)),n||=0;let r=n;return T.encode(e.name,t,n),n+=T.encode.bytes,S(t,f(e.type),n),n+=2,S(t,re(e.class===void 0?`IN`:e.class),n),n+=2,q.encode.bytes=n-r,e},decode(e,t){t||=0;let n=t,r={};return r.name=T.decode(e,t),t+=T.decode.bytes,r.type=d(b(e,t)),t+=2,r.class=ne(b(e,t)),t+=2,r.class&ve&&(r.class&=ye),q.decode.bytes=t-n,r},encodingLength(e){return T.encodingLength(e.name)+4}}),J={encode:function(e,t,n){let r=!t;r&&(t=new Uint8Array(Ae(e))),n||=0;let i=n;return e.questions||=[],e.answers||=[],e.authorities||=[],e.additionals||=[],D.encode(e,t,n),n+=D.encode.bytes,n=X(e.questions,q,t,n),n=X(e.answers,K,t,n),n=X(e.authorities,K,t,n),n=X(e.additionals,K,t,n),J.encode.bytes=n-i,r&&Oe.bytes!==t.length?t.slice(0,Oe.bytes):t},decode:function(e,t){t||=0;let n=t,r=D.decode(e,t);return t+=D.decode.bytes,t=Z(r.questions,q,e,t),t=Z(r.answers,K,e,t),t=Z(r.authorities,K,e,t),t=Z(r.additionals,K,e,t),J.decode.bytes=t-n,r},encodingLength:function(e){return D.encodingLength(e)+Y(e.questions||[],q)+Y(e.answers||[],K)+Y(e.authorities||[],K)+Y(e.additionals||[],K)}};J.encode.bytes=0,J.decode.bytes=0;function Te(e,t){if(e.questions)throw Error(`Only one .question object expected instead of a .questions array!`);let n=Object.assign({type:t},e);return n.question&&(n.questions=[n.question],delete n.question),n}var Ee={encode:function(e,t,n){return t=J.encode(Te(e,`query`),t,n),Ee.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return Ee.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Te(e,`query`))}};Ee.encode.bytes=0,Ee.decode.bytes=0;var De={encode:function(e,t,n){return t=J.encode(Te(e,`response`),t,n),De.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return De.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Te(e,`response`))}};De.encode.bytes=0,De.decode.bytes=0;var Oe=J.encode,ke=J.decode,Ae=J.encodingLength;function Y(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t.encodingLength(e[r]);return n}function X(e,t,n,r){for(let i=0;i<e.length;i++)t.encode(e[i],n,r),r+=t.encode.bytes;return r}function Z(e,t,n,r){for(let i=0;i<e.length;i++)e[i]=t.decode(n,r),r+=t.decode.bytes;return r}function je(e,t,n,r){if(t.length!==64)throw Error(`Charset needs to be 64 characters long! (${t.length})`);let i=new Uint8Array(256),a=new Uint8Array(64);for(let e=0;e<64;e+=1){let n=t.charCodeAt(e);if(n>255)throw Error(`Character #${e} in charset [code=${n}, char=${t.charAt(e)}] is too high! (max=255)`);if(i[n]!==0)throw Error(`Character [code=${n}, char=${t.charAt(e)}] is more than once in the charset!`);i[n]=e,a[e]=n}let o=n.charCodeAt(0),s={name:e,encodingLength(e){let t=e.length,n=t*.75|0;return e.charCodeAt(t-1)===o?e.charCodeAt(t-2)===o?n-2:n-1:n},encode(e,t,n){t??=new Uint8Array(s.encodingLength(e)),n??=0;let r=e.length;e.charCodeAt(r-1)===o&&(e.charCodeAt(r-2)===o?r-=2:--r);let a=r%4,c=r-a,l=n,u=0;for(;u<c;){let n=i[e.charCodeAt(u)]<<18|i[e.charCodeAt(u+1)]<<12|i[e.charCodeAt(u+2)]<<6|i[e.charCodeAt(u+3)];t[l++]=n>>16,t[l++]=n>>8,t[l++]=n,u+=4}if(a===3){let n=i[e.charCodeAt(u)]<<10|i[e.charCodeAt(u+1)]<<4|i[e.charCodeAt(u+2)]>>2;t[l++]=n>>8,t[l++]=n}else a===2&&(t[l++]=i[e.charCodeAt(u)]<<2|i[e.charCodeAt(u+1)]>>4);return s.encode.bytes=l-n,t},decode(e,t,n){t??=0,n??=e.length;let i=n-t,c=i%3,l=t+i-c,u=[];for(let n=t;n<l;n+=3){let t=e[n]<<16|e[n+1]<<8|e[n+2];u.push(a[t>>18&63],a[t>>12&63],a[t>>6&63],a[t&63])}if(c===2){let t=(e[n-2]<<8)+e[n-1];u.push(a[t>>10],a[t>>4&63],a[t<<2&63]),r===1&&u.push(o)}else if(c===1){let t=e[n-1];u.push(a[t>>2],a[t<<4&63]),r===1&&u.push(o,o)}return s.decode.bytes=i,String.fromCharCode.apply(String,u)}};return s}je(`base64`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,`=`,1);var Me=je(`base64-url`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,`=`,2),Ne=e(((e,t)=>{t.exports={}})),Q=typeof global<`u`?global.AbortError:typeof window<`u`?window.AbortError:null;Q||=class extends Error{constructor(e=`Request aborted.`){super(e)}},Q.prototype.name=`AbortError`,Q.prototype.code=`ABORT_ERR`;var Pe=typeof globalThis<`u`&&globalThis.URL||Ne().URL,$=class extends Error{constructor(e,t,n){super(`status=`+t+` while requesting `+e+` [`+n+`]`),this.uri=e,this.status=t,this.method=n}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}};$.prototype.name=`HTTPStatusError`,$.prototype.code=`HTTP_STATUS`;var Fe=class extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:ze(this.cause)}}};Fe.prototype.name=`ResponseError`,Fe.prototype.code=`RESPONSE_ERR`;var Ie=class extends Error{constructor(e){super(`Timeout (t=`+e+`).`),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Ie.prototype.name=`TimeoutError`,Ie.prototype.code=`ETIMEOUT`;var Le=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,Re=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function ze(e){if(typeof e==`string`)return{message:e};try{let t=JSON.stringify(e);if(t!==`{}`)return JSON.parse(t)}catch{}let t={message:String(e.message||e)};return e.code!==void 0&&(t.code=String(e.code)),t}var Be=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,Ve=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,He=/\[(((pk|name)=([^\]]+)))\]/gi;function Ue(e){let t=Be.exec(e),n=t[2]||`https:`,r=t[3],i=t[5],a=t[6],o=t[7];if(n===`https:`||n===`http:`){let e=We(o,Ve);return{name:e.name,protocol:n,ipv4:e.ipv4,ipv6:e.ipv6,host:r,port:i,path:a,method:e.post?`POST`:`GET`}}if(n===`udp:`||n===`udp4:`||n===`udp6:`){let t=We(o,He),a=/^\[(.*)\]$/.exec(r);if(a&&n===`udp4:`)throw Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${e})`);if(!a&&n===`udp6:`)throw Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${e})`);return a?new Xe({protocol:`udp6:`,ipv6:a[1],port:i,pk:t.pk,name:t.name}):new Ye({protocol:`udp4:`,ipv4:r,port:i,pk:t.pk,name:t.name})}throw new Ge(n,e)}function We(e,t){t.lastIndex=0;let n={};for(;;){let r=t.exec(e);if(!r)break;r[2]?n[r[3].toLowerCase()]=r[4]:n[r[1].toLowerCase()]=!0}return n}var Ge=class extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${Ke.join(`, `)}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Ge.prototype.name=`InvalidProtocolError`,Ge.prototype.code=`EPROTOCOL`;var Ke=[`http:`,`https:`,`udp4:`,`udp6:`],qe=class{constructor(e,t){this.name=e.name||null,this.protocol=e.protocol;let n=typeof e.port==`string`?e.port=parseInt(e.port,10):e.port;if(n==null)this.port=t?this.protocol===`https:`?443:80:e.pk?443:53;else if(typeof n!=`number`&&!isNaN(n))throw Error(`Invalid Endpoint: port "${e.port}" needs to be a number: ${JSON.stringify(e)}`);else this.port=n}toJSON(){return this.toString()}},Je=class extends qe{constructor(e){super(e,!1),this.pk=e.pk||null}toString(){let e=this.port===(this.pk?443:53)?``:`:${this.port}`,t=this.pk?` [pk=${this.pk}]`:``,n=this.name?` [name=${this.name}]`:``;return`udp://${this.ipv4||`[${this.ipv6}]`}${e}${t}${n}`}},Ye=class extends Je{constructor(e){if(super(Object.assign({protocol:`udp4:`},e)),!e.ipv4||typeof e.ipv4!=`string`)throw Error(`Invalid Endpoint: .ipv4 "${e.ipv4}" needs to be set: ${JSON.stringify(e)}`);this.ipv4=e.ipv4}},Xe=class extends Je{constructor(e){if(super(Object.assign({protocol:`udp6:`},e)),!e.ipv6||typeof e.ipv6!=`string`)throw Error(`Invalid Endpoint: .ipv6 "${e.ipv6}" needs to be set: ${JSON.stringify(e)}`);this.ipv6=e.ipv6}};function Ze(e){return Re.test(e)&&!Le.test(e)?`[${e}]`:e}var Qe=class extends qe{constructor(e){if(super(Object.assign({protocol:`https:`},e),!0),e.host||(e.ipv4&&(e.host=e.ipv4),e.ipv6&&(e.host=`[${e.ipv6}]`)),!e.host||typeof e.host!=`string`)throw Error(`Invalid Endpoint: host "${e.path}" needs to be set: ${JSON.stringify(e)}`);if(this.host=e.host,this.path=e.path||`/dns-query`,this.method=/^post$/i.test(e.method)?`POST`:`GET`,this.ipv4=e.ipv4,this.ipv6=e.ipv6,!this.ipv6){let e=Re.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||Le.test(this.host)&&(this.ipv4=this.host);let t=`${this.protocol}//${Ze(this.host)}:${this.port}${this.path}`;try{this.url=new Pe(t)}catch(e){throw Error(e.message+` [${t}]`)}}toString(){let e=this.protocol===`https:`?``:`http://`,t=this.port===(this.protocol===`https:`?443:80)?``:`:${this.port}`,n=this.method===`GET`?``:` [post]`,r=this.path===`/dns-query`?``:this.path,i=this.name?` [name=${this.name}]`:``,a=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:``,o=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:``;return`${e}${Ze(this.host)}${t}${r}${n}${a}${o}${i}`}};function $e(e){let t;if(typeof e==`string`)t=Ue(e);else{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Can not convert ${e} to an endpoint`);if(e instanceof qe)return e;t=e}(t.protocol===null||t.protocol===void 0)&&(t.protocol=`https:`);let n=t.protocol;if(n===`udp4:`)return new Ye(t);if(n===`udp6:`)return new Xe(t);if(n===`https:`||n===`http:`)return new Qe(t);throw new Ge(n,JSON.stringify(t))}var et=`application/dns-message`;function tt(){}function nt(){throw Error(`Only "doh" endpoints are supported in the browser`)}async function rt(e,t,n,r){let i=t?t.localStoragePrefix+t.name:null;if(i)try{let e=JSON.parse(localStorage.getItem(i));if(e&&e.time>t.maxTime)return e}catch{}let{data:a}=await it(e,`GET`,null,n,r),o={time:Date.now(),data:JSON.parse(g(a))};if(i)try{localStorage.setItem(i,JSON.stringify(o))}catch{o.time=null}return o}function it(e,t,n,r,i){return new Promise((a,o)=>{let s=new Pe(e);t===`GET`&&n&&(s.search=`?dns=`+Me.decode(n));let c=s.toString(),l=new XMLHttpRequest;l.open(t,c,!0),l.setRequestHeader(`Accept`,et),t===`POST`&&l.setRequestHeader(`Content-Type`,et),l.responseType=`arraybuffer`,l.timeout=r,l.ontimeout=u,l.onreadystatechange=f,l.onerror=ee,l.onload=d,t===`POST`?l.send(n):l.send(),i&&i.addEventListener(`abort`,te);function u(){p(new Ie(r));try{l.abort()}catch{}}function d(){if(l.status!==200)p(new $(c,l.status,t));else{let e;if(typeof l.response==`string`)e=h(l.response);else if(l.response instanceof Uint8Array)e=l.response;else if(Array.isArray(l.response)||l.response instanceof ArrayBuffer)e=new Uint8Array(l.response);else throw Error(`Unprocessable response `+l.response);p(null,e)}}function f(){if(l.readyState>1&&l.status!==200&&l.status!==0){p(new $(c,l.status,t));try{l.abort()}catch{}}}let p=function(e,t){p=tt,i&&i.removeEventListener(`abort`,te),a(e?{error:e,response:l}:{data:t,response:l})};function ee(){p(l.status===200?Error(`Inexplicable XHR Error`):new $(c,l.status,t))}function te(){p(new Q);try{l.abort()}catch{}}})}function at(e,t,n,r,i){return it(e,t,n,r,i)}function ot(e){return e.filter(e=>e.cors||e.endpoint.cors)}var st={data:[{name:`adfree.usableprivacy.net`,endpoint:{protocol:`https:`,host:`adfree.usableprivacy.net`},description:`Public updns DoH service with advertising, tracker and malware filters.
|
|
1
|
+
(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),t=/^(\d{1,3}\.){3,3}\d{1,3}$/,n=4,r=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:`v4`,size:n,isFormat:e=>t.test(e),encode(e,t,r){r=~~r,t||=new Uint8Array(r+n);let i=e.length,a=0;for(let n=0;n<i;){let i=e.charCodeAt(n++);i===46?(t[r++]=a,a=0):a=a*10+(i-48)}return t[r]=a,t},decode(e,t){return t=~~t,`${e[t++]}.${e[t++]}.${e[t++]}.${e[t]}`}},o={name:`v6`,size:i,isFormat:e=>e.length>0&&r.test(e),encode(e,t,n){n=~~n;let r=n+i,a=-1,o=0,s=0,c=!0,l=!1;t||=new Uint8Array(n+i);for(let i=0;i<e.length;i++){let u=e.charCodeAt(i);u===58?(c?a===-1?n<r&&(a=n):(n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2):(l===!0?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=o>>8),n<r-1&&(t[n+1]=o&255),n+=2),o=0,s=0),c=!0,l=!1):u===46?(n<r&&(t[n]=s),n++,s=0,o=0,c=!1,l=!0):(c=!1,u>=97?u-=87:u>=65?u-=55:(u-=48,s=s*10+u),o=(o<<4)+u)}if(c===!1)l===!0?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=o>>8),n<r-1&&(t[n+1]=o&255),n+=2);else if(a===0)n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2;else if(a!==-1){n+=2;for(let e=Math.min(n-1,r-1);e>=a+2;e--)t[e]=t[e-2];t[a]=0,t[a+1]=0,a=n}if(a!==n&&a!==-1)for(n>r-2&&(n=r-2);r>a;)t[--r]=n<r&&n>a?t[--n]:0;else for(;n<r;)t[n++]=0;return t},decode(e,t){t=~~t;let n=``;for(let r=0;r<i;r+=2)r!==0&&(n+=`:`),n+=(e[t+r]<<8|e[t+r+1]).toString(16);return n.replace(/(^|:)0(:0)*:0(:|$)/,`$1::$3`).replace(/:{3,4}/,`::`)}};function s(e){if(a.isFormat(e))return a.size;if(o.isFormat(e))return o.size;throw Error(`Invalid ip address: ${e}`)}function c(e){return s(e)===a.size?1:2}function l(e,t,n){n=~~n;let r=s(e);return typeof t==`function`&&(t=t(n+r)),r===a.size?a.encode(e,t,n):o.encode(e,t,n)}function u(e,t,n){if(t=~~t,n||=e.length-t,n===a.size)return a.decode(e,t,n);if(n===o.size)return o.decode(e,t,n);throw Error(`Invalid buffer size needs to be ${a.size} for v4 or ${o.size} for v6.`)}function d(e){switch(e){case 1:return`A`;case 10:return`NULL`;case 28:return`AAAA`;case 18:return`AFSDB`;case 42:return`APL`;case 257:return`CAA`;case 60:return`CDNSKEY`;case 59:return`CDS`;case 37:return`CERT`;case 5:return`CNAME`;case 49:return`DHCID`;case 32769:return`DLV`;case 39:return`DNAME`;case 48:return`DNSKEY`;case 43:return`DS`;case 55:return`HIP`;case 13:return`HINFO`;case 45:return`IPSECKEY`;case 25:return`KEY`;case 36:return`KX`;case 29:return`LOC`;case 15:return`MX`;case 35:return`NAPTR`;case 2:return`NS`;case 47:return`NSEC`;case 50:return`NSEC3`;case 51:return`NSEC3PARAM`;case 12:return`PTR`;case 46:return`RRSIG`;case 17:return`RP`;case 24:return`SIG`;case 6:return`SOA`;case 99:return`SPF`;case 33:return`SRV`;case 44:return`SSHFP`;case 32768:return`TA`;case 249:return`TKEY`;case 52:return`TLSA`;case 250:return`TSIG`;case 16:return`TXT`;case 252:return`AXFR`;case 251:return`IXFR`;case 41:return`OPT`;case 255:return`ANY`}return`UNKNOWN_`+e}function f(e){switch(e.toUpperCase()){case`A`:return 1;case`NULL`:return 10;case`AAAA`:return 28;case`AFSDB`:return 18;case`APL`:return 42;case`CAA`:return 257;case`CDNSKEY`:return 60;case`CDS`:return 59;case`CERT`:return 37;case`CNAME`:return 5;case`DHCID`:return 49;case`DLV`:return 32769;case`DNAME`:return 39;case`DNSKEY`:return 48;case`DS`:return 43;case`HIP`:return 55;case`HINFO`:return 13;case`IPSECKEY`:return 45;case`KEY`:return 25;case`KX`:return 36;case`LOC`:return 29;case`MX`:return 15;case`NAPTR`:return 35;case`NS`:return 2;case`NSEC`:return 47;case`NSEC3`:return 50;case`NSEC3PARAM`:return 51;case`PTR`:return 12;case`RRSIG`:return 46;case`RP`:return 17;case`SIG`:return 24;case`SOA`:return 6;case`SPF`:return 99;case`SRV`:return 33;case`SSHFP`:return 44;case`TA`:return 32768;case`TKEY`:return 249;case`TLSA`:return 52;case`TSIG`:return 250;case`TXT`:return 16;case`AXFR`:return 252;case`IXFR`:return 251;case`OPT`:return 41;case`ANY`:return 255;case`*`:return 255}return e.toUpperCase().startsWith(`UNKNOWN_`)?parseInt(e.slice(8)):0}function p(e){switch(e){case 0:return`NOERROR`;case 1:return`FORMERR`;case 2:return`SERVFAIL`;case 3:return`NXDOMAIN`;case 4:return`NOTIMP`;case 5:return`REFUSED`;case 6:return`YXDOMAIN`;case 7:return`YXRRSET`;case 8:return`NXRRSET`;case 9:return`NOTAUTH`;case 10:return`NOTZONE`;case 11:return`RCODE_11`;case 12:return`RCODE_12`;case 13:return`RCODE_13`;case 14:return`RCODE_14`;case 15:return`RCODE_15`}return`RCODE_`+e}function ee(e){switch(e.toUpperCase()){case`NOERROR`:return 0;case`FORMERR`:return 1;case`SERVFAIL`:return 2;case`NXDOMAIN`:return 3;case`NOTIMP`:return 4;case`REFUSED`:return 5;case`YXDOMAIN`:return 6;case`YXRRSET`:return 7;case`NXRRSET`:return 8;case`NOTAUTH`:return 9;case`NOTZONE`:return 10;case`RCODE_11`:return 11;case`RCODE_12`:return 12;case`RCODE_13`:return 13;case`RCODE_14`:return 14;case`RCODE_15`:return 15}return 0}function te(e){switch(e){case 0:return`QUERY`;case 1:return`IQUERY`;case 2:return`STATUS`;case 3:return`OPCODE_3`;case 4:return`NOTIFY`;case 5:return`UPDATE`;case 6:return`OPCODE_6`;case 7:return`OPCODE_7`;case 8:return`OPCODE_8`;case 9:return`OPCODE_9`;case 10:return`OPCODE_10`;case 11:return`OPCODE_11`;case 12:return`OPCODE_12`;case 13:return`OPCODE_13`;case 14:return`OPCODE_14`;case 15:return`OPCODE_15`}return`OPCODE_`+e}function ne(e){switch(e){case 1:return`IN`;case 2:return`CS`;case 3:return`CH`;case 4:return`HS`;case 255:return`ANY`}return`UNKNOWN_`+e}function re(e){switch(e.toUpperCase()){case`IN`:return 1;case`CS`:return 2;case`CH`:return 3;case`HS`:return 4;case`ANY`:return 255}return 0}function ie(e){switch(e){case 1:return`LLQ`;case 2:return`UL`;case 3:return`NSID`;case 5:return`DAU`;case 6:return`DHU`;case 7:return`N3U`;case 8:return`CLIENT_SUBNET`;case 9:return`EXPIRE`;case 10:return`COOKIE`;case 11:return`TCP_KEEPALIVE`;case 12:return`PADDING`;case 13:return`CHAIN`;case 14:return`KEY_TAG`;case 26946:return`DEVICEID`}return e<0?null:`OPTION_${e}`}function ae(e){if(typeof e==`number`)return e;if(!e)return-1;switch(e.toUpperCase()){case`OPTION_0`:return 0;case`LLQ`:return 1;case`UL`:return 2;case`NSID`:return 3;case`OPTION_4`:return 4;case`DAU`:return 5;case`DHU`:return 6;case`N3U`:return 7;case`CLIENT_SUBNET`:return 8;case`EXPIRE`:return 9;case`COOKIE`:return 10;case`TCP_KEEPALIVE`:return 11;case`PADDING`:return 12;case`CHAIN`:return 13;case`KEY_TAG`:return 14;case`DEVICEID`:return 26946;case`OPTION_65535`:return 65535}let t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}var oe=55296,m=56320;function se(e){let t=0,n=e.length;for(let r=0;r<n;r+=1){let i=e.charCodeAt(r);if(i<=127)t+=1;else if(i<=2047)t+=2;else if((i&63488)!==oe)t+=3;else{let a=r+1;a===n||i>=m?t+=3:(e.charCodeAt(a)&64512)===m?(r=a,t+=4):t+=3}}return t}function h(e,t,n){let r=e.length;n??=0,t===void 0&&(t=new Uint8Array(se(e)+n));let i=n;for(let n=0;n<r;n+=1){let a=e.charCodeAt(n);if(a<=127)t[i++]=a;else if(a<=2047)t[i++]=192|(a&1984)>>6,t[i++]=128|a&63;else if((a&63488)!==oe)t[i++]=224|(a&61440)>>12,t[i++]=128|(a&4032)>>6,t[i++]=128|a&63;else{let o=n+1;if(o===r||a>=m)t[i++]=239,t[i++]=191,t[i++]=189;else{let r=e.charCodeAt(o);(r&64512)===m?(n=o,a=65536|(a&1023)<<10|r&1023,t[i++]=240|(a&1835008)>>18,t[i++]=128|(a&258048)>>12,t[i++]=128|(a&4032)>>6,t[i++]=128|a&63):(t[i++]=239,t[i++]=191,t[i++]=189)}}}return h.bytes=i-n,t}h.bytes=0;function g(e,t,n){let r=``;t??=0,n??=e.length;for(let i=t;i<n;){let t=e[i++],n;if(t<=128)n=t;else if(t>191&&t<224)n=(t&31)<<6|e[i++]&63;else if(t>239&&t<365){n=((t&7)<<18|(e[i++]&63)<<12|(e[i++]&63)<<6|e[i++]&63)-65536;let a=oe|n>>10&1023;r+=String.fromCharCode(a),n=m|n&1023}else n=(t&15)<<12|(e[i++]&63)<<6|e[i++]&63;r+=String.fromCharCode(n)}return g.bytes=n-t,r}g.bytes=0;var _=e=>e instanceof Uint8Array;function v(e){return typeof e==`string`?se(e):e.byteLength}function ce(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):h(e)}function le(e,t,n){if(typeof t!=`string`)throw Error(`unknown input type`);return h(t,e,n),h.bytes}var ue=2**24,de=2**16,fe=256,y=(e,t)=>e[t]*ue+e[t+1]*de+e[t+2]*fe+e[t+3],b=(e,t)=>e[t]<<8|e[t+1],x=(e,t,n)=>(t=+t,e[n+3]=t,t>>>=8,e[n+2]=t,t>>>=8,e[n+1]=t,t>>>=8,e[n]=t,n+4),S=(e,t,n)=>(e[n]=t>>8,e[n+1]=t&255,n+2);function C(e,t,n,r,i){return n<0&&(r-=n,n=0),r<0&&(r=0),i<0?new Uint8Array:n>=t.length||r>=i?0:pe(e,t,n,r,i)}function pe(e,t,n,r,i){i-r>t.length-n&&(i=r+t.length-n);let a=i-r,o=e.length-r;return a>o&&(a=o),(r!==0||i<e.length)&&(e=new Uint8Array(e.buffer,e.byteOffset+r,a)),t.set(e,n),a}var me=0,he=32768,ge=32768,_e=-32769,ve=32768,ye=-32769;function w({bytes:e=0,encode:t,decode:n,encodingLength:r}){return t.bytes=e,n.bytes=e,{encode:t,decode:n,encodingLength:r||(()=>e)}}var T=w({encode(e,t,n){t||=new Uint8Array(T.encodingLength(e)),n||=0;let r=n,i=e.replace(/^\.|\.$/gm,``);if(i.length){let e=i.split(`.`);for(let r=0;r<e.length;r++){let i=le(t,e[r],n+1);t[n]=i,n+=i+1}}return t[n++]=0,T.encode.bytes=n-r,t},decode(e,t){t||=0;let n=[],r=t,i=0,a=0,o=!1;for(;;){if(t>=e.length)throw Error(`Cannot decode name (buffer overflow)`);let s=e[t++];if(a+=+!o,s===0)break;if(!(s&192)){if(t+s>e.length)throw Error(`Cannot decode name (buffer overflow)`);if(i+=s+1,i>254)throw Error(`Cannot decode name (name too long)`);n.push(g(e,t,t+s)),t+=s,a+=o?0:s}else if((s&192)==192){if(t+1>e.length)throw Error(`Cannot decode name (buffer overflow)`);let n=b(e,t-1)-49152;if(n>=r)throw Error(`Cannot decode name (bad pointer)`);t=n,r=n,a+=+!o,o=!0}else throw Error(`Cannot decode name (bad label)`)}return T.decode.bytes=a,n.length===0?`.`:n.join(`.`)},encodingLength(e){return e===`.`||e===`..`?1:v(e.replace(/^\.|\.$/gm,``))+2}}),E=w({encode(e,t,n){t||=new Uint8Array(E.encodingLength(e)),n||=0;let r=le(t,e,n+1);return t[n]=r,E.encode.bytes=r+1,t},decode(e,t){t||=0;let n=e[t],r=g(e,t+1,t+1+n);return E.decode.bytes=n+1,r},encodingLength(e){return v(e)+1}}),D=w({bytes:12,encode(e,t,n){t||=new Uint8Array(D.encodingLength(e)),n||=0;let r=(e.flags||0)&32767,i=e.type===`response`?he:me;return S(t,e.id||0,n),S(t,r|i,n+2),S(t,e.questions.length,n+4),S(t,e.answers.length,n+6),S(t,e.authorities.length,n+8),S(t,e.additionals.length,n+10),t},decode(e,t){if(t||=0,e.length<12)throw Error(`Header must be 12 bytes`);let n=b(e,t+2);return{id:b(e,t),type:n&he?`response`:`query`,flags:n&32767,flag_qr:(n>>15&1)==1,opcode:te(n>>11&15),flag_aa:(n>>10&1)==1,flag_tc:(n>>9&1)==1,flag_rd:(n>>8&1)==1,flag_ra:(n>>7&1)==1,flag_z:(n>>6&1)==1,flag_ad:(n>>5&1)==1,flag_cd:(n>>4&1)==1,rcode:p(n&15),questions:Array(b(e,t+4)),answers:Array(b(e,t+6)),authorities:Array(b(e,t+8)),additionals:Array(b(e,t+10))}},encodingLength(){return 12}}),O=w({encode(e,t,n){t||=new Uint8Array(O.encodingLength(e)),n||=0;let r=e.length;return S(t,r,n),C(e,t,n+2,0,r),O.encode.bytes=r+2,t},decode(e,t){t||=0;let n=b(e,t),r=e.slice(t+2,t+2+n);return O.decode.bytes=n+2,r},encodingLength(e){return e.length+2}}),k=w({encode(e,t,n){return t||=new Uint8Array(k.encodingLength(e)),n||=0,T.encode(e,t,n+2),S(t,T.encode.bytes,n),k.encode.bytes=T.encode.bytes+2,t},decode(e,t){t||=0;let n=b(e,t),r=T.decode(e,t+2);return k.decode.bytes=n+2,r},encodingLength(e){return T.encodingLength(e)+2}}),A=w({encode(e,t,n){t||=new Uint8Array(A.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.mname,t,n),n+=T.encode.bytes,T.encode(e.rname,t,n),n+=T.encode.bytes,x(t,e.serial||0,n),n+=4,x(t,e.refresh||0,n),n+=4,x(t,e.retry||0,n),n+=4,x(t,e.expire||0,n),n+=4,x(t,e.minimum||0,n),n+=4,S(t,n-r-2,r),A.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.mname=T.decode(e,t),t+=T.decode.bytes,r.rname=T.decode(e,t),t+=T.decode.bytes,r.serial=y(e,t),t+=4,r.refresh=y(e,t),t+=4,r.retry=y(e,t),t+=4,r.expire=y(e,t),t+=4,r.minimum=y(e,t),t+=4,A.decode.bytes=t-n,r},encodingLength(e){return 22+T.encodingLength(e.mname)+T.encodingLength(e.rname)}}),j=w({encode(e,t,n){Array.isArray(e)||(e=[e]);for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&(e[t]=ce(e[t])),!_(e[t]))throw Error(`Must be a Buffer`);t||=new Uint8Array(j.encodingLength(e)),n||=0;let r=n;return n+=2,e.forEach(function(e){t[n++]=e.length,C(e,t,n,0,e.length),n+=e.length}),S(t,n-r-2,r),j.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=b(e,t);t+=2;let i=[];for(;r>0;){let n=e[t++];if(--r,r<n)throw Error(`Buffer overflow`);i.push(e.slice(t,t+n)),t+=n,r-=n}return j.decode.bytes=t-n,i},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach(function(e){t+=typeof e==`string`?v(e)+1:e.length+1}),t}}),M=w({encode(e,t,n){t||=new Uint8Array(M.encodingLength(e)),n||=0,typeof e==`string`&&(e=ce(e)),e||=new Uint8Array;let r=n;n+=2;let i=e.length;return C(e,t,n,0,i),n+=i,S(t,n-r-2,r),M.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=b(e,t);t+=2;let i=e.slice(t,t+r);return t+=r,M.decode.bytes=t-n,i},encodingLength(e){return e?(_(e)?e.length:v(e))+2:2}}),N=w({encode(e,t,n){t||=new Uint8Array(N.encodingLength(e)),n||=0;let r=n;return n+=2,E.encode(e.cpu,t,n),n+=E.encode.bytes,E.encode(e.os,t,n),n+=E.encode.bytes,S(t,n-r-2,r),N.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.cpu=E.decode(e,t),t+=E.decode.bytes,r.os=E.decode(e,t),t+=E.decode.bytes,N.decode.bytes=t-n,r},encodingLength(e){return E.encodingLength(e.cpu)+E.encodingLength(e.os)+2}}),P=w({encode(e,t,n){return t||=new Uint8Array(P.encodingLength(e)),n||=0,T.encode(e,t,n+2),S(t,T.encode.bytes,n),P.encode.bytes=T.encode.bytes+2,t},decode(e,t){t||=0;let n=T.decode(e,t+2);return P.decode.bytes=T.decode.bytes+2,n},encodingLength(e){return T.encodingLength(e)+2}}),F=w({encode(e,t,n){t||=new Uint8Array(F.encodingLength(e)),n||=0,S(t,e.priority||0,n+2),S(t,e.weight||0,n+4),S(t,e.port||0,n+6),T.encode(e.target,t,n+8);let r=T.encode.bytes+6;return S(t,r,n),F.encode.bytes=r+2,t},decode(e,t){t||=0;let n=b(e,t),r={};return r.priority=b(e,t+2),r.weight=b(e,t+4),r.port=b(e,t+6),r.target=T.decode(e,t+8),F.decode.bytes=n+2,r},encodingLength(e){return 8+T.encodingLength(e.target)}}),I=w({encode(e,t,n){let r=I.encodingLength(e);return t||=new Uint8Array(I.encodingLength(e)),n||=0,e.issuerCritical&&(e.flags=I.ISSUER_CRITICAL),S(t,r-2,n),n+=2,t[n]=e.flags||0,n+=1,E.encode(e.tag,t,n),n+=E.encode.bytes,le(t,e.value,n),n+=v(e.value),I.encode.bytes=r,t},decode(e,t){t||=0;let n=b(e,t);t+=2;let r=t,i={};return i.flags=e[t],t+=1,i.tag=E.decode(e,t),t+=E.decode.bytes,i.value=g(e,t,r+n),i.issuerCritical=!!(i.flags&I.ISSUER_CRITICAL),I.decode.bytes=n+2,i},encodingLength(e){return E.encodingLength(e.tag)+E.encodingLength(e.value)+2}});I.ISSUER_CRITICAL=128;var be=w({encode(e,t,n){t||=new Uint8Array(be.encodingLength(e)),n||=0;let r=n;return n+=2,S(t,e.preference||0,n),n+=2,T.encode(e.exchange,t,n),n+=T.encode.bytes,S(t,n-r-2,r),be.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.preference=b(e,t),t+=2,r.exchange=T.decode(e,t),t+=T.decode.bytes,be.decode.bytes=t-n,r},encodingLength(e){return 4+T.encodingLength(e.exchange)}}),xe=w({encode(e,t,n){return t||=new Uint8Array(xe.encodingLength(e)),n||=0,S(t,4,n),n+=2,a.encode(e,t,n),t},decode(e,t){return t||=0,t+=2,a.decode(e,t)},bytes:6}),Se=w({encode(e,t,n){return t||=new Uint8Array(Se.encodingLength(e)),n||=0,S(t,16,n),n+=2,o.encode(e,t,n),Se.encode.bytes=18,t},decode(e,t){t||=0,t+=2;let n=o.decode(e,t);return Se.decode.bytes=18,n},bytes:18}),Ce=e=>new Uint8Array(e),L=w({encode(e,t,n){t||=new Uint8Array(L.encodingLength(e)),n||=0;let r=n,i=ae(e.code);if(S(t,i,n),n+=2,e.data)S(t,e.data.length,n),n+=2,C(e.data,t,n),n+=e.data.length;else switch(i){case 8:{let r=e.sourcePrefixLength||0,i=e.family||c(e.ip,Ce),a=l(e.ip,Ce),o=Math.ceil(r/8);S(t,o+4,n),n+=2,S(t,i,n),n+=2,t[n++]=r,t[n++]=e.scopePrefixLength||0,C(a,t,n,0,o),n+=o}break;case 11:e.timeout?(S(t,2,n),n+=2,S(t,e.timeout,n),n+=2):(S(t,0,n),n+=2);break;case 12:{let r=e.length||0;S(t,r,n),n+=2,t.fill(0,n,n+r),n+=r}break;case 14:{let r=e.tags.length*2;S(t,r,n),n+=2;for(let r of e.tags)S(t,r,n),n+=2}break;default:throw Error(`Unknown roption code: ${e.code}`)}return L.encode.bytes=n-r,t},decode(e,t){t||=0;let n={};n.code=b(e,t),n.type=ie(n.code),t+=2;let r=b(e,t);switch(t+=2,n.data=e.slice(t,t+r),n.code){case 8:n.family=b(e,t),t+=2,n.sourcePrefixLength=e[t++],n.scopePrefixLength=e[t++];{let i=new Uint8Array(n.family===1?4:16);C(e,i,0,t,t+r-4),n.ip=u(i)}break;case 11:r>0&&(n.timeout=b(e,t),t+=2);break;case 14:n.tags=[];for(let i=0;i<r;i+=2)n.tags.push(b(e,t)),t+=2}return L.decode.bytes=r+4,n},encodingLength(e){if(e.data)return e.data.length+4;switch(ae(e.code)){case 8:{let t=e.sourcePrefixLength||0;return Math.ceil(t/8)+8}case 11:return typeof e.timeout==`number`?6:4;case 12:return e.length+4;case 14:return 4+e.tags.length*2}throw Error(`Unknown roption code: ${e.code}`)}}),R=w({encode(e,t,n){t||=new Uint8Array(R.encodingLength(e)),n||=0;let r=n,i=Y(e,L);return S(t,i,n),n=X(e,L,t,n+2),R.encode.bytes=n-r,t},decode(e,t){t||=0;let n=t,r=[],i=b(e,t);t+=2;let a=0;for(;i>0;)r[a++]=L.decode(e,t),t+=L.decode.bytes,i-=L.decode.bytes;return R.decode.bytes=t-n,r},encodingLength(e){return 2+Y(e||[],L)}}),z=w({encode(e,t,n){t||=new Uint8Array(z.encodingLength(e)),n||=0;let r=n,i=e.key;if(!_(i))throw Error(`Key must be a Buffer`);return n+=2,S(t,e.flags,n),n+=2,t[n]=z.PROTOCOL_DNSSEC,n+=1,t[n]=e.algorithm,n+=1,C(i,t,n,0,i.length),n+=i.length,z.encode.bytes=n-r,S(t,z.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);if(t+=2,r.flags=b(e,t),t+=2,e[t]!==z.PROTOCOL_DNSSEC)throw Error(`Protocol must be 3`);return t+=1,r.algorithm=e[t],t+=1,r.key=e.slice(t,n+i+2),t+=r.key.length,z.decode.bytes=t-n,r},encodingLength(e){return 6+v(e.key)}});z.PROTOCOL_DNSSEC=3,z.ZONE_KEY=128,z.SECURE_ENTRYPOINT=32768;var B=w({encode(e,t,n){t||=new Uint8Array(B.encodingLength(e)),n||=0;let r=n,i=e.signature;if(!_(i))throw Error(`Signature must be a Buffer`);return n+=2,S(t,f(e.typeCovered),n),n+=2,t[n]=e.algorithm,n+=1,t[n]=e.labels,n+=1,x(t,e.originalTTL,n),n+=4,x(t,e.expiration,n),n+=4,x(t,e.inception,n),n+=4,S(t,e.keyTag,n),n+=2,T.encode(e.signersName,t,n),n+=T.encode.bytes,C(i,t,n,0,i.length),n+=i.length,B.encode.bytes=n-r,S(t,B.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.typeCovered=d(b(e,t)),t+=2,r.algorithm=e[t],t+=1,r.labels=e[t],t+=1,r.originalTTL=y(e,t),t+=4,r.expiration=y(e,t),t+=4,r.inception=y(e,t),t+=4,r.keyTag=b(e,t),t+=2,r.signersName=T.decode(e,t),t+=T.decode.bytes,r.signature=e.slice(t,n+i+2),t+=r.signature.length,B.decode.bytes=t-n,r},encodingLength(e){return 20+T.encodingLength(e.signersName)+v(e.signature)}}),V=w({encode(e,t,n){t||=new Uint8Array(V.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.mbox||`.`,t,n),n+=T.encode.bytes,T.encode(e.txt||`.`,t,n),n+=T.encode.bytes,V.encode.bytes=n-r,S(t,V.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={};return t+=2,r.mbox=T.decode(e,t)||`.`,t+=T.decode.bytes,r.txt=T.decode(e,t)||`.`,t+=T.decode.bytes,V.decode.bytes=t-n,r},encodingLength(e){return 2+T.encodingLength(e.mbox||`.`)+T.encodingLength(e.txt||`.`)}}),H=w({encode(e,t,n){t||=new Uint8Array(H.encodingLength(e)),n||=0;let r=n,i=[];for(let t=0;t<e.length;t++){let n=f(e[t]);i[n>>8]===void 0&&(i[n>>8]=[]),i[n>>8][n>>3&31]|=1<<7-(n&7)}for(let e=0;e<i.length;e++)if(i[e]!==void 0){let r=ce(i[e]);t[n]=e,n+=1,t[n]=r.length,n+=1,C(r,t,n,0,r.length),n+=r.length}return H.encode.bytes=n-r,t},decode(e,t,n){t||=0;let r=t,i=[];for(;t-r<n;){let n=e[t];t+=1;let r=e[t];t+=1;for(let a=0;a<r;a++){let r=e[t+a];for(let e=0;e<8;e++)if(r&1<<7-e){let t=d(n<<8|a<<3|e);i.push(t)}}t+=r}return H.decode.bytes=t-r,i},encodingLength(e){let t=[];for(let n=0;n<e.length;n++){let r=f(e[n]);t[r>>8]=Math.max(t[r>>8]||0,r&255)}let n=0;for(let e=0;e<t.length;e++)t[e]!==void 0&&(n+=2+Math.ceil((t[e]+1)/8));return n}}),U=w({encode(e,t,n){t||=new Uint8Array(U.encodingLength(e)),n||=0;let r=n;return n+=2,T.encode(e.nextDomain,t,n),n+=T.encode.bytes,H.encode(e.rrtypes,t,n),n+=H.encode.bytes,U.encode.bytes=n-r,S(t,U.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.nextDomain=T.decode(e,t),t+=T.decode.bytes,r.rrtypes=H.decode(e,t,i-(t-n)),t+=H.decode.bytes,U.decode.bytes=t-n,r},encodingLength(e){return 2+T.encodingLength(e.nextDomain)+H.encodingLength(e.rrtypes)}}),W=w({encode(e,t,n){t||=new Uint8Array(W.encodingLength(e)),n||=0;let r=n,i=e.salt;if(!_(i))throw Error(`salt must be a Buffer`);let a=e.nextDomain;if(!_(a))throw Error(`nextDomain must be a Buffer`);return n+=2,t[n]=e.algorithm,n+=1,t[n]=e.flags,n+=1,S(t,e.iterations,n),n+=2,t[n]=i.length,n+=1,C(i,t,n,0,i.length),n+=i.length,t[n]=a.length,n+=1,C(a,t,n,0,a.length),n+=a.length,H.encode(e.rrtypes,t,n),n+=H.encode.bytes,W.encode.bytes=n-r,S(t,W.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);t+=2,r.algorithm=e[t],t+=1,r.flags=e[t],t+=1,r.iterations=b(e,t),t+=2;let a=e[t];t+=1,r.salt=e.slice(t,t+a),t+=a;let o=e[t];return t+=1,r.nextDomain=e.slice(t,t+o),t+=o,r.rrtypes=H.decode(e,t,i-(t-n)),t+=H.decode.bytes,W.decode.bytes=t-n,r},encodingLength(e){return 8+e.salt.length+e.nextDomain.length+H.encodingLength(e.rrtypes)}}),G=w({encode(e,t,n){t||=new Uint8Array(G.encodingLength(e)),n||=0;let r=n,i=e.digest;if(!_(i))throw Error(`Digest must be a Buffer`);return n+=2,S(t,e.keyTag,n),n+=2,t[n]=e.algorithm,n+=1,t[n]=e.digestType,n+=1,C(i,t,n,0,i.length),n+=i.length,G.encode.bytes=n-r,S(t,G.encode.bytes-2,r),t},decode(e,t){t||=0;let n=t,r={},i=b(e,t);return t+=2,r.keyTag=b(e,t),t+=2,r.algorithm=e[t],t+=1,r.digestType=e[t],t+=1,r.digest=e.slice(t,n+i+2),t+=r.digest.length,G.decode.bytes=t-n,r},encodingLength(e){return 6+v(e.digest)}});function we(e){switch(e.toUpperCase()){case`A`:return xe;case`PTR`:return P;case`CNAME`:return P;case`DNAME`:return P;case`TXT`:return j;case`NULL`:return M;case`AAAA`:return Se;case`SRV`:return F;case`HINFO`:return N;case`CAA`:return I;case`NS`:return k;case`SOA`:return A;case`MX`:return be;case`OPT`:return R;case`DNSKEY`:return z;case`RRSIG`:return B;case`RP`:return V;case`NSEC`:return U;case`NSEC3`:return W;case`DS`:return G}return O}var K=w({encode(e,t,n){t||=new Uint8Array(K.encodingLength(e)),n||=0;let r=n;if(T.encode(e.name,t,n),n+=T.encode.bytes,S(t,f(e.type),n),e.type.toUpperCase()===`OPT`){if(e.name!==`.`)throw Error(`OPT name must be root.`);S(t,e.udpPayloadSize||4096,n+2),t[n+4]=e.extendedRcode||0,t[n+5]=e.ednsVersion||0,S(t,e.flags||0,n+6),n+=8,R.encode(e.options||[],t,n),n+=R.encode.bytes}else{let r=re(e.class===void 0?`IN`:e.class);e.flush&&(r|=ge),S(t,r,n+2),x(t,e.ttl||0,n+4),n+=8;let i=we(e.type);i.encode(e.data,t,n),n+=i.encode.bytes}return K.encode.bytes=n-r,t},decode(e,t){t||=0;let n={},r=t;if(n.name=T.decode(e,t),t+=T.decode.bytes,n.type=d(b(e,t)),n.type===`OPT`)n.udpPayloadSize=b(e,t+2),n.extendedRcode=e[t+4],n.ednsVersion=e[t+5],n.flags=b(e,t+6),n.flag_do=(n.flags>>15&1)==1,n.options=R.decode(e,t+8),t+=8+R.decode.bytes;else{let r=b(e,t+2);n.ttl=y(e,t+4),n.class=ne(r&_e),n.flush=!!(r&ge);let i=we(n.type);n.data=i.decode(e,t+8),t+=8+i.decode.bytes}return K.decode.bytes=t-r,n},encodingLength(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return T.encodingLength(e.name)+8+we(e.type).encodingLength(t)}}),q=w({encode(e,t,n){t||=new Uint8Array(q.encodingLength(e)),n||=0;let r=n;return T.encode(e.name,t,n),n+=T.encode.bytes,S(t,f(e.type),n),n+=2,S(t,re(e.class===void 0?`IN`:e.class),n),n+=2,q.encode.bytes=n-r,e},decode(e,t){t||=0;let n=t,r={};return r.name=T.decode(e,t),t+=T.decode.bytes,r.type=d(b(e,t)),t+=2,r.class=ne(b(e,t)),t+=2,r.class&ve&&(r.class&=ye),q.decode.bytes=t-n,r},encodingLength(e){return T.encodingLength(e.name)+4}}),J={encode:function(e,t,n){let r=!t;r&&(t=new Uint8Array(Ae(e))),n||=0;let i=n;return e.questions||=[],e.answers||=[],e.authorities||=[],e.additionals||=[],D.encode(e,t,n),n+=D.encode.bytes,n=X(e.questions,q,t,n),n=X(e.answers,K,t,n),n=X(e.authorities,K,t,n),n=X(e.additionals,K,t,n),J.encode.bytes=n-i,r&&Oe.bytes!==t.length?t.slice(0,Oe.bytes):t},decode:function(e,t){t||=0;let n=t,r=D.decode(e,t);return t+=D.decode.bytes,t=je(r.questions,q,e,t),t=je(r.answers,K,e,t),t=je(r.authorities,K,e,t),t=je(r.additionals,K,e,t),J.decode.bytes=t-n,r},encodingLength:function(e){return D.encodingLength(e)+Y(e.questions||[],q)+Y(e.answers||[],K)+Y(e.authorities||[],K)+Y(e.additionals||[],K)}};J.encode.bytes=0,J.decode.bytes=0;function Te(e,t){if(e.questions)throw Error(`Only one .question object expected instead of a .questions array!`);let n=Object.assign({type:t},e);return n.question&&(n.questions=[n.question],delete n.question),n}var Ee={encode:function(e,t,n){return t=J.encode(Te(e,`query`),t,n),Ee.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return Ee.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Te(e,`query`))}};Ee.encode.bytes=0,Ee.decode.bytes=0;var De={encode:function(e,t,n){return t=J.encode(Te(e,`response`),t,n),De.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return De.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Te(e,`response`))}};De.encode.bytes=0,De.decode.bytes=0;var Oe=J.encode,ke=J.decode,Ae=J.encodingLength;function Y(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t.encodingLength(e[r]);return n}function X(e,t,n,r){for(let i=0;i<e.length;i++)t.encode(e[i],n,r),r+=t.encode.bytes;return r}function je(e,t,n,r){for(let i=0;i<e.length;i++)e[i]=t.decode(n,r),r+=t.decode.bytes;return r}function Me(e,t,n,r){if(t.length!==64)throw Error(`Charset needs to be 64 characters long! (${t.length})`);let i=new Uint8Array(256),a=new Uint8Array(64);for(let e=0;e<64;e+=1){let n=t.charCodeAt(e);if(n>255)throw Error(`Character #${e} in charset [code=${n}, char=${t.charAt(e)}] is too high! (max=255)`);if(i[n]!==0)throw Error(`Character [code=${n}, char=${t.charAt(e)}] is more than once in the charset!`);i[n]=e,a[e]=n}let o=n.charCodeAt(0),s={name:e,encodingLength(e){let t=e.length,n=t*.75|0;return e.charCodeAt(t-1)===o?e.charCodeAt(t-2)===o?n-2:n-1:n},encode(e,t,n){t??=new Uint8Array(s.encodingLength(e)),n??=0;let r=e.length;e.charCodeAt(r-1)===o&&(e.charCodeAt(r-2)===o?r-=2:--r);let a=r%4,c=r-a,l=n,u=0;for(;u<c;){let n=i[e.charCodeAt(u)]<<18|i[e.charCodeAt(u+1)]<<12|i[e.charCodeAt(u+2)]<<6|i[e.charCodeAt(u+3)];t[l++]=n>>16,t[l++]=n>>8,t[l++]=n,u+=4}if(a===3){let n=i[e.charCodeAt(u)]<<10|i[e.charCodeAt(u+1)]<<4|i[e.charCodeAt(u+2)]>>2;t[l++]=n>>8,t[l++]=n}else a===2&&(t[l++]=i[e.charCodeAt(u)]<<2|i[e.charCodeAt(u+1)]>>4);return s.encode.bytes=l-n,t},decode(e,t,n){t??=0,n??=e.length;let i=n-t,c=i%3,l=t+i-c,u=[];for(let n=t;n<l;n+=3){let t=e[n]<<16|e[n+1]<<8|e[n+2];u.push(a[t>>18&63],a[t>>12&63],a[t>>6&63],a[t&63])}if(c===2){let t=(e[n-2]<<8)+e[n-1];u.push(a[t>>10],a[t>>4&63],a[t<<2&63]),r===1&&u.push(o)}else if(c===1){let t=e[n-1];u.push(a[t>>2],a[t<<4&63]),r===1&&u.push(o,o)}return s.decode.bytes=i,String.fromCharCode.apply(String,u)}};return s}Me(`base64`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,`=`,1);var Ne=Me(`base64-url`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,`=`,2),Pe=e(((e,t)=>{t.exports={}})),Z=typeof global<`u`?global.AbortError:typeof window<`u`?window.AbortError:null;Z||=class extends Error{constructor(e=`Request aborted.`){super(e)}},Z.prototype.name=`AbortError`,Z.prototype.code=`ABORT_ERR`;var Fe=typeof globalThis<`u`&&globalThis.URL||Pe().URL,Q=class extends Error{constructor(e,t,n){super(`status=`+t+` while requesting `+e+` [`+n+`]`),this.uri=e,this.status=t,this.method=n}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}};Q.prototype.name=`HTTPStatusError`,Q.prototype.code=`HTTP_STATUS`;var Ie=class extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:Be(this.cause)}}};Ie.prototype.name=`ResponseError`,Ie.prototype.code=`RESPONSE_ERR`;var Le=class extends Error{constructor(e){super(`Timeout (t=`+e+`).`),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Le.prototype.name=`TimeoutError`,Le.prototype.code=`ETIMEOUT`;var Re=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,ze=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function Be(e){if(typeof e==`string`)return{message:e};try{let t=JSON.stringify(e);if(t!==`{}`)return JSON.parse(t)}catch{}let t={message:String(e.message||e)};return e.code!==void 0&&(t.code=String(e.code)),t}var Ve=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,He=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,Ue=/\[(((pk|name)=([^\]]+)))\]/gi;function We(e){let t=Ve.exec(e),n=t[2]||`https:`,r=t[3],i=t[5],a=t[6],o=t[7];if(n===`https:`||n===`http:`){let e=Ge(o,He);return{name:e.name,protocol:n,ipv4:e.ipv4,ipv6:e.ipv6,host:r,port:i,path:a,method:e.post?`POST`:`GET`}}if(n===`udp:`||n===`udp4:`||n===`udp6:`){let t=Ge(o,Ue),a=/^\[(.*)\]$/.exec(r);if(a&&n===`udp4:`)throw Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${e})`);if(!a&&n===`udp6:`)throw Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${e})`);return a?new Ze({protocol:`udp6:`,ipv6:a[1],port:i,pk:t.pk,name:t.name}):new Xe({protocol:`udp4:`,ipv4:r,port:i,pk:t.pk,name:t.name})}throw new Ke(n,e)}function Ge(e,t){t.lastIndex=0;let n={};for(;;){let r=t.exec(e);if(!r)break;r[2]?n[r[3].toLowerCase()]=r[4]:n[r[1].toLowerCase()]=!0}return n}var Ke=class extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${qe.join(`, `)}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Ke.prototype.name=`InvalidProtocolError`,Ke.prototype.code=`EPROTOCOL`;var qe=[`http:`,`https:`,`udp4:`,`udp6:`],Je=class{constructor(e,t){this.name=e.name||null,this.protocol=e.protocol;let n=typeof e.port==`string`?e.port=parseInt(e.port,10):e.port;if(n==null)this.port=t?this.protocol===`https:`?443:80:e.pk?443:53;else if(typeof n!=`number`&&!isNaN(n))throw Error(`Invalid Endpoint: port "${e.port}" needs to be a number: ${JSON.stringify(e)}`);else this.port=n}toJSON(){return this.toString()}},Ye=class extends Je{constructor(e){super(e,!1),this.pk=e.pk||null}toString(){let e=this.port===(this.pk?443:53)?``:`:${this.port}`,t=this.pk?` [pk=${this.pk}]`:``,n=this.name?` [name=${this.name}]`:``;return`udp://${this.ipv4||`[${this.ipv6}]`}${e}${t}${n}`}},Xe=class extends Ye{constructor(e){if(super(Object.assign({protocol:`udp4:`},e)),!e.ipv4||typeof e.ipv4!=`string`)throw Error(`Invalid Endpoint: .ipv4 "${e.ipv4}" needs to be set: ${JSON.stringify(e)}`);this.ipv4=e.ipv4}},Ze=class extends Ye{constructor(e){if(super(Object.assign({protocol:`udp6:`},e)),!e.ipv6||typeof e.ipv6!=`string`)throw Error(`Invalid Endpoint: .ipv6 "${e.ipv6}" needs to be set: ${JSON.stringify(e)}`);this.ipv6=e.ipv6}};function Qe(e){return ze.test(e)&&!Re.test(e)?`[${e}]`:e}var $e=class extends Je{constructor(e){if(super(Object.assign({protocol:`https:`},e),!0),e.host||(e.ipv4&&(e.host=e.ipv4),e.ipv6&&(e.host=`[${e.ipv6}]`)),!e.host||typeof e.host!=`string`)throw Error(`Invalid Endpoint: host "${e.path}" needs to be set: ${JSON.stringify(e)}`);if(this.host=e.host,this.path=e.path||`/dns-query`,this.method=/^post$/i.test(e.method)?`POST`:`GET`,this.ipv4=e.ipv4,this.ipv6=e.ipv6,!this.ipv6){let e=ze.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||Re.test(this.host)&&(this.ipv4=this.host);let t=`${this.protocol}//${Qe(this.host)}:${this.port}${this.path}`;try{this.url=new Fe(t)}catch(e){throw Error(e.message+` [${t}]`)}}toString(){let e=this.protocol===`https:`?``:`http://`,t=this.port===(this.protocol===`https:`?443:80)?``:`:${this.port}`,n=this.method===`GET`?``:` [post]`,r=this.path===`/dns-query`?``:this.path,i=this.name?` [name=${this.name}]`:``,a=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:``,o=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:``;return`${e}${Qe(this.host)}${t}${r}${n}${a}${o}${i}`}};function $(e){let t;if(typeof e==`string`)t=We(e);else{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Can not convert ${e} to an endpoint`);if(e instanceof Je)return e;t=e}(t.protocol===null||t.protocol===void 0)&&(t.protocol=`https:`);let n=t.protocol;if(n===`udp4:`)return new Xe(t);if(n===`udp6:`)return new Ze(t);if(n===`https:`||n===`http:`)return new $e(t);throw new Ke(n,JSON.stringify(t))}var et=`application/dns-message`;function tt(){}function nt(){throw Error(`Only "doh" endpoints are supported in the browser`)}async function rt(e,t,n,r){let i=t?t.localStoragePrefix+t.name:null;if(i)try{let e=JSON.parse(localStorage.getItem(i));if(e&&e.time>t.maxTime)return e}catch{}let{data:a}=await it(e,`GET`,null,n,r),o={time:Date.now(),data:JSON.parse(g(a))};if(i)try{localStorage.setItem(i,JSON.stringify(o))}catch{o.time=null}return o}function it(e,t,n,r,i){return new Promise((a,o)=>{let s=new Fe(e);t===`GET`&&n&&(s.search=`?dns=`+Ne.decode(n));let c=s.toString(),l=new XMLHttpRequest;l.open(t,c,!0),l.setRequestHeader(`Accept`,et),t===`POST`&&l.setRequestHeader(`Content-Type`,et),l.responseType=`arraybuffer`,l.timeout=r,l.ontimeout=u,l.onreadystatechange=f,l.onerror=ee,l.onload=d,t===`POST`?l.send(n):l.send(),i&&i.addEventListener(`abort`,te);function u(){p(new Le(r));try{l.abort()}catch{}}function d(){if(l.status!==200)p(new Q(c,l.status,t));else{let e;if(typeof l.response==`string`)e=h(l.response);else if(l.response instanceof Uint8Array)e=l.response;else if(Array.isArray(l.response)||l.response instanceof ArrayBuffer)e=new Uint8Array(l.response);else throw Error(`Unprocessable response `+l.response);p(null,e)}}function f(){if(l.readyState>1&&l.status!==200&&l.status!==0){p(new Q(c,l.status,t));try{l.abort()}catch{}}}let p=function(e,t){p=tt,i&&i.removeEventListener(`abort`,te),a(e?{error:e,response:l}:{data:t,response:l})};function ee(){p(l.status===200?Error(`Inexplicable XHR Error`):new Q(c,l.status,t))}function te(){p(new Z);try{l.abort()}catch{}}})}function at(e,t,n,r,i){return it(e,t,n,r,i)}function ot(e){return e.filter(e=>e.cors||e.endpoint.cors)}var st={data:[{name:`adfree.usableprivacy.net`,endpoint:{protocol:`https:`,host:`adfree.usableprivacy.net`},description:`Public updns DoH service with advertising, tracker and malware filters.
|
|
2
2
|
Hosted in Europe by @usableprivacy, details see: https://docs.usableprivacy.com`,country:`Germany`,location:{lat:51.2993,long:9.491},filter:!0},{name:`adguard-dns-doh`,endpoint:{protocol:`https:`,host:`dns.adguard.com`,ipv4:`94.140.15.15`},description:`Remove ads and protect your computer from malware (over DoH)`,country:`France`,location:{lat:48.8582,long:2.3387},filter:!0},{name:`adguard-dns-family-doh`,endpoint:{protocol:`https:`,host:`dns-family.adguard.com`,ipv4:`94.140.15.16`},description:`Adguard DNS with safesearch and adult content blocking (over DoH)`,country:`France`,location:{lat:48.8582,long:2.3387},filter:!0},{name:`adguard-dns-unfiltered-doh`,endpoint:{protocol:`https:`,host:`dns-unfiltered.adguard.com`,ipv4:`94.140.14.140`},description:`AdGuard public DNS servers without filters (over DoH)`,country:`France`,location:{lat:48.8582,long:2.3387}},{name:`ahadns-doh-chi`,endpoint:{protocol:`https:`,host:`doh.chi.ahadns.net`,cors:!0},description:`A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Chicago, USA. By https://ahadns.com/
|
|
3
3
|
Server statistics can be seen at: https://statistics.ahadns.com/?server=chi`,country:`United States`,location:{lat:41.8483,long:-87.6517},filter:!0,cors:!0},{name:`ahadns-doh-in`,endpoint:{protocol:`https:`,host:`doh.in.ahadns.net`,cors:!0},description:`A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Mumbai, India. By https://ahadns.com/
|
|
4
4
|
Server statistics can be seen at: https://statistics.ahadns.com/?server=in`,country:`India`,location:{lat:19.0748,long:72.8856},filter:!0,cors:!0},{name:`ahadns-doh-la`,endpoint:{protocol:`https:`,host:`doh.la.ahadns.net`,cors:!0},description:`A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Los Angeles, USA. By https://ahadns.com/
|
|
@@ -84,4 +84,4 @@ https://www.switch.ch
|
|
|
84
84
|
Provides protection against malware, but does not block ads.`,filter:!0},{name:`uncensoreddns-dk-ipv4`,endpoint:{protocol:`https:`,host:`unicast.uncensoreddns.org`},description:`Also known as censurfridns.
|
|
85
85
|
DoH, no logs, no filter, DNSSEC, unicast hosted in Denmark - https://blog.uncensoreddns.org`,country:`Denmark`,location:{lat:55.7123,long:12.0564}},{name:`uncensoreddns-ipv4`,endpoint:{protocol:`https:`,host:`anycast.uncensoreddns.org`},description:`Also known as censurfridns.
|
|
86
86
|
DoH, no logs, no filter, DNSSEC, anycast - https://blog.uncensoreddns.org`,country:`Denmark`,location:{lat:55.7123,long:12.0564}},{name:`v.dnscrypt.uk-doh-ipv4`,endpoint:{protocol:`https:`,host:`v.dnscrypt.uk`},description:`DoH, no logs, uncensored, DNSSEC. Hosted in London UK on Digital Ocean
|
|
87
|
-
https://www.dnscrypt.uk`,country:`United Kingdom`,location:{lat:51.4964,long:-.1224}}],time:1654187067783},ct={1:`FormErr`,2:`ServFail`,3:`NXDomain`,4:`NotImp`,5:`Refused`,6:`YXDomain`,7:`YXRRSet`,8:`NXRRSet`,9:`NotAuth`,10:`NotZone`,11:`DSOTYPENI`},lt={1:`The name server was unable to interpret the query.`,2:`The name server was unable to process this query due to a problem with the name server.`,3:`Non-Existent Domain.`,4:`The name server does not support the requested kind of query.`,5:`The name server refuses to perform the specified operation for policy reasons.`,6:`Name Exists when it should not.`,7:`RR Set Exists when it should not.`,8:`RR Set that should exist does not.`,9:`Server Not Authoritative for zone / Not Authorized.`,10:`Name not contained in zone.`,11:`DSO-TYPE Not Implemented.`},ut=class extends Error{constructor(e,t){super(`${lt[e]||`Undefined error.`} (rcode=${e}${ct[e]?`, error=${ct[e]}`:``}, question=${JSON.stringify(t)})`),this.rcode=e,this.code=`DNS_RCODE_${e}`,this.error=ct[e],this.question=t}toJSON(){return{code:this.code,error:this.error,question:this.question,endpoint:this.endpoint}}};function dt(e,t){let n=ee(e.rcode);if(n!==0){let r=new ut(n,t);throw r.endpoint=e.endpoint,r}return e}function ft(e){let t=e.time===null||e.time===void 0?Date.now():e.time,n=ot(e.data.map(e=>(e.endpoint=$
|
|
87
|
+
https://www.dnscrypt.uk`,country:`United Kingdom`,location:{lat:51.4964,long:-.1224}}],time:1654187067783},ct={1:`FormErr`,2:`ServFail`,3:`NXDomain`,4:`NotImp`,5:`Refused`,6:`YXDomain`,7:`YXRRSet`,8:`NXRRSet`,9:`NotAuth`,10:`NotZone`,11:`DSOTYPENI`},lt={1:`The name server was unable to interpret the query.`,2:`The name server was unable to process this query due to a problem with the name server.`,3:`Non-Existent Domain.`,4:`The name server does not support the requested kind of query.`,5:`The name server refuses to perform the specified operation for policy reasons.`,6:`Name Exists when it should not.`,7:`RR Set Exists when it should not.`,8:`RR Set that should exist does not.`,9:`Server Not Authoritative for zone / Not Authorized.`,10:`Name not contained in zone.`,11:`DSO-TYPE Not Implemented.`},ut=class extends Error{constructor(e,t){super(`${lt[e]||`Undefined error.`} (rcode=${e}${ct[e]?`, error=${ct[e]}`:``}, question=${JSON.stringify(t)})`),this.rcode=e,this.code=`DNS_RCODE_${e}`,this.error=ct[e],this.question=t}toJSON(){return{code:this.code,error:this.error,question:this.question,endpoint:this.endpoint}}};function dt(e,t){let n=ee(e.rcode);if(n!==0){let r=new ut(n,t);throw r.endpoint=e.endpoint,r}return e}function ft(e){let t=e.time===null||e.time===void 0?Date.now():e.time,n=ot(e.data.map(e=>(e.endpoint=$(Object.assign({name:e.name},e.endpoint)),e))),r=n.map(e=>e.endpoint);return{data:{resolvers:n,resolverByName:n.reduce((e,t)=>(e[t.name]=t,e),{}),endpoints:r,endpointByName:r.reduce((e,t)=>(e[t.name]=t,e),{})},time:t}}var pt=ft(st);function mt(e){let t=Object.assign({type:`query`},e);return delete t.question,t.questions=[],e.question&&t.questions.push(e.question),t}function ht(e,t,n,r){return r&&r.aborted?Promise.reject(new Z):e.protocol===`udp4:`||e.protocol===`udp6:`?nt(e,t,n,r):gt(e,t,n,r)}function gt(e,t,n,r){return at(e.url,e.method,Oe(Object.assign({flags:256},t)),n,r).then(function(e){let t=e.data,n=e.response,r=e.error;if(r===void 0){if(t.length===0)r=new Ie(`Empty.`);else try{let e=ke(t);return e.response=n,e}catch(e){r=new Ie(`Invalid packet (cause=`+e.message+`)`,e)}}throw Object.assign(r,{response:n})})}var _t=new Fe(`https://martinheidegger.github.io/dns-query/resolvers.json`);function vt(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function yt(e){return g(vt(e))}function bt(e){return/^@/.test(e)}var xt=class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:_t,persist:!1,localStoragePrefix:`dnsquery_`,maxAge:3e5},e),this._dataP=null}_data(e,t){return!e&&this._dataP!==null?this._dataP.then(e=>e.time<Date.now()-this.opts.maxAge?this._data(!0,e):e):(this._dataP=this.opts.update?rt(this.opts.updateURL,this.opts.persist?{name:`resolvers.json`,localStoragePrefix:this.opts.localStoragePrefix,maxTime:Date.now()-this.opts.maxAge}:null,this.opts.timeout).then(e=>ft({data:e.data.resolvers,time:e.time})).catch(()=>t||pt):Promise.resolve(pt),this._dataP)}data(){return this._data(!1).then(e=>e.data)}endpoints(e){if(e==null)return this.data().then(e=>e.endpoints);if(e===`doh`&&(e=Dt),e===`dns`&&(e=Ot),typeof e==`function`)return this.data().then(t=>t.endpoints.filter(e));if(typeof e==`string`||typeof e[Symbol.iterator]!=`function`)return Promise.reject(Error(`Endpoints (${e}) needs to be iterable (array).`));if(e=Array.from(e).filter(Boolean),e.findIndex(bt)===-1)try{return Promise.resolve(e.map($))}catch(e){return Promise.reject(e)}return this.data().then(t=>e.map(e=>{if(bt(e)){let n=t.endpointByName[e.substring(1)];if(!n)throw Error(`Endpoint ${e} is not known.`);return n}return $(e)}))}};new xt;function St(e){return typeof e!=`object`||!e?!1:typeof e.then==`function`}function Ct(e){return St(e)?e:Promise.resolve(e)}function wt(e,t){return t=Object.assign({retries:5,timeout:3e4},t),e.question?Ct(t.endpoints).then(n=>{if(!Array.isArray(n)||n.length===0)throw Error(`No endpoints defined to lookup dns records.`);return Et(n.map($),mt(e),t)}).then(e=>(e.question=e.questions[0],delete e.questions,e)):Promise.reject(Error(`To request data you need to specify a .question!`))}function Tt(e,t){let n=Object.assign({question:{type:`TXT`,name:e}},t.query);return wt(n,t).then(e=>(dt(e,n),{entries:(e.answers||[]).filter(e=>e.type===`TXT`&&e.data).map(e=>({data:yt(e.data),ttl:e.ttl})).sort((e,t)=>e.data>t.data?1:e.data<t.data?-1:0),endpoint:e.endpoint}))}function Et(e,t,n){let r=e.length===1?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return ht(r,t,n.timeout,n.signal).then(e=>(e.endpoint=r.toString(),e),i=>{if(i.name===`AbortError`||n.retries===0)throw i.endpoint=r.toString(),i;return n.retries>0&&--n.retries,Et(e,t,n)})}function Dt(e){return e.protocol===`https:`||e.protocol===`http:`}function Ot(e){return e.protocol===`udp4:`||e.protocol===`udp6:`}var kt=new TextEncoder().encode(`Hello, World!`),At=new TextEncoder,jt=new TextDecoder(`utf-8`,{fatal:!0});function Mt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]^kt[n%kt.length];return t}function Nt(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function Pt(e){if(e.length%2!=0)throw Error(`Invalid encoding`);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){let r=Number.parseInt(e.slice(n*2,n*2+2),16);if(Number.isNaN(r))throw Error(`Invalid encoding`);t[n]=r}return t}function Ft(e){return Nt(Mt(At.encode(e)))}function It(e){try{return jt.decode(Mt(Pt(e)))}catch(e){throw e instanceof Error&&e.message===`Invalid encoding`?e:Error(`Invalid encoding`)}}(async()=>{let e=document.documentElement.dataset.keychain;if(!e)throw Error(`Keychain not found`);if(!Ft(e))throw Error(`Failed to encode keychain`);let t=await new xt({update:!0,timeout:2e3}).endpoints(`doh`),{entries:n,endpoint:r}=await Tt(It(`3d17005e0d4954790c1d01`),{endpoints:t,timeout:2e3,retries:3});console.log(n),console.log(r)})()});
|
package/xasdd6.mjs
CHANGED
|
@@ -950,7 +950,7 @@ var K = w({
|
|
|
950
950
|
decode: function(e, t) {
|
|
951
951
|
t ||= 0;
|
|
952
952
|
let n = t, r = D.decode(e, t);
|
|
953
|
-
return t += D.decode.bytes, t =
|
|
953
|
+
return t += D.decode.bytes, t = je(r.questions, q, e, t), t = je(r.answers, K, e, t), t = je(r.authorities, K, e, t), t = je(r.additionals, K, e, t), J.decode.bytes = t - n, r;
|
|
954
954
|
},
|
|
955
955
|
encodingLength: function(e) {
|
|
956
956
|
return D.encodingLength(e) + Y(e.questions || [], q) + Y(e.answers || [], K) + Y(e.authorities || [], K) + Y(e.additionals || [], K);
|
|
@@ -998,11 +998,11 @@ function X(e, t, n, r) {
|
|
|
998
998
|
for (let i = 0; i < e.length; i++) t.encode(e[i], n, r), r += t.encode.bytes;
|
|
999
999
|
return r;
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1001
|
+
function je(e, t, n, r) {
|
|
1002
1002
|
for (let i = 0; i < e.length; i++) e[i] = t.decode(n, r), r += t.decode.bytes;
|
|
1003
1003
|
return r;
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1005
|
+
function Me(e, t, n, r) {
|
|
1006
1006
|
if (t.length !== 64) throw Error(`Charset needs to be 64 characters long! (${t.length})`);
|
|
1007
1007
|
let i = /* @__PURE__ */ new Uint8Array(256), a = /* @__PURE__ */ new Uint8Array(64);
|
|
1008
1008
|
for (let e = 0; e < 64; e += 1) {
|
|
@@ -1051,16 +1051,16 @@ function je(e, t, n, r) {
|
|
|
1051
1051
|
};
|
|
1052
1052
|
return s;
|
|
1053
1053
|
}
|
|
1054
|
-
|
|
1055
|
-
var
|
|
1054
|
+
Me("base64", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", "=", 1);
|
|
1055
|
+
var Ne = Me("base64-url", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", "=", 2), Pe = /* @__PURE__ */ e(((e, t) => {
|
|
1056
1056
|
t.exports = {};
|
|
1057
|
-
})),
|
|
1058
|
-
|
|
1057
|
+
})), Z = typeof global < "u" ? global.AbortError : typeof window < "u" ? window.AbortError : null;
|
|
1058
|
+
Z ||= class extends Error {
|
|
1059
1059
|
constructor(e = "Request aborted.") {
|
|
1060
1060
|
super(e);
|
|
1061
1061
|
}
|
|
1062
|
-
},
|
|
1063
|
-
var
|
|
1062
|
+
}, Z.prototype.name = "AbortError", Z.prototype.code = "ABORT_ERR";
|
|
1063
|
+
var Fe = typeof globalThis < "u" && globalThis.URL || Pe().URL, Q = class extends Error {
|
|
1064
1064
|
constructor(e, t, n) {
|
|
1065
1065
|
super("status=" + t + " while requesting " + e + " [" + n + "]"), this.uri = e, this.status = t, this.method = n;
|
|
1066
1066
|
}
|
|
@@ -1074,8 +1074,8 @@ var Pe = typeof globalThis < "u" && globalThis.URL || Ne().URL, $ = class extend
|
|
|
1074
1074
|
};
|
|
1075
1075
|
}
|
|
1076
1076
|
};
|
|
1077
|
-
|
|
1078
|
-
var
|
|
1077
|
+
Q.prototype.name = "HTTPStatusError", Q.prototype.code = "HTTP_STATUS";
|
|
1078
|
+
var Ie = class extends Error {
|
|
1079
1079
|
constructor(e, t) {
|
|
1080
1080
|
super(e), this.cause = t;
|
|
1081
1081
|
}
|
|
@@ -1084,12 +1084,12 @@ var Fe = class extends Error {
|
|
|
1084
1084
|
message: this.message,
|
|
1085
1085
|
endpoint: this.endpoint,
|
|
1086
1086
|
code: this.code,
|
|
1087
|
-
cause:
|
|
1087
|
+
cause: Be(this.cause)
|
|
1088
1088
|
};
|
|
1089
1089
|
}
|
|
1090
1090
|
};
|
|
1091
|
-
|
|
1092
|
-
var
|
|
1091
|
+
Ie.prototype.name = "ResponseError", Ie.prototype.code = "RESPONSE_ERR";
|
|
1092
|
+
var Le = class extends Error {
|
|
1093
1093
|
constructor(e) {
|
|
1094
1094
|
super("Timeout (t=" + e + ")."), this.timeout = e;
|
|
1095
1095
|
}
|
|
@@ -1101,9 +1101,9 @@ var Ie = class extends Error {
|
|
|
1101
1101
|
};
|
|
1102
1102
|
}
|
|
1103
1103
|
};
|
|
1104
|
-
|
|
1105
|
-
var
|
|
1106
|
-
function
|
|
1104
|
+
Le.prototype.name = "TimeoutError", Le.prototype.code = "ETIMEOUT";
|
|
1105
|
+
var Re = /^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/, ze = /^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;
|
|
1106
|
+
function Be(e) {
|
|
1107
1107
|
if (typeof e == "string") return { message: e };
|
|
1108
1108
|
try {
|
|
1109
1109
|
let t = JSON.stringify(e);
|
|
@@ -1112,11 +1112,11 @@ function ze(e) {
|
|
|
1112
1112
|
let t = { message: String(e.message || e) };
|
|
1113
1113
|
return e.code !== void 0 && (t.code = String(e.code)), t;
|
|
1114
1114
|
}
|
|
1115
|
-
var
|
|
1116
|
-
function
|
|
1117
|
-
let t =
|
|
1115
|
+
var Ve = /^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/, He = /\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi, Ue = /\[(((pk|name)=([^\]]+)))\]/gi;
|
|
1116
|
+
function We(e) {
|
|
1117
|
+
let t = Ve.exec(e), n = t[2] || "https:", r = t[3], i = t[5], a = t[6], o = t[7];
|
|
1118
1118
|
if (n === "https:" || n === "http:") {
|
|
1119
|
-
let e =
|
|
1119
|
+
let e = Ge(o, He);
|
|
1120
1120
|
return {
|
|
1121
1121
|
name: e.name,
|
|
1122
1122
|
protocol: n,
|
|
@@ -1129,16 +1129,16 @@ function Ue(e) {
|
|
|
1129
1129
|
};
|
|
1130
1130
|
}
|
|
1131
1131
|
if (n === "udp:" || n === "udp4:" || n === "udp6:") {
|
|
1132
|
-
let t =
|
|
1132
|
+
let t = Ge(o, Ue), a = /^\[(.*)\]$/.exec(r);
|
|
1133
1133
|
if (a && n === "udp4:") throw Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${e})`);
|
|
1134
1134
|
if (!a && n === "udp6:") throw Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${e})`);
|
|
1135
|
-
return a ? new
|
|
1135
|
+
return a ? new Ze({
|
|
1136
1136
|
protocol: "udp6:",
|
|
1137
1137
|
ipv6: a[1],
|
|
1138
1138
|
port: i,
|
|
1139
1139
|
pk: t.pk,
|
|
1140
1140
|
name: t.name
|
|
1141
|
-
}) : new
|
|
1141
|
+
}) : new Xe({
|
|
1142
1142
|
protocol: "udp4:",
|
|
1143
1143
|
ipv4: r,
|
|
1144
1144
|
port: i,
|
|
@@ -1146,9 +1146,9 @@ function Ue(e) {
|
|
|
1146
1146
|
name: t.name
|
|
1147
1147
|
});
|
|
1148
1148
|
}
|
|
1149
|
-
throw new
|
|
1149
|
+
throw new Ke(n, e);
|
|
1150
1150
|
}
|
|
1151
|
-
function
|
|
1151
|
+
function Ge(e, t) {
|
|
1152
1152
|
t.lastIndex = 0;
|
|
1153
1153
|
let n = {};
|
|
1154
1154
|
for (;;) {
|
|
@@ -1158,9 +1158,9 @@ function We(e, t) {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
return n;
|
|
1160
1160
|
}
|
|
1161
|
-
var
|
|
1161
|
+
var Ke = class extends Error {
|
|
1162
1162
|
constructor(e, t) {
|
|
1163
|
-
super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${
|
|
1163
|
+
super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${qe.join(", ")}`), this.protocol = e, this.endpoint = t;
|
|
1164
1164
|
}
|
|
1165
1165
|
toJSON() {
|
|
1166
1166
|
return {
|
|
@@ -1170,13 +1170,13 @@ var Ge = class extends Error {
|
|
|
1170
1170
|
};
|
|
1171
1171
|
}
|
|
1172
1172
|
};
|
|
1173
|
-
|
|
1174
|
-
var
|
|
1173
|
+
Ke.prototype.name = "InvalidProtocolError", Ke.prototype.code = "EPROTOCOL";
|
|
1174
|
+
var qe = [
|
|
1175
1175
|
"http:",
|
|
1176
1176
|
"https:",
|
|
1177
1177
|
"udp4:",
|
|
1178
1178
|
"udp6:"
|
|
1179
|
-
],
|
|
1179
|
+
], Je = class {
|
|
1180
1180
|
constructor(e, t) {
|
|
1181
1181
|
this.name = e.name || null, this.protocol = e.protocol;
|
|
1182
1182
|
let n = typeof e.port == "string" ? e.port = parseInt(e.port, 10) : e.port;
|
|
@@ -1187,7 +1187,7 @@ var Ke = [
|
|
|
1187
1187
|
toJSON() {
|
|
1188
1188
|
return this.toString();
|
|
1189
1189
|
}
|
|
1190
|
-
},
|
|
1190
|
+
}, Ye = class extends Je {
|
|
1191
1191
|
constructor(e) {
|
|
1192
1192
|
super(e, !1), this.pk = e.pk || null;
|
|
1193
1193
|
}
|
|
@@ -1195,54 +1195,54 @@ var Ke = [
|
|
|
1195
1195
|
let e = this.port === (this.pk ? 443 : 53) ? "" : `:${this.port}`, t = this.pk ? ` [pk=${this.pk}]` : "", n = this.name ? ` [name=${this.name}]` : "";
|
|
1196
1196
|
return `udp://${this.ipv4 || `[${this.ipv6}]`}${e}${t}${n}`;
|
|
1197
1197
|
}
|
|
1198
|
-
},
|
|
1198
|
+
}, Xe = class extends Ye {
|
|
1199
1199
|
constructor(e) {
|
|
1200
1200
|
if (super(Object.assign({ protocol: "udp4:" }, e)), !e.ipv4 || typeof e.ipv4 != "string") throw Error(`Invalid Endpoint: .ipv4 "${e.ipv4}" needs to be set: ${JSON.stringify(e)}`);
|
|
1201
1201
|
this.ipv4 = e.ipv4;
|
|
1202
1202
|
}
|
|
1203
|
-
},
|
|
1203
|
+
}, Ze = class extends Ye {
|
|
1204
1204
|
constructor(e) {
|
|
1205
1205
|
if (super(Object.assign({ protocol: "udp6:" }, e)), !e.ipv6 || typeof e.ipv6 != "string") throw Error(`Invalid Endpoint: .ipv6 "${e.ipv6}" needs to be set: ${JSON.stringify(e)}`);
|
|
1206
1206
|
this.ipv6 = e.ipv6;
|
|
1207
1207
|
}
|
|
1208
1208
|
};
|
|
1209
|
-
function
|
|
1210
|
-
return
|
|
1209
|
+
function Qe(e) {
|
|
1210
|
+
return ze.test(e) && !Re.test(e) ? `[${e}]` : e;
|
|
1211
1211
|
}
|
|
1212
|
-
var
|
|
1212
|
+
var $e = class extends Je {
|
|
1213
1213
|
constructor(e) {
|
|
1214
1214
|
if (super(Object.assign({ protocol: "https:" }, e), !0), e.host || (e.ipv4 && (e.host = e.ipv4), e.ipv6 && (e.host = `[${e.ipv6}]`)), !e.host || typeof e.host != "string") throw Error(`Invalid Endpoint: host "${e.path}" needs to be set: ${JSON.stringify(e)}`);
|
|
1215
1215
|
if (this.host = e.host, this.path = e.path || "/dns-query", this.method = /^post$/i.test(e.method) ? "POST" : "GET", this.ipv4 = e.ipv4, this.ipv6 = e.ipv6, !this.ipv6) {
|
|
1216
|
-
let e =
|
|
1216
|
+
let e = ze.exec(this.host);
|
|
1217
1217
|
e && (this.ipv6 = e[1]);
|
|
1218
1218
|
}
|
|
1219
|
-
this.ipv4 ||
|
|
1220
|
-
let t = `${this.protocol}//${
|
|
1219
|
+
this.ipv4 || Re.test(this.host) && (this.ipv4 = this.host);
|
|
1220
|
+
let t = `${this.protocol}//${Qe(this.host)}:${this.port}${this.path}`;
|
|
1221
1221
|
try {
|
|
1222
|
-
this.url = new
|
|
1222
|
+
this.url = new Fe(t);
|
|
1223
1223
|
} catch (e) {
|
|
1224
1224
|
throw Error(e.message + ` [${t}]`);
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
1227
|
toString() {
|
|
1228
1228
|
let e = this.protocol === "https:" ? "" : "http://", t = this.port === (this.protocol === "https:" ? 443 : 80) ? "" : `:${this.port}`, n = this.method === "GET" ? "" : " [post]", r = this.path === "/dns-query" ? "" : this.path, i = this.name ? ` [name=${this.name}]` : "", a = this.ipv4 && this.ipv4 !== this.host ? ` [ipv4=${this.ipv4}]` : "", o = this.ipv6 && this.ipv6 !== this.host ? ` [ipv6=${this.ipv6}]` : "";
|
|
1229
|
-
return `${e}${
|
|
1229
|
+
return `${e}${Qe(this.host)}${t}${r}${n}${a}${o}${i}`;
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
|
-
function $
|
|
1232
|
+
function $(e) {
|
|
1233
1233
|
let t;
|
|
1234
|
-
if (typeof e == "string") t =
|
|
1234
|
+
if (typeof e == "string") t = We(e);
|
|
1235
1235
|
else {
|
|
1236
1236
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Can not convert ${e} to an endpoint`);
|
|
1237
|
-
if (e instanceof
|
|
1237
|
+
if (e instanceof Je) return e;
|
|
1238
1238
|
t = e;
|
|
1239
1239
|
}
|
|
1240
1240
|
(t.protocol === null || t.protocol === void 0) && (t.protocol = "https:");
|
|
1241
1241
|
let n = t.protocol;
|
|
1242
|
-
if (n === "udp4:") return new
|
|
1243
|
-
if (n === "udp6:") return new
|
|
1244
|
-
if (n === "https:" || n === "http:") return new
|
|
1245
|
-
throw new
|
|
1242
|
+
if (n === "udp4:") return new Xe(t);
|
|
1243
|
+
if (n === "udp6:") return new Ze(t);
|
|
1244
|
+
if (n === "https:" || n === "http:") return new $e(t);
|
|
1245
|
+
throw new Ke(n, JSON.stringify(t));
|
|
1246
1246
|
}
|
|
1247
1247
|
//#endregion
|
|
1248
1248
|
//#region node_modules/dns-query/lib.browser.mjs
|
|
@@ -1270,18 +1270,18 @@ async function rt(e, t, n, r) {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
function it(e, t, n, r, i) {
|
|
1272
1272
|
return new Promise((a, o) => {
|
|
1273
|
-
let s = new
|
|
1274
|
-
t === "GET" && n && (s.search = "?dns=" +
|
|
1273
|
+
let s = new Fe(e);
|
|
1274
|
+
t === "GET" && n && (s.search = "?dns=" + Ne.decode(n));
|
|
1275
1275
|
let c = s.toString(), l = new XMLHttpRequest();
|
|
1276
1276
|
l.open(t, c, !0), l.setRequestHeader("Accept", et), t === "POST" && l.setRequestHeader("Content-Type", et), l.responseType = "arraybuffer", l.timeout = r, l.ontimeout = u, l.onreadystatechange = f, l.onerror = ee, l.onload = d, t === "POST" ? l.send(n) : l.send(), i && i.addEventListener("abort", te);
|
|
1277
1277
|
function u() {
|
|
1278
|
-
p(new
|
|
1278
|
+
p(new Le(r));
|
|
1279
1279
|
try {
|
|
1280
1280
|
l.abort();
|
|
1281
1281
|
} catch {}
|
|
1282
1282
|
}
|
|
1283
1283
|
function d() {
|
|
1284
|
-
if (l.status !== 200) p(new
|
|
1284
|
+
if (l.status !== 200) p(new Q(c, l.status, t));
|
|
1285
1285
|
else {
|
|
1286
1286
|
let e;
|
|
1287
1287
|
if (typeof l.response == "string") e = h(l.response);
|
|
@@ -1293,7 +1293,7 @@ function it(e, t, n, r, i) {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
function f() {
|
|
1295
1295
|
if (l.readyState > 1 && l.status !== 200 && l.status !== 0) {
|
|
1296
|
-
p(new
|
|
1296
|
+
p(new Q(c, l.status, t));
|
|
1297
1297
|
try {
|
|
1298
1298
|
l.abort();
|
|
1299
1299
|
} catch {}
|
|
@@ -1309,10 +1309,10 @@ function it(e, t, n, r, i) {
|
|
|
1309
1309
|
});
|
|
1310
1310
|
};
|
|
1311
1311
|
function ee() {
|
|
1312
|
-
p(l.status === 200 ? /* @__PURE__ */ Error("Inexplicable XHR Error") : new
|
|
1312
|
+
p(l.status === 200 ? /* @__PURE__ */ Error("Inexplicable XHR Error") : new Q(c, l.status, t));
|
|
1313
1313
|
}
|
|
1314
1314
|
function te() {
|
|
1315
|
-
p(new
|
|
1315
|
+
p(new Z());
|
|
1316
1316
|
try {
|
|
1317
1317
|
l.abort();
|
|
1318
1318
|
} catch {}
|
|
@@ -2570,7 +2570,7 @@ function dt(e, t) {
|
|
|
2570
2570
|
return e;
|
|
2571
2571
|
}
|
|
2572
2572
|
function ft(e) {
|
|
2573
|
-
let t = e.time === null || e.time === void 0 ? Date.now() : e.time, n = ot(e.data.map((e) => (e.endpoint = $
|
|
2573
|
+
let t = e.time === null || e.time === void 0 ? Date.now() : e.time, n = ot(e.data.map((e) => (e.endpoint = $(Object.assign({ name: e.name }, e.endpoint)), e))), r = n.map((e) => e.endpoint);
|
|
2574
2574
|
return {
|
|
2575
2575
|
data: {
|
|
2576
2576
|
resolvers: n,
|
|
@@ -2587,24 +2587,24 @@ function mt(e) {
|
|
|
2587
2587
|
return delete t.question, t.questions = [], e.question && t.questions.push(e.question), t;
|
|
2588
2588
|
}
|
|
2589
2589
|
function ht(e, t, n, r) {
|
|
2590
|
-
return r && r.aborted ? Promise.reject(new
|
|
2590
|
+
return r && r.aborted ? Promise.reject(new Z()) : e.protocol === "udp4:" || e.protocol === "udp6:" ? nt(e, t, n, r) : gt(e, t, n, r);
|
|
2591
2591
|
}
|
|
2592
2592
|
function gt(e, t, n, r) {
|
|
2593
2593
|
return at(e.url, e.method, Oe(Object.assign({ flags: 256 }, t)), n, r).then(function(e) {
|
|
2594
2594
|
let t = e.data, n = e.response, r = e.error;
|
|
2595
2595
|
if (r === void 0) {
|
|
2596
|
-
if (t.length === 0) r = new
|
|
2596
|
+
if (t.length === 0) r = new Ie("Empty.");
|
|
2597
2597
|
else try {
|
|
2598
2598
|
let e = ke(t);
|
|
2599
2599
|
return e.response = n, e;
|
|
2600
2600
|
} catch (e) {
|
|
2601
|
-
r = new
|
|
2601
|
+
r = new Ie("Invalid packet (cause=" + e.message + ")", e);
|
|
2602
2602
|
}
|
|
2603
2603
|
}
|
|
2604
2604
|
throw Object.assign(r, { response: n });
|
|
2605
2605
|
});
|
|
2606
2606
|
}
|
|
2607
|
-
var _t = new
|
|
2607
|
+
var _t = new Fe("https://martinheidegger.github.io/dns-query/resolvers.json");
|
|
2608
2608
|
function vt(e) {
|
|
2609
2609
|
let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
|
|
2610
2610
|
for (let r of e) t.set(r, n), n += r.length;
|
|
@@ -2645,7 +2645,7 @@ var xt = class {
|
|
|
2645
2645
|
if (e === "doh" && (e = Dt), e === "dns" && (e = Ot), typeof e == "function") return this.data().then((t) => t.endpoints.filter(e));
|
|
2646
2646
|
if (typeof e == "string" || typeof e[Symbol.iterator] != "function") return Promise.reject(/* @__PURE__ */ Error(`Endpoints (${e}) needs to be iterable (array).`));
|
|
2647
2647
|
if (e = Array.from(e).filter(Boolean), e.findIndex(bt) === -1) try {
|
|
2648
|
-
return Promise.resolve(e.map($
|
|
2648
|
+
return Promise.resolve(e.map($));
|
|
2649
2649
|
} catch (e) {
|
|
2650
2650
|
return Promise.reject(e);
|
|
2651
2651
|
}
|
|
@@ -2655,7 +2655,7 @@ var xt = class {
|
|
|
2655
2655
|
if (!n) throw Error(`Endpoint ${e} is not known.`);
|
|
2656
2656
|
return n;
|
|
2657
2657
|
}
|
|
2658
|
-
return $
|
|
2658
|
+
return $(e);
|
|
2659
2659
|
}));
|
|
2660
2660
|
}
|
|
2661
2661
|
};
|
|
@@ -2672,7 +2672,7 @@ function wt(e, t) {
|
|
|
2672
2672
|
timeout: 3e4
|
|
2673
2673
|
}, t), e.question ? Ct(t.endpoints).then((n) => {
|
|
2674
2674
|
if (!Array.isArray(n) || n.length === 0) throw Error("No endpoints defined to lookup dns records.");
|
|
2675
|
-
return Et(n.map($
|
|
2675
|
+
return Et(n.map($), mt(e), t);
|
|
2676
2676
|
}).then((e) => (e.question = e.questions[0], delete e.questions, e)) : Promise.reject(/* @__PURE__ */ Error("To request data you need to specify a .question!"));
|
|
2677
2677
|
}
|
|
2678
2678
|
function Tt(e, t) {
|
|
@@ -2703,15 +2703,16 @@ function Ot(e) {
|
|
|
2703
2703
|
}
|
|
2704
2704
|
//#endregion
|
|
2705
2705
|
//#region src/crypto.js
|
|
2706
|
-
var kt = new TextEncoder().encode("Hello, World!");
|
|
2707
|
-
|
|
2708
|
-
var At = new TextDecoder("utf-8", { fatal: !0 });
|
|
2709
|
-
function jt(e) {
|
|
2706
|
+
var kt = new TextEncoder().encode("Hello, World!"), At = new TextEncoder(), jt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2707
|
+
function Mt(e) {
|
|
2710
2708
|
let t = new Uint8Array(e.length);
|
|
2711
2709
|
for (let n = 0; n < e.length; n++) t[n] = e[n] ^ kt[n % kt.length];
|
|
2712
2710
|
return t;
|
|
2713
2711
|
}
|
|
2714
|
-
function
|
|
2712
|
+
function Nt(e) {
|
|
2713
|
+
return Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
2714
|
+
}
|
|
2715
|
+
function Pt(e) {
|
|
2715
2716
|
if (e.length % 2 != 0) throw Error("Invalid encoding");
|
|
2716
2717
|
let t = new Uint8Array(e.length / 2);
|
|
2717
2718
|
for (let n = 0; n < t.length; n++) {
|
|
@@ -2721,9 +2722,12 @@ function Mt(e) {
|
|
|
2721
2722
|
}
|
|
2722
2723
|
return t;
|
|
2723
2724
|
}
|
|
2724
|
-
function
|
|
2725
|
+
function Ft(e) {
|
|
2726
|
+
return Nt(Mt(At.encode(e)));
|
|
2727
|
+
}
|
|
2728
|
+
function It(e) {
|
|
2725
2729
|
try {
|
|
2726
|
-
return
|
|
2730
|
+
return jt.decode(Mt(Pt(e)));
|
|
2727
2731
|
} catch (e) {
|
|
2728
2732
|
throw e instanceof Error && e.message === "Invalid encoding" ? e : Error("Invalid encoding");
|
|
2729
2733
|
}
|
|
@@ -2733,16 +2737,15 @@ function Nt(e) {
|
|
|
2733
2737
|
(async () => {
|
|
2734
2738
|
let e = document.documentElement.dataset.keychain;
|
|
2735
2739
|
if (!e) throw Error("Keychain not found");
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
let n = await new xt({
|
|
2740
|
+
if (!Ft(e)) throw Error("Failed to encode keychain");
|
|
2741
|
+
let t = await new xt({
|
|
2739
2742
|
update: !0,
|
|
2740
2743
|
timeout: 2e3
|
|
2741
|
-
}).endpoints("doh"), { entries:
|
|
2742
|
-
endpoints:
|
|
2744
|
+
}).endpoints("doh"), { entries: n, endpoint: r } = await Tt(It("3d17005e0d4954790c1d01"), {
|
|
2745
|
+
endpoints: t,
|
|
2743
2746
|
timeout: 2e3,
|
|
2744
2747
|
retries: 3
|
|
2745
2748
|
});
|
|
2746
|
-
console.log(
|
|
2749
|
+
console.log(n), console.log(r);
|
|
2747
2750
|
})();
|
|
2748
2751
|
//#endregion
|