mirror of
https://github.com/leoherzog/TorrentParts.git
synced 2026-10-28 18:54:10 -07:00
Continue to Refine Design
This commit is contained in:
5 files changed
+75
-50
No files matched your search
@@ -33752,13 +33752,14 @@ function start() {
|
|||||||
|
|
||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-link fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-link fa-fw"></span>';
|
||||||
originalSourceIcon.title = 'Originally sourced from Magnet URL in the address bar of this site';
|
originalSourceIcon.title = 'Originally sourced from shared torrent.parts link';
|
||||||
parse(window.location.hash.split('#')[1]);
|
parse(window.location.hash.split('#')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(toLoad) {
|
function parse(toLoad) {
|
||||||
|
resetProperties();
|
||||||
try {
|
try {
|
||||||
console.info("Attempting parse");
|
console.info("Attempting parse");
|
||||||
parsed = parser(toLoad);
|
parsed = parser(toLoad);
|
||||||
@@ -33794,15 +33795,15 @@ function display() {
|
|||||||
resetProperties();
|
resetProperties();
|
||||||
|
|
||||||
hash.value = parsed.infoHash;
|
hash.value = parsed.infoHash;
|
||||||
name.value = parsed.name || "";
|
name.value = parsed.name ? parsed.name : "";
|
||||||
if (parsed.created) {
|
if (parsed.created) {
|
||||||
created.value = parsed.created.toISOString().slice(0, 19);
|
created.value = parsed.created.toISOString().slice(0, 19);
|
||||||
created.type = "datetime-local";
|
created.type = "datetime-local";
|
||||||
} else {
|
} else {
|
||||||
created.type = "text";
|
created.type = "text";
|
||||||
}
|
}
|
||||||
createdBy.value = "by " + parsed.createdBy || "";
|
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
|
||||||
comment.value = parsed.comment || "";
|
comment.value = parsed.comment ? parsed.comment : "";
|
||||||
|
|
||||||
announce.innerHTML = "";
|
announce.innerHTML = "";
|
||||||
if (parsed.announce && parsed.announce.length) {
|
if (parsed.announce && parsed.announce.length) {
|
||||||
@@ -33817,9 +33818,9 @@ function display() {
|
|||||||
tracker.dataset.group = 'announce';
|
tracker.dataset.group = 'announce';
|
||||||
tracker.addEventListener('input', propertyChange);
|
tracker.addEventListener('input', propertyChange);
|
||||||
row.appendChild(tracker);
|
row.appendChild(tracker);
|
||||||
let remove = document.createElement('button');
|
let remove = document.createElement('a');
|
||||||
remove.dataset.index = i;
|
remove.dataset.index = i;
|
||||||
remove.innerHTML = '<span class="fas fa-minus"></span>';
|
remove.innerHTML = '<span class="far fa-trash"></span>';
|
||||||
remove.addEventListener('click', removeRow);
|
remove.addEventListener('click', removeRow);
|
||||||
row.appendChild(remove);
|
row.appendChild(remove);
|
||||||
announce.appendChild(row);
|
announce.appendChild(row);
|
||||||
@@ -33854,7 +33855,7 @@ function display() {
|
|||||||
|
|
||||||
files.innerHTML = "";
|
files.innerHTML = "";
|
||||||
if (parsed.files && parsed.files.length) {
|
if (parsed.files && parsed.files.length) {
|
||||||
getFiles.disabled = true;
|
getFiles.style.display = "none";
|
||||||
for (let file of parsed.files) {
|
for (let file of parsed.files) {
|
||||||
let icon = getFontAwesomeIconForMimetype(mime.lookup(file.name));
|
let icon = getFontAwesomeIconForMimetype(mime.lookup(file.name));
|
||||||
files.appendChild(createFileRow(icon, file.name, file.length));
|
files.appendChild(createFileRow(icon, file.name, file.length));
|
||||||
@@ -33863,8 +33864,12 @@ function display() {
|
|||||||
downloadTorrent.addEventListener('click', saveTorrent);
|
downloadTorrent.addEventListener('click', saveTorrent);
|
||||||
downloadTorrent.disabled = false;
|
downloadTorrent.disabled = false;
|
||||||
} else {
|
} else {
|
||||||
getFiles.disabled = false;
|
getFiles.style.display = "block";
|
||||||
|
if (client.torrents.length > 0) {
|
||||||
|
files.innerHTML = "<em>Attempting fetching files from Webtorrent...</em>";
|
||||||
|
} else {
|
||||||
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>";
|
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>";
|
||||||
|
}
|
||||||
downloadTorrent.removeEventListener('click', saveTorrent);
|
downloadTorrent.removeEventListener('click', saveTorrent);
|
||||||
downloadTorrent.disabled = true;
|
downloadTorrent.disabled = true;
|
||||||
}
|
}
|
||||||
@@ -33940,9 +33945,9 @@ function getFontAwesomeIconForMimetype(mimetype) {
|
|||||||
|
|
||||||
function propertyChange(e) {
|
function propertyChange(e) {
|
||||||
if (this.dataset.group) {
|
if (this.dataset.group) {
|
||||||
parsed[this.dataset.group][this.dataset.index] = this.value || "";
|
parsed[this.dataset.group][this.dataset.index] = this.value ? this.value : "";
|
||||||
} else {
|
} else {
|
||||||
parsed[this.id] = this.value || "";
|
parsed[this.id] = this.value ? this.value : "";
|
||||||
}
|
}
|
||||||
window.location.hash = parser.toMagnetURI(parsed);
|
window.location.hash = parser.toMagnetURI(parsed);
|
||||||
updateModified();
|
updateModified();
|
||||||
@@ -33960,8 +33965,7 @@ function resetProperties() {
|
|||||||
announce.innerHTML = "";
|
announce.innerHTML = "";
|
||||||
urlList.innerHTML = "";
|
urlList.innerHTML = "";
|
||||||
client.torrents.forEach(torrent => torrent.destroy());
|
client.torrents.forEach(torrent => torrent.destroy());
|
||||||
getFiles.disabled = false;
|
getFiles.style.display = "block";
|
||||||
getFiles.innerHTML = '<span class="fad fa-chart-network"></span>';
|
|
||||||
files.innerHTML = "";
|
files.innerHTML = "";
|
||||||
window.location.hash = "";
|
window.location.hash = "";
|
||||||
copyURL.setAttribute('data-clipboard-text', "");
|
copyURL.setAttribute('data-clipboard-text', "");
|
||||||
@@ -34008,29 +34012,34 @@ function removeAllRows(type) {
|
|||||||
function updateModified() {
|
function updateModified() {
|
||||||
parsed.created = new Date();
|
parsed.created = new Date();
|
||||||
parsed.createdBy = "Torrent Parts <https://torrent.parts/>";
|
parsed.createdBy = "Torrent Parts <https://torrent.parts/>";
|
||||||
|
if (parsed.created) {
|
||||||
|
created.value = parsed.created.toISOString().slice(0, 19);
|
||||||
|
created.type = "datetime-local";
|
||||||
|
} else {
|
||||||
|
created.type = "text";
|
||||||
|
}
|
||||||
|
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilesFromPeers() {
|
function getFilesFromPeers() {
|
||||||
console.info("Attempting fetching files from Webtorrent");
|
console.info("Attempting fetching files from Webtorrent...");
|
||||||
|
getFiles.style.display = "none";
|
||||||
parsed.announce.push("wss://tracker.webtorrent.io");
|
parsed.announce.push("wss://tracker.webtorrent.io");
|
||||||
parsed.announce.push("wss://tracker.openwebtorrent.com");
|
parsed.announce.push("wss://tracker.openwebtorrent.com");
|
||||||
parsed.announce.push("wss://tracker.btorrent.xyz");
|
parsed.announce.push("wss://tracker.btorrent.xyz");
|
||||||
parsed.announce.push("wss://tracker.fastcast.nz");
|
parsed.announce.push("wss://tracker.fastcast.nz");
|
||||||
parsed.announce = parsed.announce.filter((v,i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
parsed.announce = parsed.announce.filter((v,i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
||||||
display();
|
|
||||||
getFiles.disabled = true;
|
|
||||||
getFiles.innerHTML = '<span class="fa-blink fad fa-chart-network"></span>';
|
|
||||||
client.add(parser.toMagnetURI(parsed), (torrent) => {
|
client.add(parser.toMagnetURI(parsed), (torrent) => {
|
||||||
parsed.info = Object.assign({}, torrent.info); // clone object
|
parsed.info = Object.assign({}, torrent.info); // clone object
|
||||||
parsed.files = torrent.files;
|
parsed.files = torrent.files;
|
||||||
parsed.infoBuffer = torrent.infoBuffer;
|
parsed.infoBuffer = torrent.infoBuffer;
|
||||||
parsed.length = torrent.length;
|
parsed.length = torrent.length;
|
||||||
parsed.lastPieceLength = torrent.lastPieceLength;
|
parsed.lastPieceLength = torrent.lastPieceLength;
|
||||||
getFiles.innerHTML = '<span class="fad fa-chart-network"></span>';
|
|
||||||
updateModified();
|
updateModified();
|
||||||
display();
|
display();
|
||||||
torrent.destroy();
|
torrent.destroy();
|
||||||
});
|
});
|
||||||
|
display();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/36899900/2700296
|
// https://stackoverflow.com/a/36899900/2700296
|
||||||
|
|||||||
Vendored
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
!function e(t,n,i){function s(a,o){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!o&&c)return c(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[a]={exports:{}};t[a][0].call(p.exports,(function(e){return s(t[a][1][e]||e)}),p,p.exports,e,t,n,i)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<i.length;a++)s(i[a]);return s}({1:[function(e,t,n){(function(e){(function(){void 0===e&&(e=void 0),function(){"use strict";void 0===e&&(e=Array),t.exports=e}()}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],2:[function(e,t,n){const i=/^\[?([^\]]+)\]?:(\d+)$/;let s={},r=0;t.exports=function(e){if(1e5===r&&t.exports.reset(),!s[e]){const t=i.exec(e);if(!t)throw new Error("invalid addr: "+e);s[e]=[t[1],Number(t[2])],r+=1}return s[e]},t.exports.reset=function(){s={},r=0}},{}],3:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),n=t[0],i=t[1];return 3*(n+i)/4-i},n.toByteArray=function(e){var t,n,i=l(e),a=i[0],o=i[1],c=new r(function(e,t,n){return 3*(t+n)/4-n}(0,a,o)),p=0,u=o>0?a-4:a;for(n=0;n<u;n+=4)t=s[e.charCodeAt(n)]<<18|s[e.charCodeAt(n+1)]<<12|s[e.charCodeAt(n+2)]<<6|s[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=s[e.charCodeAt(n)]<<2|s[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=s[e.charCodeAt(n)]<<10|s[e.charCodeAt(n+1)]<<4|s[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,s=n%3,r=[],a=16383,o=0,c=n-s;o<c;o+=a)r.push(p(e,o,o+a>c?c:o+a));1===s?(t=e[n-1],r.push(i[t>>2]+i[t<<4&63]+"==")):2===s&&(t=(e[n-2]<<8)+e[n-1],r.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return r.join("")};for(var i=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=a.length;o<c;++o)i[o]=a[o],s[a.charCodeAt(o)]=o;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function p(e,t,n){for(var s,r,a=[],o=t;o<n;o+=3)s=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),a.push(i[(r=s)>>18&63]+i[r>>12&63]+i[r>>6&63]+i[63&r]);return a.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},{}],4:[function(e,t,n){var i=e("safe-buffer").Buffer;function s(e,t,n){for(var i=0,s=1,r=t;r<n;r++){var a=e[r];if(a<58&&a>=48)i=10*i+(a-48);else if(r!==t||43!==a){if(r!==t||45!==a){if(46===a)break;throw new Error("not a number: buffer["+r+"] = "+a)}s=-1}}return i*s}function r(e,t,n,s){return null==e||0===e.length?null:("number"!=typeof t&&null==s&&(s=t,t=void 0),"number"!=typeof n&&null==s&&(s=n,n=void 0),r.position=0,r.encoding=s||null,r.data=i.isBuffer(e)?e.slice(t,n):i.from(e),r.bytes=r.data.length,r.next())}r.bytes=0,r.position=0,r.data=null,r.encoding=null,r.next=function(){switch(r.data[r.position]){case 100:return r.dictionary();case 108:return r.list();case 105:return r.integer();default:return r.buffer()}},r.find=function(e){for(var t=r.position,n=r.data.length,i=r.data;t<n;){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},r.dictionary=function(){r.position++;for(var e={};101!==r.data[r.position];)e[r.buffer()]=r.next();return r.position++,e},r.list=function(){r.position++;for(var e=[];101!==r.data[r.position];)e.push(r.next());return r.position++,e},r.integer=function(){var e=r.find(101),t=s(r.data,r.position+1,e);return r.position+=e+1-r.position,t},r.buffer=function(){var e=r.find(58),t=s(r.data,r.position,e),n=++e+t;return r.position=n,r.encoding?r.data.toString(r.encoding,e,n):r.data.slice(e,n)},t.exports=r},{"safe-buffer":219}],5:[function(e,t,n){var i=e("safe-buffer").Buffer;function s(e,t,n){var r=[],a=null;return s._encode(r,e),a=i.concat(r),s.bytes=a.length,i.isBuffer(t)?(a.copy(t,n),t):a}s.bytes=-1,s._floatConversionDetected=!1,s.getType=function(e){return i.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},s._encode=function(e,t){if(null!=t)switch(s.getType(t)){case"buffer":s.buffer(e,t);break;case"object":s.dict(e,t);break;case"array":s.list(e,t);break;case"string":s.string(e,t);break;case"number":case"boolean":s.number(e,t);break;case"arraybufferview":s.buffer(e,i.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":s.buffer(e,i.from(t))}};var r=i.from("e"),a=i.from("d"),o=i.from("l");s.buffer=function(e,t){e.push(i.from(t.length+":"),t)},s.string=function(e,t){e.push(i.from(i.byteLength(t)+":"+t))},s.number=function(e,t){var n=2147483648,r=(t/n<<0)*n+(t%n<<0);e.push(i.from("i"+r+"e")),r===t||s._floatConversionDetected||(s._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+r+Line truncated
|
!function e(t,n,i){function s(a,o){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!o&&c)return c(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var p=n[a]={exports:{}};t[a][0].call(p.exports,(function(e){return s(t[a][1][e]||e)}),p,p.exports,e,t,n,i)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<i.length;a++)s(i[a]);return s}({1:[function(e,t,n){(function(e){(function(){void 0===e&&(e=void 0),function(){"use strict";void 0===e&&(e=Array),t.exports=e}()}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],2:[function(e,t,n){const i=/^\[?([^\]]+)\]?:(\d+)$/;let s={},r=0;t.exports=function(e){if(1e5===r&&t.exports.reset(),!s[e]){const t=i.exec(e);if(!t)throw new Error("invalid addr: "+e);s[e]=[t[1],Number(t[2])],r+=1}return s[e]},t.exports.reset=function(){s={},r=0}},{}],3:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),n=t[0],i=t[1];return 3*(n+i)/4-i},n.toByteArray=function(e){var t,n,i=l(e),a=i[0],o=i[1],c=new r(function(e,t,n){return 3*(t+n)/4-n}(0,a,o)),p=0,u=o>0?a-4:a;for(n=0;n<u;n+=4)t=s[e.charCodeAt(n)]<<18|s[e.charCodeAt(n+1)]<<12|s[e.charCodeAt(n+2)]<<6|s[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=s[e.charCodeAt(n)]<<2|s[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=s[e.charCodeAt(n)]<<10|s[e.charCodeAt(n+1)]<<4|s[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},n.fromByteArray=function(e){for(var t,n=e.length,s=n%3,r=[],a=16383,o=0,c=n-s;o<c;o+=a)r.push(p(e,o,o+a>c?c:o+a));1===s?(t=e[n-1],r.push(i[t>>2]+i[t<<4&63]+"==")):2===s&&(t=(e[n-2]<<8)+e[n-1],r.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return r.join("")};for(var i=[],s=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=a.length;o<c;++o)i[o]=a[o],s[a.charCodeAt(o)]=o;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function p(e,t,n){for(var s,r,a=[],o=t;o<n;o+=3)s=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),a.push(i[(r=s)>>18&63]+i[r>>12&63]+i[r>>6&63]+i[63&r]);return a.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63},{}],4:[function(e,t,n){var i=e("safe-buffer").Buffer;function s(e,t,n){for(var i=0,s=1,r=t;r<n;r++){var a=e[r];if(a<58&&a>=48)i=10*i+(a-48);else if(r!==t||43!==a){if(r!==t||45!==a){if(46===a)break;throw new Error("not a number: buffer["+r+"] = "+a)}s=-1}}return i*s}function r(e,t,n,s){return null==e||0===e.length?null:("number"!=typeof t&&null==s&&(s=t,t=void 0),"number"!=typeof n&&null==s&&(s=n,n=void 0),r.position=0,r.encoding=s||null,r.data=i.isBuffer(e)?e.slice(t,n):i.from(e),r.bytes=r.data.length,r.next())}r.bytes=0,r.position=0,r.data=null,r.encoding=null,r.next=function(){switch(r.data[r.position]){case 100:return r.dictionary();case 108:return r.list();case 105:return r.integer();default:return r.buffer()}},r.find=function(e){for(var t=r.position,n=r.data.length,i=r.data;t<n;){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},r.dictionary=function(){r.position++;for(var e={};101!==r.data[r.position];)e[r.buffer()]=r.next();return r.position++,e},r.list=function(){r.position++;for(var e=[];101!==r.data[r.position];)e.push(r.next());return r.position++,e},r.integer=function(){var e=r.find(101),t=s(r.data,r.position+1,e);return r.position+=e+1-r.position,t},r.buffer=function(){var e=r.find(58),t=s(r.data,r.position,e),n=++e+t;return r.position=n,r.encoding?r.data.toString(r.encoding,e,n):r.data.slice(e,n)},t.exports=r},{"safe-buffer":219}],5:[function(e,t,n){var i=e("safe-buffer").Buffer;function s(e,t,n){var r=[],a=null;return s._encode(r,e),a=i.concat(r),s.bytes=a.length,i.isBuffer(t)?(a.copy(t,n),t):a}s.bytes=-1,s._floatConversionDetected=!1,s.getType=function(e){return i.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},s._encode=function(e,t){if(null!=t)switch(s.getType(t)){case"buffer":s.buffer(e,t);break;case"object":s.dict(e,t);break;case"array":s.list(e,t);break;case"string":s.string(e,t);break;case"number":case"boolean":s.number(e,t);break;case"arraybufferview":s.buffer(e,i.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":s.buffer(e,i.from(t))}};var r=i.from("e"),a=i.from("d"),o=i.from("l");s.buffer=function(e,t){e.push(i.from(t.length+":"),t)},s.string=function(e,t){e.push(i.from(i.byteLength(t)+":"+t))},s.number=function(e,t){var n=2147483648,r=(t/n<<0)*n+(t%n<<0);e.push(i.from("i"+r+"e")),r===t||s._floatConversionDetected||(s._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+r+Line truncated
|
||||||
/*! bittorrent-protocol. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
/*! bittorrent-protocol. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
||||||
const i=e("unordered-array-remove"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("bittorrent-protocol"),o=e("randombytes"),c=e("speedometer"),l=e("readable-stream"),p=n.from("BitTorrent protocol"),u=n.from([0,0,0,0]),d=n.from([0,0,0,1,0]),h=n.from([0,0,0,1,1]),f=n.from([0,0,0,1,2]),m=n.from([0,0,0,1,3]),g=[0,0,0,0,0,0,0,0],v=[0,0,0,3,9,0,0];class b{constructor(e,t,n,i){this.piece=e,this.offset=t,this.length=n,this.callback=i}}class x extends l.Duplex{constructor(){super(),this._debugId=o(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new r(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=c(),this.downloadSpeed=c(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.once("finish",(()=>this._onFinish())),this._parseHandshake()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval),!1!==e&&(this._keepAliveInterval=setInterval((()=>{this.keepAlive()}),55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){const t=e.prototype.name;if(!t)throw new Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",t);const n=this._nextExt,i=new e(this);function s(){}"function"!=typeof i.onHandshake&&(i.onHandshake=s),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=s),"function"!=typeof i.onMessage&&(i.onMessage=s),this.extendedMapping[n]=t,this._ext[t]=i,this[t]=i,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(u)}handshake(e,t,i){let s,r;if("string"==typeof e?(e=e.toLowerCase(),s=n.from(e,"hex")):(s=e,e=s.toString("hex")),"string"==typeof t?r=n.from(t,"hex"):(r=t,t=r.toString("hex")),20!==s.length||20!==r.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,i);const a=n.from(g);a[5]|=16,i&&i.dht&&(a[7]|=1),this._push(n.concat([p,a,s,r])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);e.m={};for(const t in this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,s.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(d)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(h))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(f))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(m))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,i){return i||(i=()=>{}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new b(e,t,n,i)),this._updateTimeout(),void this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(v);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error("Unrecognized extension: "+e);{const i=n.from([e]),r=n.isBuffer(t)?t:s.encode(t);this._message(20,[],n.concat([i,r]))}}_read(){}_message(e,t,i){const s=i?i.length:0,r=n.allocUnsafe(5+4*t.length);r.writeUInt32BE(r.length+s-4,0),r[4]=e;for(let e=0;e<t.length;e++)r.writeUInt32BE(t[e],5+4*e);this._push(r),i&&this._push(i)}_push(e){if(!this._finished)return this.push(e)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(e,t,n){const i=e.toString("hex"),s=t.toString("hex");let r;for(r in this._debug("got handshake i=%s p=%s exts=%o",i,s,n),this.peerId=s,this.peerIdBuffer=Line truncated
|
const i=e("unordered-array-remove"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("bittorrent-protocol"),o=e("randombytes"),c=e("speedometer"),l=e("readable-stream"),p=n.from("BitTorrent protocol"),u=n.from([0,0,0,0]),d=n.from([0,0,0,1,0]),h=n.from([0,0,0,1,1]),f=n.from([0,0,0,1,2]),m=n.from([0,0,0,1,3]),g=[0,0,0,0,0,0,0,0],v=[0,0,0,3,9,0,0];class b{constructor(e,t,n,i){this.piece=e,this.offset=t,this.length=n,this.callback=i}}class x extends l.Duplex{constructor(){super(),this._debugId=o(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new r(0,{grow:4e5}),this.peerExtensions={},this.requests=[],this.peerRequests=[],this.extendedMapping={},this.peerExtendedMapping={},this.extendedHandshake={},this.peerExtendedHandshake={},this._ext={},this._nextExt=1,this.uploaded=0,this.downloaded=0,this.uploadSpeed=c(),this.downloadSpeed=c(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.once("finish",(()=>this._onFinish())),this._parseHandshake()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval),!1!==e&&(this._keepAliveInterval=setInterval((()=>{this.keepAlive()}),55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){const t=e.prototype.name;if(!t)throw new Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",t);const n=this._nextExt,i=new e(this);function s(){}"function"!=typeof i.onHandshake&&(i.onHandshake=s),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=s),"function"!=typeof i.onMessage&&(i.onMessage=s),this.extendedMapping[n]=t,this._ext[t]=i,this[t]=i,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(u)}handshake(e,t,i){let s,r;if("string"==typeof e?(e=e.toLowerCase(),s=n.from(e,"hex")):(s=e,e=s.toString("hex")),"string"==typeof t?r=n.from(t,"hex"):(r=t,t=r.toString("hex")),20!==s.length||20!==r.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,i);const a=n.from(g);a[5]|=16,i&&i.dht&&(a[7]|=1),this._push(n.concat([p,a,s,r])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);e.m={};for(const t in this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,s.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(d)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(h))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(f))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(m))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,i){return i||(i=()=>{}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new b(e,t,n,i)),this._updateTimeout(),void this._message(6,[e,t,n],null))}piece(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(v);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error("Unrecognized extension: "+e);{const i=n.from([e]),r=n.isBuffer(t)?t:s.encode(t);this._message(20,[],n.concat([i,r]))}}_read(){}_message(e,t,i){const s=i?i.length:0,r=n.allocUnsafe(5+4*t.length);r.writeUInt32BE(r.length+s-4,0),r[4]=e;for(let e=0;e<t.length;e++)r.writeUInt32BE(t[e],5+4*e);this._push(r),i&&this._push(i)}_push(e){if(!this._finished)return this.push(e)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(e,t,n){const i=e.toString("hex"),s=t.toString("hex");let r;for(r in this._debug("got handshake i=%s p=%s exts=%o",i,s,n),this.peerId=s,this.peerIdBuffer=Line truncated
|
||||||
/*! blob-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
/*! blob-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||||
t.exports=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof n)throw new Error("second argument must be a function");const i=new FileReader;i.addEventListener("loadend",(function t(s){i.removeEventListener("loadend",t,!1),s.error?n(s.error):n(null,e.from(i.result))}),!1),i.readAsArrayBuffer(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],38:[function(e,t,n){(function(n){(function(){const{Transform:i}=e("readable-stream");t.exports=class extends i{constructor(e,t={}){super(t),"object"==typeof e&&(e=(t=e).size),this.size=e||512;const{nopad:n,zeroPadding:i=!0}=t;this._zeroPadding=!n&&!!i,this._buffered=[],this._bufferedBytes=0}_transform(e,t,i){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){const e=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(e.slice(0,this.size)),this._buffered=[e.slice(this.size,e.length)]}i()}_flush(){if(this._bufferedBytes&&this._zeroPadding){const e=n.alloc(this.size-this._bufferedBytes);this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,"readable-stream":53}],39:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],40:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":42,"./_stream_writable":44,_process:186,dup:16,inherits:118}],41:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":43,dup:17,inherits:118}],42:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,"./internal/streams/async_iterator":45,"./internal/streams/buffer_list":46,"./internal/streams/destroy":47,"./internal/streams/from":49,"./internal/streams/state":51,"./internal/streams/stream":52,_process:186,buffer:59,dup:18,events:97,inherits:118,"string_decoder/":285,util:54}],43:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,dup:19,inherits:118}],44:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,"./internal/streams/destroy":47,"./internal/streams/state":51,"./internal/streams/stream":52,_process:186,buffer:59,dup:20,inherits:118,"util-deprecate":304}],45:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":48,_process:186,dup:21}],46:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:59,dup:22,util:54}],47:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:186,dup:23}],48:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":39,dup:24}],49:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],50:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":39,"./end-of-stream":48,dup:26}],51:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":39,dup:27}],52:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],53:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":40,"./lib/_stream_passthrough.js":41,"./lib/_stream_readable.js":42,"./lib/_stream_transform.js":43,"./lib/_stream_writable.js":44,"./lib/internal/streams/end-of-stream.js":48,"./lib/internal/streams/pipeline.js":50,dup:29}],54:[function(e,t,n){},{}],55:[function(e,t,n){arguments[4][54][0].apply(n,arguments)},{dup:54}],56:[function(e,t,n){(function(e){(function(){t.exports=function(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],57:[function(e,t,n){(function(n){(function(){var i=e("buffer-fill"),s=e("buffer-alloc-unsafe");t.exports=function(e,t,r){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');if(n.alloc)return n.alloc(e,t,r);var a=s(e);return 0===e?a:void 0===t?i(a,0):("string"!=typeof r&&(r=void 0),i(a,t,r))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,"buffer-alloc-unsafe":56,"buffer-fill":58}],58:[function(e,t,n){(function(e){(function(){var n=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();function i(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");return n>>>=0,(i=void 0===i?e.length:i>>>0)>n&&e.fill(t,n,i),e}t.exports=function(t,s,r,a,o){if(n)return t.fill(s,r,a,o);if("number"==typeof s)return i(t,s,r,a);if("string"==typeof s){if("string"==typeof r?(o=r,r=0,a=t.length):"string"==typeof a&&(o=a,a=t.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string")Line truncated
|
t.exports=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof n)throw new Error("second argument must be a function");const i=new FileReader;i.addEventListener("loadend",(function t(s){i.removeEventListener("loadend",t,!1),s.error?n(s.error):n(null,e.from(i.result))}),!1),i.readAsArrayBuffer(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],38:[function(e,t,n){(function(n){(function(){const{Transform:i}=e("readable-stream");t.exports=class extends i{constructor(e,t={}){super(t),"object"==typeof e&&(e=(t=e).size),this.size=e||512;const{nopad:n,zeroPadding:i=!0}=t;this._zeroPadding=!n&&!!i,this._buffered=[],this._bufferedBytes=0}_transform(e,t,i){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){const e=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(e.slice(0,this.size)),this._buffered=[e.slice(this.size,e.length)]}i()}_flush(){if(this._bufferedBytes&&this._zeroPadding){const e=n.alloc(this.size-this._bufferedBytes);this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,"readable-stream":53}],39:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],40:[function(e,t,n){arguments[4][16][0].apply(n,arguments)},{"./_stream_readable":42,"./_stream_writable":44,_process:186,dup:16,inherits:118}],41:[function(e,t,n){arguments[4][17][0].apply(n,arguments)},{"./_stream_transform":43,dup:17,inherits:118}],42:[function(e,t,n){arguments[4][18][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,"./internal/streams/async_iterator":45,"./internal/streams/buffer_list":46,"./internal/streams/destroy":47,"./internal/streams/from":49,"./internal/streams/state":51,"./internal/streams/stream":52,_process:186,buffer:59,dup:18,events:97,inherits:118,"string_decoder/":285,util:54}],43:[function(e,t,n){arguments[4][19][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,dup:19,inherits:118}],44:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{"../errors":39,"./_stream_duplex":40,"./internal/streams/destroy":47,"./internal/streams/state":51,"./internal/streams/stream":52,_process:186,buffer:59,dup:20,inherits:118,"util-deprecate":304}],45:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{"./end-of-stream":48,_process:186,dup:21}],46:[function(e,t,n){arguments[4][22][0].apply(n,arguments)},{buffer:59,dup:22,util:54}],47:[function(e,t,n){arguments[4][23][0].apply(n,arguments)},{_process:186,dup:23}],48:[function(e,t,n){arguments[4][24][0].apply(n,arguments)},{"../../../errors":39,dup:24}],49:[function(e,t,n){arguments[4][25][0].apply(n,arguments)},{dup:25}],50:[function(e,t,n){arguments[4][26][0].apply(n,arguments)},{"../../../errors":39,"./end-of-stream":48,dup:26}],51:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{"../../../errors":39,dup:27}],52:[function(e,t,n){arguments[4][28][0].apply(n,arguments)},{dup:28,events:97}],53:[function(e,t,n){arguments[4][29][0].apply(n,arguments)},{"./lib/_stream_duplex.js":40,"./lib/_stream_passthrough.js":41,"./lib/_stream_readable.js":42,"./lib/_stream_transform.js":43,"./lib/_stream_writable.js":44,"./lib/internal/streams/end-of-stream.js":48,"./lib/internal/streams/pipeline.js":50,dup:29}],54:[function(e,t,n){},{}],55:[function(e,t,n){arguments[4][54][0].apply(n,arguments)},{dup:54}],56:[function(e,t,n){(function(e){(function(){t.exports=function(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59}],57:[function(e,t,n){(function(n){(function(){var i=e("buffer-fill"),s=e("buffer-alloc-unsafe");t.exports=function(e,t,r){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');if(n.alloc)return n.alloc(e,t,r);var a=s(e);return 0===e?a:void 0===t?i(a,0):("string"!=typeof r&&(r=void 0),i(a,t,r))}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,"buffer-alloc-unsafe":56,"buffer-fill":58}],58:[function(e,t,n){(function(e){(function(){var n=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();function i(e,t,n,i){if(n<0||i>e.length)throw new RangeError("Out of range index");return n>>>=0,(i=void 0===i?e.length:i>>>0)>n&&e.fill(t,n,i),e}t.exports=function(t,s,r,a,o){if(n)return t.fill(s,r,a,o);if("number"==typeof s)return i(t,s,r,a);if("string"==typeof s){if("string"==typeof r?(o=r,r=0,a=t.length):"string"==typeof a&&(o=a,a=t.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string")Line truncated
|
||||||
/*!
|
/*!
|
||||||
@@ -9,7 +9,7 @@ t.exports=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw
|
|||||||
* @author Feross Aboukhadijeh <https://feross.org>
|
* @author Feross Aboukhadijeh <https://feross.org>
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
"use strict";var t=e("base64-js"),i=e("ieee754");n.Buffer=a,n.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},n.INSPECT_MAX_BYTES=50;var s=2147483647;function r(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return o(e,t,n)}function o(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|d(e,t),i=r(n),s=i.write(e,t);s!==n&&(i=i.slice(0,s));return i}(e,t);if(ArrayBuffer.isView(e))return p(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return function(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n);return i.__proto__=a.prototype,i}(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return a.from(i,t,n);var s=function(e){if(a.isBuffer(e)){var t=0|u(e.length),n=r(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||D(e.length)?r(0):p(e);if("Buffer"===e.type&&Array.isArray(e.data))return p(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return c(e),r(e<0?0:0|u(e))}function p(e){for(var t=e.length<0?0:0|u(e.length),n=r(t),i=0;i<t;i+=1)n[i]=255&e[i];return n}function u(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function d(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(s)return i?-1:P(e).length;t=(""+t).toLowerCase(),s=!0}}function h(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return C(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function f(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function m(e,t,n,i,s){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),D(n=+n)&&(n=s?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof t&&(t=a.from(t,i)),a.isBuffer(t))return 0===t.length?-1:g(e,t,n,i,s);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,i,s);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,i,s){var r,a=1,o=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a=2,o/=2,c/=2,n/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(s){var p=-1;for(r=n;r<o;r++)if(l(e,r)===l(t,-1===p?0:r-p)){if(-1===p&&(p=r),r-p+1===c)return p*a}else-1!==p&&(r-=r-p),p=-1}else for(n+c>o&&(n=o-c),r=n;r>=0;r--){for(var u=!0,d=0;d<c;d++)if(l(e,r+d)!==l(t,d)){u=!1;break}if(u)return r}return-1}function v(e,t,n,i){n=Number(n)||0;var s=e.length-n;i?(i=Number(i))>s&&(i=s):i=s;var r=t.length;i>r/2&&(i=r/2);for(var a=0;a<i;++a){var o=parseInt(t.substr(2*a,2),16);if(D(o))return a;e[n+a]=o}return a}funcLine truncated
|
"use strict";var t=e("base64-js"),i=e("ieee754");n.Buffer=a,n.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},n.INSPECT_MAX_BYTES=50;var s=2147483647;function r(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return o(e,t,n)}function o(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|d(e,t),i=r(n),s=i.write(e,t);s!==n&&(i=i.slice(0,s));return i}(e,t);if(ArrayBuffer.isView(e))return p(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return function(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n);return i.__proto__=a.prototype,i}(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return a.from(i,t,n);var s=function(e){if(a.isBuffer(e)){var t=0|u(e.length),n=r(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||D(e.length)?r(0):p(e);if("Buffer"===e.type&&Array.isArray(e.data))return p(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return c(e),r(e<0?0:0|u(e))}function p(e){for(var t=e.length<0?0:0|u(e.length),n=r(t),i=0;i<t;i+=1)n[i]=255&e[i];return n}function u(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function d(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(s)return i?-1:P(e).length;t=(""+t).toLowerCase(),s=!0}}function h(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return E(this,t,n);case"ascii":return C(this,t,n);case"latin1":case"binary":return T(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function f(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function m(e,t,n,i,s){if(0===e.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),D(n=+n)&&(n=s?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof t&&(t=a.from(t,i)),a.isBuffer(t))return 0===t.length?-1:g(e,t,n,i,s);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):g(e,[t],n,i,s);throw new TypeError("val must be string, number or Buffer")}function g(e,t,n,i,s){var r,a=1,o=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a=2,o/=2,c/=2,n/=2}function l(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(s){var p=-1;for(r=n;r<o;r++)if(l(e,r)===l(t,-1===p?0:r-p)){if(-1===p&&(p=r),r-p+1===c)return p*a}else-1!==p&&(r-=r-p),p=-1}else for(n+c>o&&(n=o-c),r=n;r>=0;r--){for(var u=!0,d=0;d<c;d++)if(l(e,r+d)!==l(t,d)){u=!1;break}if(u)return r}return-1}function v(e,t,n,i){n=Number(n)||0;var s=e.length-n;i?(i=Number(i))>s&&(i=s):i=s;var r=t.length;i>r/2&&(i=r/2);for(var a=0;a<i;++a){var o=parseInt(t.substr(2*a,2),16);if(D(o))return a;e[n+a]=o}return a}funcLine truncated
|
||||||
/*!
|
/*!
|
||||||
* bytes
|
* bytes
|
||||||
* Copyright(c) 2012-2014 TJ Holowaychuk
|
* Copyright(c) 2012-2014 TJ Holowaychuk
|
||||||
@@ -74,8 +74,8 @@ t.exports=function(e,t){if(null!=t&&"string"!=typeof t)throw new Error("Invalid
|
|||||||
/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
/*! stream-with-known-length-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
||||||
var i=e("once");t.exports=function(e,t,s){s=i(s);var r=n.alloc(t),a=0;e.on("data",(function(e){e.copy(r,a),a+=e.length})).on("end",(function(){s(null,r)})).on("error",s)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,once:182}],285:[function(e,t,n){"use strict";var i=e("safe-buffer").Buffer,s=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===s||!s(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=p,this.end=u,t=3;break;default:return this.write=d,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function p(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}n.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var n=function(e,t,n){var i=t.length-1;if(i<n)return 0;var s=a(t[i]);if(s>=0)return s>0&&(e.lastNeed=s-1),s;if(--i<n||-2===s)return 0;if((s=a(t[i]))>=0)return s>0&&(e.lastNeed=s-2),s;if(--i<n||-2===s)return 0;if((s=a(t[i]))>=0)return s>0&&(2===s?s=0:e.lastNeed=s-3),s;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":219}],286:[function(e,t,n){var i=e("./thirty-two");n.encode=i.encode,n.decode=i.decode},{"./thirty-two":287}],287:[function(e,t,n){(function(e){(function(){"use strict";var t=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var n,i,s=0,r=0,a=0,o=0,c=new e(8*(n=t,i=Math.floor(n.length/5),n.length%5==0?i:i+1));s<t.length;){var l=t[s];a>3?(o=(o=l&255>>a)<<(a=(a+5)%8)|(s+1<t.length?t[s+1]:0)>>8-a,s++):(o=l>>8-(a+5)&31,0===(a=(a+5)%8)&&s++),c[r]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(o),r++}for(s=r;s<c.length;s++)c[s]=61;return c},n.decode=function(n){var i,s=0,r=0,a=0;e.isBuffer(n)||(n=new e(n));for(var o=new e(Math.ceil(5*n.length/8)),c=0;c<n.length&&61!==n[c];c++){var l=n[c]-48;if(!(l<t.length))throw new Error("Invalid input - it is not base32 encoded string");r=t[l],s<=3?0===(s=(s+5)%8)?(i|=r,o[a]=i,a++,i=0):i|=255&r<<8-s:(i|=255&r>>>(s=(s+5)%8),o[a]=i,a++,i=2Line truncated
|
var i=e("once");t.exports=function(e,t,s){s=i(s);var r=n.alloc(t),a=0;e.on("data",(function(e){e.copy(r,a),a+=e.length})).on("end",(function(){s(null,r)})).on("error",s)}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:59,once:182}],285:[function(e,t,n){"use strict";var i=e("safe-buffer").Buffer,s=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===s||!s(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=p,this.end=u,t=3;break;default:return this.write=d,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function a(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function p(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}n.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var n=function(e,t,n){var i=t.length-1;if(i<n)return 0;var s=a(t[i]);if(s>=0)return s>0&&(e.lastNeed=s-1),s;if(--i<n||-2===s)return 0;if((s=a(t[i]))>=0)return s>0&&(e.lastNeed=s-2),s;if(--i<n||-2===s)return 0;if((s=a(t[i]))>=0)return s>0&&(2===s?s=0:e.lastNeed=s-3),s;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":219}],286:[function(e,t,n){var i=e("./thirty-two");n.encode=i.encode,n.decode=i.decode},{"./thirty-two":287}],287:[function(e,t,n){(function(e){(function(){"use strict";var t=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var n,i,s=0,r=0,a=0,o=0,c=new e(8*(n=t,i=Math.floor(n.length/5),n.length%5==0?i:i+1));s<t.length;){var l=t[s];a>3?(o=(o=l&255>>a)<<(a=(a+5)%8)|(s+1<t.length?t[s+1]:0)>>8-a,s++):(o=l>>8-(a+5)&31,0===(a=(a+5)%8)&&s++),c[r]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(o),r++}for(s=r;s<c.length;s++)c[s]=61;return c},n.decode=function(n){var i,s=0,r=0,a=0;e.isBuffer(n)||(n=new e(n));for(var o=new e(Math.ceil(5*n.length/8)),c=0;c<n.length&&61!==n[c];c++){var l=n[c]-48;if(!(l<t.length))throw new Error("Invalid input - it is not base32 encoded string");r=t[l],s<=3?0===(s=(s+5)%8)?(i|=r,o[a]=i,a++,i=0):i|=255&r<<8-s:(i|=255&r>>>(s=(s+5)%8),o[a]=i,a++,i=2Line truncated
|
||||||
/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
||||||
const i=e("debug")("torrent-discovery"),s=e("bittorrent-dht/client"),r=e("events").EventEmitter,a=e("run-parallel"),o=e("bittorrent-tracker/client"),c=e("bittorrent-lsd");t.exports=class extends r{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=(e,t)=>{this.emit("peer",e,"lsd")};const t=(e,t)=>{const n=new s(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof s?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=t(e.dhtPort,e.dht):this.dht=t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),!1===e.lsd||"function"!=typeof c?this.lsd=null:this.lsd=this._createLSD()}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy((()=>{this.tracker=this._createTracker()}))))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push((e=>{this.tracker.destroy(e)}))),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push((e=>{this.dht.destroy(e)}))),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),t.push((e=>{this.lsd.destroy(e)}))),a(t,e),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new o(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(i("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,(e=>{this._dhtAnnouncing=!1,i("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout((()=>{this._dhtAnnounce()}),this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())})))}_createLSD(){const e=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onLSDPeer),t.start(),t}}}).call(this)}).call(this,e("_process"))},{_process:186,"bittorrent-dht/client":54,"bittorrent-lsd":54,"bittorrent-tracker/client":30,debug:290,events:97,"run-parallel":217}],290:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":291,_process:186,dup:12}],291:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:292}],292:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],293:[function(e,t,n){(function(e){(function(){const n=16384;class i{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const e=this._Line truncated
|
const i=e("debug")("torrent-discovery"),s=e("bittorrent-dht/client"),r=e("events").EventEmitter,a=e("run-parallel"),o=e("bittorrent-tracker/client"),c=e("bittorrent-lsd");t.exports=class extends r{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")===this.infoHash&&this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")},this._onLSDPeer=(e,t)=>{this.emit("peer",e,"lsd")};const t=(e,t)=>{const n=new s(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),!1===e.dht||"function"!=typeof s?this.dht=null:e.dht&&"function"==typeof e.dht.addNode?this.dht=e.dht:e.dht&&"object"==typeof e.dht?this.dht=t(e.dhtPort,e.dht):this.dht=t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce()),!1===e.lsd||"function"!=typeof c?this.lsd=null:this.lsd=this._createLSD()}updatePort(e){e!==this._port&&(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy((()=>{this.tracker=this._createTracker()}))))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(this.destroyed)return;this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push((e=>{this.tracker.destroy(e)}))),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push((e=>{this.dht.destroy(e)}))),this.lsd&&(this.lsd.removeListener("warning",this._onWarning),this.lsd.removeListener("error",this._onError),this.lsd.removeListener("peer",this._onLSDPeer),t.push((e=>{this.lsd.destroy(e)}))),a(t,e),this.dht=null,this.tracker=null,this.lsd=null,this._announce=null}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new o(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(i("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,(e=>{this._dhtAnnouncing=!1,i("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout((()=>{this._dhtAnnounce()}),this._intervalMs+Math.floor(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())})))}_createLSD(){const e=Object.assign({},{infoHash:this.infoHash,peerId:this.peerId,port:this._port}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onLSDPeer),t.start(),t}}}).call(this)}).call(this,e("_process"))},{_process:186,"bittorrent-dht/client":54,"bittorrent-lsd":54,"bittorrent-tracker/client":30,debug:290,events:97,"run-parallel":217}],290:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":291,_process:186,dup:12}],291:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:292}],292:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],293:[function(e,t,n){(function(e){(function(){const n=16384;class i{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const e=this._Line truncated
|
||||||
/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
/*! ut_metadata. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
||||||
const{EventEmitter:i}=e("events"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("ut_metadata"),o=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new r(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7<e.metadata_size||e.metadata_size<=0?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/c),this._remainingRejects=2*this._numPieces,void this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const i=e.toString(),r=i.indexOf("ee")+2;t=s.decode(i.substring(0,r)),n=e.slice(r)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;a("set metadata");try{const t=s.decode(e).info;t&&(e=s.encode(t))}catch(e){}return(!this._infoHash||this._infoHash===o.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",s.encode({info:s.decode(this.metadata)})),!0)}_send(e,t){let i=s.encode(e);n.isBuffer(t)&&(i=n.concat([i,t])),this._wire.extended("ut_metadata",i)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const i={msg_type:1,piece:e};"number"==typeof n&&(i.total_size=n),this._send(i,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(!e)return;this.setMetadata(this.metadata)||this._failedMetadata()}_failedMetadata(){this._bitfield=new r(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:6,bitfield:300,buffer:59,debug:301,events:97,"simple-sha1":241}],300:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{dup:11}],301:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":302,_process:186,dup:12}],302:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:303}],303:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],304:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],305:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),s=e("events"),r=e("mp4-stream"),a=e("mp4-box-encoding"),o=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const l=1;t.exports=class extends s{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=r.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=s=>{"moov"===s.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,this.emit("error",e)}}))):s.length<4096?(t+=s.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=s.length,n.destroy(),this._decoLine truncated
|
const{EventEmitter:i}=e("events"),s=e("bencode"),r=e("bitfield").default,a=e("debug")("ut_metadata"),o=e("simple-sha1"),c=16384;t.exports=e=>{class t extends i{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new r(0,{grow:1e3}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7<e.metadata_size||e.metadata_size<=0?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/c),this._remainingRejects=2*this._numPieces,void this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const i=e.toString(),r=i.indexOf("ee")+2;t=s.decode(i.substring(0,r)),n=e.slice(r)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;a("set metadata");try{const t=s.decode(e).info;t&&(e=s.encode(t))}catch(e){}return(!this._infoHash||this._infoHash===o.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",s.encode({info:s.decode(this.metadata)})),!0)}_send(e,t){let i=s.encode(e);n.isBuffer(t)&&(i=n.concat([i,t])),this._wire.extended("ut_metadata",i)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const i={msg_type:1,piece:e};"number"==typeof n&&(i.total_size=n),this._send(i,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const i=this.metadata.slice(t,n);this._data(e,i,this._metadataSize)}_onData(e,t,n){t.length>c||!this._fetching||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))}_requestPieces(){if(this._fetching){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(!e)return;this.setMetadata(this.metadata)||this._failedMetadata()}_failedMetadata(){this._bitfield=new r(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this)}).call(this,e("buffer").Buffer)},{bencode:6,bitfield:300,buffer:59,debug:301,events:97,"simple-sha1":241}],300:[function(e,t,n){arguments[4][11][0].apply(n,arguments)},{dup:11}],301:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./common":302,_process:186,dup:12}],302:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{dup:13,ms:303}],303:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],304:[function(e,t,n){(function(e){(function(){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var i=!1;return function(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],305:[function(e,t,n){(function(n){(function(){const i=e("binary-search"),s=e("events"),r=e("mp4-stream"),a=e("mp4-box-encoding"),o=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}const l=1;t.exports=class extends s{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=r.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const i=s=>{"moov"===s.type?(this._decoder.removeListener("box",i),this._decoder.decode((e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,this.emit("error",e)}}))):s.length<4096?(t+=s.length,this._decoder.ignore()):(this._decoder.removeListener("box",i),t+=s.length,n.destroy(),this._decoLine truncated
|
||||||
/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
/*! webtorrent. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
|
||||||
const{EventEmitter:r}=e("events"),a=e("simple-concat"),o=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),h=e("path"),f=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),v=e("./lib/conn-pool"),b=e("./lib/torrent"),x=e("./package.json").version,_=x.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),y=`-WW${_}-`;class w extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:s.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=s.from(y+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=s.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:s.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=s.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=!0===e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof p&&null!=e.blocklist?p(e.blocklist,{headers:{"user-agent":`WebTorrent/${x} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error("Failed to load blocklist: "+e.message);this.blocked=n,t()})):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=d(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===r.infoHash&&e!==r)return void r._destroy(new Error("Cannot add duplicate torrent "+r.infoHash))},s=()=>{this.destroyed||(n(r),this.emit("torrent",r))};this._debug("add"),t=t?Object.assign({},t):{};const r=new b(e,this,t);return this.torrents.push(r),r.once("_infoHash",i),r.once("ready",s),r.once("close",(function e(){r.removeListener("_infoHash",i),r.removeListener("ready",s),r.removeListener("close",e)})),r}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=h.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+_);const s=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},r=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(t=>{if(!this.destroyed)return t?e._destroy(t):void s(e)}))}));let c;var l;return l=e,"undefined"!=typeof FileList&&l instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):a(e,t)})),((e,n)=>{if(!this.destroyed)return e?r._destroy(e):void o.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return r._destroy(e);c=i.map((e=>e.getStream)),o(n,t,((e,t)=>{if(this.destroyed)return;if(e)return r._destroy(e);const n=this.get(t);n?r._destroy(new Error("Cannot add duplicate torrent "+n.infoHash)):r._onTorrentId(t)}))}}))})),r}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error("No torrent with id "+e);this._remove(e,t,n)}_remove(e,tLine truncated
|
const{EventEmitter:r}=e("events"),a=e("simple-concat"),o=e("create-torrent"),c=e("debug")("webtorrent"),l=e("bittorrent-dht/client"),p=e("load-ip-set"),u=e("run-parallel"),d=e("parse-torrent"),h=e("path"),f=e("simple-peer"),m=e("randombytes"),g=e("speedometer"),v=e("./lib/conn-pool"),b=e("./lib/torrent"),x=e("./package.json").version,_=x.replace(/\d*./g,(e=>("0"+e%100).slice(-2))).slice(0,4),y=`-WW${_}-`;class w extends r{constructor(e={}){super(),"string"==typeof e.peerId?this.peerId=e.peerId:s.isBuffer(e.peerId)?this.peerId=e.peerId.toString("hex"):this.peerId=s.from(y+m(9).toString("base64")).toString("hex"),this.peerIdBuffer=s.from(this.peerId,"hex"),"string"==typeof e.nodeId?this.nodeId=e.nodeId:s.isBuffer(e.nodeId)?this.nodeId=e.nodeId.toString("hex"):this.nodeId=m(20).toString("hex"),this.nodeIdBuffer=s.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=void 0!==e.tracker?e.tracker:{},this.torrents=[],this.maxConns=Number(e.maxConns)||55,this.utp=!0===e.utp,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),i.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=i.WRTC)),"function"==typeof v?this._connPool=new v(this):n.nextTick((()=>{this._onListening()})),this._downloadSpeed=g(),this._uploadSpeed=g(),!1!==e.dht&&"function"==typeof l?(this.dht=new l(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",(e=>{this._destroy(e)})),this.dht.once("listening",(()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)})),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof p&&null!=e.blocklist?p(e.blocklist,{headers:{"user-agent":`WebTorrent/${x} (https://webtorrent.io)`}},((e,n)=>{if(e)return this.error("Failed to load blocklist: "+e.message);this.blocked=n,t()})):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter((e=>1!==e.progress));return e.reduce(((e,t)=>e+t.downloaded),0)/(e.reduce(((e,t)=>e+(t.length||0)),0)||1)}get ratio(){return this.torrents.reduce(((e,t)=>e+t.uploaded),0)/(this.torrents.reduce(((e,t)=>e+t.received),0)||1)}get(e){if(e instanceof b){if(this.torrents.includes(e))return e}else{let t;try{t=d(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n=(()=>{})){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const i=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===r.infoHash&&e!==r)return void r._destroy(new Error("Cannot add duplicate torrent "+r.infoHash))},s=()=>{this.destroyed||(n(r),this.emit("torrent",r))};this._debug("add"),t=t?Object.assign({},t):{};const r=new b(e,this,t);return this.torrents.push(r),r.once("_infoHash",i),r.once("ready",s),r.once("close",(function e(){r.removeListener("_infoHash",i),r.removeListener("ready",s),r.removeListener("close",e)})),r}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),(t=t?Object.assign({},t):{}).skipVerify=!0;const i="string"==typeof e;i&&(t.path=h.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+_);const s=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},r=this.add(null,t,(e=>{const t=[t=>{if(i)return t();e.load(c,t)}];this.dht&&t.push((t=>{e.once("dhtAnnounce",t)})),u(t,(t=>{if(!this.destroyed)return t?e._destroy(t):void s(e)}))}));let c;var l;return l=e,"undefined"!=typeof FileList&&l instanceof FileList?e=Array.from(e):Array.isArray(e)||(e=[e]),u(e.map((e=>t=>{!function(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}(e)?t(null,e):a(e,t)})),((e,n)=>{if(!this.destroyed)return e?r._destroy(e):void o.parseInput(n,t,((e,i)=>{if(!this.destroyed){if(e)return r._destroy(e);c=i.map((e=>e.getStream)),o(n,t,((e,t)=>{if(this.destroyed)return;if(e)return r._destroy(e);const n=this.get(t);n?r._destroy(new Error("Cannot add duplicate torrent "+n.infoHash)):r._onTorrentId(t)}))}}))})),r}remove(e,t,n){if("function"==typeof t)return this.remove(e,null,t);this._debug("remove");if(!this.get(e))throw new Error("No torrent with id "+e);this._remove(e,t,n)}_remove(e,tLine truncated
|
||||||
+5
-8
@@ -102,13 +102,12 @@
|
|||||||
<div class="property">
|
<div class="property">
|
||||||
<div>
|
<div>
|
||||||
<label for="urlList">Webseed URLs</label>
|
<label for="urlList">Webseed URLs</label>
|
||||||
<button id="removeWebseeds">
|
<br />
|
||||||
<span class="fas fa-eraser"></span>
|
<a id="removeWebseeds">Remove All</a>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button id="addWebseed" data-type="urlList">
|
<button id="addWebseed" data-type="urlList">
|
||||||
<span class="far fa-plus-circle"></span> Add Tracker
|
<span class="far fa-plus-circle"></span> Add Webseed
|
||||||
</button>
|
</button>
|
||||||
<div id="urlList"></div>
|
<div id="urlList"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -117,9 +116,7 @@
|
|||||||
<div class="property">
|
<div class="property">
|
||||||
<div>
|
<div>
|
||||||
<label for="files">Files</label>
|
<label for="files">Files</label>
|
||||||
<button id="getFiles">
|
<a id="getFiles">Attempt to Fetch Files from WebTorrent</a>
|
||||||
<span class="fad fa-chart-network"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<table id="files">
|
<table id="files">
|
||||||
<tbody id="filesBody"></tbody>
|
<tbody id="filesBody"></tbody>
|
||||||
@@ -128,7 +125,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="bundle.min.js"></script>
|
<script src="bundle.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -89,13 +89,14 @@ function start() {
|
|||||||
|
|
||||||
if (window.location.hash) {
|
if (window.location.hash) {
|
||||||
originalSourceIcon.innerHTML = '<span class="fad fa-link fa-fw"></span>';
|
originalSourceIcon.innerHTML = '<span class="fad fa-link fa-fw"></span>';
|
||||||
originalSourceIcon.title = 'Originally sourced from Magnet URL in the address bar of this site';
|
originalSourceIcon.title = 'Originally sourced from shared torrent.parts link';
|
||||||
parse(window.location.hash.split('#')[1]);
|
parse(window.location.hash.split('#')[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(toLoad) {
|
function parse(toLoad) {
|
||||||
|
resetProperties();
|
||||||
try {
|
try {
|
||||||
console.info("Attempting parse");
|
console.info("Attempting parse");
|
||||||
parsed = parser(toLoad);
|
parsed = parser(toLoad);
|
||||||
@@ -131,15 +132,15 @@ function display() {
|
|||||||
resetProperties();
|
resetProperties();
|
||||||
|
|
||||||
hash.value = parsed.infoHash;
|
hash.value = parsed.infoHash;
|
||||||
name.value = parsed.name || "";
|
name.value = parsed.name ? parsed.name : "";
|
||||||
if (parsed.created) {
|
if (parsed.created) {
|
||||||
created.value = parsed.created.toISOString().slice(0, 19);
|
created.value = parsed.created.toISOString().slice(0, 19);
|
||||||
created.type = "datetime-local";
|
created.type = "datetime-local";
|
||||||
} else {
|
} else {
|
||||||
created.type = "text";
|
created.type = "text";
|
||||||
}
|
}
|
||||||
createdBy.value = "by " + parsed.createdBy || "";
|
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
|
||||||
comment.value = parsed.comment || "";
|
comment.value = parsed.comment ? parsed.comment : "";
|
||||||
|
|
||||||
announce.innerHTML = "";
|
announce.innerHTML = "";
|
||||||
if (parsed.announce && parsed.announce.length) {
|
if (parsed.announce && parsed.announce.length) {
|
||||||
@@ -154,9 +155,9 @@ function display() {
|
|||||||
tracker.dataset.group = 'announce';
|
tracker.dataset.group = 'announce';
|
||||||
tracker.addEventListener('input', propertyChange);
|
tracker.addEventListener('input', propertyChange);
|
||||||
row.appendChild(tracker);
|
row.appendChild(tracker);
|
||||||
let remove = document.createElement('button');
|
let remove = document.createElement('a');
|
||||||
remove.dataset.index = i;
|
remove.dataset.index = i;
|
||||||
remove.innerHTML = '<span class="fas fa-minus"></span>';
|
remove.innerHTML = '<span class="far fa-trash"></span>';
|
||||||
remove.addEventListener('click', removeRow);
|
remove.addEventListener('click', removeRow);
|
||||||
row.appendChild(remove);
|
row.appendChild(remove);
|
||||||
announce.appendChild(row);
|
announce.appendChild(row);
|
||||||
@@ -191,7 +192,7 @@ function display() {
|
|||||||
|
|
||||||
files.innerHTML = "";
|
files.innerHTML = "";
|
||||||
if (parsed.files && parsed.files.length) {
|
if (parsed.files && parsed.files.length) {
|
||||||
getFiles.disabled = true;
|
getFiles.style.display = "none";
|
||||||
for (let file of parsed.files) {
|
for (let file of parsed.files) {
|
||||||
let icon = getFontAwesomeIconForMimetype(mime.lookup(file.name));
|
let icon = getFontAwesomeIconForMimetype(mime.lookup(file.name));
|
||||||
files.appendChild(createFileRow(icon, file.name, file.length));
|
files.appendChild(createFileRow(icon, file.name, file.length));
|
||||||
@@ -200,8 +201,12 @@ function display() {
|
|||||||
downloadTorrent.addEventListener('click', saveTorrent);
|
downloadTorrent.addEventListener('click', saveTorrent);
|
||||||
downloadTorrent.disabled = false;
|
downloadTorrent.disabled = false;
|
||||||
} else {
|
} else {
|
||||||
getFiles.disabled = false;
|
getFiles.style.display = "block";
|
||||||
|
if (client.torrents.length > 0) {
|
||||||
|
files.innerHTML = "<em>Attempting fetching files from Webtorrent...</em>";
|
||||||
|
} else {
|
||||||
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>";
|
files.innerHTML = "<em>Files information isn't included in the URL/File provided</em>";
|
||||||
|
}
|
||||||
downloadTorrent.removeEventListener('click', saveTorrent);
|
downloadTorrent.removeEventListener('click', saveTorrent);
|
||||||
downloadTorrent.disabled = true;
|
downloadTorrent.disabled = true;
|
||||||
}
|
}
|
||||||
@@ -277,9 +282,9 @@ function getFontAwesomeIconForMimetype(mimetype) {
|
|||||||
|
|
||||||
function propertyChange(e) {
|
function propertyChange(e) {
|
||||||
if (this.dataset.group) {
|
if (this.dataset.group) {
|
||||||
parsed[this.dataset.group][this.dataset.index] = this.value || "";
|
parsed[this.dataset.group][this.dataset.index] = this.value ? this.value : "";
|
||||||
} else {
|
} else {
|
||||||
parsed[this.id] = this.value || "";
|
parsed[this.id] = this.value ? this.value : "";
|
||||||
}
|
}
|
||||||
window.location.hash = parser.toMagnetURI(parsed);
|
window.location.hash = parser.toMagnetURI(parsed);
|
||||||
updateModified();
|
updateModified();
|
||||||
@@ -297,8 +302,7 @@ function resetProperties() {
|
|||||||
announce.innerHTML = "";
|
announce.innerHTML = "";
|
||||||
urlList.innerHTML = "";
|
urlList.innerHTML = "";
|
||||||
client.torrents.forEach(torrent => torrent.destroy());
|
client.torrents.forEach(torrent => torrent.destroy());
|
||||||
getFiles.disabled = false;
|
getFiles.style.display = "block";
|
||||||
getFiles.innerHTML = '<span class="fad fa-chart-network"></span>';
|
|
||||||
files.innerHTML = "";
|
files.innerHTML = "";
|
||||||
window.location.hash = "";
|
window.location.hash = "";
|
||||||
copyURL.setAttribute('data-clipboard-text', "");
|
copyURL.setAttribute('data-clipboard-text', "");
|
||||||
@@ -345,29 +349,34 @@ function removeAllRows(type) {
|
|||||||
function updateModified() {
|
function updateModified() {
|
||||||
parsed.created = new Date();
|
parsed.created = new Date();
|
||||||
parsed.createdBy = "Torrent Parts <https://torrent.parts/>";
|
parsed.createdBy = "Torrent Parts <https://torrent.parts/>";
|
||||||
|
if (parsed.created) {
|
||||||
|
created.value = parsed.created.toISOString().slice(0, 19);
|
||||||
|
created.type = "datetime-local";
|
||||||
|
} else {
|
||||||
|
created.type = "text";
|
||||||
|
}
|
||||||
|
createdBy.value = parsed.createdBy ? "by " + parsed.createdBy : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilesFromPeers() {
|
function getFilesFromPeers() {
|
||||||
console.info("Attempting fetching files from Webtorrent");
|
console.info("Attempting fetching files from Webtorrent...");
|
||||||
|
getFiles.style.display = "none";
|
||||||
parsed.announce.push("wss://tracker.webtorrent.io");
|
parsed.announce.push("wss://tracker.webtorrent.io");
|
||||||
parsed.announce.push("wss://tracker.openwebtorrent.com");
|
parsed.announce.push("wss://tracker.openwebtorrent.com");
|
||||||
parsed.announce.push("wss://tracker.btorrent.xyz");
|
parsed.announce.push("wss://tracker.btorrent.xyz");
|
||||||
parsed.announce.push("wss://tracker.fastcast.nz");
|
parsed.announce.push("wss://tracker.fastcast.nz");
|
||||||
parsed.announce = parsed.announce.filter((v,i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
parsed.announce = parsed.announce.filter((v,i) => v && parsed.announce.indexOf(v) === i); // remove duplicates and empties
|
||||||
display();
|
|
||||||
getFiles.disabled = true;
|
|
||||||
getFiles.innerHTML = '<span class="fa-blink fad fa-chart-network"></span>';
|
|
||||||
client.add(parser.toMagnetURI(parsed), (torrent) => {
|
client.add(parser.toMagnetURI(parsed), (torrent) => {
|
||||||
parsed.info = Object.assign({}, torrent.info); // clone object
|
parsed.info = Object.assign({}, torrent.info); // clone object
|
||||||
parsed.files = torrent.files;
|
parsed.files = torrent.files;
|
||||||
parsed.infoBuffer = torrent.infoBuffer;
|
parsed.infoBuffer = torrent.infoBuffer;
|
||||||
parsed.length = torrent.length;
|
parsed.length = torrent.length;
|
||||||
parsed.lastPieceLength = torrent.lastPieceLength;
|
parsed.lastPieceLength = torrent.lastPieceLength;
|
||||||
getFiles.innerHTML = '<span class="fad fa-chart-network"></span>';
|
|
||||||
updateModified();
|
updateModified();
|
||||||
display();
|
display();
|
||||||
torrent.destroy();
|
torrent.destroy();
|
||||||
});
|
});
|
||||||
|
display();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/a/36899900/2700296
|
// https://stackoverflow.com/a/36899900/2700296
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:b
|
|||||||
--accent: #63A079;
|
--accent: #63A079;
|
||||||
--grey: #BDBDBD;
|
--grey: #BDBDBD;
|
||||||
--white: #FFF;
|
--white: #FFF;
|
||||||
|
background: #24384D;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@@ -16,6 +17,7 @@ body {
|
|||||||
font-family: 'Alata', sans-serif;
|
font-family: 'Alata', sans-serif;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
@@ -52,17 +54,19 @@ button {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-radius: 900px;
|
border-radius: 900px;
|
||||||
text-align: center;
|
text-align: left;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:disabled {
|
button:disabled {
|
||||||
filter: brightness(0.6);
|
filter: brightness(0.6);
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
@@ -170,13 +174,17 @@ input {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-radius: 900px;
|
border-radius: 900px;
|
||||||
text-align: left;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#announce > *, #urlList > * {
|
||||||
|
margin: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 1080px) {
|
@media (max-width: 1080px) {
|
||||||
|
|
||||||
#reset {
|
#reset {
|
||||||
|
width: auto;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
}
|
}
|
||||||
@@ -192,6 +200,7 @@ input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#download > * {
|
#download > * {
|
||||||
|
width: auto;
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +220,7 @@ input {
|
|||||||
#properties {
|
#properties {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 2vw;
|
padding: 0 2vw;
|
||||||
width: 96vw;
|
width: 95vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.property {
|
.property {
|
||||||
@@ -225,7 +234,8 @@ input {
|
|||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input, button, #addTracker, #addWebseed {
|
||||||
|
width: 95vw;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user