xasdd6 1.0.6 → 1.0.7

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/xasdd6.js +2 -2
  3. package/xasdd6.mjs +344 -203
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xasdd6",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "commonjs",
5
5
  "description": "DNS Query and Spoofing Tool",
6
6
  "main": "./xasdd6.js",
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){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 te(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 ne(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 re(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 ie(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 ae=55296,m=56320;function oe(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)!==ae)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(oe(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)!==ae)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=ae|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`?oe(e):e.byteLength}function se(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):h(e)}function ce(e,t,n){if(typeof t!=`string`)throw Error(`unknown input type`);return h(t,e,n),h.bytes}var le=2**24,ue=2**16,de=256,y=(e,t)=>e[t]*le+e[t+1]*ue+e[t+2]*de+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:fe(e,t,n,r,i)}function fe(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 pe=0,me=32768,he=32768,ge=-32769,_e=32768,ve=-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=ce(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=ce(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`?me:pe;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&me?`response`:`query`,flags:n&32767,flag_qr:(n>>15&1)==1,opcode:ee(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}}),ye=w({encode(e,t,n){t||=new Uint8Array(ye.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),ye.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,ye.decode.bytes=t-n,r},encodingLength(e){return 22+T.encodingLength(e.mname)+T.encodingLength(e.rname)}}),be=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]=se(e[t])),!_(e[t]))throw Error(`Must be a Buffer`);t||=new Uint8Array(be.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),be.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 be.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}}),A=w({encode(e,t,n){t||=new Uint8Array(A.encodingLength(e)),n||=0,typeof e==`string`&&(e=se(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),A.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,A.decode.bytes=t-n,i},encodingLength(e){return e?(_(e)?e.length:v(e))+2:2}}),j=w({encode(e,t,n){t||=new Uint8Array(j.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),j.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,j.decode.bytes=t-n,r},encodingLength(e){return E.encodingLength(e.cpu)+E.encodingLength(e.os)+2}}),M=w({encode(e,t,n){return t||=new Uint8Array(M.encodingLength(e)),n||=0,T.encode(e,t,n+2),S(t,T.encode.bytes,n),M.encode.bytes=T.encode.bytes+2,t},decode(e,t){t||=0;let n=T.decode(e,t+2);return M.decode.bytes=T.decode.bytes+2,n},encodingLength(e){return T.encodingLength(e)+2}}),N=w({encode(e,t,n){t||=new Uint8Array(N.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),N.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),N.decode.bytes=n+2,r},encodingLength(e){return 8+T.encodingLength(e.target)}}),P=w({encode(e,t,n){let r=P.encodingLength(e);return t||=new Uint8Array(P.encodingLength(e)),n||=0,e.issuerCritical&&(e.flags=P.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,ce(t,e.value,n),n+=v(e.value),P.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&P.ISSUER_CRITICAL),P.decode.bytes=n+2,i},encodingLength(e){return E.encodingLength(e.tag)+E.encodingLength(e.value)+2}});P.ISSUER_CRITICAL=128;var F=w({encode(e,t,n){t||=new Uint8Array(F.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),F.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,F.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}),I=w({encode(e,t,n){return t||=new Uint8Array(I.encodingLength(e)),n||=0,S(t,16,n),n+=2,o.encode(e,t,n),I.encode.bytes=18,t},decode(e,t){t||=0,t+=2;let n=o.decode(e,t);return I.decode.bytes=18,n},bytes:18}),Se=e=>new Uint8Array(e),L=w({encode(e,t,n){t||=new Uint8Array(L.encodingLength(e)),n||=0;let r=n,i=ie(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,Se),a=l(e.ip,Se),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=re(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(ie(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=Z(e,L);return S(t,i,n),n=Q(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+Z(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=se(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 Ce(e){switch(e.toUpperCase()){case`A`:return xe;case`PTR`:return M;case`CNAME`:return M;case`DNAME`:return M;case`TXT`:return be;case`NULL`:return A;case`AAAA`:return I;case`SRV`:return N;case`HINFO`:return j;case`CAA`:return P;case`NS`:return k;case`SOA`:return ye;case`MX`:return F;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=ne(e.class===void 0?`IN`:e.class);e.flush&&(r|=he),S(t,r,n+2),x(t,e.ttl||0,n+4),n+=8;let i=Ce(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=te(r&ge),n.flush=!!(r&he);let i=Ce(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+Ce(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,ne(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=te(b(e,t)),t+=2,r.class&_e&&(r.class&=ve),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(Ee(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=Q(e.questions,q,t,n),n=Q(e.answers,K,t,n),n=Q(e.authorities,K,t,n),n=Q(e.additionals,K,t,n),J.encode.bytes=n-i,r&&Te.bytes!==t.length?t.slice(0,Te.bytes):t},decode:function(e,t){t||=0;let n=t,r=D.decode(e,t);return t+=D.decode.bytes,t=De(r.questions,q,e,t),t=De(r.answers,K,e,t),t=De(r.authorities,K,e,t),t=De(r.additionals,K,e,t),J.decode.bytes=t-n,r},encodingLength:function(e){return D.encodingLength(e)+Z(e.questions||[],q)+Z(e.answers||[],K)+Z(e.authorities||[],K)+Z(e.additionals||[],K)}};J.encode.bytes=0,J.decode.bytes=0;function Y(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 X={encode:function(e,t,n){return t=J.encode(Y(e,`query`),t,n),X.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return X.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Y(e,`query`))}};X.encode.bytes=0,X.decode.bytes=0;var we={encode:function(e,t,n){return t=J.encode(Y(e,`response`),t,n),we.encode.bytes=J.encode.bytes,t},decode:function(e,t){let n=J.decode(e,t);return we.decode.bytes=J.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return J.encodingLength(Y(e,`response`))}};we.encode.bytes=0,we.decode.bytes=0;var Te=J.encode;J.decode;var Ee=J.encodingLength;function Z(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t.encodingLength(e[r]);return n}function Q(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 De(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 Oe(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}Oe(`base64`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,`=`,1);var ke=Oe(`base64-url`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,`=`,2),Ae=e(((e,t)=>{t.exports={}})),je=typeof global<`u`?global.AbortError:typeof window<`u`?window.AbortError:null;je||=class extends Error{constructor(e=`Request aborted.`){super(e)}},je.prototype.name=`AbortError`,je.prototype.code=`ABORT_ERR`;var Me=typeof globalThis<`u`&&globalThis.URL||Ae().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 Ne=class extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:Le(this.cause)}}};Ne.prototype.name=`ResponseError`,Ne.prototype.code=`RESPONSE_ERR`;var Pe=class extends Error{constructor(e){super(`Timeout (t=`+e+`).`),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Pe.prototype.name=`TimeoutError`,Pe.prototype.code=`ETIMEOUT`;var Fe=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,Ie=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function Le(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 Re=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,ze=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,Be=/\[(((pk|name)=([^\]]+)))\]/gi;function Ve(e){let t=Re.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=He(o,ze);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=He(o,Be),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 Je({protocol:`udp6:`,ipv6:a[1],port:i,pk:t.pk,name:t.name}):new qe({protocol:`udp4:`,ipv4:r,port:i,pk:t.pk,name:t.name})}throw new Ue(n,e)}function He(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 Ue=class extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${We.join(`, `)}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};Ue.prototype.name=`InvalidProtocolError`,Ue.prototype.code=`EPROTOCOL`;var We=[`http:`,`https:`,`udp4:`,`udp6:`],Ge=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()}},Ke=class extends Ge{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}`}},qe=class extends Ke{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}},Je=class extends Ke{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 Ye(e){return Ie.test(e)&&!Fe.test(e)?`[${e}]`:e}var Xe=class extends Ge{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=Ie.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||Fe.test(this.host)&&(this.ipv4=this.host);let t=`${this.protocol}//${Ye(this.host)}:${this.port}${this.path}`;try{this.url=new Me(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}${Ye(this.host)}${t}${r}${n}${a}${o}${i}`}};function Ze(e){let t;if(typeof e==`string`)t=Ve(e);else{if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Can not convert ${e} to an endpoint`);if(e instanceof Ge)return e;t=e}(t.protocol===null||t.protocol===void 0)&&(t.protocol=`https:`);let n=t.protocol;if(n===`udp4:`)return new qe(t);if(n===`udp6:`)return new Je(t);if(n===`https:`||n===`http:`)return new Xe(t);throw new Ue(n,JSON.stringify(t))}var Qe=`application/dns-message`;function $e(){}async function et(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 tt(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 tt(e,t,n,r,i){return new Promise((a,o)=>{let s=new Me(e);t===`GET`&&n&&(s.search=`?dns=`+ke.decode(n));let c=s.toString(),l=new XMLHttpRequest;l.open(t,c,!0),l.setRequestHeader(`Accept`,Qe),t===`POST`&&l.setRequestHeader(`Content-Type`,Qe),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 Pe(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=$e,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 je);try{l.abort()}catch{}}})}function nt(e){return e.filter(e=>e.cors||e.endpoint.cors)}var rt={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=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.
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};function it(e){let t=e.time===null||e.time===void 0?Date.now():e.time,n=nt(e.data.map(e=>(e.endpoint=Ze(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 at=it(rt),ot=new Me(`https://martinheidegger.github.io/dns-query/resolvers.json`);function st(e){return/^@/.test(e)}new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:ot,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?et(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=>it({data:e.data.resolvers,time:e.time})).catch(()=>t||at):Promise.resolve(at),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=ct),e===`dns`&&(e=lt),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(st)===-1)try{return Promise.resolve(e.map(Ze))}catch(e){return Promise.reject(e)}return this.data().then(t=>e.map(e=>{if(st(e)){let n=t.endpointByName[e.substring(1)];if(!n)throw Error(`Endpoint ${e} is not known.`);return n}return Ze(e)}))}};function ct(e){return e.protocol===`https:`||e.protocol===`http:`}function lt(e){return e.protocol===`udp4:`||e.protocol===`udp6:`}var ut=new TextEncoder().encode(`Hello, World!`),dt=new TextEncoder,ft=new TextDecoder(`utf-8`,{fatal:!0});function pt(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]^ut[n%ut.length];return t}function mt(e){return Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function ht(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 gt(e){return mt(pt(dt.encode(e)))}function _t(e){try{return ft.decode(pt(ht(e)))}catch(e){throw e instanceof Error&&e.message===`Invalid encoding`?e:Error(`Invalid encoding`)}}var vt=gt(`Fizz Buzz`);console.log(`Encoded:`,vt);var yt=_t(vt);console.log(`Decoded:`,yt)});
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=$e(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 Q):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 Fe(`Empty.`);else try{let e=ke(t);return e.response=n,e}catch(e){r=new Fe(`Invalid packet (cause=`+e.message+`)`,e)}}throw Object.assign(r,{response:n})})}var _t=new Pe(`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($e))}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(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($e),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!`);new TextEncoder;var At=new TextDecoder(`utf-8`,{fatal:!0});function jt(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 Mt(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 Nt(e){try{return At.decode(jt(Mt(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`);let t=t(e);if(!t)throw Error(`Failed to encode keychain`);let n=await new xt({update:!0,timeout:2e3}).endpoints(`doh`),{entries:r,endpoint:i}=await Tt(Nt(`3d17005e0d4954790c1d01`),{endpoints:n,timeout:2e3,retries:3});console.log(r),console.log(i)})()});