diff --git a/install/node-Tor-min.js b/install/node-Tor-min.js index 0f8ef39..1d91d75 100644 --- a/install/node-Tor-min.js +++ b/install/node-Tor-min.js @@ -156,16 +156,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ !function(){var e=!1;if("undefined"!=typeof require)var t=require("buffer").Buffer;var r=!1,s=!1,a=!1,o="",c=!0,l=!1,h=!1,u=!1,d=!1,f=!1,p=!1,_=!1,g=!1,m=!1,y=!1,v=!1,b=!1,w=!1,E="undefined"!=typeof WebSocket?!1:a?!1:!0,C=a,C=!1,S=!1,A=E||a?!1:!0,I=!1,T=!1,x=!1;if(A&&!I){process={},process.on=function(){},process.platform={indexOf:function(){}};var t=function(){};require=function(e){var t=function(){},r={};switch(r.Rsa=t,r.PEM=t,r.Hash=null,r.Guards=[],r.Relays=[],r.Dirs=[],r.Exit=[],e){case"fs":var i={};return i.openSync=t,i.writeSync=t,i.closeSync=t,i.open=function(e,t,r){r()},i.write=t,i.close=t,i.unlinkSync=t,i.readFileSync=t,i.readFile=t,i.stat=t,i.rename=t,i;case"domain":var n={};return n.create=function(){return{on:function(){},run:function(e){e()}}},n;case"child_process":var s={};return s.exec=t,s;case o+"crypto.js":return r;case o+"guards.js":return r;case o+"relays.js":return r;case o+"dirs.js":return r;case o+"exit.js":return r;default:return t}}}var B=require("domain").create();B.on("error",function(e){console.error("Caught error ",e.stack)}),B.run(function(){function B(e,t,r){return e>=t&&r>=e}function k(e,t){return Math.floor(e/t)}function R(e){var t=0;this.get=function(){return t>=e.length?Nc:Number(e[t])},this.offset=function(r){if(t+=r,0>t)throw new Error("Seeking past start of the buffer");if(t>e.length)throw new Error("Seeking past EOF")},this.match=function(r){if(r.length>t+e.length)return!1;var i;for(i=0;ir)throw new Error("Seeking past start of the buffer");if(r>i.length)throw new Error("Seeking past EOF")},this.get=function(){return r>=i.length?Lc:i[r]}}function N(){var e="";this.string=function(){return e},this.emit=function(t){65535>=t?e+=String.fromCharCode(t):(t-=65536,e+=String.fromCharCode(55296+(1023&t>>10)),e+=String.fromCharCode(56320+(1023&t)))}}function L(e){this.name="EncodingError",this.message=e,this.code=0}function O(e,t){if(e)throw new L("Decoder error");return t||65533}function P(e){throw new L("The code point "+e+" could not be encoded.")}function F(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(Fc,e)?Fc[e]:null}function q(e,t){return(t||[])[e]||null}function H(e,t){var r=t.indexOf(e);return-1===r?null:r}function M(e){if(e>39419&&189e3>e||e>1237575)return null;var t,r=0,i=0,n=qc.gb18030;for(t=0;t0;){var a=k(r,Math.pow(64,i-1));s=e.emit(128+a%64),i-=1}return s}}function K(e,t){var r=t.fatal;this.decode=function(t){var i=t.get();if(i===Nc)return Lc;if(t.offset(1),B(i,0,127))return i;var n=e[i-128];return null===n?O(r):n}}function G(e,t){t.fatal,this.encode=function(t,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127))return t.emit(i);var n=H(i,e);return null===n&&P(i),t.emit(n+128)}}function Y(e,t){var r=t.fatal,i=0,n=0,s=0;this.decode=function(t){var a=t.get();if(a===Nc&&0===i&&0===n&&0===s)return Lc;a!==Nc||0===i&&0===n&&0===s||(i=0,n=0,s=0,O(r)),t.offset(1);var o;if(0!==s)return o=null,B(a,48,57)&&(o=M(10*(126*(10*(i-129)+(n-48))+(s-129))+a-48)),i=0,n=0,s=0,null===o?(t.offset(-3),O(r)):o;if(0!==n)return B(a,129,254)?(s=a,null):(t.offset(-2),i=0,n=0,O(r));if(0!==i){if(B(a,48,57)&&e)return n=a,null;var c=i,l=null;i=0;var h=127>a?64:65;return(B(a,64,126)||B(a,128,254))&&(l=190*(c-129)+(a-h)),o=null===l?null:q(l,qc.gbk),null===l&&t.offset(-1),null===o?O(r):o}return B(a,0,127)?a:128===a?8364:B(a,129,254)?(i=a,null):O(r)}}function W(e,t){t.fatal,this.encode=function(t,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127))return t.emit(i);var n=H(i,qc.gbk);if(null!==n){var s=k(n,190)+129,a=n%190,o=63>a?64:65;return t.emit(s,a+o)}if(null===n&&!e)return P(i);n=j(i);var c=k(k(k(n,10),126),10);n-=10*126*10*c;var l=k(k(n,10),126);n-=126*10*l;var h=k(n,10),u=n-10*h;return t.emit(c+129,l+48,h+129,u+48)}}function Q(e){var t=e.fatal,r=!1,i=0;this.decode=function(e){var n=e.get();if(n===Nc&&0===i)return Lc;if(n===Nc&&0!==i)return i=0,O(t);if(e.offset(1),126===i)return i=0,123===n?(r=!0,null):125===n?(r=!1,null):126===n?126:10===n?null:(e.offset(-1),O(t));if(0!==i){var s=i;i=0;var a=null;return B(n,33,126)&&(a=q(190*(s-1)+(n+63),qc.gbk)),10===n&&(r=!1),null===a?O(t):a}return 126===n?(i=126,null):r?B(n,32,127)?(i=n,null):(10===n&&(r=!1),O(t)):B(n,0,127)?n:O(t)}}function X(e){e.fatal;var t=!1;this.encode=function(e,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127)&&t)return r.offset(-1),t=!1,e.emit(126,125);if(126===i)return e.emit(126,126);if(B(i,0,127))return e.emit(i);if(!t)return r.offset(-1),t=!0,e.emit(126,123);var n=H(i,qc.gbk);if(null===n)return P(i);var s=k(n,190)+1,a=n%190-63;return B(s,33,126)&&B(a,33,126)?e.emit(s,a):P(i)}}function J(e){var t=e.fatal,r=0,i=null;this.decode=function(e){if(null!==i){var n=i;return i=null,n}var s=e.get();if(s===Nc&&0===r)return Lc;if(s===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var a=r,o=null;r=0;var c=127>s?64:98;if((B(s,64,126)||B(s,161,254))&&(o=157*(a-129)+(s-c)),1133===o)return i=772,202;if(1135===o)return i=780,202;if(1164===o)return i=772,234;if(1166===o)return i=780,234;var l=null===o?null:q(o,qc.big5);return null===o&&e.offset(-1),null===l?O(t):l}return B(s,0,127)?s:B(s,129,254)?(r=s,null):O(t)}}function Z(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);var i=H(r,qc.big5);if(null===i)return P(r);var n=k(i,157)+129,s=i%157,a=63>s?64:98;return e.emit(n,s+a)}}function $(e){var t=e.fatal,r=0,i=0;this.decode=function(e){var n=e.get();if(n===Nc)return 0===r&&0===i?Lc:(r=0,i=0,O(t));e.offset(1);var s,a;return 0!==i?(s=i,i=0,a=null,B(s,161,254)&&B(n,161,254)&&(a=q(94*(s-161)+n-161,qc.jis0212)),B(n,161,254)||e.offset(-1),null===a?O(t):a):142===r&&B(n,161,223)?(r=0,65377+n-161):143===r&&B(n,161,254)?(r=0,i=n,null):0!==r?(s=r,r=0,a=null,B(s,161,254)&&B(n,161,254)&&(a=q(94*(s-161)+n-161,qc.jis0208)),B(n,161,254)||e.offset(-1),null===a?O(t):a):B(n,0,127)?n:142===n||143===n||B(n,161,254)?(r=n,null):O(t)}}function et(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);if(165===r)return e.emit(92);if(8254===r)return e.emit(126);if(B(r,65377,65439))return e.emit(142,r-65377+161);var i=H(r,qc.jis0208);if(null===i)return P(r);var n=k(i,94)+161,s=i%94+161;return e.emit(n,s)}}function tt(e){var t=e.fatal,r={ASCII:0,escape_start:1,escape_middle:2,escape_final:3,lead:4,trail:5,Katakana:6},i=r.ASCII,n=!1,s=0;this.decode=function(e){var a=e.get();switch(a!==Nc&&e.offset(1),i){default:case r.ASCII:return 27===a?(i=r.escape_start,null):B(a,0,127)?a:a===Nc?Lc:O(t);case r.escape_start:return 36===a||40===a?(s=a,i=r.escape_middle,null):(a!==Nc&&e.offset(-1),i=r.ASCII,O(t));case r.escape_middle:var o=s;return s=0,36!==o||64!==a&&66!==a?36===o&&40===a?(i=r.escape_final,null):40!==o||66!==a&&74!==a?40===o&&73===a?(i=r.Katakana,null):(a===Nc?e.offset(-1):e.offset(-2),i=r.ASCII,O(t)):(i=r.ASCII,null):(n=!1,i=r.lead,null);case r.escape_final:return 68===a?(n=!0,i=r.lead,null):(a===Nc?e.offset(-2):e.offset(-3),i=r.ASCII,O(t));case r.lead:return 10===a?(i=r.ASCII,O(t,10)):27===a?(i=r.escape_start,null):a===Nc?Lc:(s=a,i=r.trail,null);case r.trail:if(i=r.lead,a===Nc)return O(t);var c=null,l=94*(s-33)+a-33;return B(s,33,126)&&B(a,33,126)&&(c=n===!1?q(l,qc.jis0208):q(l,qc.jis0212)),null===c?O(t):c;case r.Katakana:return 27===a?(i=r.escape_start,null):B(a,33,95)?65377+a-33:a===Nc?Lc:O(t)}}}function rt(e){e.fatal;var t={ASCII:0,lead:1,Katakana:2},r=t.ASCII;this.encode=function(e,i){var n=i.get();if(n===Lc)return Nc;if(i.offset(1),(B(n,0,127)||165===n||8254===n)&&r!==t.ASCII)return i.offset(-1),r=t.ASCII,e.emit(27,40,66);if(B(n,0,127))return e.emit(n);if(165===n)return e.emit(92);if(8254===n)return e.emit(126);if(B(n,65377,65439)&&r!==t.Katakana)return i.offset(-1),r=t.Katakana,e.emit(27,40,73);if(B(n,65377,65439))return e.emit(n-65377-33);if(r!==t.lead)return i.offset(-1),r=t.lead,e.emit(27,36,66);var s=H(n,qc.jis0208);if(null===s)return P(n);var a=k(s,94)+33,o=s%94+33;return e.emit(a,o)}}function it(e){var t=e.fatal,r=0;this.decode=function(e){var i=e.get();if(i===Nc&&0===r)return Lc;if(i===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var n=r;if(r=0,B(i,64,126)||B(i,128,252)){var s=127>i?64:65,a=160>n?129:193,o=q(188*(n-a)+i-s,qc.jis0208);return null===o?O(t):o}return e.offset(-1),O(t)}return B(i,0,128)?i:B(i,161,223)?65377+i-161:B(i,129,159)||B(i,224,252)?(r=i,null):O(t)}}function nt(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,128))return e.emit(r);if(165===r)return e.emit(92);if(8254===r)return e.emit(126);if(B(r,65377,65439))return e.emit(r-65377+161);var i=H(r,qc.jis0208);if(null===i)return P(r);var n=k(i,188),s=31>n?129:193,a=i%188,o=63>a?64:65;return e.emit(n+s,a+o)}}function st(e){var t=e.fatal,r=0;this.decode=function(e){var i=e.get();if(i===Nc&&0===r)return Lc;if(i===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var n=r,s=null;if(r=0,B(n,129,198)){var a=178*(n-129);B(i,65,90)?s=a+i-65:B(i,97,122)?s=a+26+i-97:B(i,129,254)&&(s=a+26+26+i-129)}B(n,199,253)&&B(i,161,254)&&(s=12460+94*(n-199)+(i-161));var o=null===s?null:q(s,qc["euc-kr"]);return null===s&&e.offset(-1),null===o?O(t):o}return B(i,0,127)?i:B(i,129,253)?(r=i,null):O(t)}}function at(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);var i=H(r,qc["euc-kr"]);if(null===i)return P(r);var n,s;if(12460>i){n=k(i,178)+129,s=i%178;var a=26>s?65:52>s?71:77;return e.emit(n,s+a)}return i-=12460,n=k(i,94)+199,s=i%94+161,e.emit(n,s)}}function ot(e){var t=e.fatal,r={ASCII:0,escape_start:1,escape_middle:2,escape_end:3,lead:4,trail:5},i=r.ASCII,n=0;this.decode=function(e){var s=e.get();switch(s!==Nc&&e.offset(1),i){default:case r.ASCII:return 14===s?(i=r.lead,null):15===s?null:27===s?(i=r.escape_start,null):B(s,0,127)?s:s===Nc?Lc:O(t);case r.escape_start:return 36===s?(i=r.escape_middle,null):(s!==Nc&&e.offset(-1),i=r.ASCII,O(t));case r.escape_middle:return 41===s?(i=r.escape_end,null):(s===Nc?e.offset(-1):e.offset(-2),i=r.ASCII,O(t));case r.escape_end:return 67===s?(i=r.ASCII,null):(s===Nc?e.offset(-2):e.offset(-3),i=r.ASCII,O(t));case r.lead:return 10===s?(i=r.ASCII,O(t,10)):14===s?null:15===s?(i=r.ASCII,null):s===Nc?Lc:(n=s,i=r.trail,null);case r.trail:if(i=r.lead,s===Nc)return O(t);var a=null;return B(n,33,70)&&B(s,33,126)?a=q(178*(n-1)+26+26+s-1,qc["euc-kr"]):B(n,71,126)&&B(s,33,126)&&(a=q(12460+94*(n-71)+(s-33),qc["euc-kr"])),null!==a?a:O(t)}}}function ct(e){e.fatal;var t={ASCII:0,lead:1},r=!1,i=t.ASCII;this.encode=function(e,n){var s=n.get();if(s===Lc)return Nc;if(r||(r=!0,e.emit(27,36,41,67)),n.offset(1),B(s,0,127)&&i!==t.ASCII)return n.offset(-1),i=t.ASCII,e.emit(15);if(B(s,0,127))return e.emit(s);if(i!==t.lead)return n.offset(-1),i=t.lead,e.emit(14);var a=H(s,qc["euc-kr"]);if(null===a)return P(s);var o,c;return 12460>a?(o=k(a,178)+1,c=a%178-26-26+1,B(o,33,70)&&B(c,33,126)?e.emit(o,c):P(s)):(a-=12460,o=k(a,94)+71,c=a%94+33,B(o,71,126)&&B(c,33,126)?e.emit(o,c):P(s))}}function lt(e,t){var r=t.fatal,i=null,n=null;this.decode=function(t){var s=t.get();if(s===Nc&&null===i&&null===n)return Lc;if(s===Nc&&(null!==i||null!==n))return O(r);if(t.offset(1),null===i)return i=s,null;var a;if(a=e?(i<<8)+s:(s<<8)+i,i=null,null!==n){var o=n;return n=null,B(a,56320,57343)?65536+1024*(o-55296)+(a-56320):(t.offset(-2),O(r))}return B(a,55296,56319)?(n=a,null):B(a,56320,57343)?O(r):a}}function ht(e,t){t.fatal,this.encode=function(t,r){function i(r){var i=r>>8,n=255&r;return e?t.emit(i,n):t.emit(n,i)}var n=r.get();if(n===Lc)return Nc;if(r.offset(1),B(n,55296,57343)&&P(n),65535>=n)return i(n);var s=k(n-65536,1024)+55296,a=(n-65536)%1024+56320;return i(s),i(a)}}function ut(e,t){return t.match([255,254])&&"utf-16"===e?(t.offset(2),void 0):t.match([254,255])&&"utf-16be"==e?(t.offset(2),void 0):t.match([239,187,191])&&"utf-8"==e?(t.offset(3),void 0):void 0}function dt(e,t){if(e=e?String(e):Hc,t=Object(t),this._encoding=F(e),null===this._encoding||"utf-8"!==this._encoding.name&&"utf-16"!==this._encoding.name&&"utf-16be"!==this._encoding.name)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function ft(e,t){if(e=e?String(e):Hc,t=Object(t),this._encoding=F(e),null===this._encoding)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._decoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function pt(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function _t(){return new pt(null)}function gt(e,t,r,i,n,s){for(;--s>=0;){var a=t*this[e++]+r[i]+n;n=Math.floor(a/67108864),r[i++]=67108863&a}return n}function mt(e,t,r,i,n,s){for(var a=32767&t,o=t>>15;--s>=0;){var c=32767&this[e],l=this[e++]>>15,h=o*c+l*a;c=a*c+((32767&h)<<15)+r[i]+(1073741823&n),n=(c>>>30)+(h>>>15)+o*l+(n>>>30),r[i++]=1073741823&c}return n}function yt(e,t,r,i,n,s){for(var a=16383&t,o=t>>14;--s>=0;){var c=16383&this[e],l=this[e++]>>14,h=o*c+l*a;c=a*c+((16383&h)<<14)+r[i]+n,n=(c>>28)+(h>>14)+o*l,r[i++]=268435455&c}return n}function vt(e){return Wc.charAt(e)}function bt(e,t){var r=Qc[e.charCodeAt(t)];return null==r?-1:r}function wt(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function Et(e){this.t=1,this.s=0>e?-1:0,e>0?this[0]=e:-1>e?this[0]=e+DV:this.t=0}function Ct(e){var t=_t();return t.fromInt(e),t}function St(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.fromRadix(e,t),void 0;r=2}this.t=0,this.s=0;for(var i=e.length,n=!1,s=0;--i>=0;){var a=8==r?255&e[i]:bt(e,i);0>a?"-"==e.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function It(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,i=(1<0)for(o>o)>0&&(n=!0,s=vt(r));a>=0;)t>o?(r=(this[a]&(1<>(o+=this.DB-t)):(r=this[a]>>(o-=t)&i,0>=o&&(o+=this.DB,--a)),r>0&&(n=!0),n&&(s+=vt(r));return n?s:"0"}function Tt(){var e=_t();return pt.ZERO.subTo(this,e),e}function xt(){return this.s<0?this.negate():this}function Bt(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(t=r-e.t,0!=t)return t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}function kt(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Rt(){return this.t<=0?0:this.DB*(this.t-1)+kt(this[this.t-1]^this.s&this.DM)}function Ut(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}function Dt(e,t){for(var r=e;r=0;--r)t[r+a+1]=this[r]>>n|o,o=(this[r]&s)<=0;--r)t[r]=0;t[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()}function Lt(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)return t.t=0,void 0;var i=e%this.DB,n=this.DB-i,s=(1<>i;for(var a=r+1;a>i;i>0&&(t[this.t-r-1]|=(this.s&s)<r;)i+=this[r]-e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=e.s}t.s=0>i?-1:0,-1>i?t[r++]=this.DV+i:i>0&&(t[r++]=i),t.t=r,t.clamp()}function Pt(e,t){var r=this.abs(),i=e.abs(),n=r.t;for(t.t=n+i.t;--n>=0;)t[n]=0;for(n=0;n=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}function qt(e,t,r){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t0?(i.lShiftTo(c,s),n.lShiftTo(c,r)):(i.copyTo(s),n.copyTo(r));var l=s.t,h=s[l-1];if(0!=h){var u=h*(1<1?s[l-2]>>this.F2:0),d=this.FV/u,f=(1<=0&&(r[r.t++]=1,r.subTo(m,r)),pt.ONE.dlShiftTo(l,m),m.subTo(s,s);s.t=0;){var y=r[--_]==h?this.DM:Math.floor(r[_]*d+(r[_-1]+p)*f);if((r[_]+=s.am(0,y,r,g,0,l))0&&r.rShiftTo(c,r),0>a&&pt.ZERO.subTo(r,r)}}}function Ht(e){var t=_t();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(pt.ZERO)>0&&e.subTo(t,t),t}function Mt(e){this.m=e}function jt(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function zt(e){return e}function Vt(e){e.divRemTo(this.m,null,e)}function Kt(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function Gt(e,t){e.squareTo(t),this.reduce(t)}function Yt(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return t=15&t*(2-(15&e)*t),t=255&t*(2-(255&e)*t),t=65535&t*(2-(65535&(65535&e)*t)),t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Wt(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function Xt(e){var t=_t();return e.copyTo(t),this.reduce(t),t}function Jt(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e[r]+=this.m.am(0,i,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Zt(e,t){e.squareTo(t),this.reduce(t)}function $t(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function er(){return 0==(this.t>0?1&this[0]:this.s)}function tr(e,t){if(e>4294967295||1>e)return pt.ONE;var r=_t(),i=_t(),n=t.convert(this),s=kt(e)-1;for(n.copyTo(r);--s>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,n,r);else{var a=r;r=i,i=a}return t.revert(r)}function rr(e,t){var r;return r=256>e||t.isEven()?new Mt(t):new Wt(t),this.exp(e,r)}function ir(){this.i=0,this.j=0,this.S=new Array}function nr(e){var t,r,i;for(t=0;256>t;++t)this.S[t]=t;for(r=0,t=0;256>t;++t)r=255&r+this.S[t]+e[t%e.length],i=this.S[t],this.S[t]=this.S[r],this.S[r]=i;this.i=0,this.j=0}function sr(){var e;return this.i=255&this.i+1,this.j=255&this.j+this.S[this.i],e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[255&e+this.S[this.i]]}function ar(){return new ir}function or(e){Jc[Zc++]^=255&e,Jc[Zc++]^=255&e>>8,Jc[Zc++]^=255&e>>16,Jc[Zc++]^=255&e>>24,Zc>=$c&&(Zc-=$c)}function cr(){or((new Date).getTime())}function lr(){if(null==Xc){for(cr(),Xc=ar(),Xc.init(Jc),Zc=0;Zc=1&&t>0;){var n=e[i--],s=e[i--];r[--t]=(bt(s,0)<<4)+bt(n,0)}r[--t]=0;for(var a=new ur,o=new Array;t>2;){for(o[0]=0;0==o[0];)a.nextBytes(o);r[--t]=o[0]}return r[--t]=2,r[--t]=0,new pt(r)}function pr(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function _r(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=dr(e,16),this.e=parseInt(t,16)):alert("Invalid RSA public key")}function gr(e){return e.modPowInt(this.e,this.n)}function mr(e){var t=fr(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var i=r.toString(16);return 0==(1&i.length)?i:"0"+i}function yr(){var e=_t();return this.copyTo(e),e}function vr(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function wr(){return 0==this.t?this.s:this[0]<<16>>16}function Er(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Cr(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Sr(e){if(null==e&&(e=10),0==this.signum()||2>e||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=Ct(r),n=_t(),s=_t(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(e)+a}function Ar(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),n=!1,s=0,a=0,o=0;oc?"-"==e.charAt(o)&&0==this.signum()&&(n=!0):(a=t*a+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),n&&pt.ZERO.subTo(this,this)}function Ir(e,t,r){if("number"==typeof t)if(2>e)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(pt.ONE.shiftLeft(e-1),Nr,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(pt.ONE.shiftLeft(e-1),this);else{var i=new Array,n=7&e;i.length=(e>>3)+1,t.nextBytes(i),n>0?i[0]&=(1<0)for(i>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<=0;)8>i?(r=(this[e]&(1<>(i+=this.DB-8)):(r=255&this[e]>>(i-=8),0>=i&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function xr(e){return 0==this.compareTo(e)}function Br(e){return this.compareTo(e)<0?this:e}function kr(e){return this.compareTo(e)>0?this:e}function Rr(e,t,r){var i,n,s=Math.min(e.t,this.t);for(i=0;s>i;++i)r[i]=t(this[i],e[i]);if(e.te?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function jr(e){var t=_t();return 0>e?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function zr(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Vr(){for(var e=0;e=this.t?0!=this.s:0!=(this[t]&1<r;)i+=this[r]+e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=e.s}t.s=0>i?-1:0,i>0?t[r++]=i:-1>i&&(t[r++]=this.DV+i),t.t=r,t.clamp()}function $r(e){var t=_t();return this.addTo(e,t),t}function ei(e){var t=_t();return this.subTo(e,t),t}function ti(e){var t=_t();return this.multiplyTo(e,t),t}function ri(){var e=_t();return this.squareTo(e),e}function ii(e){var t=_t();return this.divRemTo(e,t,null),t}function ni(e){var t=_t();return this.divRemTo(e,null,t),t}function si(e){var t=_t(),r=_t();return this.divRemTo(e,t,r),new Array(t,r)}function ai(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function oi(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}function ci(){}function li(e){return e}function hi(e,t,r){e.multiplyTo(t,r)}function ui(e,t){e.squareTo(t)}function di(e){return this.exp(e,new ci)}function fi(e,t,r){var i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;var n;for(n=r.t-this.t;n>i;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(n=Math.min(e.t,t);n>i;++i)this.am(0,e[i],r,i,0,t-i);r.clamp()}function pi(e,t,r){--t;var i=r.t=this.t+e.t-t;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(t-this.t,0);i2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=_t();return e.copyTo(t),this.reduce(t),t}function mi(e){return e}function yi(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function vi(e,t){e.squareTo(t),this.reduce(t)}function bi(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function wi(e,t){var r,i,n=e.bitLength(),s=Ct(1);if(0>=n)return s;r=18>n?1:48>n?3:144>n?4:768>n?5:6,i=8>n?new Mt(t):t.isEven()?new _i(t):new Wt(t);var a=new Array,o=3,c=r-1,l=(1<1){var h=_t();for(i.sqrTo(a[1],h);l>=o;)a[o]=_t(),i.mulTo(h,a[o-2],a[o]),o+=2}var u,d,f=e.t-1,p=!0,_=_t();for(n=kt(e[f])-1;f>=0;){for(n>=c?u=e[f]>>n-c&l:(u=(e[f]&(1<0&&(u|=e[f-1]>>this.DB+n-c)),o=r;0==(1&u);)u>>=1,--o;if((n-=o)<0&&(n+=this.DB,--f),p)a[u].copyTo(s),p=!1;else{for(;o>1;)i.sqrTo(s,_),i.sqrTo(_,s),o-=2;o>0?i.sqrTo(s,_):(d=s,s=_,_=d),i.mulTo(_,a[u],s)}for(;f>=0&&0==(e[f]&1<s)return t;for(s>n&&(s=n),s>0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function Ci(e){if(0>=e)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this[i])%e;return r}function Si(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return pt.ZERO;for(var r=e.clone(),i=this.clone(),n=Ct(1),s=Ct(0),a=Ct(0),o=Ct(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(e,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(i)>=0?(r.subTo(i,r),t&&n.subTo(a,n),s.subTo(o,s)):(i.subTo(r,i),t&&a.subTo(n,a),o.subTo(s,o))}return 0!=i.compareTo(pt.ONE)?pt.ZERO:o.compareTo(e)>=0?o.subtract(e):o.signum()<0?(o.addTo(e,o),o.signum()<0?o.add(e):o):o}function Ai(e){var t,r=this.abs();if(1==r.t&&r[0]<=rl[rl.length-1]){for(t=0;ti;)i*=rl[n++];for(i=r.modInt(i);n>t;)if(0==i%rl[t++])return!1}return r.millerRabin(e)}function Ii(e){var t=this.subtract(pt.ONE),r=t.getLowestSetBit();if(0>=r)return!1;var i=t.shiftRight(r);e=e+1>>1,e>rl.length&&(e=rl.length);for(var n=_t(),s=0;e>s;++s){n.fromInt(rl[Math.floor(Math.random()*rl.length)]);var a=n.modPow(i,this);if(0!=a.compareTo(pt.ONE)&&0!=a.compareTo(t)){for(var o=1;o++>3:null},a.DecoderConfigDescriptor=function(e){a.Descriptor.call(this,t,e)},a.DecoderConfigDescriptor.prototype=new a.Descriptor,a.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},a.DecoderSpecificInfo=function(e){a.Descriptor.call(this,r,e)},a.DecoderSpecificInfo.prototype=new a.Descriptor,a.SLConfigDescriptor=function(e){a.Descriptor.call(this,i,e)},a.SLConfigDescriptor.prototype=new a.Descriptor,this}function Bi(){this.boxes=new Array,this.mdats=new Array,this.moofs=new Array,this.isProgressive=!1,this.lastMoofIndex=0,this.lastPosition=0}function ki(){this.log_level=this.LOG_LEVEL_INFO,this.sampleListBuilt=!1,this.inputStream=null,this.inputIsoFile=null,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.fragmentedTracks=new Array,this.extractedTracks=new Array,this.isFragmentationStarted=!1,this.nextMoofNumber=0}var Ri=require("fs"),Ui=require("child_process"),Di=function(e,t){t+=" "+(new Date).toDateString()+" "+(new Date).toTimeString();var r=function(e,r){try{if(e||(Ri.write(r,t+"\n",function(){}),Ri.close(r)),A&&"undefined"!=typeof Wa){var i=Wa("console");i.innerHTML.length>1e6&&(i.innerHTML="");var n=document.createElement("p");n.className="log",n.innerHTML=t,i.appendChild(n)}}catch(s){}};try{Ri.open(o+Dn+"-"+e,"a",r)}catch(i){}};process.on("uncaughtException",function(e){var t=Ri.openSync("/debug.txt","a");Ri.writeSync(t,(new Date).toDateString()+" "+(new Date).toTimeString()),Ri.writeSync(t,e.stack),Ri.closeSync(t)}),process.on("exit",function(){setTimeout(function(){console.log("Process ended")},0),console.log("About to exit "+(new Date).toDateString()+" "+(new Date).toTimeString())});var Ni=console.log.bind(console),Li=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)},Oi=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)};console.log=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),(!a&&!S&&!c||-1!==process.platform.indexOf("win")&&T)&&Ni(e+" "+(new Date).toDateString()+" "+(new Date).toTimeString())};var Pi,Fi,qi,Hi,Mi,ji,zi;if(!A){if(process.argv&&process.argv.length>1){var Vi=process.argv.splice(2);if(5===Vi.length)Pi=Vi[0],Fi=Vi[1],qi=Vi[2],Hi=Vi[3],Mi=Vi[4];else{if(o=Vi[0]||"",o.length){if(-1===process.platform.indexOf("win")){var Ki=o[o.length-1];"/"!==Ki&&(o+="/")}}else Ni("Invalid directory parameter");if(T=!0,Vi.length>1)if("-P"!==Vi[1])ji=Vi[1],Vi.length>2&&(zi=!0);else{if(T=!1,x=!0,!(Vi.length>2))return;if(isNaN(parseInt(Vi[2])))return;Hi=parseInt(Vi[2])}}}var Gi=function(){console.log("update routers "+(new Date).toDateString()+" "+(new Date).toTimeString());var e=function(){console.log("child_process "+(new Date).toDateString()+" "+(new Date).toTimeString())};Ui.exec("/usr/local/bin/node "+o+"build-relays_and_dirs7.js",{timeout:12e5},e),Pi&&Ui.exec("/usr/local/bin/node "+o+"publish2.js "+Pi+" "+Fi+":"+qi+" "+Mi,{timeout:12e5},e)};T||x||setInterval(Gi,36e5)}if(T)var Yi,Wi,Qi,Xi=function(e){var t={host:"peersm.com",port:80,path:"/peersmclient/proxy.pac",method:"GET"};Yi="";var r=nn.request(t,function(t){t.on("data",function(e){Yi+=e.toString("utf8")}),t.on("end",function(){e()}),t.on("error",function(){console.log("Error proxy.pac")})});r.end()};else var Xi=function(e){var t=new XMLHttpRequest;return t?(t.open("GET",e,!1),t.send(null),t.responseText):void 0};var Ji,Zi,$i,en,tn=require("tls"),rn=require("net"),nn=require("http"),sn=(require("url"),require("crypto")),an=T?require(o+"node_modules/torrent-stream"):{},Guards=T||x?{}:require(o+"guards.js").Guards,on=T||x?{}:require(o+"relays.js").Relays,cn=T||x?{}:require(o+"dirs.js").Dirs,Exit=T||x?{}:require(o+"exit.js").Exit,ln=!1,hn=!0,un=hn?null:require(o+"crypto.js").Rsa,dn=hn?null:require(o+"crypto.js").PEM,fn=hn?null:require(o+"crypto.js").Hash,pn=498,_n=65535,gn={},mn=[],yn={},vn={},bn={},wn={},En={},Cn={},Sn={},An=[],In={},Tn={},xn={},Bn={},kn=0,Rn=Fi||"",Un="2679B51C906158F3DF4C59AFD73E2B1FDA6535E1",Dn=a?C?1:0:S?0:0,Nn="010001",Ln=new t("00000000000000000000000000000000","hex"),On=32767,Pn=Hi||(a?2:0),Fn=5,qn=5,Hn=3,Mn=zi?2:3,jn="-----BEGIN RSA PUBLIC KEY-----",zn="-----END RSA PUBLIC KEY-----",Vn=5e3,Kn=1e3,Gn=7e3,Yn=3,Wn=0,Qn=0,Xn=30,Jn=12,Zn=10,$n=s?20:5,es=!1,ts=5,rs=5e3,is=72e5,ns=36e5,ss=36e5,as=[],os=[],cs=1e3,ls=100,hs=500,us=50,ds=.8,fs=15e3,ps=16184,_s=t,gs="0d0a",ms=".com",ys=5e3,vs=2e3,bs={},ws="http:",Es="www.f4116a30c08bbdfd01813b96c909.com",Cs=null,Ss=null,As=36e6,Is=1e4,Ts=3e5,xs=9e5,Bs=5,ks=a?!1:!0,Rs=a?!1:!0,Us=a?!1:!0,Ds="",Ns=!1,Ls=1024,Os=!0,Ps=!1,Fs={},qs="undefined"!=typeof document?document.location.href:"",Hs=!1,Ms=!0,js=!1,zs=a?!1:!0,Vs=0,Ks=1e5,Gs="Retrieving... ",Ys=!0,Ws=!0,Qs="enc",Xs=T||x?null:Ri.readFileSync(o+"priv-key.pem"),Js=!1,Zs=65536,$s=2097152,ea=0,ta=0,ra=0,ia=100,na=0,sa=0,aa=0,oa=100,ca=0,la=0,ha=0,ua=100,da=0,fa=0,pa=0,_a=100,ga=0,ma=0,ya=0,va=100,ba=1e6,wa=2e6,Ea=1e3,Ca=125,Sa=3e4,Aa="0000000000000000000000000000000000000000",Ia=3e5,Ta="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF",xa={323:"text/h323","3gp":"video/3gpp",a:"application/octet-stream",acx:"application/internet-property-stream",ai:"application/postscript",aif:"audio/x-aiff",aifc:"audio/x-aiff",aiff:"audio/x-aiff",asc:"application/pgp-signature",asf:"video/x-ms-asf",asr:"video/x-ms-asf",asm:"text/x-asm",asx:"video/x-ms-asf",atom:"application/atom+xml",au:"audio/basic",avi:"video/x-msvideo",axs:"application/olescript",bas:"text/plain",bat:"application/x-msdownload",bcpio:"application/x-bcpio",bin:"application/octet-stream",bmp:"image/bmp",bz2:"application/x-bzip2",c:"text/x-c",cab:"application/vnd.ms-cab-compressed",cat:"application/vnd.ms-pkiseccat",cc:"text/x-c",cdf:"application/x-netcdf",cer:"application/x-x509-ca-cert",cgm:"image/cgm",chm:"application/vnd.ms-htmlhelp","class":"application/octet-stream",clp:"application/x-msclip",cmx:"image/x-cmx",cod:"image/cis-cod",com:"application/x-msdownload",conf:"text/plain",cpio:"application/x-cpio",cpp:"text/x-c",cpt:"application/mac-compactpro",crd:"application/x-mscardfile",crl:"application/pkix-crl",crt:"application/x-x509-ca-cert",csh:"application/x-csh",css:"text/css",csv:"text/csv",cxx:"text/x-c",dcr:"application/x-director",deb:"application/x-debian-package",der:"application/x-x509-ca-cert",diff:"text/x-diff",dir:"application/x-director",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dll:"application/x-msdownload",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dtd:"application/xml-dtd",dv:"video/x-dv",dvi:"application/x-dvi",dxr:"application/x-director",ear:"application/java-archive",eml:"message/rfc822",eps:"application/postscript",etx:"text/x-setext",evy:"application/envoy",exe:"application/x-msdownload",ez:"application/andrew-inset",f:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",fif:"application/fractals",flr:"x-world/x-vrml",flv:"video/x-flv","for":"text/x-fortran",gem:"application/octet-stream",gemspec:"text/x-script.ruby",gif:"image/gif",gram:"application/srgs",grxml:"application/srgs+xml",gtar:"application/x-gtar",gz:"application/x-gzip",h:"text/x-c",hdf:"application/x-hdf",hh:"text/x-c",hlp:"application/winhlp",hqx:"application/mac-binhex40",hta:"application/hta",htc:"text/x-component",htm:"text/html",html:"text/html",htt:"text/webviewhtml",ice:"x-conference/x-cooltalk",ico:"image/vnd.microsoft.icon",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",iii:"application/x-iphone",ins:"application/x-internet-signup",isp:"application/x-internet-signup",iso:"application/octet-stream",jar:"application/java-archive",java:"text/x-java-source",jfif:"image/pipeg",jnlp:"application/x-java-jnlp-file",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",kar:"audio/midi",latex:"application/x-latex",lha:"application/octet-stream",lsf:"video/x-la-asf",lsx:"video/x-la-asf",lzh:"application/octet-stream",log:"text/plain",m13:"application/x-msmediaview",m14:"application/x-msmediaview",m3u:"audio/x-mpegurl",m4a:"audio/mp4a-latm",m4b:"audio/mp4a-latm",m4p:"audio/mp4a-latm",m4u:"video/vnd.mpegurl",m4v:"video/mp4",mac:"image/x-macpaint",man:"text/troff",mathml:"application/mathml+xml",mbox:"application/mbox",mdb:"application/x-msaccess",mdoc:"text/troff",me:"text/troff",mesh:"model/mesh",mht:"message/rfc822",mhtml:"message/rfc822",mid:"audio/midi",midi:"audio/midi",mif:"application/vnd.mif",mime:"message/rfc822",mml:"application/mathml+xml",mng:"video/x-mng",mny:"application/x-msmoney",mov:"video/quicktime",movie:"video/x-sgi-movie",mp2:"video/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4v:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpg:"video/mpeg",mpga:"audio/mpeg",mpp:"application/vnd.ms-project",mpv2:"video/mpeg",ms:"text/troff",msh:"model/mesh",msi:"application/x-msdownload",mvb:"application/x-msmediaview",mxu:"video/vnd.mpegurl",nc:"application/x-netcdf",nws:"message/rfc822",oda:"application/oda",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",ogg:"application/ogg",p:"text/x-pascal",p10:"application/pkcs10",p12:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",p7c:"application/x-pkcs7-mime",p7m:"application/x-pkcs7-mime",p7r:"application/x-pkcs7-certreqresp",p7s:"application/x-pkcs7-signature",pac:"text/plain",pas:"text/x-pascal",pbm:"image/x-portable-bitmap",pct:"image/pict",pdb:"chemical/x-pdb",pdf:"application/pdf",pem:"application/x-x509-ca-cert",pfx:"application/x-pkcs12",pgm:"image/x-portable-graymap",pgn:"application/x-chess-pgn",pgp:"application/pgp-encrypted",pic:"image/pict",pict:"image/pict",pkg:"application/octet-stream",pko:"application/ynd.ms-pkipko",pl:"text/x-script.perl",pm:"text/x-script.perl-module",pma:"application/x-perfmon",pmc:"application/x-perfmon",pml:"application/x-perfmon",pmr:"application/x-perfmon",pmw:"application/x-perfmon",png:"image/png",pnm:"image/x-portable-anymap",pnt:"image/x-macpaint",pntg:"image/x-macpaint",pot:"application/vnd.ms-powerpoint",ppm:"image/x-portable-pixmap",pps:"application/vnd.ms-powerpoint",ppt:"application/vnd.ms-powerpoint",prf:"application/pics-rules",ps:"application/postscript",psd:"image/vnd.adobe.photoshop",pub:"application/x-mspublisher",py:"text/x-script.python",qt:"video/quicktime",qti:"image/x-quicktime",qtif:"image/x-quicktime",ra:"audio/x-pn-realaudio",rake:"text/x-script.ruby",ram:"audio/x-pn-realaudio",rar:"application/x-rar-compressed",ras:"image/x-cmu-raster",rb:"text/x-script.ruby",rdf:"application/rdf+xml",rgb:"image/x-rgb",rm:"application/vnd.rn-realmedia",rmi:"audio/mid",roff:"text/troff",rpm:"application/x-redhat-package-manager",rss:"application/rss+xml",rtf:"application/rtf",rtx:"text/richtext",ru:"text/x-script.ruby",s:"text/x-asm",scd:"application/x-msschedule",sct:"text/scriptlet",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgm:"text/sgml",sgml:"text/sgml",sh:"application/x-sh",shar:"application/x-shar",sig:"application/pgp-signature",silo:"model/mesh",sit:"application/x-stuffit",skd:"application/x-koan",skm:"application/x-koan",skp:"application/x-koan",skt:"application/x-koan",smi:"application/smil",smil:"application/smil",snd:"audio/basic",so:"application/octet-stream",spc:"application/x-pkcs7-certificates",spl:"application/x-futuresplash",src:"application/x-wais-source",sst:"application/vnd.ms-pkicertstore",stl:"application/vnd.ms-pkistl",stm:"text/html",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",svg:"image/svg+xml",svgz:"image/svg+xml",swf:"application/x-shockwave-flash",t:"text/troff",tar:"application/x-tar",tbz:"application/x-bzip-compressed-tar",tcl:"application/x-tcl",tex:"application/x-tex",texi:"application/x-texinfo",texinfo:"application/x-texinfo",text:"text/plain",tgz:"application/x-compressed",tif:"image/tiff",tiff:"image/tiff",torrent:"application/x-bittorrent",tr:"text/troff",trm:"application/x-msterminal",tsv:"text/tab-seperated-values",txt:"text/plain",uls:"text/iuls",ustar:"application/x-ustar",vcd:"application/x-cdlink",vcf:"text/x-vcard",vcs:"text/x-vcalendar",vrml:"model/vrml",vxml:"application/voicexml+xml",war:"application/java-archive",wav:"audio/x-wav",wbmp:"image/vnd.wap.wbmp",wbxml:"application/vnd.wap.wbxml",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",webm:"video/webm",wks:"application/vnd.ms-works",wma:"audio/x-ms-wma",wmf:"application/x-msmetafile",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",wmlsc:"application/vnd.wap.wmlscriptc",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wps:"application/vnd.ms-works",wri:"application/x-mswrite",wrl:"model/vrml",wrz:"x-world/x-vrml",wsdl:"application/wsdl+xml",xaf:"x-world/x-vrml",xbm:"image/x-xbitmap",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xml:"application/xml",xof:"x-world/x-vrml",xpm:"image/x-xpixmap",xsl:"application/xml",xslt:"application/xslt+xml",xul:"application/vnd.mozilla.xul+xml",xwd:"image/x-xwindowdump",xyz:"chemical/x-xyz",yaml:"text/yaml",yml:"text/yaml",z:"application/x-compress",zip:"application/zip"};if(Ms&&!A)var Ba={};if(A&&!I){var Yi=Xi("proxy.pac");Us||(Yi="var FindProxyForUrl="+Yi,eval(Yi),Zi=FindProxyForUrl("http://"+Es,Es,!0))}else Zi={ip:Rn,port:kn,wsport:Pn,fing:Un,o_modulus:"8bd0a81286858b11f2856ac2f3efd8a5e538b2f851a4c02cc717c94ea52418c587cc69515e46b5381d17cd2299cb4c59fae38250898eab31c9b8acfcf02110a96f0f03442ecd34f1befb0604e1ffbb981848534da9f3f23795ed7df047730cb9dab711722ad6504b893cebda2de4b41123d667474a166eba3ead7df8267dda15"};if(Us){ks=!1,Rs=!1;var ka=Zi;if(js=!0,zs=!1,T){var Ra=ji?1e6*ji:1e5,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,qa=0,Ha={};E=!1,Ha.list=function(e,r){Ri.readdir(o,function(i,n){i||n.forEach(function(i){if(-1===i.indexOf("debug.txt")&&-1===i.indexOf("debug-prod.txt")){var n,s,a=i.split("#");if(a.length>1){var c=a[1].split(".");n=a[0]+(c.length>1?"."+c[1]:""),s=a[1].split(".")[0]}if(n)r||Ri.stat(o+i,function(t,r){if(!t){var a={file_name:i,name:n,name_hash:s,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(a)}});else{var l=sn.createhash("sha1");l.update(new t(Date.now().toString()+El.localAddress.toString()+El.localPort.toString(),"utf8")),l=l.digest("hex");var c=i.split(".");if(c.length){var h=c.pop();if(c.length){var n=c.join("."),u=n+"#"+l+"."+h;Ri.rename(o+i,o+u,function(){Ri.stat(o+u,function(t,r){if(!t){var i={file_name:u,name:n,name_hash:l,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(i)}})})}}}}})})};var Ma=function(){Ss&&Ss.send_db_info(!0)},ja=function(e){e=e.split("ws://")[1].split(":");var t=e[1],r=e[0];console.log("peersm client "+r+" "+t);var i=new rn.Socket;return i.on("connect",function(){i.key_=sn.randomBytes(16).toString("base64");var e="GET / HTTP/1.1\r\n";e+="Host: "+i.remoteAddress+":"+i.remotePort+"\r\n",e+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",e+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",e+="Accept-Language: en-us,en;q=0.5\r\n",e+="Accept-Encoding: gzip, deflate\r\n",e+="Connection: keep-alive, Upgrade\r\n",e+="Sec-WebSocket-Version: 13\r\n",e+="Origin: http://peersm.com\r\n",e+="Sec-WebSocket-Key: "+i.key_+"\r\n",e+="Pragma: no-cache\r\n",e+="Cache-Control: no-cache\r\n",e+="Upgrade: websocket\r\n",e+="\r\n",console.log(e),i.write(e)}),i.on("data",function(e){if(i.connected__){var t=Sc(i.stream_ws__?[i.stream_ws__,e].concatBuffers():e);i.stream_ws__=t[1].length?t[1]:null,i.onmessage({data:t[0]})}else{i.on("end",function(){console.log("websocket_node end"),i.onclose()}),i.on("error",function(){console.log("websocket_node error"),i.onclose()});var r=ic(e.toString("utf8")),n=r["Sec-WebSocket-Accept"]||r["Sec-Websocket-Accept"];if(n){var s=sn.createHash("sha1");s.update(i.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var a=s.digest("base64");n===a?(console.log("Client says : Handshake successfull for "+El.remoteAddress+" "+El.remotePort),i.write=function(e){i._write(Ac(e,2,!0),null,function(){})},i.send=i.write,i.connected__=!0,i.onopen()):i.end()}else i.end()}}),i.close=i.end,i.connect(t,r),i},za=function(){};za.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Va=function(){};Va.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Ka=function(e){this.data=[],this.cursor=0,this.size=e};Ka.prototype.push=function(e){this.data.push(e),this.cursor+=e.length},Ka.prototype.unshift=function(e){this.data.unshift(e),this.cursor-=e.length},Ka.prototype.slice=function(e,r){var i,n,s=r-e,a=0,o=[];if(s>0&&this.data.length){for(s=Math.min(s,this.cursor);s>a;){var c=this.data.shift(),l=c.length;o.push(c),a+=l,this.cursor-=l}return i=o.concatBuffers(),n=i.slice(s),i=i.slice(0,s),this.cursor+=n.length,n.length&&this.data.unshift(n),i}return new t(0)};var Ga=function(e){this.fd=e.fd,this.size=e.size,this.type=e.type,this.cursor=0};Ga.prototype.slice=function(e,r){if(r){if(r>e){var i=new t(r-e);return Ri.readSync(this.fd,i,0,r-e,e+this.cursor),i}return new t(0)}return this.size=this.size-e,this.cursor=e,this};var Ya=function(){var e={};return e.get=function(e){var t={};return Ri.readdir(o,function(r,i){if(r)t.onsuccess({target:{result:null}});else{for(var n,s=!1,a=i.length,c=0;a>c;c++){var l=i[c];if(-1===l.indexOf("debug.txt")){var h,u,d=l.split("#");if(d.length>1){var f=d[1].split(".");f.length>1&&(n=f[1],h=d[0]+(f.length>1?"."+f[1]:"")),u=d[1].split(".")[0]}if(u===e){s=!0,Ri.stat(o+l,function(e,r){!e&&n?Ri.open(o+l,"r",function(e,i){if(e)t.onsuccess({target:{result:null}});else{var s;n&&(s=xa[n]),s||(s="application/octet-binary"),console.log(h+" "+u+" "+s);var a={fd:i,size:r.size,type:s};t.onsuccess({target:{result:{file_length:r.size,current_length:r.size,type:s,data:a}}})}}):t.onsuccess({target:{result:null}})});break}}}s||t.onsuccess({target:{result:null}})}}),t},e};Wi=function(){Yi="var FindProxyForUrl="+Yi,eval(Yi);var t=FindProxyForUrl("http://"+Es,Es,!0);Zi=t[1][_o(t[1].length)],ka=e?{ip:"213.246.53.127",port:0,wsport:0,fing:"E0671CF9CB593F27CD389CD4DD819BF9448EA834",o_modulus:"ca2a670479816ca562f7afc2667db1811f0efa7d595aa27cf532092a052c697b102c03d8b8dddc276050fe9cad15efe72758d9d9b0f581f5cbfd0be92ecd721711797354006625e74e0f733efee3ee779116efe87da3b5f8c1729e2d0a5f2c4de4d5906b6e383c0a0d8dddbc076cf426423f6f2b6fd46fab9f54fb8e42601a2d",name:"Tor Bridge"}:t[2],Js=!0,on=Guards,Ba.userAgent="node-Tor",Il()},Qi=function(){var e=function(){console.log("update prox --------"),Yi="var FindProxyForUrl="+Yi,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0)};Xi(e)},Xi(Wi),setInterval(Ma,1e4),setInterval(Qi,ss)}if(A){var Ha,Ra=0,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,Wa=document.getElementById.bind(document),qa=0,Qa=document.location.href.split("/"),Xa=Qa[Qa.length-1].split("#")[0],Ja=function(e){return e.pageY?e.pageY:e.clientY},Za=function(e){return e.pageX?e.pageX:e.clientX},$a=function(e,t,r,i){e.__event=e.__event||{},e.__event[t]&&eo(e,t,e.__event[t][0],e.__event[t][1]),e.__event[t]=[r,i],e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r)},eo=function(e,t,r,i){e.addEventListener?e.removeEventListener(t,r,i):e.attachEvent&&e.detachEvent("on"+t,r)},to=[Qs,"exe","com","bin","php","php3","php4","php5","phtml","inc","sql","pl","cgi","py","sh","c","cc","cpp","cxx","h","hpp","java","class","jar","html","html","shtml","dhtml","xhtml","xml","js","css","zip","tar","tgz","gz","bz2","tbz","rar","mp3","wav","3ga","midi","mid","rm","ra","ram","pls","m3u","mkw","webm","avi","mp4","m4v","mpg","mpeg","mov","swf","fla","doc","docx","xls","xlsx","rtf","pdf","txt","ppt","pptx","vcard","vcf","obj","max","3ds","3dm","kml","torrent","gpx","dxf","dwg","wsg","vb","pif","gadget","apk","msi","sxc","123","ots","nb","gsheet","xlr","ods","svgz","cdr","svg","ps","eps","orf","pef","rwl","mrw","mef","fff","erf","dcr","bay","3fr","srf","rw2","nef","cr2","arw","dng","dwt","irs","ait","art","aip","aia","ai","indd","prtpset","ppj","plb","prproj","aetx","aet","aes","aepx","aep","aec","ncorx","ncor","em","abr","csh","psb","psd","as","asc","ascs","aif","aiff","flac","iff","m4a","wma","srt","flv","3g2","3gp","asf","wmv","pcast","xlt","xltm","xltx","ans","ascii","log","odt","wpd","accdb","db","dbf","mdb","pdb","asp","aspx","asx","fnt","otf","ttf","dotx","wps2","dll","fon","cmd","srt"],ro=["tga","gif","jpg","tiff","jpeg","bmp","png"];to.forEach(function(e){La[e]="http://www.peersm.com/img/extensions/"+e+".png"});var io=function(){var e=new XMLHttpRequest;if(e){e.open("POST","bandwidth.html",!0);var t=Date.now(),r=1e5;e.send(new Uint8Array(r)),e.onreadystatechange=function(){if(4==e.readyState){var r=1e5/((Date.now()-t)/1e3);Ra=parseInt((Ra?(Ra+r)/2:r)/Ua),console.log("bandwidth : "+8*Ra/1e3+" Kbps")}}}};setInterval(io,18e6),io()}}on=Guards;var no=function(){Ri.rename(o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt"),o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt")+".old",function(){})};no(),A||T||x||console.log(Pi+" "+Fi+" "+qi+" "+Hi+" "+Mi);var so=function(e){var t=e.split("magnet:?xt=urn:btih:");return t.length>1?t[1]:void 0},ao=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Accept-Ranges:bytes",e+="Content-Encoding:gzip\r\n",e+="Content-Length:0\r\n",e+="Content-Type:*\r\n",e+="\r\n"},oo=function(){var e="HTTP/1.1 410 Gone\r\n";return e+="\r\n"},co=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Vary: Accept-Encoding\r\n",e+="Keep-Alive: timeout=2, max=100\r\n",e+="Connection: Keep-Alive\r\n",e+="Transfer-Encoding: chunked\r\n",e+="Content-Type: text/html\r\n",e+="\r\n1f\r\n//Outside of authorized domains\r\n0\r\n\r\n"},lo=function(e){var t="HTTP/1.1 301 Moved Permanently\r\n";return t+="Location: "+e+"\r\n",t+="\r\n"},ho=function(e){var t={url:e},r=e.split("/"),i=function(e){if(e.length){var r=e[0];t.host=r,e.shift()}t.rest=e.join("/")};return r.length>1?""===r[1]?(t.protocol=r[0]?r[0]:ws,r.shift(),r.shift()):t.protocol=ws:t.protocol=ws,i(r),t},uo=function(e){var t=[];return t.push(e.protocol?e.protocol:protocol),t.push(""),e.host&&t.push(e.host),e.rest&&t.push(e.rest),t.join("/")},fo=function(e,r){var i=new t(Eo(r?new t(e,"utf8"):new t(e,"hex"),Bl),"hex");return r?i.toString("hex"):i.toString("utf8")},po=function(e){var t=e.slice(0,1),r=e.slice(1,2),i=e.slice(2,2+r.readUInt());return e=e.slice(r.readUInt()+2),{data:e,addr:{type:t,length:r,value:i}}},_o=function(e){return parseInt(Math.random()*e)},go=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()+(e.getMilliseconds()>500?1:0),0)},mo=function(e){var t,r,i=[],n=[],s=[],a=e.nb_hop||Fn;if(a>Fn&&(a=Fn),e.nb_try=e.nb_try||1,e.nb_try>qn)return console.log("PATH : createPath : Too many attempts"),void 0;for(r=Guards.length,t=_o(r),t=Guards[t].split("-"),s.push(t[1]),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),a--,r=on.length,a--;a;)t=_o(r),-1==i.indexOf(t)&&on[t].split("-")[1]!=n[0].ip&&(i.push(t),a--);var o=function(e){var t=on[e].split("-"),r={ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]};s.push(t[1]),n.push(r)};for(i.forEach(o),r=Exit.length,t=_o(r);-1!=s.indexOf(Exit[t].split("-")[1]);)t=_o(r);return t=Exit[t].split("-"),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),n},yo=function(e,r){var i="GET /"+r+" HTTP/1.1\r\n";return i+="Host: "+e+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",new t(i,"utf8")},vo=function(e,r,i){var n="GET /"+r+" HTTP/1.1\r\n";return n+="Host: "+e+"\r\n",n+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",n+="Range: bytes="+i+"-\r\n",n+="Accept: */*\r\n",n+="Accept-Language: en\r\n",n+="Accept-Encoding: gzip, deflate\r\n",n+="Connection: keep-alive\r\n",n+="\r\n",new t(n,"utf8")},bo=function(e,t,r){var i=0;if(e.nbc_=e.nbc_?e.nbc_:0,t){if(e.nbc_===On)return!1}else if(65534===e.nbc_)return!1;for(;e[i]||0===i;)i=t?r?e.cid?++e.cid%On:On:e.cid?++e.cid%On:1:e.cid?++e.cid%65535:1;return e.cid=i,e.nbc_++,i},wo=function(e){for(var r="",i=0;5>i;i++){var n=sn.createhash("sha1");n.update(new t(e+"0"+i,"hex")),r+=n.digest("hex")}return new t(r,"hex")},Eo=function(e,t){var r=sn.createcipheriv("aes-128-ctr",t,Ln),i=r.update(e,"hex","hex");return i+=r.final("hex")},Co=function(e,r){var i=r.slice(0,70),n=r.slice(70),s=No(16),a=[s,i].concatBuffers(),o=new un;a=o.encrypt(new t(e.toString("hex"),"binary"),new t(Nn,"binary"),new t(a.toString("binary"),"binary"),"RSA_PKCS1_OAEP_PADDING","hex");var c=Eo(n,s);return[new t(a,"hex"),new t(c,"hex")].concatBuffers()},So=function(e,r,i){var n=new un,s=new t(n.decrypt(e,r,"RSA_PKCS1_OAEP_PADDING","hex"),"hex"),a=s.slice(0,16);return[s.slice(16),new t(Eo(i,a),"hex")].concatBuffers()},Ao=function(e){if(T){if(this.fc_t.length){var t=this.fc_t.shift();t()}}else if(e.source==window&&e.data==this.messageName&&(e.stopPropagation(),this.fc_t.length)){var t=this.fc_t.shift();t()}},Io=function(e,t,r,i){if(r)if(r.stop_)r._torrent_&&r._torrent_stream.destroy(),r=null,console.log("delete sid 2"),delete this[t];else{if(r._torrent_&&T&&"undefined"==typeof i){var n=Date.now()-r.start_t0;i=Math.ceil(1e6*n*ji/1e3/Da/ds),console.log("first blocks nb "+i)}else i="undefined"==typeof i?Fa:i;var s=[];if(r.reader.onload=function(n){if(n.target.result){var a=n.target.result instanceof ArrayBuffer?new Uint8Array(n.target.result):n.target.result;if(a.length)for(var o=0;i>o;o++){if(0===r.stream_window_s){r.cursor-=a.length,r._torrent_&&r._torrent_.unshift(a);break}if(r.stream_window_s--,s.push(a.slice(0,Math.min(a.length,pn))),!(a.length>pn))break;a=a.slice(pn)}}var c=Date.now();r.fc_t.push(function(){To.call(this,e,s,r,t,c)}.bind(this)),T?setTimeout(Ao.bind(r),0):window.postMessage("flush","*")}.bind(this),0!==i){var a=e.slice(r.cursor,Math.min(e.size,r.cursor+i*pn));r.cursor+=a.length,r.reader.readAsArrayBuffer(a)}else r.reader.onload({target:{result:null}})}},To=function(e,t,r,i,n){t.forEach(function(e){r.sent_+=e.length;var t=new qo(qo.prototype.RELAY_DB_DATA,i,e,this.last_.Df_hash),n=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(n)},this);var s,a=Date.now()-n,o=T?this.socket_.bufferSize:this.socket_.bufferedAmount,c=parseInt((r.cursor-o)/((Date.now()-r.start_t0)/1e3)),l=8*c,h=ba;if(r.cursorh)s=0;else if(T)s=Math.ceil(a*c/1e3/Da/ds);else{var u=Pa>o?Math.ceil((Pa-o)/Da):0;a&&(s=Math.ceil(a*c/1e3/Da/ds)),s=s?Math.min(u,s):u}s=l>h?0:o>Pa?0:s>Fa?s:Fa,m&&0!==a&&0!==s&&console.log("real bandwidth "+parseInt(8*c/1e3)+" kbps "+"- advertised bandwidth "+parseInt(8*Ra/1e3)+" kbps time "+a+" nbblocs "+s+" buffered amount "+o+" cursor "+r.cursor+" torrent buffered "+(r._torrent_?r._torrent_.cursor:"")),0!==r.stream_window_s||r.pause_[i]?e.size===r.cursor?(console.log("delete sid"),delete this[i],console.log(parseInt(8*r.cd_length/((Date.now()-r.start_t0)/1e3))+" bps")):this.send_db_data(e,i,s,!0):(console.log(parseInt(8*r.cursor/((Date.now()-r.start_t0)/1e3))+" kbps"),console.log("Pausing download CIC "+this.circId+" for stream "+i+" sent "+r.sent_+" remaining length "+(e.size-r.cursor)+" time "+Date.now()+" buffered amount "+o+" fc_t "+r.fc_t.length),r.pause_[i]=e)},xo=function(e){var t=bo(e),r={};return r.sid_=t,r.received_=0,r.sent_=0,r.stream_window=Oa,r.stream_window_s=Oa,r.send_data=!0,e[t]=r,r.pause_={},t},Bo=function(e){if(e){var t=e.split(".");return t=t.length?t[t.length-1]:""}return"exe"},ko=function(e){var t=e.cid_,r=e.sid_;r&&delete t[r],delete e.cid_,delete e.sid_},Ro=function(e){lh(e.bar_),lh(Th),lh(nh)},Uo=function(e,r,i){console.log("search in bittorrent");for(var n=An;n.length;)if(n[0].socket_)if(n[0].socket_.remoteAddress){if(!n[0].destroyed_)break;console.log("ORDB remove destroyed CIC fac "+n[0].circId),n.shift()}else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();if(n.length){var s=n[0];n.shift(),n.push(s);var a=No(16),o={d_length:r,hash_:new t(i,"hex")};In[a.toString("hex")]=[this,e,n,o,1],s.send_db_query(o,a)}else this.send_db_end(0,e)},Do=function(e){if("open"===e._stream_.readyState&&!e._source_.updating)if(e.append_buffer.length){e.append_cursor++;var t=e.append_buffer.shift();try{e._source_.appendBuffer(t)}catch(r){console.log("error updateend ")}}else e.append_cursor=0};t.prototype.readUInt=function(){switch(this.length){case 1:return this[0];case 2:return this.readUInt16BE(0);case 4:return this.readUInt32BE(0);default:return 0}},t.prototype.writeUInt=function(e){switch(this.length){case 1:this.writeUInt8(e,0);break;case 2:this.writeUInt16BE(e,0);break;case 4:this.writeUInt32BE(e,0)}return this},t.prototype.map=function(e){var t=e.length;Hs||A?(this.set(e),this.fill(0,t)):(e.copy(this),this.fill(0,t))},Array.prototype.concatBuffers2=function(){var e=[];return this.forEach(function(t){e.push(t.toString("hex"))}),new t(e.join(""),"hex")},Array.prototype.concatBuffers1=function(){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){for(var t=e.length,n=0;t>n;n++)r[i]=e[n],i++}),r},Array.prototype.concatBuffers=function(){if(Hs||A){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){var t=e.length;r.set(e,i),i+=t}),r}return t.concat(this)},t.prototype.parse=function(e){e.WS_OP_&&e.ws_;for(var t=e.stream_tor_;t.length;){var r,i=t.slice(0,2),n=t.slice(2,3),s=i.readUInt();if(e[s]&&e[s].clear_timers(),7==n.readUInt()||n.readUInt()>=128){var a=t.length;if(!(a>=5))break;var o=t.readUInt16BE(3);if(!(a>=o+5))break;r=t.slice(5,o+5),t=t.slice(o+5)}else{if(!(t.length>=512))break;r=t.slice(3,512),t=t.slice(512)}var c=new Po(i.readUInt(),n.readUInt(),r,!0);Vo.bind(e)([c])}e.stream_tor_=t;var l=e.queue_;e.WS_OP_&&e.ws_,l.shift(),l.length&&l[0]()},t.prototype.parseTLS=function(e){for(var r,i=e.stream_tor_;i.length;){var n=i.length;if(!(n>=5))break;var s=i.readUInt16BE(3);if(!(n>=s+5))break;if(r=i.slice(0,s+5),i=i.slice(s+5),22!==r[0]||e.ccs_)20===r[0]&&(e.ccs_=!0),e.process(r);else for(var a=r.readUInt(1,2),o=r.readUInt(3,3),c=r.slice(5,o);c.length;){var n=c.length;if(!(n>=4))break;var l=c.readUInt(1,3);if(!(n>=l+4))break;var h=[new t(1).writeUInt(22),new t(2).writeUInt(a),new t(2).writeUInt(l+4),c.slice(0,l+4)].concatBuffers();e.process(h),c=c.slice(l+4)}}e.stream_tor_=i;var u=e.queue_;u.shift(),u.length&&u[0]()},(A||Hs)&&(t=function(e,t){if(t||"string"!=typeof e||(t="utf8"),e instanceof Array||!isNaN(e)&&!t)return new Uint8Array(e);if("utf8"===t)return new dt("utf-8").encode(e);if("hex"===t)try{for(var r=new Uint8Array(e.length/2),i=e.length,n=0;i>n;n+=2)r[n/2]=parseInt(e[n]+e[n+1],16) -}catch(s){return new Uint8Array}if("binary"===t)for(var r=new Uint8Array(e.length),i=r.length,n=0;i>n;n++)r[n]=e.charCodeAt(n);return r},_s.isBuffer=function(e){return e instanceof this||e instanceof Uint8Array},Uint8Array.prototype.isBuffer=_s.prototype.isBuffer,Uint8Array.prototype.parse=_s.prototype.parse,Uint8Array.prototype.parseTLS=_s.prototype.parseTLS,t.isBuffer=function(e){return e instanceof Uint8Array},Uint8Array.prototype.slice=function(e,t){return t?this.subarray(e,t):this.subarray(e)},Uint8Array.prototype.map=function(e){var t=e.length;this.set(e),this.fill(0,t)},Uint8Array.prototype.readUInt=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16BE(e);case 3:return this.readUInt24BE(e);case 4:return this.readUInt32BE(e);default:return 0}},Uint8Array.prototype.readUIntLE=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16LE(e);case 4:return this.readUInt32LE(e);default:return 0}},Uint8Array.prototype.writeUInt=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16BE(e,t);break;case 3:this.writeUInt24BE(e,t);break;case 4:this.writeUInt32BE(e,t)}return this},Uint8Array.prototype.writeUIntLE=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16LE(e,t);break;case 4:this.writeUInt32LE(e,t)}return this},Uint8Array.prototype.fill=function(e,t){for(var r=this.length,i=t;r>i;i++)this[i]=e},Uint8Array.prototype.readUInt16BE=function(e){return this[e]<<8^this[e+1]},Uint8Array.prototype.readUInt24BE=function(e){return this[e]<<16^this[e+1]<<8^this[e+2]},Uint8Array.prototype.readUInt32BE=function(e){return this[e]<<24^this[e+1]<<16^this[e+2]<<8^this[e+3]},Uint8Array.prototype.readUInt16LE=function(e){return this[e]^this[e+1]<<8},Uint8Array.prototype.readUInt32LE=function(e){return this[e]^this[e+1]<<8^this[e+2]<<16^this[e+3]<<24},Uint8Array.prototype.writeUInt8=function(e,t){this[t]=e},Uint8Array.prototype.writeUInt16BE=function(e,t){this[t]=255&e>>8,this[t+1]=255&e},Uint8Array.prototype.writeUInt24BE=function(e,t){this[t]=255&e>>16,this[t+1]=255&e>>8,this[t+2]=255&e},Uint8Array.prototype.writeUInt32BE=function(e,t){this[t]=255&e>>24,this[t+1]=255&e>>16,this[t+2]=255&e>>8,this[t+3]=255&e},Uint8Array.prototype.writeUInt16LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8},Uint8Array.prototype.writeUInt32LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8,this[t+2]=255&e>>16,this[t+3]=255&e>>24},Uint8Array.prototype.toString=function(e){var t=this.length,r=[];if("utf8"===e)return new ft("utf-8").decode(this);if("hex"===e)for(var i=0;t>i;i++){var n=this[i].toString(16);r.push(1===n.length?"0"+n:n)}return"binary"===e?String.fromCharCode.apply(null,this):r.join("")},Ln=new t("00000000000000000000000000000000","hex"));var No=function(e){return sn.randomBytes(e)},Lo=function(e){for(var t=e.length,r=[],i=0;t>i;i++)r.push(e[i]);return r.join(".")},Oo=function(e){return new t(e.split("."))},Po=function(e,r,i,n){this.CircID=new t(2).writeUInt(e),this.Command=new t(1).writeUInt(r),this.Length=new t(2).writeUInt(i.length),this.Payload=n?zo.bind(this)(i):i};Po.prototype={PADDING:0,CREATE:1,CREATED:2,RELAY:3,DESTROY:4,CREATE_FAST:5,CREATED_FAST:6,NETINFO:8,RELAY_EARLY:9,VERSIONS:7,CREATE_FAST_WS:120,CREATED_FAST_WS:121,VPADDING:128,CERTS:129,AUTH_CHALLENGE:130,AUTHENTICATE:131,AUTHORIZE:132,RELAY_WS:190,versions_cell_decode:function(e){for(var t=[];e.length;)t.push(e.slice(0,2)),e=e.slice(2);return t},certs_cell_decode:function(e){var t=e.slice(0,1);e=e.slice(1);var r=[];for(r.push(t);e.length;){var i={};i.CertType=e.slice(0,1),i.CLEN=e.slice(1,3);var n=i.CLEN.readUInt();i.Certificate=e.slice(3,3+n),e=e.slice(3+n),r.push(i)}return r},auth_challenge_cell_decode:function(e){var t=[],r={};return r.Challenge=e.slice(0,32),r.N_Methods=e.slice(32,34),r.Methods=e.slice(34,34+r.N_Methods.readUInt()),t.push(r),t},netinfo_cell_decode:function(e){var t=[],r={};r.Timestamp=e.slice(0,4);var i=po(e.slice(4));e=i.data,r.other_OR=i.addr,r.nb_addresses=e.slice(0,1),r.this_ORs=[],e=e.slice(1);for(var n=r.nb_addresses.readUInt(),s=0;n>s;s++){var a=po(e);r.this_ORs.push(a.addr),e=a.data}return t.push(r),t},create_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),t.push(r),t},create_fast_ws_cell_decode:function(e){var r=[],i={},n=new un;try{i.key_material=new t(n.decrypt(Xs,e.slice(0,128).toString("hex"),"","hex"),"hex"),r.push(i)}catch(s){console.log("create fast pb decrypting")}return r},created_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),r.derivative_key_data=e.slice(20,40),t.push(r),t},created_fast_ws_cell_decode:function(e){var t=[],r={};return r.key=e.slice(0,40),t.push(r),t},create_cell_decode:function(e){var t=[],r={};return r.M_=e.slice(0,128),r.M2_=e.slice(128,186),t.push(r),t},created_cell_decode:function(e){var t=[],r={};return r.dh_data=e.slice(0,128),r.derivative_key_data=e.slice(128,148),t.push(r),t}};var Fo=function(e){e&&(this.OP_=!0,this.server_=e[0],this.path_=e,this.nb_=0,this.conn_=0,this.sent_=0,this.received_=0,this.circuit_window=cs,this.circuit_window_s=cs,this.stream_=[],this.pause_={},this.time_=(new Date).valueOf(),this.resolved_failed=0),this.perf_=0,this.time_average=0};Fo.prototype={padding_cell_handle:function(){this.next_&&this.next_.keep_alive()},versions_cell_handle:function(e){var r=this.socket_;if(!this.OR_||this.onion_)e.Payload.forEach(function(e){3==e.readUInt()&&(r.handshake_=3)},this),r.handshake_||this.end("v3 handshake not supported","handshake");else{var e=new Po(this.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));if(this.send(e),!r.ws_){var i={};i.CertType=new t(1).writeUInt(1),i.Certificate=new t(al(o+"pub-key.pem",o+"priv-id-key.pem","der",r.certid_,r.cert_date,r.cert_subject,r.cert_issuer),"hex"),i.CLEN=new t(2).writeUInt(i.Certificate.length),i=[i.CertType,i.CLEN,i.Certificate].concatBuffers();var n={};n.CertType=new t(1).writeUInt(2),n.Certificate=new t(al(o+"pub-id-key.pem",o+"priv-id-key.pem","der",parseInt(No(8).toString("hex"),16),r.cert_date,r.cert_issuer,r.cert_issuer),"hex"),n.CLEN=new t(2).writeUInt(n.Certificate.length),n=[n.CertType,n.CLEN,n.Certificate].concatBuffers(),e=new Po(this.circId,Po.prototype.CERTS,[new t(1).writeUInt(2),i,n].concatBuffers()),this.send(e);var s={};s.Challenge=No(32),s.N_Methods=new t(2).writeUInt(1),s.Methods=new t(2).writeUInt(0),e=new Po(this.circId,Po.prototype.AUTH_CHALLENGE,[s.Challenge,s.N_Methods,s.Methods].concatBuffers()),this.send(e)}var a=[],c={};c.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),c.other_OR={type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.remoteAddress)},c.nb_addresses=new t("01","hex"),c.this_ORs=[{type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.address().address)}],a.push(c),e=new Po(this.circId,Po.prototype.NETINFO,a),this.send(e)}},certs_cell_handle:function(){},auth_challenge_cell_handle:function(){},netinfo_cell_handle:function(e){var r={};if(!this.OR_f){var i=this.socket_.remoteAddress;if(e.Length=0,r.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),e.Length+=4,e.Payload[0].this_ORs.forEach(function(t){(Lo(t.value)==i||this)&&(r.other_OR=t,e.Length+=t.length,this._OR_ip_verified=!0)},this),this._OR_ip_verified)if(r.nb_addresses=new t(1).writeUInt(1),e.Length++,r.this_ORs=[e.Payload[0].other_OR],e.Length+=r.this_ORs[0].length,e.Payload=[r],this.send(e),this.socket_.handshake=!0,this.OP_)if(this.setCircId(),!zs&&!js||!ks&&!Us||Cs&&!Js)this.create();else if(A&&Zi&&(!Cs&&$i||!Js)){this.X_=No(20);var n=new t(vl.encrypt(this.X_.toString("hex")),"hex"),s=new Po(this.circId,Po.prototype.CREATE_FAST_WS,n);this.send(s)}else{this.X_=No(20);var s=new Po(this.circId,Po.prototype.CREATE_FAST,this.X_);this.send(s)}else this.setCircId(),this.create();else this.end("remote IP does not match","handshake")}},create_fast_cell_handle:function(e){console.log("OR receive create fast from "+this.socket_.remoteAddress+" CIC "+this.circId+" sending created_fast"),this.X_=e.Payload[0].key_material,this.Y_=No(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new Po(this.circId,Po.prototype.CREATED_FAST,[this.Y_,r].concatBuffers());this.send(i)},create_fast_ws_cell_handle:function(e){if(e.Payload.length){this.X_=e.Payload[0].key_material,this.Y_=No(20);var r=[this.X_,this.Y_].concatBuffers(),i=this.circuit_keys(r),n=new Po(this.circId,Po.prototype.CREATED_FAST_WS,new t(Eo([this.Y_,i].concatBuffers(),this.X_.slice(0,16)),"hex"));this.send(n)}else this.destroy(1)},created_handle:function(){if(this.conn_++,(zs||js)&&(ks||Us)&&!Cs&&$i&&this.request_.params_.ws===Cl&&delete this.next_,this.next_)this.extended_=this.next_,this.extend();else if((zs||js)&&(ks||Us)){if(console.log("CIRC : CIRCUIT ESTABLISHED FAST - CID "+this.circId+" "+(this.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(this.prev_?this.prev_.server_.ip:"NONE")+" LAST OR : "+this.server_.ip),Cs=this,ks)for(var e in bs)bs[e].associated||El.associate(this.first_,e);!es&&Zi&&(ks?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):El.db_cid_launched||rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})),this.first_.last_=this}else console.log("CIRC : CAN NOT HAVE ONLY ONE NODE IN THE PATH"),this.end("CAN NOT HAVE ONLY ONE NODE IN THE PATH")},created_fast_cell_handle:function(e){console.log("created fast received CIC "+this.circId),this.Y_=e.Payload[0].key_material;var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t);r.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},created_fast_ws_cell_handle:function(e){var r=new t(Eo(e.Payload[0].key,this.X_.slice(0,16)),"hex");this.Y_=r.slice(0,20);var i=[this.X_,this.Y_].concatBuffers(),n=this.circuit_keys(i);n.toString("hex")!=r.slice(20,40).toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},create_cell_handle:function(e){var r=e.Payload[0].M_,i=e.Payload[0].M2_;this.X_=So(this.socket_.privkey_.toString("utf-8"),r.toString("hex"),i);var n=sn.getDiffieHellman("modp2");n.generateKeys(),this.Y_=new t(n.getPublicKey("hex"),"hex");var s=new t(n.computeSecret(this.X_,"hex","hex"),"hex"),a=this.circuit_keys(s),o=new Po(this.circId,Po.prototype.CREATED,[this.Y_,a].concatBuffers());this.send(o)},created_cell_handle:function(e){if(this.OP_){console.log("OP created "+this.circId);var r=this.extended_?this.extended_:this;if(r.Y_=e.Payload[0].dh_data,A&&!r.DH_.computeSecret){var i=new t(1).writeUInt(2);vn[r.cid_hex]=function(t){var r=this.extended_?this.extended_:this,i=t.toString("hex");r.DH_.computeSecret=function(){return i},delete vn[r.cid_hex],this.created_cell_handle(e)}.bind(this);var n=new qo(qo.prototype.RELAY_INFO,0,[i,new t(r.cid_hex,"hex"),r.Y_].concatBuffers(),Cs.Df_hash),s=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(n));return Cs.send(s),void 0}var a=new t(r.DH_.computeSecret(r.Y_,"hex","hex"),"hex"),o=r.circuit_keys(a);if(o.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex"))r.end("KH key does not match","created_extended_key");else if(this.conn_++,r.ok_=!0,r.next_)r.extended_=r.next_,r.extend();else{if(zs&&ks)for(var c in bs)bs[c].associated||El.associate(this.first_,c);Us&&this.first_.request_.params_.db&&!Ss?(Ss=this.first_,Ss.send_db_info(),Ss.process=Ss.send_db_query,setInterval(this.send_db_info.bind(Ss),As),r?console.log("CIRC : CIRCUIT ESTABLISHED -CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined")):this.first_.request_.params_.db?(console.log("created handle circuit destroy"),this.first_.circuit_destroy()):(r?console.log("CIRC : CIRCUIT ESTABLISHED - CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined"),Qn++),$n>Qn&&Zi&&(js||zs?ks||Ss?(console.log("create new dl circuit"),rc({params_:{OP:!0,nb_hop:Hn,ws:El}})):rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}):rc({params_:{OP:!0,nb_hop:Hn}})),this.first_.last_=r,this.first_.process();var l=mn;if(l)for(;l.length;)this.first_.process(l[0]),l.shift()}}else if(this.prev_){console.log("OR process extend - created received from "+this.server_.ip+" sending relay_extended to CIC "+(this.prev_?this.prev_.circId:"undefined"));var h=e.Payload[0],n=new qo(qo.prototype.RELAY_EXTENDED,0,[h.dh_data,h.derivative_key_data].concatBuffers(),this.prev_.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY_EARLY,!0)}else this.next_.destroy()},extend_cell_handle:function(e){if(ka&&this.socket_.address().port===kn&&this.OR_f)console.log("ORDB - Do not extend send destroy"),this.circuit_destroy();else{var r=Lo(e.slice(0,4)),i=e.slice(4,6).readUInt(),n=e.slice(6,192),s=e.slice(192,212).toString("hex"),a=new Fo;if(a.server_={ip:r,port:i,fing:s},console.log("OR process extend toward "+a.server_.ip+" "+a.server_.port+" "+a.server_.fing),this.next_=a,a.prev_=this,a.onion_=n,a.OR_=!0,a.way_="socket out",a.circId=0,bn[r])a.socket_=bn[r],a.socket_.stream_tor_=new t(0),a.setCircId(),a.create(),console.log("OUTGOING OR SOCKET EXTEND : ---------Socket already exists send create ------------ CIC "+a.circId+" for "+a.server_.ip);else{var c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",l="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",h={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,c,l),servername:c,rejectUnauthorized:!1};console.log("OUTGOING OR SOCKET EXTEND : ---------OR starts client socket with------------"+h.servername+" "+a.server_.ip+" "+a.server_.port);var u=tn.connect(a.server_.port,a.server_.ip,h,function(){bn[a.server_.ip]=this,console.log("OR process extend sending versions"),a.socket_=this,this.OR_=!0,this.way_="socket out",this[a.circId]=a,this.stream_tor_=new t(0);var e=new Po(a.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));a.send(e)});u.on("data",Qo),u.circuits_destroy=function(){for(var e in wn)Object.keys(wn[e]).forEach(function(t){if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=wn[e][t];r&&r.socket_&&r.socket_.remoteAddress&&r.next_&&r.next_.socket_===u&&(console.log("destroy circ in CIC "+r.circId+" "+r.socket_.remoteAddress),r.circuit_destroy())}})},u.on("end",function(){console.log("or_tls_socket end"),delete bn[r],u.circuits_destroy()}),u.on("close",function(){console.log("or_tls_socket close"),delete bn[r],u.circuits_destroy()}),u.on("error",function(){console.log("or_tls_socket error"),delete bn[r],u.circuits_destroy()})}}},handle_destroy:function(e){if(this.OP_){var t=this.first_||this;console.log("OP receive destroy CIC "+t.circId+(t===Ss?" ------- DB_CID destroyed --------------- ":"")),t.destroyed_=!0,this.clear_timers(),t.circuit_destroy(!0)}else{console.log("OR "+(this.OR_f?"in":"out")+" received destroy from "+this.socket_.remoteAddress+" on CID "+this.circId);var t=this.prev_||this.next_;t?(console.log("OR "+(this.OR_f?"in":"out")+" send destroy to "+(t.socket_?t.socket_.remoteAddress:"")+" on CID "+t.circId),e=e.toString(),e=1===e.length?"0"+e:e,t.circuit_destroy(),this.circuit_destroy(!0)):this.circuit_destroy()}},relay_cell_handle:function(e,t){var r=e.Payload[0],i=e.Command.readUInt();this.OP_?this.stream_decrypt_backward(r,t):this.prev_?this.stream_encrypt_or_b(r,i):this.stream_decrypt_or_f(r,i)},relay_send_truncate:function(e){var r=new qo(qo.prototype.RELAY_TRUNCATE,0,new t(1).writeUInt(e),this.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(r));this.send(i)},relay_end_handle:function(e,r){var i=this.first_,n=i[e],s=function(){n.download_&&(Lh('

An unexpected event occured(error '+r+"), please retry

"),lh(n.bar_)),n._write_(new t(oo(),"utf8")),n.end()};if(n&&(n.abstract_client_tls&&n.abstract_client_tls.close(),delete n.abstract_client_tls,!n.destroyed))if(-1===[6,12].indexOf(r))Us||(console.log(n.nb_try),n.nb_tryZn||0===i.sent_)&&(i.bad_=!0),i.destroy_cid(n),i.request_retry(n,r)):s());else if(n._data_)if(12===parseInt(r))if(console.log("END : CONNRESET RETRY "+r+" CID "+this.first_.circId+" on port "+n.remotePort+" for request "+n.i_id),n.download_)if(n.url_){var a=function(){n.queue_.shift(),Lh('

Remote server closed the connection (error '+r+"), download could not be completed, resuming...

"),setTimeout(function(){Wa("alert_box").style.display="none"},1e4);var s=function(r){var n=ho(r.url_);r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.params_.stream=vo(n.host,n.rest,length),r.queue_=[],r.queue_s=[],delete r.eof_,delete i[e],delete r.cid_,delete r.check_hash,delete r.file_id,delete r.start_t0,r.received_=0,rc(r)};ah(n,!0,s)};n.queue_.push(a),1===n.queue_.length&&n.queue_[0]()}else $a(document.body,"mousedown",function(){},!1),Lh('

Remote server closed the connection (error '+r+"), download could not be completed, please use Resume to resume the download.

"),n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]());else i.perf_--,i.destroy_cid(n),n.destroy();else n.bufferSize||(ks&&n.abstract_client_tls?n.done_=!0:n.download_?n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]()):(i.destroy_cid(n),n.end()));else n.nb_try++,i.perf_--,i.destroy_cid(n),i.request_retry(n,r)},request_retry:function(e,t){console.log("Retry for request "+e.i_id),ks?e.relay_ws_handle(e.ini_data,!0):rc(e,this,"end "+t)},relay_truncated_handle:function(e){console.log("STREAM : Truncated received from "+this.server_.ip+" CIRC "+this.circId+" "+e);var t=this.first_;switch(e){case 8:this.handle_destroy(0);break;case 11:this.handle_destroy(0);break;default:var r=t.last_?t.last_.ok_:null;r||this.next_.change_or("- relay truncated",this.extend)}},relay_truncate_handle:function(e){console.log("truncate "+this.circId);var r=this.next_,i=new Po(r.circId,Po.prototype.DESTROY,new t("05","hex"));r.send(i);var n=new qo(qo.prototype.RELAY_TRUNCATED,0,new t(1).writeUInt(e),this.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY,!0)},stream_handle:function(e){switch(e.command.readUInt()){case e.RELAY_EXTEND:this.extend_cell_handle(e.data);break;case e.RELAY_TRUNCATE:this.end("Error OR receive truncate :"+e.data.slice(0,1).readUInt(),"truncate");break;case e.RELAY_EXTENDED:this.created_cell_handle(new Po(this.circId,Po.prototype.CREATED,e.data,!0));break;case e.RELAY_TRUNCATED:this.end("Error OP receive truncated :"+e.data.slice(0,1).readUInt(),"truncated");break;case e.RELAY_END:this.end("End :"+e.data.slice(0,1).readUInt(),"relay_end",e.streamId.readUInt());break;case e.RELAY_CONNECTED:this.stream_decode_connected(e),this.stream_handle_connected(e.streamId.readUInt());break;case e.RELAY_DATA:this.stream_handle_data(e);break;case e.RELAY_SENDME:Oi("RECEIVING SENDME CIC "+this.circId+" for stream "+e.streamId.readUInt()),this.stream_handle_sendme(e.streamId.readUInt());break;case e.RELAY_ASSOCIATE:this.associate(e.data.slice(0,e.length.readUInt()).toString("utf8"));break;case e.RELAY_INFO:this.info(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_WS:this.relay_ws_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_INFO:this.relay_db_info_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_QUERY:this.relay_db_query_handle(e);break;case e.RELAY_DB_CONNECTED:this.relay_db_connected_handle(e);break;case e.RELAY_DB_END:this.relay_db_end_handle(e);break;case e.RELAY_DB_DATA:this.relay_db_data_handle(e);break;case e.RELAY_DB_SENDME:this.relay_db_sendme_handle(e)}},stream_decode_connected:function(){},stream_handle_sendme:function(e){var t=this.first_,r=t.stream_;Oi("FLUSH BUFFER CIC "+t.circId+" sid "+(e||" whole circuit ")+" buffer length "+r.length);var i=Math.min(e?us:ls,r.length),n=0;for(e?t[e].stream_window_s+=us:t.circuit_window_s+=ls;i>n;){var s=e?r[n]:r[0];e?e===s[1]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),s[0]=null,n++):(s[0]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),n++),r.shift())}},stream_handle_connected:function(e,r){var i=this.first_,n=i[e];if(n)if(Us&&clearTimeout(n.socket_retry),this.clear_timers(),console.log("STREAM RELAY :--------------RELAY_CONNECTED TO---------------------- "+this.server_.ip+" VIA "+this.first_.server_.ip+" CID "+this.circId+" Stream "+e+" for request "+n.i_id),n.params_.stream){for(var s=n.params_.stream;s.length;){if(n.tls_client_connected||!n.abstract_client_tls,r)var a=new qo(qo.prototype.RELAY_DB_DATA,e,[new t(r,"hex"),s.slice(0,Math.min(s.length,pn-16))].concatBuffers(),this.Df_hash);else var a=new qo(qo.prototype.RELAY_DATA,e,s.slice(0,Math.min(s.length,pn)),this.Df_hash);var o=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(a));if(n.sent_++,i.resolved_failed=0,i.sent_++,i.time_=Date.now(),n.start_t0=i.time_,n.stream_window_s--,i.circuit_window_s--,0===n.stream_window_s||0===i.circuit_window_s?(console.log("Bufferizing CIC "+i.circId+" for request "+n.i_id),i.stream_.push[e]):this.send(o),!(s.length>pn))break;s=s.slice(pn)}n.squeue_&&(n.squeue_.shift(),n.squeue_.length&&n.squeue_[0]())}else sc(n)},stream_handle_data:function(e,r,i){var n=this.first_;if(n){var s=e.streamId.readUInt(),a=i||n[s];if(a){r||a.time_resp||(a.time_resp=Date.now(),n.time_average=(n.time_average+(a.time_resp-a.time_ini))/(n.time_average?2:1)),r?(console.log("STREAM RELAY : --------------RECEIVE DECODED TLS DATA FROM---------------------- "+this.server_.ip+" CID "+this.circId+" Stream "+s+" for request "+a.i_id+" length "+e.length.readUInt()),e.data.slice(0,e.length.readUInt())):a.tls_client_connected||!a.abstract_client_tls;var o=e.data.slice(0,e.length.readUInt());if(r)a.received_++;else{if(!a._data_||a.wait_header){var c;if(a._data_=!0,a.download_){if(o=a.wait_header?[a.wait_header,o].concatBuffers():o,c=ic(o.toString("utf8")),"undefined"==typeof c["1a"]||""!==c["1a"])return a.wait_header=o,void 0;delete a.wait_header;var l=c["0a"].split(" ");if(l=l[1]?l[1]:null){if(Oi("STREAM : status code "+l+" for request "+a.i_id),l=l.toString(),-1===["2","3"].indexOf(l[0]))return Lh('

Wrong URL, please check and try again

'),lh(a.bar_),n.send_relay_end(a.sid_),void 0;if("3"===l[0]){if(c.Location){var h=ho(c.Location);a.params_.stream=yo(h.host,h.rest),n.send_relay_end(a.sid_),delete n[a.sid_],delete a.cid_,rc(a)}return}if(a.d_length=a.d_length||0,a.content_=c["Content-Type"]?c["Content-Type"]:"application/octet-binary",c["Content-Length"]&&!a.clength_&&(a.clength_=parseInt(c["Content-Length"])),!a.clength_)for(var u in c)if(-1!==u.toLowerCase().indexOf("content-length")){a.clength_=parseInt(c[u]);break}a.pieces=Math.ceil(a.clength_/Da),c["Transfer-Encoding"]&&(a.encoding_=c["Transfer-Encoding"]),console.log("Start relay_data"),console.log(a.content_),console.log(a.clength_),console.log(a.encoding_?a.encoding_:"No encoding"),a._stream_&&fh(a),o=o.toString("hex").split(gs+gs),o.shift(),o=new t(o.join(gs+gs),"hex")}}}a._data_=!0,a.received_++,n.received_++,n.circuit_window--,a.stream_window--,a.resp__=a.resp__?a.resp__+o.length:o.length,0===n.received_%ls&&n.circuit_window1))return a.header_=o,void 0;a.header_=[a.header_?a.header_:new t(0),new t(f[0]+gs+gs,"hex")].concatBuffers(),a.header_l=a.header_.length}if(a.header_l){if(f.shift(),"chunked"!==a.encoding_){var c=ic(a.header_.toString("utf8"));c["Content-Length"]&&(a.clength_=parseInt(c["Content-Length"]),a.content_l=!0)}else f=f.join(gs+gs).split(gs),a.header_l=a.header_.length,a.clength_=f.length>1?parseInt(new t(f[0],"hex").toString("utf8"),16):0,f.shift(),a.pass_="",a.buff_="";o=new t(f.join(gs),"hex")}}if("chunked"===a.encoding_){if(a.html_.length+o.length>=a.clength_||a.wait_)var p=cc(o.toString("hex"),a);t.isBuffer(a.html_)?a.html_={length:parseInt((p?p:o).length)}:a.html_.length+=p?0:parseInt(o.length)}else a.html_=[a.html_,o].concatBuffers()}}try{}catch(_){}r||n.perf_++,a.nb_try=0;var f=a.html_?a.content_l&&a.clength_===a.html_.length||"chunked"===a.encoding_?!1:!0:!1;if(!f){if("chunked"!==a.encoding_&&(a.socks_s=!1),a.html_){var g=a.content_l?a.html_.toString("utf8"):a.decoder_.decode(p?p:o,{stream:!0});if(!a.content_l){if(a.buff_+=g,a.buff_.length=128)&&i.push(e.Length);var s=function(e){if(e.push)e.forEach(function(e){t.isBuffer(e)?i.push(e):s(e)});else for(var r in e)t.isBuffer(e[r])?i.push(e[r]):s(e[r])};if(e.Payload.push?e.Payload.forEach(function(e){s(e)}):i.push(e.Payload),i=i.concatBuffers(),7!==e.Command.readUInt()&&e.Command.readUInt()<128){var a=new t(512);a.map(i),i=a}if(this.OP_&&!r.last_){var o;this.clear_timers();var c;this===r?this.socket_?this.socket_.handshake_?(o=function(){console.log("CIRC : Create or first extend too long "+this.circId),this.circuit_retry()},c=Vn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){console.log("CIRC : Extend delay expired - change or "+this.server_.ip),this.change_or("- extend too long",this.extend)},c=Gn)}if(yh&&_h&&(chart1_int||chart2_int)&&parseInt(n)!==Po.prototype.PADDING){var l=go(new Date).getTime(),h=i.length;r===Ss?chart2_int&&(yh.dynRow2[l]=yh.dynRow2[l]?yh.dynRow2[l]+h:h):chart1_int&&(_h.dynRow2[l]=_h.dynRow2[l]?_h.dynRow2[l]+h:h)}if(this.OP_||this.OR_)try{if(this.OR_&&6===e.Command.readUInt()&&console.log("sending FAST to "+(this.server_?this.server_.ip:"OP")+" CIC "+e.CircID.readUInt()),this.socket_.ws_)if(this.OP_){if(A&&!I||T)var a=i;else var a=Ac(i,2,!0);this.socket_.write(a)}else this.socket_.write(Ac(i,2,!1));else this.socket_.write(i)}catch(u){if(console.log("OUTGOING SOCKET "+(this.OP_?"OP ":"OR ")+(this.socket_?this.socket_.ws_?"WS":"TLS":"")+" IP "+(this.server_?this.server_.ip:"")+" socket does not exist any longer"),this.OP_)this.socket_?T||this.socket_.destroy():(console.log("send1 circuit destroy"),this.circuit_destroy(!0));else if(!this.OR_f){var d=this.socket_;console.log("send2 circuit destroy"),this.circuit_destroy(!0),d&&d.circuits_destroy()}}else d.write(e)},navigate:function(e){var t=ho(e._host_);t.host="www."+fo(t.host,!0)+ms,Es=t.host,protocol=t.protocol,El.associate(Cs,t.host),console.log("send 301 and associate fake_d "+t.host+" location "+uo(t)),this.redirect(e,uo(t))},redirect:function(e,r){console.log("redirect send 301 for url "+r),Ds?(alert(lo(r)),e.__write__(new t(lo(r),"utf8"))):e._write_(new t(lo(r),"utf8")),e.destroy(),this.destroy_cid(e,!0),delete e._host_},send_db_info:function(e){e=e||null;var r=function(e){if(e.file_length===e.current_length&&Ss){console.log("send_db_info"),console.log(e.name_hash);var r=new t(e.name_hash,"hex"),i=new t(1).writeUInt(r.length),n=new t(1).writeUInt(0),s=T?new t(1).writeUInt(1):new t(0),a=[i,r,n,s].concatBuffers(),o=new qo(qo.prototype.RELAY_DB_INFO,0,a,Ss.last_.Df_hash),c=new Po(Ss.circId,Po.prototype.RELAY,Ss.last_.stream_encrypt_forward(o));Ss.send(c)}};Ha.list(r,e)},send_db_query:function(e,r){if(e){console.log("send_db_query");var i,n=e.params_?e.params_.hash_:e.hash_,s=e.d_length.toString(16);s=s.length%2?"0"+s:s,s=new t(s,"hex"),size_l=new t(1).writeUInt(s.length),console.log("send_db_query hash "+n.toString("hex")+" "+size_l[0]+" "+s.toString("hex")+" tid "+(r?r.toString("hex"):""));var a=[new t(1).writeUInt(n.length),n,size_l,s].concatBuffers();if(r)a=[a,r].concatBuffers(),i=0;else{if(i=bo(this),e.cid_=this,!i)return;this[i]=e,e.sid_=i,e.received_=0,e.sent_=0}if(this.OP_){console.log("OP send db_query CID "+this.circId+" sid "+i);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));e.query_time=Date.now(),this.send(c);var l=function(){this.socket_&&(e._torrentc_||(console.log("serving party not responding"),e.db_try++,this.send_db_end(1,i),delete e.sid_,this.send_db_query(e)))}.bind(this);e.db_tryNo answer from the network, changing peer to peer circuits, please wait and retry

'),lh(e.bar_),console.log("db_query no answer circuit destroy"),Ss.circuit_destroy(),Ss=null)}else{this.prev_=this,this.nb_query=this.nb_query||0,this.nb_query++,console.log("ORDB send db_query CID "+this.prev_.circId+" sid "+i+" "+this.prev_.socket_.remoteAddress);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.prev_.Db_hash);this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}}},send_db_end:function(e,r,i){r=r||0,console.log("send db_end CID "+this.circId+" sid "+r+" reason "+e+" "+("undefined"!=typeof i?i.toString("hex"):""));var n=new t(1).writeUInt(e);if(n=i?[n,i].concatBuffers():n,this.OP_){var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.last_.Df_hash),a=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(s));this.send(a)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_connected:function(e,r,i,n){e=e.toString(16),e=e.length%2?"0"+e:e,e=new t(e,"hex"),size_l=new t(1).writeUInt(e.length),i=new t(i,"utf8");var s=new t(2).writeUInt(i.length);console.log("send db_connected "+e.toString("hex")+" CID "+this.circId+" sid "+r+" type "+i.toString("utf8"));var a=[size_l,e,s,i].concatBuffers();if(n&&(a=[n,a].concatBuffers()),this.OP_){var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));this.send(c)}else{this.prev_=this;var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.prev_.Db_hash); -this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_data:function(e,t,r,i){if(this.OP_){var n=this[t];i||(n.fc_t=[],console.log("sending db data "+(this.OP_?"OP ":"ORDB sid ")+t+" BANDWIDTH "+8*Ra+" bps "+(this.OP_?" 512 bytes every "+(1+1e3/(Ra/Da))+" ms then nbblocks "+Math.ceil(Na*Ra/1e3/Da)+" every "+Na+"ms window size "+n.stream_window_s+" "+this.circuit_window_s:"")+" cd "+e.size),n.start_t0=Date.now(),n.cd_length=e.size,n.messageName="flush",T||$a(window,"message",Ao.bind(n),!0),n.reader=T?new Va:new FileReader,n.cursor=0),Io.call(this,e,t,n,r)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_DATA,t,e.slice(0,Math.min(e.length,pn)),this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_sendme:function(e){if(e=e||0,this.OP_){var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)}else{this.prev_=this;var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.prev_.Db_hash);this.stream_encrypt_or_b(r.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},circuit_keys:function(e){var t=wo(e.toString("hex")),r=t.slice(0,20);return this.Df_=t.slice(20,40),this.Db_=t.slice(40,60),this.Kf_=t.slice(60,76),this.Kb_=t.slice(76,92),this.Kf_cipher=sn.createcipheriv("aes-128-ctr",this.Kf_,Ln),this.Kb_cipher=sn.createcipheriv("aes-128-ctr",this.Kb_,Ln),this.Df_hash=new fn("sha1"),this.Db_hash=new fn("sha1"),this.Df_hash.update(this.Df_),this.Db_hash.update(this.Db_),r},stream_encrypt_forward:function(e){for(var r=this,i=e.toBuffer();r;)i=new t(r.Kf_cipher.update(i,"hex","hex"),"hex"),r=r.prev_;return i},stream_decrypt_backward:function(e,r){var i,n=this;if(w)var s=Date.now();for(var a=e.length;n&&!(n.Kb_&&(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),i=n.recognized(e)));)n=n.extended_;if(s&&(ga++,ma+=a,ya+=Date.now()-s,0===ga%va&&ya&&(console.log("CRYPTO perf decrypt backward: "+parseInt(8*ma/(ya/1e3))+" bps"),ga=0,ma=0,ya=0)),i&&41===i.command.readUInt(),i)if(r){var o=new qo(qo.prototype.RELAY_END,i.streamId,new t("0A","hex"),n.Df_hash),c=new Po(n.circId,Po.prototype.RELAY,n.stream_encrypt_forward(o));n.send(c)}else n.stream_handle(i);else this.end("Unrecognized stream","unrecognized"),console.log(e.toString("hex"))},stream_decrypt_or_f:function(e,r,i){if(this.Kf_cipher){if(e=new t(this.Kf_cipher.update(e,"hex","hex"),"hex"),!i)var n=this.recognized(e);if(n)this.stream_handle(n);else if(Rs&&this.socket_.fake_cid===this);else if(this.next_){var s=new Po(this.next_.circId,r,e);this.next_.send(s)}}},stream_encrypt_or_b:function(e,r,i){var n=this.prev_;if(n&&n.Kb_cipher){if(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),!i)var s=n.recognized(e);if(s)this.stream_handle(s);else if(n){var a=new Po(n.circId,r,e);n.send(a)}}},recognized:function(e){if(0==e.slice(1,3).readUInt()){var r=e.slice(9,11),i=Math.min(11+r.readUInt(),e.length),n=new qo(e.slice(0,1).readUInt(),e.slice(3,5).readUInt(),e.slice(11,i));n.length=r;var s=e.slice(5,9);if(this.OR_f){this.Df_hash.update(n.toBuffer());var a=new t(this.Df_hash.digest("hex"),"hex").slice(0,4)}else{this.Db_hash.update(n.toBuffer());var a=new t(this.Db_hash.digest("hex"),"hex").slice(0,4)}if(a.toString("hex")==s.toString("hex"))return n}},extend:function(){var e=this.extended_,r=Oo(e.server_.ip),i=new t(2).writeUInt(parseInt(e.server_.port)),n=new t(e.server_.fing,"hex");if(!A||sn.getDiffieHellman){var s=sn.getDiffieHellman("modp2");s.generateKeys(),e.DH_=s,e.X_=new t(s.getPublicKey("hex"),"hex");var a=function(){var s=Co(new t(e.server_.o_modulus,"hex"),e.X_),a=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,s,n].concatBuffers(),this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(a));this.send(o)};e.server_.o_modulus?a.call(this):e.get_certs(a)}else{var a=function(t){var s=t.slice(0,2).readUInt();e.X_=t.slice(2,2+s),e.DH_={};var a=t.slice(2+s),o=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,a,n].concatBuffers(),this.Df_hash),c=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(o));delete vn[e.cid_hex],this.send(c)}.bind(this);e.create_extend_info(a)}},create:function(){if(this.onion_){var e=new Po(this.circId,Po.prototype.CREATE,this.onion_);this.send(e)}else if(A){var r=function(e){var t=e.slice(0,2).readUInt();this.X_=e.slice(2,2+t);var r=e.slice(2+t),i=new Po(this.circId,Po.prototype.CREATE,r);delete vn[this.cid_hex],this.send(i)}.bind(this);this.DH_={},this.create_extend_info(r)}else{var i=sn.getDiffieHellman("modp2");i.generateKeys(),this.DH_=i,this.X_=new t(i.getPublicKey("hex"),"hex");var r=function(){var e=Co(new t(this.server_.o_modulus,"hex"),this.X_),r=new Po(this.circId,Po.prototype.CREATE,e);this.send(r)};this.server_.o_modulus?r.call(this):this.get_certs(r)}},create_extend_info:function(e){var r=new t(1).writeUInt(1),i=No(16),n=i.toString("hex");this.cid_hex=n;var s=new t(this.server_.o_modulus,"hex");vn[n]=e;var a=new qo(qo.prototype.RELAY_INFO,0,[r,i,s].concatBuffers(),Cs.Df_hash),o=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(a));Cs.send(o)},destroy:function(){console.log("CIRC : -------------------------- SEND DESTROY ------------------- "+(this.server_?this.server_.ip:this.socket_.remoteAddress)+(this.OP_?" OP":" OR")+" CID "+this.circId);var e=new Po(this.circId,Po.prototype.DESTROY,new t("09","hex"));this.send(e)},send_relay_end:function(e){var r=this.first_||this,i=new qo(qo.prototype.RELAY_END,e,new t(0),r.last_.Df_hash),n=new Po(r.circId,Po.prototype.RELAY,r.last_.stream_encrypt_forward(i));r.send(n)},associate:function(e){console.log("ASSOCIATE OR RECEIVE "+e),this.socket_.fake_cid=this,En[e]={circ_:this}},info:function(e){if(this.OP_){var r=e.slice(0,16).toString("hex");vn[r]&&vn[r](e.slice(16))}else{var i=e.slice(0,1).readUInt(),r=e.slice(1,17);switch(i){case 1:var n=e.slice(17),s=sn.getDiffieHellman("modp2");s.generateKeys(),Bn[r.toString("hex")]=s;var a=new t(s.getPublicKey("hex"),"hex"),o=Co(n,a);e=new qo(qo.prototype.RELAY_INFO,0,[r,new t(2).writeUInt(a.length),a,o].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);this.send(c);break;case 2:var l=r.toString("hex");if(Bn[l]){var h=new t(Bn[l].computeSecret(e.slice(17),"hex","hex"),"hex");e=new qo(qo.prototype.RELAY_INFO,0,[r,h].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);delete Bn[l],this.send(c)}}}},relay_ws_handle:function(e,r){if(this.OP_){var i=null,s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8").split(":");if(e=e.slice(2+s),console.log("OP ws receive request "+a[3]+" adresse "+a[0]+" port "+a[1]+" data "+e.length),e.length){var o={},c=yn[a[3]];c?c.params_&&(i=c.params_.host):(c={nb_try:0,no_exit:[],i_id:a[3]},yn[a[3]]=c);var l=function(e){for(var r=e,i=new t(new t(a[0]+":"+a[1],"utf8").toString("hex"),"hex"),n=i.length.toString(16);4!==n.length;)n="0"+n;if(i=[new t(n,"hex"),i].concatBuffers(),n=i.length,0===r.length){var s=new qo(qo.prototype.RELAY_WS,0,i,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));this.send(o)}else for(;r.length;){var c;c=r.length+n>_n?r.slice(0,_n-n):r,c=[i,c].concatBuffers();var s=new qo(qo.prototype.RELAY_WS,0,c,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));if(this.send(o),!(r.length+n>_n))break;r=r.slice(_n-n)}}.bind(Cs);if(!Ds||!c.tls_server_connected){var h=function(){if(c.wait_header=c.wait_header?[c.wait_header,e].concatBuffers():e,c.wsqueue_&&c.wsqueue_.length){var t=c.wsqueue_[0];c.wsqueue_.shift(),t()}};if(e.length>=4){var u=e.toString("hex");u.substr(u.length-8)!==gs+gs?h():(e=c.wait_header?c.wait_header:e,delete c.wait_header)}else h();c._write_=l,c.destroy=function(){Ds?(delete c.abstract_server_tls,c.abstract_client_tls?(delete c.abstract_client_tls,l(new t(0))):c._write_(new t(0))):c._write_(new t(0))}}var d=function(e){var s=a[2],l=ic(e),h=l.Accept?l.Accept:"";-1!==h.indexOf("text/html")&&delete l["Accept-Encoding"],c.referer_=l.Referer,delete l.Referer,l.Connection="keep-alive";var u=l["0a"].split(" "),d="";if(u.length>1){var f="/"===u[1].substr(0,1)?u[1].substr(1):u[1];d=fo(f)}var p=function(){if("http"===d.substr(0,4)){var h=ho(d);u[1]="/"+(h.rest?h.rest:""),l["0a"]=u.join(" "),l.Host&&(l.Host=h.host?h.host:""),delete l.Cookie,l["X-Requested-With"]||(c._host_=h.protocol+"//"+l.Host)}else l.Host&&(c.fake_domain=l.Host,l.Host=bs[l.Host].real_domain);l.Accept&&-1!==l.Accept.indexOf("text/html")&&(l["Accept-Encoding"]="identity"),e=nc(l),o.OP=!0,o.nb_hop=Hn,o.one_c=!0,Ds&&(s=protocol===ws&&"443"===s?"80":s),o.host=l.Host+":"+s,i&&o.host!==i&&(delete c.tls_client_connected,delete c.abstract_client_tls,c.cid_&&c.cid_.destroy_cid(c,!0)),o.stream=new t(e,"utf8"),c.params_=o,c._data_=!1,c._init_=Xo,c._init_(),r&&(c.nb_try=n),c.remoteAddress=a[0],c.remotePort=a[1],c.end=c.destroy};if("https"===d.substr(0,5)||"https:"===protocol){if(!Ns)return console.log("https not supported now "+d),c._write_(new t(ao(),"utf8")),void 0;if(p(),c.abstract_client_tls){console.log("Reuse TLS Client for request "+c.i_id);var _=function(){c.abstract_client_tls.prepare(sl(c.params_.stream.toString("hex")))};c.request_decoded.socks_s?(console.log("Queue "+c.i_id),c.abstract_client_tls.queue_socks.push(_)):_()}else{console.log("Create TLS Client for request "+c.i_id);var g=ho(d),e=c.params_.stream;c.abstract_client_tls=cl(c,g.host),c.abstract_client_tls.stream_tor_=new t(0),c.abstract_client_tls.queue_socks=[];var m={};m._init_=Xo,m._init_(),m._host_=c._host_,m.cid_=c.cid_,m.i_id=c.i_id,m.fake_domain=c.fake_domain,m.socks_s=!0,m.__write__=c.__write__,m.destroy=c.destroy,m.referer_=c.referer_,c.request_decoded=m,m.request_=c,m.received_=0;var y=c.abstract_client_tls,v=function(e){var t=function(e){return function(){this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.stream_tor_.parseTLS(this)}};y.queue_=y.queue_||[],y.queue_.push(t(e).bind(y)),1===y.queue_.length&&y.queue_[0](),y.queue_socks.length&&!m.socks_s&&(m.socks_s=!0,console.log("Unqueue request "+c.i_id),y.queue_socks[0](),y.queue_socks.shift())};c._write_=v,c.write_c=function(e){c.params_.stream=e,rc(c)},c.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.error=function(e,t){console.log(" Error TLS client disconnected "+t.message),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.connected=function(t){console.log("TLS client connected to site for request "+c.i_id),c.tls_client_connected=!0,c._data_=!1,console.log("Sending https request for request "+c.i_id+" to site "+e.toString("utf8")),t.prepare(sl(e.toString("hex")))},c.abstract_client_tls.dataReady=function(e){var r=e.data.data.slice(e.data.read,e.data.length_);e.data.read=e.data.length_;var i={streamId:new t(2).writeUInt(c.sid_),data:r,length:new t(2).writeUInt(r.length)};c.cid_&&c.cid_.last_.stream_handle_data(i,c.__write__,m)},c.abstract_client_tls.handshake()}}else p(),rc(c)};if(c.relay_ws_handle=d,Ds)c.abstract_server_tls||(c.abstract_server_tls=cl(c,Es,!0),c.write_s=l,c.abstract_server_tls.closed=function(){console.log(" TLS server disconnected for request "+c.i_id),c.destroy()},c.abstract_server_tls.error=function(e,t){-1===t.message.indexOf("Unknown")&&(console.log("Error TLS server disconnected for request "+c.i_id+" "+t.message),c.destroy())},c.abstract_server_tls.connected=function(){console.log("TLS server connected to socks client for request "+c.i_id),c.tls_server_connected=!0,c._write_=function(e){c.abstract_server_tls?(console.log("tls server send to SOCKS"),c.abstract_server_tls.prepare(sl(e.toString("hex"))),c.done_&&c.destroy()):console.log("can't send to SOCKS server connection closed for request "+c.i_id)},c.__write__=c._write_,c.abstract_server_tls.dataReady=function(e){console.log(e.data.read);var t=e.data.data.slice(e.data.read,e.data.length_).toString("utf8");-1!==t.indexOf("Host")&&(e.data.read=e.data.length_,console.log("TLS server receive "+t),c.ini_data=t,d(t))}}),c.abstract_server_tls.process(e);else{var f=e.toString("utf8");c.ini_data=f,d(f)}}}if(this.OR_){var s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8");e=e.slice(2+s);var c=Cn[a];if(e.length)return c.write(e),void 0;c.bufferSize||(console.log("OR ws destroy request "+c.i_id),c.end())}},relay_db_info_handle:function(e){console.log("receive relay_db_info CID "+this.circId);var t,r,i,n,s,a;t=e[0],e=e.slice(1),n=e.slice(0,t).toString("hex"),e=e.slice(t),r=e[0],e=e.slice(1),e.length&&(i=e[0]),console.log("db_info "+n+" part "+r+" fac "+(i?"yes":"no")),s=Sn[n],s?(s.forEach(function(e){e[0]===this&&(a=!0)},this),a||s.push([this,null,null,0])):Sn[n]=[[this,null,null,0]],i&&(console.log(An.indexOf(this)),-1===An.indexOf(this)&&(console.log("pushing facilitator CID "+this.circId),An.push(this)))},relay_db_query_handle:function(e){var r=e.streamId.readUInt();console.log("receive relay_db_query CIC "+this.circId+" sid "+r),e=e.data.slice(0,e.length.readUInt());var i=e[0];e=e.slice(1);var n=e.slice(0,i).toString("hex");e=e.slice(i),i=e[0],e=e.slice(1);var s=parseInt(e.slice(0,i).toString("hex"),16);if(e=e.slice(i),console.log("Receive db_query for "+n+" on CID "+this.circId+" sid "+r+" requesting "+s+" bytes "+e.toString("hex")),this.OP_){var a=e.slice(0,16),c=this.first_;if(n!==Aa){var l=Ya(),h=l.get(n);h.onsuccess=function(e){var t=e.target.result;if(t)if(t.file_length===t.current_length&&se.length&&(e=t)}),sr?-1:1}).sort(function(e,t){return e[0].socket_?t[0].socket_?0:1:-1});var i=u.length;if(u.forEach(function(e){console.log("f has "+e[0].circId+" valid "+(e[0].socket_?"yes":"no"))}),i){for(;u.length;)if(u[0][0].socket_)if(u[0][0].socket_.remoteAddress){if(!u[0][0].destroyed_)break;console.log("ORDB remove destroyed CIC "+u[0][0].circId),u.shift()}else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();if(u.length){var d=u[0][0];u[0][3]++;var a=No(16),f={d_length:s,hash_:new t(n,"hex")};In[a.toString("hex")]=[this,r,u,f,1],d.send_db_query(f,a)}else Uo.call(this,r,s,n)}else Uo.call(this,r,s,n)}else An.length?Uo.call(this,r,s,n):(console.log("ORDB does not know the file"),this.send_db_end(0,r))}},relay_db_connected_handle:function(e){var t=e.streamId.readUInt();if(console.log("receive relay_db_connected CID "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt()),this.OP_){var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),s=this.first_[t];if(s){if("torrent"===n){if(s.url_)return console.log("direct download"),this.first_.send_db_end(1,t),ko(s),Fh(s.query_t0),rc(s),void 0;$a(document.body,"mousedown",function(){},!1),console.log("put torrent timer"),s._streaming_||Lh('

The file is not available in Peersm network, looking for it in Bittorrent network.

'),s._torrentc_=setTimeout(function(){this.first_.send_db_end(1,t),ko(s),Ro(s),Lh('

Could not find the file in bittorrent, stopping download

')}.bind(this),Ia)}else Wa("alert_box").style.display="none",s._torrentc_&&(console.log("remove torrent timer"),clearTimeout(s._torrentc_));s.flowc=s.flowc?s.flowc:Date.now()-s.query_time,console.log("db_query/db_connected "+(Date.now()-s.query_time)+" ms "+s.flowc),Fh(s.query_t0),s.clength_=i,s.pieces=Math.ceil(s.clength_/Da),s.content_=n,s.sid_=t,s.received_=0,s.sent_=0,s.nb_try=0,s.stream_window=Oa,s.stream_window_s=Oa,s._stream_&&"torrent"!==n&&fh(s)}}else{var a=e.slice(0,16).toString("hex");e=e.slice(16);var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),o=In[a];"torrent"!==n&&delete In[a],console.log("db_connected "+a+" type "+n+" size "+i+" "+typeof o),this.nb_query=0,o&&(this.socket_?o[0].socket_&&(o[0].send_db_connected(i,o[1],n),Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t]=o,xn[o[0].socket_.remotePort+"-"+o[0].socket_.remoteAddress+"-"+o[0].circId+"-"+o[1]]=[this,t],this[t]={},o[0][o[1]]={},console.log("i_or associated with remote port "+this.socket_.remotePort+" remote address "+this.socket_.remoteAddress+" CIC "+this.circId+" Stream "+t),console.log("f_or associated with remote port "+o[0].socket_.remotePort+" remote address "+o[0].socket_.remoteAddress+" CIC "+o[0].circId+" Stream "+o[1])):o[0].send_db_end(0,o[1]))}},relay_db_end_handle:function(e){var r=e.streamId.readUInt();e=e.data.slice(0,e.length.readUInt());var i=e.slice(0,1).readUInt();if(console.log("receive db_end sid "+r+" reason "+i+" CIC "+this.circId),this.OP_){var n=this.first_,s=n[r];if(s)if(s.send_data)s.fc_t?s.fc_t.length?(console.log("queue not empty - stop sending"),s.stop_=!0):(console.log("queue empty - delete request"),s._torrent_&&s._torrent_stream.destroy(),delete n[r]):s.__torrent__&&(console.log("destroying engine"),s.__torrent__.destroy());else if(Fh(s.query_t0),Fh(s.sendme_tout),Fh(s.waiting_),2===i||s.reason_||3===i){Fh(s.sendme_tout),Fh(s.waiting_),s.reason_=2;var a=function(){if(s.nb_tryThe remote peers closed the connections, attempts to resume streaming failed.

')):($a(document.body,"mousedown",function(){},!1),Lh('

The remote peers closed the connections during the download, attempts to resume failed, storing downloaded part, please wait that the file appears in Local Storage.

Use resume later to get the complete file.

'),rh(s)),delete s.reason_)};s.queue_=s.queue_||[],s.queue_.push(a),1===s.queue_.length&&s.queue_[0]()}else if(s.url_)if(s.reload2_||s.reload_){console.log("resuming direct download");var o=function(e){var i=e.d_length;e.blob_=Ji?new t(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_});var s=ho(e.url_);e.params_.stream=vo(s.host,s.rest,i),delete e.params_.db_,delete e.cid_,delete n[r],delete e.file_id,delete e.start_t0,e.received_=0,rc(e)};ah(s,!0,o)}else this.destroy_cid(s),delete s.params_.db_,delete s.content_,delete s.d_length,delete s.clength_,delete s.blob_,_h&&(gh.vAxis.maxValue=Ks,_h.draw(mh,gh)),rc(s);else $a(document.body,"mousedown",function(){},!1),Lh('

The file is currently not available from peers in Peersm and Bittorrent networks and can not be downloaded directly, please check the URL or the Hash Name you are using

'),ko(s),Ro(s)}else if(this.nb_query=0,e.length>1){console.log("db_end with tid CIC "+this.circId+" db_test length "+(this.db_test?this.db_test.length:"")),this.db_test&&this.db_test.forEach(function(e){clearTimeout(e)});var c=e.slice(1,17).toString("hex"),l=In[c];if(l){var h=l[2],u=l[4];if(h[u]){l[4]++;var d=h[u][0];d.send_db_query(l[3],new t(c,"hex")),console.log("try another peer "+d.circId+" tid "+c+" stream length "+e.length)}else An.length?Uo.call(this,r,l[3].d_length,l[3].hash):(l[0].send_db_end(i,l[1]),delete In[c])}}else{console.log("forwarding db_end");var f=xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(f)try{3!==i&&(delete Tn[f[0].socket_.remotePort+"-"+f[0].socket_.remoteAddress+"-"+f[0].circId+"-"+f[1]],delete xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete f[0][f[2]]),f[0].send_db_end(i,f[1])}catch(p){}else{var _=Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(_)try{_[0].send_db_end(i,_[1]),delete xn[_[0].socket_.remotePort+"-"+_[0].socket_.remoteAddress+"-"+_[0].circId+"-"+_[1]],delete Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete _[0][_[2]]}catch(p){}}delete this[r]}},relay_db_data_handle:function(e){if(b)var r=Date.now();var i=e.streamId.readUInt();if(e=e.data.slice(0,e.length.readUInt()),this.OP_){var n=this.first_,s=n[i];if(s){0===s.received_&&(console.log("start_t0 received "+Date.now()),s.start_t0=Date.now(),n.send_db_sendme(i)),s.received_++,n.received_++,s.stream_window--,s._write_(e);var a=s.received_,o=parseInt(e.length*s.received_/((Date.now()-s.start_t0)/1e3)),c=Math.ceil(o*(s.flowc/2/1e3)/e.length);c=Math.ceil(Oa-c>0?Math.min(c,Oa*(1-ds)):Oa*(1-ds));var l,h=function(r){var a=function(e){console.log("sendme timeout received_ "+s.received_+" rec "+e+" stream-blocs "+(Oa-c)),s.received_!==e||s._stream_?h(s.received_):(Fh(s.sendme_tout),Fh(s.waiting_),console.log("resuming peer to peer download received "+s.received_),n.send_db_end(1,i),n.relay_db_end_handle({streamId:new t(2).writeUInt(i),length:new t(2).writeUInt(1),data:new t(1).writeUInt(2)}))};Fh(s.sendme_tout),Fh(s.waiting_),console.log(8*o+" bps nbBlocs "+c+" stream window "+s.stream_window+" - sending sendme stream received "+n.received_*e.length+" - Buffer Amount: "+El.bufferedAmount+" "+Date.now()),n.send_db_sendme(i),s.stream_window+=Oa,console.log("sendme timeout "+l+" stream length "+e.length),s.sendme_tout.push(setTimeout(function(){a(r)},l))};s.stream_window===c&&(0===El.bufferedAmount||n.received_*e.lengthr;r++){var i=new Fo;i.OP_=!0,i.t0_=[],i.server_=e.path_[r+1],e.next_=i,i.prev_=e,i.path_=e.path_,i.nb_=e.nb_+1,i.socket_=this.socket_,i.circId=this.circId,i.first_=this,e=i}return!0}var n=parseInt(this.server_.fing,16)Resuming direct download from '+this.last_.server_.ip+"

")):Lh('

File not available from Peers, starting direct download from '+this.last_.server_.ip+"

"),setTimeout(function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},12e3)),e.cid_=this,e.params_.host&&!e.destroyed){var r=new t(e.params_.host);r=new t(r.toString("hex")+"00","hex");var i=bo(this);if(i){console.log("STREAM : --------------SEND RELAY_BEGIN---------------------- CID "+this.circId+" on OR "+this.first_.server_.ip+" Stream "+i+" for request "+e.i_id+" on port "+e.remotePort+" host "+r.toString("utf8")),console.log(e.params_.stream.toString("utf8").substr(0,300)),this[i]=e,e.sid_=i,e.received_=0,e.sent_=0,e.stream_window=hs,e.stream_window_s=hs;var n=function(){var t=this;console.log("Timeout Bad circuit "+t.circId),!t.perf_>0&&(t.bad_=!0),t.send_relay_end(i),e.nb_try++,delete e.cid_,delete t[i],rc(e)},s=function(){var t=new qo(qo.prototype.RELAY_BEGIN,i,r,this.last_.Df_hash),s=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));Us&&(e.socket_retry=setTimeout(n.bind(this),rs)),this.send(s)};s.call(this)}}},sendme:function(e){e=e||{sid_:0,i_id:-1};var r=new qo(qo.prototype.RELAY_SENDME,e.sid_,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)},set_certs:function(e){try{e=e.split(jn),this.server_.onion_k=jn+e[1].split(zn)[0]+zn,this.server_.sign_k=jn+e[2].split(zn)[0]+zn;var t=new dn;return this.server_.o_modulus=t.modulus(this.server_.onion_k),this.server_.s_modulus=t.modulus(this.server_.sign_k),!0}catch(r){return this.nb_error=this.nb_error?++this.nb_error:1,!1}},get_certs:function(e){if(this.server_&&!this.ok_){var t=cn.length,r=this.server_.fing,i=_o(t),n=cn[i].split(":"),s=n[0],a=n[1],o={host:s,path:"/tor/server/fp/"+r,port:a,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip deflate","Accept-Language":"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3","Cache-Control":"max-age=0",Connection:"keep-alive",Host:s,"User-Agent":"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0"}},c=nn.request(o,function(t){if(c.data_="",200!=t.statusCode){this.clear_t0_();try{this.get_certs(e)}catch(i){}}t.on("data",function(e){this.clear_t0_(),c.data_+=e.toString("utf8")}.bind(this)),t.on("end",function(){this.server_&&!c.destroy_&&(this.certs_||(this.set_certs(c.data_)?(this.certs_=!0,this.prev_?e.call(this.prev_):e.call(this)):this.nb_error>4?this.change_or("CERTS : get_certs wrong cert for "+r,this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e)))}.bind(this))}.bind(this)),l=function(){this.clear_t0_(),this.server_&&(this.nb_error=this.nb_error?++this.nb_error:1,this.nb_error>4?this.change_or("error get_certs",this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e))}.bind(this);c.on("error",l),c.end();var h=function(){this.clear_t0_(),c.removeListener("error",l),l=function(){console.log("CERTS : error fired after abort for "+s)},c.on("error",l),c.destroy_=!0,c.socket.destroy(),this.server_&&this.get_certs(e)}.bind(this);this.t0_.push(setTimeout(h,1e3))}},change_or:function(e,t){if(this.server_){console.log("change_or ----------- CIC "+this.circId);var r,i,n=[];if(this.first_)var s=this.first_.request_;var a="undefined"==typeof s?null:s.params_?s.params_.db:null;if(this.prev_||!Zi||("undefined"==typeof this.server_?1:this.server_!==Zi)){if(this.first_===Ss||a)return this.first_&&(console.log("change_or circuit destroy"),this.first_.circuit_destroy(),s&&Ko(s)),void 0;var i=this.prev_?this.next_?on:Exit:Guards,o=i.length;for(this.clear_timers(),this.clear_t0_(),this.path_?n=this.path_.map(function(e){return e.ip}):n.push(this.server_.ip),r=_o(o);-1!=n.indexOf(i[r].split("-")[1]);)r=_o(o);var c=i[r].split("-");i={ip:c[1],fing:c[0],port:c[2],band:c[3],o_modulus:c[5]?c[5]:c[4]}}else console.log("change_or one OR "+this.circId),i=Zi;for(var l=this;l;)delete l.destroy_,delete l.nb_error,delete l.ok_,l=l.next_;delete this.first_.last_;var h=new Fo;Object.keys(this).forEach(function(e){h[e]=this[e]},this),h.server_=i;try{var u=this.server_.ip;this.server_o=this.server_}catch(d){console.log("_server error"),this.clear_timers();for(var f in this)"function"!=typeof this[f]&&console.log(f+" "+this[f]);this.first_.destroy()}delete this.server_,delete h.certs_,this.next_&&(h.next_.prev_=h),this.prev_?(h.prev_.extended_&&(h.prev_.extended_=h),h.prev_.next_=h,-1==e.indexOf("get_certs")&&(h=h.prev_,delete h.certs_)):h.first_=h,h.first_.reconstruct_path(),t&&(this.prev_||this.first_===this)?t.call(h):this.socket_.first_===this?(delete gn[u],h.socket_&&(this.destroy_=!0,h.socket_.destroy(),delete h.socket_),delete h.extended_,h.circId=0,h.first_=h,h.path_.shift(),h.path_.unshift(h.server_),tc(h)):this.next_.change_or("PATH : first socket exists, change path",this.create)}},circuit_retry:function(){if(!es)if(this.ok_||this.socket_.first_!==this){this.destroy(),delete this.ok_,delete this.first_.last_;var e=this.circId;this.circId=bo(this.socket_),delete this.socket_[e],this.socket_[this.circId]=this,this.socket_.nbc_--;for(var t=this;t.extended_;)t.extended_.circId=this.circId,t=t.extended_,delete t.extended_;this===t&&this.socket_.first_!==this?t.create():t.change_or("circuit_retry from first OR circId="+this.circId,this.create.bind(this)) -}else this.change_or("initial socket closed unexpectedly or unexpected circuit creation error or new circuit creation error")},reconstruct_path:function(){for(var e=this,t=[];e.next_;)t.push(e.server_),e=e.next_;for(;e.prev_;)e.path_=t,e.first_=this,e=e.prev_},circuit_destroy:function(e){if(this.socket_){this.socket_.remoteAddress?console.log("CIRC : circuit destroy "+(this.OP_?"OP ":"OR "+(this.OR_f?"in ":"out "))+(this.socket_.address()?this.socket_.address().address:"")+" CID "+this.circId+" remote "+this.socket_.remoteAddress):console.log("circuit destroy : socket no remote address CIC "+(this.OP_?"OP ":"OR ")+" "+this.circId);var t;if(this.socket_){var r=this.socket_;this.next_?e||this.destroyed_||(this.destroyed_=!0,r.remoteAddress&&(console.log("circuit_destroy remote address "+r.remoteAddress+" CIC "+this.circId),this.destroy())):this.socket_.address()&&ka&&parseInt(this.socket_.address().port)===parseInt(kn)&&r.OR_f&&(console.log("ORDB - call db_destroy"),this.circuit_db_destroy()),delete r[this.circId],delete this.socket_,Object.keys(r).forEach(function(e){isNaN(e)||null==e||(t=!0)},this),t||this===Ss||r.ws_||(console.log("circuit_destroy: destroy socket"),r.destroy())}}console.log("circuit_destroy "+(this.OP_?"OP":"OR")),this.OP_&&(console.log("requests_destroy"),this.requests_destroy()),delete this.next_,delete this.prev_},circuit_db_destroy:function(){this.socket_&&Object.keys(this).forEach(function(e){if(!isNaN(e)&&null!=e){var t=this.socket_?this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+e:this.server_?this.server_.port+"-"+this.server_.ip+"-"+this.circId+"-"+e:"",r=Tn[t]||xn[t];r&&(console.log("------- "+r[1]),r[0].send_db_end(2,r[1]),delete xn[t],delete Tn[t],delete this[e],delete r[0][r[1]])}},this)},requests_destroy:function(){for(var e in this)if(!isNaN(e)&&null!=e){var t=this[e];t.abstract_client_tls&&t.abstract_client_tls.close(),delete t.abstract_client_tls,this.destroy_cid(t),Ss?this!==Ss?t._data_?t.destroy():this.request_retry(t,"requests_destroy"):Sl(t):Us&&Sl(t)}if(ks){if(this===Cs){console.log("destroy CIC resend associate ");for(var e in bs)delete bs[e].associated;Cs=null,rc({params_:{OP:!0,nb_hop:Hn,ws:El}})}}else Ss?this===Ss&&(Ss=null,rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})):Us&&rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})},clear_timers:function(){this.OP_&&(this.first_.tc_.forEach(function(e){clearTimeout(e)}),this.first_.tc_=[])},clear_t0_:function(){this.t0_&&(this.t0_.forEach(function(e){clearTimeout(e)}),this.t0_=[])},end:function(e,t,r){if(r)var i=this.first_||this,n=i[r]?i[r]:i.request_;this.OP_,e=e.split(":"),console.log2=function(){};var s=function(){if(e.length>1)switch(parseInt(e[1])){case 0:return console.log2("-- CIC NONE (No reason given.)"),0;case 1:return console.log2("-- CIC PROTOCOL (Tor protocol violation.)"),1;case 2:return console.log2("-- CIC INTERNAL (Internal error.)"),2;case 3:return console.log2("-- CIC REQUESTED (A client sent a TRUNCATE command.)"),3;case 4:return console.log2("-- CIC HIBERNATING (Not currently operating; trying to save bandwidth.)"),4;case 5:return console.log2("-- CIC RESOURCELIMIT (Out of memory, sockets, or circuit IDs.) "+this.circId+" "+(this.OP_?" OP ":" OR ")),5;case 6:return console.log2(" -- CIC CONNECTFAILED (Unable to reach relay.)"),6;case 7:return console.log2("-- CIC OR_IDENTITY (Connected to relay, but its OR identity was not as expected.)"),7;case 8:return console.log2("-- CIC OR_CONN_CLOSED (The OR connection that was carrying this circuit died CID "+this.circId+" "+(this.OP_?" OP ":" OR ")),8;case 9:return console.log2("-- CIC FINISHED (The circuit has expired for being dirty or old.)"),9;case 10:return console.log2("-- CIC TIMEOUT (Circuit construction took too long)"),10;case 11:return console.log2("-- CIC DESTROYED (The circuit was destroyed w/o client TRUNCATE)"),11;case 12:return console.log2("-- CIC NOSUCHSERVICE (Request for unknown hidden service)"),12}}.bind(this),a=function(){if(e.length>1)switch(parseInt(e[1])){case 1:return console.log2("-- RELAY REASON_MISC (catch-all for unlisted reasons) request "+(n?n.i_id:"")),1;case 2:return console.log2("-- RELAY REASON_RESOLVEFAILED (couldn t look up hostname) request "+(n?n.i_id:"")),2;case 3:return console.log2("-- RELAY REASON_CONNECTREFUSED (remote host refused connection) [*] request "+(n?n.i_id:"")),3;case 4:return console.log2("-- RELAY REASON_EXITPOLICY (OR refuses to connect to host or port) request "+(n?n.i_id:"")),4;case 5:return console.log2("-- RELAY REASON_DESTROY (Circuit is being destroyed) request "+(n?n.i_id:"")),5;case 6:return console.log2("-- RELAY REASON_DONE (Anonymized TCP connection was closed) request "+(n?n.i_id:"")),6;case 7:return console.log2("-- RELAY REASON_TIMEOUT (Connection timed out, or OR timed out while connecting) request "+(n?n.i_id:"")),7;case 8:return console.log2("-- RELAY REASON_NOROUTE (Routing error while attempting to contact destination) request "+(n?n.i_id:"")),8;case 9:return console.log2("-- RELAY REASON_HIBERNATING (OR is temporarily hibernating) request "+(n?n.i_id:"")),9;case 10:return console.log2("-- RELAY REASON_INTERNAL (Internal error at the OR) request "+(n?n.i_id:"")),10;case 11:return console.log2("-- RELAY REASON_RESOURCELIMIT (OR has no resources to fulfill request) request "+(n?n.i_id:"")),11;case 12:return console.log2("-- RELAY REASON_CONNRESET (Connection was unexpectedly reset) request "+(n?n.i_id:"")),12;case 13:return console.log2("-- RELAY REASON_TORPROTOCOL (Sent when closing connection because of Tor protocol violations.) request "+(n?n.i_id:"")),13;case 14:return console.log2("-- RELAY REASON_NOTDIRECTORY (Client sent RELAY_BEGIN_DIR to a non-directory relay.) request "+(n?n.i_id:"")),14}}.bind(this);if(t)switch(t){case"handshake":this.change_or("handshake failed");break;case"fast_key":this.change_or("wrong fast key");break;case"created_extended_key":this.change_or("wrong create or extend key",this.prev_?this.prev_.extend:null);break;case"truncated":this.relay_truncated_handle(s());break;case"truncate":this.relay_truncate_handle(s());break;case"destroy":this.handle_destroy(s());break;case"unrecognized":console.log("end unrecognized circuit destroy"),this.circuit_destroy();break;case"relay_end":n&&"undefined"!=typeof n.i_id&&this.relay_end_handle(r,a())}else delete this.socket_[this.circId]}};var qo=function(e,r,i,n){this.command=new t(1).writeUInt(e),this.recognize=new t("0000","hex"),this.streamId=new t(2).writeUInt(r),this.digest=new t("00000000","hex"),this.length=new t(2).writeUInt(i.length),this.data=e===this.RELAY_WS?new t(i.length):new t(pn),this.data.map(i),n&&(n.update(this.toBuffer()),this.digest=new t(n.digest("hex"),"hex").slice(0,4))};qo.prototype={RELAY_BEGIN:1,RELAY_DATA:2,RELAY_END:3,RELAY_CONNECTED:4,RELAY_SENDME:5,RELAY_EXTEND:6,RELAY_EXTENDED:7,RELAY_TRUNCATE:8,RELAY_TRUNCATED:9,RELAY_DROP:10,RELAY_RESOLVE:11,RELAY_RESOLVED:12,RELAY_BEGIN_DIR:13,RELAY_ASSOCIATE:40,RELAY_WS:41,RELAY_INFO:42,RELAY_DB_INFO:80,RELAY_DB_QUERY:81,RELAY_DB_CONNECTED:82,RELAY_DB_DATA:83,RELAY_DB_END:84,RELAY_DB_SENDME:85,toBuffer:function(){return[this.command,this.recognize,this.streamId,this.digest,this.length,this.data].concatBuffers()}};var Ho,Mo,jo,zo=function(e){switch(this.Command.readUInt()){case this.VERSIONS:return this.versions_cell_decode(e);case this.CERTS:return this.certs_cell_decode(e);case this.AUTH_CHALLENGE:return this.auth_challenge_cell_decode(e);case this.NETINFO:return this.netinfo_cell_decode(e);case this.CREATED_FAST:return this.created_fast_cell_decode(e);case this.CREATED_FAST_WS:return this.created_fast_ws_cell_decode(e);case this.CREATE_FAST:return this.create_fast_cell_decode(e);case this.CREATE_FAST_WS:return this.create_fast_ws_cell_decode(e);case this.CREATED:return this.created_cell_decode(e);case this.CREATE:return this.create_cell_decode(e);default:return[e]}},Vo=function(e,t){if(e)for(var r=e.length,i=0;r>i;i++){var n=e[i],s=n.CircID.readUInt();if(this[s])var a=this[s];else{if(!this.OR_||!this.OR_f)return;if(this[0]){var a=this[0];a.circId=s,this[s]=a,delete this[0]}else{var a=new Fo;a.OR_=!0,a.OR_f=!0,a.circId=s,a.socket_=this,a.way_="socket in",this[s]=a}}try{a.clear_timers()}catch(o){}if(6===n.Command.readUInt()&&console.log("handle cell "+n.Command.readUInt()),yh&&_h&&(chart1_int||chart2_int)&&n.Command.readUInt()!==n.PADDING){var c=go(new Date).getTime(),l=0;n.Payload.forEach(function(e){l+=e.length}),a.first_===Ss?chart2_int&&(yh.dynRow[c]=yh.dynRow[c]?yh.dynRow[c]+l:l):chart1_int&&(_h.dynRow[c]=_h.dynRow[c]?_h.dynRow[c]+l:l)}if(a.destroyed_)console.log("received cell for destroyed CIC "+a.circId);else switch(n.Command.readUInt()){case n.PADDING:a.padding_cell_handle(n);break;case n.VERSIONS:a.versions_cell_handle(n);break;case n.CERTS:a.certs_cell_handle(n);break;case n.AUTH_CHALLENGE:a.auth_challenge_cell_handle(n);break;case n.NETINFO:a.netinfo_cell_handle(n);break;case n.CREATE_FAST:a.create_fast_cell_handle(n);break;case n.CREATE_FAST_WS:a.create_fast_ws_cell_handle(n);break;case n.CREATED_FAST:a.created_fast_cell_handle(n);break;case n.CREATED_FAST_WS:a.created_fast_ws_cell_handle(n);break;case n.CREATE:a.create_cell_handle(n);break;case n.CREATED:a.created_cell_handle(n);break;case n.RELAY:a.relay_cell_handle(n,t);break;case n.RELAY_WS:a.relay_cell_handle(n,t);break;case n.RELAY_EARLY:a.relay_cell_handle(n,t);break;case n.DESTROY:a.end("Destroy reason:"+n.Payload[0].slice(0,1).readUInt(),"destroy")}}else console.log("end or banish circuit_destroy"),this.circuit_destroy()},Ko=function(e){console.log("circuit_start"),Us&&Qn>Xn&&(document.location.href=document.location.href);var t=e.params_,r=[];if(t.nb_hop?t.nb_hop>2&&(r=mo(t)):r=mo(t),Zi&&(r[0]=Zi),(ks||Us)&&$i&&!Cs){if(t.ws!==Cl)return;r[0]=$i}t.db&&(r[Mn-1]=ka);var i=gn[r[0].ip],n=new Fo(r);if(n.request_=e,n.first_=n,n.tc_=[],i)if(i.abstract_client_tls&&!i.tls_connected&&i.wsconnected_)console.log("start TLS handshake - circuit start "),i.abstract_client_tls.handshake();else if(console.log("TLS connected - start create_fast"),n.server_=i.server_,n.socket_=i,n.tc_=[],n.setCircId())if(Js){console.log("Sending fast CIC "+n.circId+" "+i.server_.ip+" "+n.destroyed_),t.db&&(El.db_cid_launched=!0),n.X_=No(20);var s=new Po(n.circId,Po.prototype.CREATE_FAST,n.X_);n.send(s)}else n.create();else console.log("PATH : no more circuits available");else console.log("circuit_start init socket"),n.circId=0,t.ws?t.ws.wsconnected_&&($o(t.ws,n),Zo.call(t.ws,n)):tc(n)},Go=function(e){e&&(console.log("CIRCUITS destroy "+(e.remoteAddress?e.remoteAddress:"")),e.OP_&&delete gn[e.remoteAddress],Object.keys(e).forEach(function(t){if(!isNaN(t)&&null!=t){var r=e[t];console.log("delete cic "+r.circId+" socket "+(r.server_?r.server_.ip:"")),e.OP_?(r.requests_destroy(),delete gn[r.server_.ip]):r.next_?r.next_.destroy():r.prev_?r.prev_.destroy():r.circuit_db_destroy(),delete r.socket_,delete e[t]}}))},Yo=function(e,t){var r=[];for(var i in gn){var n=[];Object.keys(gn[i]).forEach(function(t){var r=gn[i][t];isNaN(t)||null==t||!r.last_||-1!==e.no_exit.indexOf(r)||r.bad_||(!Us||r!==Ss&&r!==Cs)&&n.push(r)}),n.length&&r.push(n)}if(r.length){if(!t){var s,a,o=r[_o(r.length)];if(e.nb_try){o=o.map(function(e){return[e,e.time_average]}),o.sort(function(e,t){return e=e[1],t=t[1],e==t?0:t>e?-1:1});var i=0,c=o.length;if(Us)i=parseInt(o.length/2);else for(var l=0;c>l;l++)if(0!==o[l][1]){i=l;break}i&&(o=o.slice(i,Math.min(o.length,Yn+i))),Oi("best circuits "+(o[0]?o[0][0].circId:"")+" "+(o[1]?o[1][0].circId:"")+" "+(o[2]?o[2][0].circId:"")),a=_o(o.length),s=o[a][0]}else a=_o(o.length),s=o[a],s.time_=(new Date).valueOf();return s}if(1===r.length&&1===r[0].length)return!0}else Us&&console.log("choose circuit no circuit found for request "+e.i_id)},Wo=function(e){return function(){if(this.OR_&&this.address().port===kn,this.ws_&&(!A||I||this.OR_)&&!T){this.WS_OP_;var r=Sc(this.stream_ws_?[this.stream_ws_,e].concatBuffers():e);try{e=r[0]}catch(i){return console.log("wsdecode error or FIN (first bit at 1):"+(e.length?e[0]:"")+" closing WS."),this.end(),void 0}this.ws_&&this.WS_OP_&&r[1].length,this.stream_ws_=r[1].length?r[1]:null}if(this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.WS_OP_&&this.ws_,h)var n=Date.now();if(this.ws_&&Us&&!A&&!T){this.pair.encrypted.t0&&(ca++,la+=this.stream_tor_.length,ha+=Date.now()-this.pair.encrypted.t0,0===ca%ua&&ha&&(console.log("wsdecode perf (pass to encrypted): "+parseInt(8*la/(ha/1e3))+" bps"),ca=0,la=0,ha=0)),this.pair.encrypted.write(this.stream_tor_),this.stream_tor_=new t(0);var s=this.queue_;s.shift(),s.length&&s[0]()}else this.stream_tor_.parse(this);n&&(ea++,ta+=e.length,ra+=Date.now()-n,0===ea%ia&&ra&&(this.OR_?this.address()&&ka&&this.address().port===kn&&this.OR_f&&console.log("Parser perf (ORDB):"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length):console.log("Parser perf:"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length),ea=0,ta=0,ra=0))}},Qo=function(e){this.queue_=this.queue_||[],this.queue_.push(Wo(e).bind(this)),1===this.queue_.length&&this.queue_[0]()},Xo=function(){delete this.end_,delete this.html_,delete this.header_,delete this.header_l,delete this.content_,delete this.content_l,delete this.clength_,delete this.encoding_,delete this.pass_,delete this.t0_,delete this.script_,delete this.header_sent,delete this.decoder_,delete this.f_,delete this.wait_,delete this.buff_,this.nb_try=0,delete this.time_resp},Jo=function(e){var r={};Xo.call(r),r.params_={},r.params_.OP=!0,r.params_.nb_hop=Hn,r.params_.one_c=!0,r.nb_try=0,r.no_exit=[],r.squeue_=[],r.wsqueue_=[],r._date_=Date.now(),r.i_id=qa,qa++,e=ho(e),r.params_.host=e.host;var i="GET /"+e.rest+" HTTP/1.1\r\n";return i+="Host: "+e.host+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",r.params_.stream=new t(i,"utf8"),r.remotePort="60000",r.remoteAddress="1.2.3.4",r.write=function(){},r.end=function(){},r.destroy=function(){},r.close=function(){},r._init_=Xo,r._write_=r.write,r},Zo=function(e){gn[e.server_.ip]=this,this[e.circId]=e,this.stream_tor_=new t(0);var r=new Po(e.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));e.send(r)},$o=function(e,r){r.socket_=e,e.first_=r,e.server_=r.server_,e.nbc_=0,Js&&e===El&&(e.buff_w=Os?new Mc.util.ByteBuffer:new t(0),e.abstract_client_tls=cl(e,"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net"),e.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),clearInterval(en),Al(e),e.destroy(),Dc()},e.abstract_client_tls.error=function(t,r){-1===r.message.indexOf("MAC")?(console.log(" Error TLS client disconnected "+r.message),clearInterval(en),Al(e),e.destroy(),Dc()):console.log("bad MAC")},e.write=function(t){Os?e.buff_w.putBytes(t.toString("binary")):e.buff_w=e.buff_w.length?[e.buff_w,t].concatBuffers():t},e.abstract_client_tls.connected=function(){console.log("TLS client connected"),en=setInterval(xc,1e4),e.tls_connected=!0,e.write=function(t){Os?e.abstract_client_tls.prepare(t.data?t.getBytes():t.toString("binary")):e.abstract_client_tls.prepare(sl(t.toString("hex")))},e.write(e.buff_w)},e.write_c=function(r){r.length&&(Os?e.send(new t(r,"binary")):e.send(r))},e.abstract_client_tls.dataReady=function(r){if(Os){if(r.data.length()){var i=new t(r.data.getBytes(),"binary");e.t0&&(xh++,Bh+=i.length,kh+=Date.now()-e.t0,0===xh%Rh&&kh&&(console.log("TLS perf (dataReady): "+parseInt(8*Bh/(kh/1e3))+" bps"),xh=0,Bh=0,kh=0)),Qo.call(e,i)}}else{var i=r.data.data.slice(r.data.read,r.data.length_);r.data.read=r.data.length_,console.log(i.length),i.length&&Qo.call(e,i)}},e.wsconnected_&&(console.log("start TLS handshake "),delete e.abstract_client_tls.handshaking,e.abstract_client_tls.handshake()))},ec=function(e){e.OR_=!0,e.OR_f=!0,e.way_="socket in",e.privkey_=Xs,e.stream_tor_=new t(0);var r=new Fo;r.remote_=e.remoteAddress,r.OR_=!0,r.OR_f=!0,r.circId=0,r.socket_=e,r.way_="socket in",e[0]=r},tc=function(e){var t="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",r="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",i={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,t,r),servername:t,rejectUnauthorized:!1};console.log("OUTGOING SOCKET : ---------start initial socket------------"+i.servername+" "+e.server_.ip+" "+e.server_.port);var n=tn.connect(e.server_.port,e.server_.ip,i,function(){clearTimeout(c),Zo.call(this,e)});n.on("data",Qo);var s=function(){n.nbc_>1?Go(tc):(clearTimeout(c),e.destroy_?Go(tc):e.last_?Go(tc):(e.clear_t0_(),delete e.ok_,delete gn[e.server_.ip],e.circuit_retry()))};n.on("end",s),n.on("close",s),n.on("error",function(){clearTimeout(c),e.destroy_=!0,n.destroy(),e.last_||e.change_or("initial socket error")});var a=function(){e.destroy_=!0,n.destroy(),e.change_or("initial socket failed")};$o(n,e);var c=setTimeout(a,2e3)},rc=function(e,t){var r=e.params_;if(e.time_ini=Date.now(),r)if(r.OP)if(r.one_c)if(t)if(Yo(e,!0)===!0)Ko(e);else{var i;if(!ks||e.params_.ws){if(i=Yo(e),t)for(var n=5;t===i&&0!==n;)i=Yo(e),n--}else for(i=Cs;i===Cs;)i=Yo(e);i?i.process(e):Ko(e)}else{var i;if(e.cid_&&e.cid_.bad_&&(delete e.tls_client_connected,delete e.abstract_client_tls,e.cid_.destroy_cid(e)),!ks&&!Us||e.params_.ws||e.params_.db_)i=e.cid_?e.cid_:r.one_c?Yo(e):null;else for(i=e.cid_?e.cid_:Cs;i===Cs||i===Ss;)i=Yo(e);i?(console.log("choose circuit "+i.circId+" for request "+e.i_id),i[e.sid_]?i.last_?i.last_.stream_handle_connected(e.sid_):(i.destroy_cid(e),rc(e)):i.process(e)):(console.log("no circuits"),0===mn.length?Ko(e):mn.push(e))}else Ko(e);else{var s="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",c=new Date,l=parseInt(No(8).toString("hex"),16),h=al(o+"pub-key.pem",o+"priv-key.pem","pem",l,c,s,a),u={key:Ri.readFileSync(o+"priv-key.pem"),cert:h,servername:s,requestCert:!0},d=tn.createServer(u,function(e){var t=e.remoteAddress,r=e.remotePort;ec(e),e.on("data",Qo),e.on("error",function(e){console.log("OR socket error"),console.log(e),delete wn[t+":"+r]}),e.on("end",function(){delete wn[t+":"+r]}),e.on("close",function(){delete wn[t+":"+r]}),e.cert_issuer=a,e.cert_subject=s,e.cert_date=c,e.certid_=l,wn[t+":"+r]=e});d.listen(r.port,function(){console.log("OR : server launched port "+r.port),Us&&setInterval(Uc,xs)}),d.on("OR : clientError",function(e){console.log(e)}),d.on("error",function(e){console.log(e)}),d.on("end",function(e){console.log(e)})}},ic=function(e){try{var t={},r=0;return e=e.split("\r\n"),e.forEach(function(e,i){if(e=e.split(":"),e.length>1&&0!=i){var n=e[0];e=e.map(function(e){return e.trim()}),e.shift(),e=e.join(":"),t[n]=e}else t[r+"a"]=e.join(":"),r++}),t}catch(i){console.log("caller"),console.log(ic.caller.toString().substr(0,50))}},nc=function(e){var t=[],r=0;for(var i in e)isNaN(i.substr(0,1))?t.push(i+": "+e[i]):e[i]?t.push(e[i]):r++;for(var n=0;r>n;n++)t.push("");return t.join("\r\n")},sc=function(e){e.start_&&(e.write(e.start_),delete e.start_)},ac=function(e,t,r){var i=/(((\b(https?|ftp|file):\/\/)|\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,n=!1,s=function(i){var s=e.split(i);if(""===s[s.length-1]&&!r)return n=!0,void 0;var a=e;i=ho(i);var o=t.fake_domain,c=bs[o],l=c.real_domain_s;if(i.host)if(-1!==i.host.indexOf(l)){var h=i.host.split("."),u=c.real_domain_a;a=i.host===c.real_domain?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):2===h.length&&"www"===u[0]||2===u.length&&"www"===h[0]?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):"http"+Ds+"://"+o+"/"+fo(uo(i),!0)}else-1===i.host.indexOf(o)&&(a="http"+Ds+"://"+o+"/"+fo(uo(i),!0));return a},a=e.replace(i,s);return n&&(t.pass_+=e),{html:n?e:a,pass:n}},oc=function(e){var t="";return t="",[t,e].join("")},cc=function(e,r){var i=e.toString("hex").split(gs),n=n||[],s=[];return i.forEach(function(e,a){if(r.wait_){var o=parseInt(new t(e,"hex").toString("utf8"),16);return 0===o&&(r.end_=!0,n.push("0d0a300d0a0d0a")),r.clength_+=o?o:0,e.length?a!==i.length-1&&(r.wait_=!1):0===a&&(r.wait_=!1),void 0}var c=r.clength_,l=r.html_.length,h=new t(e,"hex").length+2;(c>=l+h||l+h-2===c)&&s.push(e),l+h-2===c||a===i.length-1?(s=s.join(gs),n.push(s),r.html_.length+=h-2,a!==i.length-1&&(r.wait_=!0),s=[]):r.html_.length+=h}),new t(n.join(""),"hex")},lc=function(e){if(!(e instanceof Uint8Array)){var r=new t(e.length);r.map(e),e=r}return e},hc=function(e){console.log("destroy ws cid"),e.remoteAddress&&e.remotePort?delete wn[e.remoteAddress+":"+e.remotePort]:Rc()},uc=function(e,r){var i=e["Sec-WebSocket-Key"],n=sn.createhash("sha1");n.update(i+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64");var a="HTTP/1.1 101 WebSocket Protocol Handshake\r\n";a+="Upgrade: websocket\r\n",a+="Connection: Upgrade\r\n",a+="Sec-WebSocket-Accept:"+s+"\r\n",a+="Access-Control-Allow-Origin:"+e.Origin+"\r\n",a+="\r\n",console.log("INCOMING SOCKET :"+a),r.ws_=!0,ec(r),r.connected_=!0,r.wsconnected_=!0,r.write(a)},dc=function(e){this.key_=sn.randomBytes(16).toString("base64");var t="GET / HTTP/1.1\r\n";return t+="Host: "+e.ip+(js?":"+e.wsport:"")+"\r\n",t+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",t+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",t+="Accept-Language: en-us,en;q=0.5\r\n",t+="Accept-Encoding: gzip, deflate\r\n",t+="Connection: keep-alive, Upgrade\r\n",t+="Sec-WebSocket-Version: 13\r\n",t+="Origin: http://ianonym.com\r\n",t+="Sec-WebSocket-Key: "+this.key_+"\r\n",t+="Pragma: no-cache\r\n",t+="Cache-Control: no-cache\r\n",t+="Upgrade: websocket\r\n",t+="\r\n"},fc=0,pc=0,_c=0,gc=100,mc=0,yc=0,vc=0,bc=100,wc=function(e){d&&(Ho=Date.now()),f&&(Mo=Date.now()),console.log("start websocket");var t=T?new ja("ws://"+e.ip+":"+e.wsport):new WebSocket("ws://"+e.ip+":"+e.wsport);return T||(t.write=t.send),t.binaryType="arraybuffer",t.setNoDelay=function(){},t.connect=function(){},t.WS_OP_=!0,t.onopen=Cc,t.onmessage=function(e){var r=e.data instanceof ArrayBuffer?new Uint8Array(e.data):e.data;Ho&&(fc++,pc+=r.length,_c+=Date.now()-Ho,0===fc%gc&&_c&&(console.log("WS perf (received from WS before processing): "+parseInt(8*pc/(_c/1e3))+" bps - Buffered : "+t.bufferedAmount),fc=0,pc=0,_c=0)),(d||p)&&(Ho=Date.now()),Js&&t===El?(g&&(t.t0=Date.now()),jo&&0!==Ho-jo&&console.log("WS delay between processed and next received: "+(Ho-jo)+" data length "+r.length),Os?t.abstract_client_tls.process(r.toString("binary")):t.abstract_client_tls.process(r),p&&(jo=Date.now()),Mo&&(mc++,yc+=r.length,vc+=Date.now()-Mo,0===mc%bc&&vc&&(console.log("WS perf (received from WS after processed): "+parseInt(8*yc/(vc/1e3))+" bps - Buffered : "+t.bufferedAmount),mc=0,yc=0,vc=0)),f&&(Mo=Date.now())):Qo.call(this,r)},t.onclose=function(){console.log("Websocket closed ws://"+e.ip+":"+e.wsport)},T||(t.destroy=t.close,t.bufferSize=t.bufferedAmount),t.remoteAddress=e.ip,t.remotePort=Dn,t.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},t.setKeepAlive=function(){},t},Ec=function(e){var r=ic(e.toString("utf8")),i=r["Sec-WebSocket-Accept"];if(i){var n=sn.createhash("sha1");n.update(this.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64"),i===s&&(console.log("WS Client says : Handshake successfull"),Cc.call(this))}},Cc=function(){console.log("websocket connected");try{Kl.innerHTML="

Websocket connected

"}catch(e){}this.connected_=!0,this.wsconnected_=!0,this.ws_=!0,Us&&(this===Cl&&$i&&rc({params_:{OP:!0,nb_hop:Hn,ws:this}}),!Js||this!==El||!Cs&&$i||(console.log("launch db_cid"),this.db_cid_launched=!0,rc({params_:{OP:!0,nb_hop:Mn,ws:this,db:!0}})),Js||setInterval(xc,1e4))},Sc=function(e,r){r=r||[];var i,n=e.length,s=0,a=0,n=e.length,o=new t(0),c=new t(0);if(0===e.length)return[o,c];var l=e[0];if(e.length>1){var h=128&e[1],u=127&e[1];if(126===u?(s=e.slice(2,4).readUInt(),h=h&&e.slice(4,8),a=h?8:4):127===u?(s=parseInt(e.slice(2,10).toString("hex"),16),h=h&&e.slice(10,14),a=h?14:10):(s=u,h=h&&e.slice(2,6),a=h?6:2),o=e.slice(a,a+s),i=o.length,h&&o.length===s&&0!=s)for(var d=0;i>d;d++)o[d]=o[d]^h[d%4]}return o.length!==s||0===s?(i=o.length,a=n,c=e):r.push(o),n-a>i?Sc(e.slice(i+a),r):1&l?[r.concatBuffers().toString("utf8"),c.toString("utf8")]:2&l?[r.concatBuffers(),c]:void 0},Ac=function(e,r,i){var n,s,a,o=e.length;i=i?sn.randomBytes(4):i;var c=1===r?"81":"82";if(126>o?(s=(i?128|o:o).toString(16),s=1===s.length?"0"+s:s):o>=126&&65535>=o?(c+=i?"FE":"7E",a=2):(c+=i?"FF":"7F",a=8),!s)for(s=o.toString(16),s=s.length%2?"0"+s:s;s.length!==2*a;)s="00"+s;if(c+=s,n=new t(c,"hex"),i)for(var l=e.length,h=new t(l),u=0;l>u;u++)h[u]=e[u]^i[u%4];else h=e;return i?[n,i,h].concatBuffers():[n,h].concatBuffers()},Ic=function(e,r){for(var i=e.remoteAddress+":"+e.remotePort+":"+e.port_+":"+e.i_id,n=e.fake_,s=new t(new t(i,"utf8").toString("hex"),"hex"),a=s.length.toString(16);4!==a.length;)a="0"+a;for(s=[new t(a,"hex"),s].concatBuffers(),a=s.toString("hex");r.length;){var o;o=r.length+a>_n?r.slice(0,_n-a):r,o=[s,o].concatBuffers();var c=new qo(qo.prototype.RELAY_WS,0,o,n.Db_hash).toBuffer();c=new t(n.Kb_cipher.update(c,"hex","hex"),"hex");var l=new Po(n.circId,Po.prototype.RELAY_WS,c); +this.URL=e.readString(t),this.size-=t+1}else this.URL=null;32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},a.ES_Descriptor.prototype.getOTI=function(){var e=this.findDescriptor(t);return e?e.oti:0},a.ES_Descriptor.prototype.getAudioConfig=function(){var e=this.findDescriptor(t);if(!e)return null;var i=e.findDescriptor(r);return i&&i.data?(248&i.data[0])>>3:null},a.DecoderConfigDescriptor=function(e){a.Descriptor.call(this,t,e)},a.DecoderConfigDescriptor.prototype=new a.Descriptor,a.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},a.DecoderSpecificInfo=function(e){a.Descriptor.call(this,r,e)},a.DecoderSpecificInfo.prototype=new a.Descriptor,a.SLConfigDescriptor=function(e){a.Descriptor.call(this,i,e)},a.SLConfigDescriptor.prototype=new a.Descriptor,this}function Bi(){this.boxes=new Array,this.mdats=new Array,this.moofs=new Array,this.isProgressive=!1,this.lastMoofIndex=0,this.lastPosition=0}function ki(){this.log_level=this.LOG_LEVEL_INFO,this.sampleListBuilt=!1,this.inputStream=null,this.inputIsoFile=null,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.fragmentedTracks=new Array,this.extractedTracks=new Array,this.isFragmentationStarted=!1,this.nextMoofNumber=0}var Ri=require("fs"),Ui=require("child_process"),Di=function(e,t){t+=" "+(new Date).toDateString()+" "+(new Date).toTimeString();var r=function(e,r){try{if(e||(Ri.write(r,t+"\n",function(){}),Ri.close(r)),A&&"undefined"!=typeof Wa){var i=Wa("console");i.innerHTML.length>1e6&&(i.innerHTML="");var n=document.createElement("p");n.className="log",n.innerHTML=t,i.appendChild(n)}}catch(s){}};try{Ri.open(o+Dn+"-"+e,"a",r)}catch(i){}};process.on("uncaughtException",function(e){var t=Ri.openSync("/debug.txt","a");Ri.writeSync(t,(new Date).toDateString()+" "+(new Date).toTimeString()),Ri.writeSync(t,e.stack),Ri.closeSync(t)}),process.on("exit",function(){setTimeout(function(){console.log("Process ended")},0),console.log("About to exit "+(new Date).toDateString()+" "+(new Date).toTimeString())});var Ni=console.log.bind(console),Li=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)},Oi=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)};console.log=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),(!a&&!S&&!c||-1!==process.platform.indexOf("win")&&T)&&Ni(e+" "+(new Date).toDateString()+" "+(new Date).toTimeString())};var Pi,Fi,qi,Hi,Mi,ji,zi;if(!A){if(process.argv&&process.argv.length>1){var Vi=process.argv.splice(2);if(5===Vi.length)Pi=Vi[0],Fi=Vi[1],qi=Vi[2],Hi=Vi[3],Mi=Vi[4];else{if(o=Vi[0]||"",o.length){if(-1===process.platform.indexOf("win")){var Ki=o[o.length-1];"/"!==Ki&&(o+="/")}}else Ni("Invalid directory parameter");if(T=!0,Vi.length>1)if("-P"!==Vi[1])ji=Vi[1],Vi.length>2&&(zi=!0);else{if(T=!1,x=!0,!(Vi.length>2))return;if(isNaN(parseInt(Vi[2])))return;Hi=parseInt(Vi[2])}}}var Gi=function(){console.log("update routers "+(new Date).toDateString()+" "+(new Date).toTimeString());var e=function(){console.log("child_process "+(new Date).toDateString()+" "+(new Date).toTimeString())};Ui.exec("/usr/local/bin/node "+o+"build-relays_and_dirs7.js",{timeout:12e5},e),Pi&&Ui.exec("/usr/local/bin/node "+o+"publish2.js "+Pi+" "+Fi+":"+qi+" "+Mi,{timeout:12e5},e)};T||x||setInterval(Gi,36e5)}if(T)var Yi,Wi,Qi,Xi=function(e){var t={host:"peersm.com",port:80,path:"/peersmclient/proxy.pac",method:"GET"};Yi="";var r=nn.request(t,function(t){t.on("data",function(e){Yi+=e.toString("utf8")}),t.on("end",function(){e()}),t.on("error",function(){console.log("Error proxy.pac")})});r.end()};else var Xi=function(e){var t=new XMLHttpRequest;return t?(t.open("GET",e,!1),t.send(null),t.responseText):void 0};var Ji,Zi,$i,en,tn=require("tls"),rn=require("net"),nn=require("http"),sn=(require("url"),require("crypto")),an=T?require(o+"node_modules/torrent-stream"):{},Guards=T||x?{}:require(o+"guards.js").Guards,on=T||x?{}:require(o+"relays.js").Relays,cn=T||x?{}:require(o+"dirs.js").Dirs,Exit=T||x?{}:require(o+"exit.js").Exit,ln=!1,hn=!0,un=hn?null:require(o+"crypto.js").Rsa,dn=hn?null:require(o+"crypto.js").PEM,fn=hn?null:require(o+"crypto.js").Hash,pn=498,_n=65535,gn={},mn=[],yn={},vn={},bn={},wn={},En={},Cn={},Sn={},An=[],In={},Tn={},xn={},Bn={},kn=0,Rn=Fi||"",Un="2679B51C906158F3DF4C59AFD73E2B1FDA6535E1",Dn=a?C?1:0:S?0:0,Nn="010001",Ln=new t("00000000000000000000000000000000","hex"),On=32767,Pn=Hi||(a?2:0),Fn=5,qn=5,Hn=3,Mn=zi?2:3,jn="-----BEGIN RSA PUBLIC KEY-----",zn="-----END RSA PUBLIC KEY-----",Vn=5e3,Kn=1e3,Gn=7e3,Yn=3,Wn=0,Qn=0,Xn=30,Jn=12,Zn=10,$n=s?20:5,es=!1,ts=5,rs=5e3,is=72e5,ns=36e5,ss=36e5,as=[],os=[],cs=1e3,ls=100,hs=500,us=50,ds=.8,fs=15e3,ps=16184,_s=t,gs="0d0a",ms=".com",ys=5e3,vs=2e3,bs={},ws="http:",Es="www.f4116a30c08bbdfd01813b96c909.com",Cs=null,Ss=null,As=36e6,Is=1e4,Ts=3e5,xs=9e5,Bs=5,ks=a?!1:!0,Rs=a?!1:!0,Us=a?!1:!0,Ds="",Ns=!1,Ls=1024,Os=!0,Ps=!1,Fs={},qs="undefined"!=typeof document?document.location.href:"",Hs=!1,Ms=!0,js=!1,zs=a?!1:!0,Vs=0,Ks=1e5,Gs="Retrieving... ",Ys=!0,Ws=!0,Qs="enc",Xs=T||x?null:Ri.readFileSync(o+"priv-key.pem"),Js=!1,Zs=65536,$s=2097152,ea=0,ta=0,ra=0,ia=100,na=0,sa=0,aa=0,oa=100,ca=0,la=0,ha=0,ua=100,da=0,fa=0,pa=0,_a=100,ga=0,ma=0,ya=0,va=100,ba=1e6,wa=2e6,Ea=1e3,Ca=125,Sa=3e4,Aa="0000000000000000000000000000000000000000",Ia=3e5,Ta="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF",xa={323:"text/h323","3gp":"video/3gpp",a:"application/octet-stream",acx:"application/internet-property-stream",ai:"application/postscript",aif:"audio/x-aiff",aifc:"audio/x-aiff",aiff:"audio/x-aiff",asc:"application/pgp-signature",asf:"video/x-ms-asf",asr:"video/x-ms-asf",asm:"text/x-asm",asx:"video/x-ms-asf",atom:"application/atom+xml",au:"audio/basic",avi:"video/x-msvideo",axs:"application/olescript",bas:"text/plain",bat:"application/x-msdownload",bcpio:"application/x-bcpio",bin:"application/octet-stream",bmp:"image/bmp",bz2:"application/x-bzip2",c:"text/x-c",cab:"application/vnd.ms-cab-compressed",cat:"application/vnd.ms-pkiseccat",cc:"text/x-c",cdf:"application/x-netcdf",cer:"application/x-x509-ca-cert",cgm:"image/cgm",chm:"application/vnd.ms-htmlhelp","class":"application/octet-stream",clp:"application/x-msclip",cmx:"image/x-cmx",cod:"image/cis-cod",com:"application/x-msdownload",conf:"text/plain",cpio:"application/x-cpio",cpp:"text/x-c",cpt:"application/mac-compactpro",crd:"application/x-mscardfile",crl:"application/pkix-crl",crt:"application/x-x509-ca-cert",csh:"application/x-csh",css:"text/css",csv:"text/csv",cxx:"text/x-c",dcr:"application/x-director",deb:"application/x-debian-package",der:"application/x-x509-ca-cert",diff:"text/x-diff",dir:"application/x-director",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dll:"application/x-msdownload",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dtd:"application/xml-dtd",dv:"video/x-dv",dvi:"application/x-dvi",dxr:"application/x-director",ear:"application/java-archive",eml:"message/rfc822",eps:"application/postscript",etx:"text/x-setext",evy:"application/envoy",exe:"application/x-msdownload",ez:"application/andrew-inset",f:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",fif:"application/fractals",flr:"x-world/x-vrml",flv:"video/x-flv","for":"text/x-fortran",gem:"application/octet-stream",gemspec:"text/x-script.ruby",gif:"image/gif",gram:"application/srgs",grxml:"application/srgs+xml",gtar:"application/x-gtar",gz:"application/x-gzip",h:"text/x-c",hdf:"application/x-hdf",hh:"text/x-c",hlp:"application/winhlp",hqx:"application/mac-binhex40",hta:"application/hta",htc:"text/x-component",htm:"text/html",html:"text/html",htt:"text/webviewhtml",ice:"x-conference/x-cooltalk",ico:"image/vnd.microsoft.icon",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",iii:"application/x-iphone",ins:"application/x-internet-signup",isp:"application/x-internet-signup",iso:"application/octet-stream",jar:"application/java-archive",java:"text/x-java-source",jfif:"image/pipeg",jnlp:"application/x-java-jnlp-file",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",kar:"audio/midi",latex:"application/x-latex",lha:"application/octet-stream",lsf:"video/x-la-asf",lsx:"video/x-la-asf",lzh:"application/octet-stream",log:"text/plain",m13:"application/x-msmediaview",m14:"application/x-msmediaview",m3u:"audio/x-mpegurl",m4a:"audio/mp4a-latm",m4b:"audio/mp4a-latm",m4p:"audio/mp4a-latm",m4u:"video/vnd.mpegurl",m4v:"video/mp4",mac:"image/x-macpaint",man:"text/troff",mathml:"application/mathml+xml",mbox:"application/mbox",mdb:"application/x-msaccess",mdoc:"text/troff",me:"text/troff",mesh:"model/mesh",mht:"message/rfc822",mhtml:"message/rfc822",mid:"audio/midi",midi:"audio/midi",mif:"application/vnd.mif",mime:"message/rfc822",mml:"application/mathml+xml",mng:"video/x-mng",mny:"application/x-msmoney",mov:"video/quicktime",movie:"video/x-sgi-movie",mp2:"video/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4v:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpg:"video/mpeg",mpga:"audio/mpeg",mpp:"application/vnd.ms-project",mpv2:"video/mpeg",ms:"text/troff",msh:"model/mesh",msi:"application/x-msdownload",mvb:"application/x-msmediaview",mxu:"video/vnd.mpegurl",nc:"application/x-netcdf",nws:"message/rfc822",oda:"application/oda",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",ogg:"application/ogg",p:"text/x-pascal",p10:"application/pkcs10",p12:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",p7c:"application/x-pkcs7-mime",p7m:"application/x-pkcs7-mime",p7r:"application/x-pkcs7-certreqresp",p7s:"application/x-pkcs7-signature",pac:"text/plain",pas:"text/x-pascal",pbm:"image/x-portable-bitmap",pct:"image/pict",pdb:"chemical/x-pdb",pdf:"application/pdf",pem:"application/x-x509-ca-cert",pfx:"application/x-pkcs12",pgm:"image/x-portable-graymap",pgn:"application/x-chess-pgn",pgp:"application/pgp-encrypted",pic:"image/pict",pict:"image/pict",pkg:"application/octet-stream",pko:"application/ynd.ms-pkipko",pl:"text/x-script.perl",pm:"text/x-script.perl-module",pma:"application/x-perfmon",pmc:"application/x-perfmon",pml:"application/x-perfmon",pmr:"application/x-perfmon",pmw:"application/x-perfmon",png:"image/png",pnm:"image/x-portable-anymap",pnt:"image/x-macpaint",pntg:"image/x-macpaint",pot:"application/vnd.ms-powerpoint",ppm:"image/x-portable-pixmap",pps:"application/vnd.ms-powerpoint",ppt:"application/vnd.ms-powerpoint",prf:"application/pics-rules",ps:"application/postscript",psd:"image/vnd.adobe.photoshop",pub:"application/x-mspublisher",py:"text/x-script.python",qt:"video/quicktime",qti:"image/x-quicktime",qtif:"image/x-quicktime",ra:"audio/x-pn-realaudio",rake:"text/x-script.ruby",ram:"audio/x-pn-realaudio",rar:"application/x-rar-compressed",ras:"image/x-cmu-raster",rb:"text/x-script.ruby",rdf:"application/rdf+xml",rgb:"image/x-rgb",rm:"application/vnd.rn-realmedia",rmi:"audio/mid",roff:"text/troff",rpm:"application/x-redhat-package-manager",rss:"application/rss+xml",rtf:"application/rtf",rtx:"text/richtext",ru:"text/x-script.ruby",s:"text/x-asm",scd:"application/x-msschedule",sct:"text/scriptlet",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgm:"text/sgml",sgml:"text/sgml",sh:"application/x-sh",shar:"application/x-shar",sig:"application/pgp-signature",silo:"model/mesh",sit:"application/x-stuffit",skd:"application/x-koan",skm:"application/x-koan",skp:"application/x-koan",skt:"application/x-koan",smi:"application/smil",smil:"application/smil",snd:"audio/basic",so:"application/octet-stream",spc:"application/x-pkcs7-certificates",spl:"application/x-futuresplash",src:"application/x-wais-source",sst:"application/vnd.ms-pkicertstore",stl:"application/vnd.ms-pkistl",stm:"text/html",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",svg:"image/svg+xml",svgz:"image/svg+xml",swf:"application/x-shockwave-flash",t:"text/troff",tar:"application/x-tar",tbz:"application/x-bzip-compressed-tar",tcl:"application/x-tcl",tex:"application/x-tex",texi:"application/x-texinfo",texinfo:"application/x-texinfo",text:"text/plain",tgz:"application/x-compressed",tif:"image/tiff",tiff:"image/tiff",torrent:"application/x-bittorrent",tr:"text/troff",trm:"application/x-msterminal",tsv:"text/tab-seperated-values",txt:"text/plain",uls:"text/iuls",ustar:"application/x-ustar",vcd:"application/x-cdlink",vcf:"text/x-vcard",vcs:"text/x-vcalendar",vrml:"model/vrml",vxml:"application/voicexml+xml",war:"application/java-archive",wav:"audio/x-wav",wbmp:"image/vnd.wap.wbmp",wbxml:"application/vnd.wap.wbxml",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",webm:"video/webm",wks:"application/vnd.ms-works",wma:"audio/x-ms-wma",wmf:"application/x-msmetafile",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",wmlsc:"application/vnd.wap.wmlscriptc",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wps:"application/vnd.ms-works",wri:"application/x-mswrite",wrl:"model/vrml",wrz:"x-world/x-vrml",wsdl:"application/wsdl+xml",xaf:"x-world/x-vrml",xbm:"image/x-xbitmap",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xml:"application/xml",xof:"x-world/x-vrml",xpm:"image/x-xpixmap",xsl:"application/xml",xslt:"application/xslt+xml",xul:"application/vnd.mozilla.xul+xml",xwd:"image/x-xwindowdump",xyz:"chemical/x-xyz",yaml:"text/yaml",yml:"text/yaml",z:"application/x-compress",zip:"application/zip"};if(Ms&&!A)var Ba={};if(A&&!I){var Yi=Xi("proxy.pac");Us||(Yi="var FindProxyForUrl="+Yi,eval(Yi),Zi=FindProxyForUrl("http://"+Es,Es,!0))}else Zi={ip:Rn,port:kn,wsport:Pn,fing:Un,o_modulus:"8bd0a81286858b11f2856ac2f3efd8a5e538b2f851a4c02cc717c94ea52418c587cc69515e46b5381d17cd2299cb4c59fae38250898eab31c9b8acfcf02110a96f0f03442ecd34f1befb0604e1ffbb981848534da9f3f23795ed7df047730cb9dab711722ad6504b893cebda2de4b41123d667474a166eba3ead7df8267dda15"};if(Us){ks=!1,Rs=!1;var ka=Zi;if(js=!0,zs=!1,T){var Ra=ji?1e6*ji:1e5,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,qa=0,Ha={};E=!1,Ha.list=function(e,r){Ri.readdir(o,function(i,n){i||n.forEach(function(i){if(-1===i.indexOf("debug.txt")&&-1===i.indexOf("debug-prod.txt")){var n,s,a=i.split("#");if(a.length>1){var c=a[1].split(".");n=a[0]+(c.length>1?"."+c[1]:""),s=a[1].split(".")[0]}if(n)r||Ri.stat(o+i,function(t,r){if(!t){var a={file_name:i,name:n,name_hash:s,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(a)}});else{var l=sn.createhash("sha1");l.update(new t(Date.now().toString()+El.localAddress.toString()+El.localPort.toString(),"utf8")),l=l.digest("hex");var c=i.split(".");if(c.length){var h=c.pop();if(c.length){var n=c.join("."),u=n+"#"+l+"."+h;Ri.rename(o+i,o+u,function(){Ri.stat(o+u,function(t,r){if(!t){var i={file_name:u,name:n,name_hash:l,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(i)}})})}}}}})})};var Ma=function(){Ss&&Ss.send_db_info(!0)},ja=function(e){e=e.split("ws://")[1].split(":");var t=e[1],r=e[0];console.log("peersm client "+r+" "+t);var i=new rn.Socket;return i.on("connect",function(){i.key_=sn.randomBytes(16).toString("base64");var e="GET / HTTP/1.1\r\n";e+="Host: "+i.remoteAddress+":"+i.remotePort+"\r\n",e+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",e+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",e+="Accept-Language: en-us,en;q=0.5\r\n",e+="Accept-Encoding: gzip, deflate\r\n",e+="Connection: keep-alive, Upgrade\r\n",e+="Sec-WebSocket-Version: 13\r\n",e+="Origin: http://peersm.com\r\n",e+="Sec-WebSocket-Key: "+i.key_+"\r\n",e+="Pragma: no-cache\r\n",e+="Cache-Control: no-cache\r\n",e+="Upgrade: websocket\r\n",e+="\r\n",console.log(e),i.write(e)}),i.on("data",function(e){if(i.connected__){var t=Sc(i.stream_ws__?[i.stream_ws__,e].concatBuffers():e);i.stream_ws__=t[1].length?t[1]:null,i.onmessage({data:t[0]})}else{i.on("end",function(){console.log("websocket_node end"),i.onclose()}),i.on("error",function(){console.log("websocket_node error"),i.onclose()});var r=ic(e.toString("utf8")),n=r["Sec-WebSocket-Accept"]||r["Sec-Websocket-Accept"];if(n){var s=sn.createHash("sha1");s.update(i.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var a=s.digest("base64");n===a?(console.log("Client says : Handshake successfull for "+El.remoteAddress+" "+El.remotePort),i.write=function(e){i._write(Ac(e,2,!0),null,function(){})},i.send=i.write,i.connected__=!0,i.onopen()):i.end()}else i.end()}}),i.close=i.end,i.connect(t,r),i},za=function(){};za.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Va=function(){};Va.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Ka=function(e){this.data=[],this.cursor=0,this.size=e};Ka.prototype.push=function(e){this.data.push(e),this.cursor+=e.length},Ka.prototype.unshift=function(e){this.data.unshift(e),this.cursor-=e.length},Ka.prototype.slice=function(e,r){var i,n,s=r-e,a=0,o=[];if(s>0&&this.data.length){for(s=Math.min(s,this.cursor);s>a;){var c=this.data.shift(),l=c.length;o.push(c),a+=l,this.cursor-=l}return i=o.concatBuffers(),n=i.slice(s),i=i.slice(0,s),this.cursor+=n.length,n.length&&this.data.unshift(n),i}return new t(0)};var Ga=function(e){this.fd=e.fd,this.size=e.size,this.type=e.type,this.cursor=0};Ga.prototype.slice=function(e,r){if(r){if(r>e){var i=new t(r-e);return Ri.readSync(this.fd,i,0,r-e,e+this.cursor),i}return new t(0)}return this.size=this.size-e,this.cursor=e,this};var Ya=function(){var e={};return e.get=function(e){var t={};return Ri.readdir(o,function(r,i){if(r)t.onsuccess({target:{result:null}});else{for(var n,s=!1,a=i.length,c=0;a>c;c++){var l=i[c];if(-1===l.indexOf("debug.txt")){var h,u,d=l.split("#");if(d.length>1){var f=d[1].split(".");f.length>1&&(n=f[1],h=d[0]+(f.length>1?"."+f[1]:"")),u=d[1].split(".")[0]}if(u===e){s=!0,Ri.stat(o+l,function(e,r){!e&&n?Ri.open(o+l,"r",function(e,i){if(e)t.onsuccess({target:{result:null}});else{var s;n&&(s=xa[n]),s||(s="application/octet-binary"),console.log(h+" "+u+" "+s);var a={fd:i,size:r.size,type:s};t.onsuccess({target:{result:{file_length:r.size,current_length:r.size,type:s,data:a}}})}}):t.onsuccess({target:{result:null}})});break}}}s||t.onsuccess({target:{result:null}})}}),t},e};Wi=function(){Yi="var FindProxyForUrl="+Yi,eval(Yi);var t=FindProxyForUrl("http://"+Es,Es,!0);Zi=t[1][_o(t[1].length)],ka=e?{ip:"213.246.53.127",port:0,wsport:0,fing:"E0671CF9CB593F27CD389CD4DD819BF9448EA834",o_modulus:"ca2a670479816ca562f7afc2667db1811f0efa7d595aa27cf532092a052c697b102c03d8b8dddc276050fe9cad15efe72758d9d9b0f581f5cbfd0be92ecd721711797354006625e74e0f733efee3ee779116efe87da3b5f8c1729e2d0a5f2c4de4d5906b6e383c0a0d8dddbc076cf426423f6f2b6fd46fab9f54fb8e42601a2d",name:"Tor Bridge"}:t[2],Js=!0,on=Guards,Ba.userAgent="node-Tor",Il()},Qi=function(){var e=function(){console.log("update prox --------"),Yi="var FindProxyForUrl="+Yi,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0)};Xi(e)},Xi(Wi),setInterval(Ma,1e4),setInterval(Qi,ss)}if(A){var Ha,Ra=0,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,Wa=document.getElementById.bind(document),qa=0,Qa=document.location.href.split("/"),Xa=Qa[Qa.length-1].split("#")[0],Ja=function(e){return e.pageY?e.pageY:e.clientY},Za=function(e){return e.pageX?e.pageX:e.clientX},$a=function(e,t,r,i){e.__event=e.__event||{},e.__event[t]&&eo(e,t,e.__event[t][0],e.__event[t][1]),e.__event[t]=[r,i],e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r)},eo=function(e,t,r,i){e.addEventListener?e.removeEventListener(t,r,i):e.attachEvent&&e.detachEvent("on"+t,r)},to=[Qs,"exe","com","bin","php","php3","php4","php5","phtml","inc","sql","pl","cgi","py","sh","c","cc","cpp","cxx","h","hpp","java","class","jar","html","html","shtml","dhtml","xhtml","xml","js","css","zip","tar","tgz","gz","bz2","tbz","rar","mp3","wav","3ga","midi","mid","rm","ra","ram","pls","m3u","mkw","webm","avi","mp4","m4v","mpg","mpeg","mov","swf","fla","doc","docx","xls","xlsx","rtf","pdf","txt","ppt","pptx","vcard","vcf","obj","max","3ds","3dm","kml","torrent","gpx","dxf","dwg","wsg","vb","pif","gadget","apk","msi","sxc","123","ots","nb","gsheet","xlr","ods","svgz","cdr","svg","ps","eps","orf","pef","rwl","mrw","mef","fff","erf","dcr","bay","3fr","srf","rw2","nef","cr2","arw","dng","dwt","irs","ait","art","aip","aia","ai","indd","prtpset","ppj","plb","prproj","aetx","aet","aes","aepx","aep","aec","ncorx","ncor","em","abr","csh","psb","psd","as","asc","ascs","aif","aiff","flac","iff","m4a","wma","srt","flv","3g2","3gp","asf","wmv","pcast","xlt","xltm","xltx","ans","ascii","log","odt","wpd","accdb","db","dbf","mdb","pdb","asp","aspx","asx","fnt","otf","ttf","dotx","wps2","dll","fon","cmd","srt"],ro=["tga","gif","jpg","tiff","jpeg","bmp","png"];to.forEach(function(e){La[e]="http://www.peersm.com/img/extensions/"+e+".png"});var io=function(){var e=new XMLHttpRequest;if(e){e.open("POST","bandwidth.html",!0);var t=Date.now(),r=1e5;e.send(new Uint8Array(r)),e.onreadystatechange=function(){if(4==e.readyState){var r=1e5/((Date.now()-t)/1e3);Ra=parseInt((Ra?(Ra+r)/2:r)/Ua),console.log("bandwidth : "+8*Ra/1e3+" Kbps")}}}};setInterval(io,18e6),io()}}on=Guards;var no=function(){Ri.rename(o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt"),o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt")+".old",function(){})};no(),A||T||x||console.log(Pi+" "+Fi+" "+qi+" "+Hi+" "+Mi);var so=function(e){var t=e.split("magnet:?xt=urn:btih:");return t.length>1?t[1]:void 0},ao=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Accept-Ranges:bytes",e+="Content-Encoding:gzip\r\n",e+="Content-Length:0\r\n",e+="Content-Type:*\r\n",e+="\r\n"},oo=function(){var e="HTTP/1.1 410 Gone\r\n";return e+="\r\n"},co=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Vary: Accept-Encoding\r\n",e+="Keep-Alive: timeout=2, max=100\r\n",e+="Connection: Keep-Alive\r\n",e+="Transfer-Encoding: chunked\r\n",e+="Content-Type: text/html\r\n",e+="\r\n1f\r\n//Outside of authorized domains\r\n0\r\n\r\n"},lo=function(e){var t="HTTP/1.1 301 Moved Permanently\r\n";return t+="Location: "+e+"\r\n",t+="\r\n"},ho=function(e){var t={url:e},r=e.split("/"),i=function(e){if(e.length){var r=e[0];t.host=r,e.shift()}t.rest=e.join("/")};return r.length>1?""===r[1]?(t.protocol=r[0]?r[0]:ws,r.shift(),r.shift()):t.protocol=ws:t.protocol=ws,i(r),t},uo=function(e){var t=[];return t.push(e.protocol?e.protocol:protocol),t.push(""),e.host&&t.push(e.host),e.rest&&t.push(e.rest),t.join("/")},fo=function(e,r){var i=new t(Eo(r?new t(e,"utf8"):new t(e,"hex"),Bl),"hex");return r?i.toString("hex"):i.toString("utf8")},po=function(e){var t=e.slice(0,1),r=e.slice(1,2),i=e.slice(2,2+r.readUInt());return e=e.slice(r.readUInt()+2),{data:e,addr:{type:t,length:r,value:i}}},_o=function(e){return parseInt(Math.random()*e)},go=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()+(e.getMilliseconds()>500?1:0),0)},mo=function(e){var t,r,i=[],n=[],s=[],a=e.nb_hop||Fn;if(a>Fn&&(a=Fn),e.nb_try=e.nb_try||1,e.nb_try>qn)return console.log("PATH : createPath : Too many attempts"),void 0;for(r=Guards.length,t=_o(r),t=Guards[t].split("-"),s.push(t[1]),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),a--,r=on.length,a--;a;)t=_o(r),-1==i.indexOf(t)&&on[t].split("-")[1]!=n[0].ip&&(i.push(t),a--);var o=function(e){var t=on[e].split("-"),r={ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]};s.push(t[1]),n.push(r)};for(i.forEach(o),r=Exit.length,t=_o(r);-1!=s.indexOf(Exit[t].split("-")[1]);)t=_o(r);return t=Exit[t].split("-"),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),n},yo=function(e,r){var i="GET /"+r+" HTTP/1.1\r\n";return i+="Host: "+e+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",new t(i,"utf8")},vo=function(e,r,i){var n="GET /"+r+" HTTP/1.1\r\n";return n+="Host: "+e+"\r\n",n+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",n+="Range: bytes="+i+"-\r\n",n+="Accept: */*\r\n",n+="Accept-Language: en\r\n",n+="Accept-Encoding: gzip, deflate\r\n",n+="Connection: keep-alive\r\n",n+="\r\n",new t(n,"utf8")},bo=function(e,t,r){var i=0;if(e.nbc_=e.nbc_?e.nbc_:0,t){if(e.nbc_===On)return!1}else if(65534===e.nbc_)return!1;for(;e[i]||0===i;)i=t?r?e.cid?++e.cid%On:On:e.cid?++e.cid%On:1:e.cid?++e.cid%65535:1;return e.cid=i,e.nbc_++,i},wo=function(e){for(var r="",i=0;5>i;i++){var n=sn.createhash("sha1");n.update(new t(e+"0"+i,"hex")),r+=n.digest("hex")}return new t(r,"hex")},Eo=function(e,t){var r=sn.createcipheriv("aes-128-ctr",t,Ln),i=r.update(e,"hex","hex");return i+=r.final("hex")},Co=function(e,r){var i=r.slice(0,70),n=r.slice(70),s=No(16),a=[s,i].concatBuffers(),o=new un;a=o.encrypt(new t(e.toString("hex"),"binary"),new t(Nn,"binary"),new t(a.toString("binary"),"binary"),"RSA_PKCS1_OAEP_PADDING","hex");var c=Eo(n,s);return[new t(a,"hex"),new t(c,"hex")].concatBuffers()},So=function(e,r,i){var n=new un,s=new t(n.decrypt(e,r,"RSA_PKCS1_OAEP_PADDING","hex"),"hex"),a=s.slice(0,16);return[s.slice(16),new t(Eo(i,a),"hex")].concatBuffers()},Ao=function(e){if(T){if(this.fc_t.length){var t=this.fc_t.shift();t()}}else if(e.source==window&&e.data==this.messageName&&(e.stopPropagation(),this.fc_t.length)){var t=this.fc_t.shift();t()}},Io=function(e,t,r,i){if(r)if(r.stop_)r._torrent_&&r._torrent_stream.destroy(),r=null,console.log("delete sid 2"),delete this[t];else{if(r._torrent_&&T&&"undefined"==typeof i){var n=Date.now()-r.start_t0;i=Math.ceil(1e6*n*ji/1e3/Da/ds),console.log("first blocks nb "+i)}else i="undefined"==typeof i?Fa:i;var s=[];if(r.reader.onload=function(n){if(n.target.result){var a=n.target.result instanceof ArrayBuffer?new Uint8Array(n.target.result):n.target.result;if(a.length)for(var o=0;i>o;o++){if(0===r.stream_window_s){r.cursor-=a.length,r._torrent_&&r._torrent_.unshift(a);break}if(r.stream_window_s--,s.push(a.slice(0,Math.min(a.length,pn))),!(a.length>pn))break;a=a.slice(pn)}}var c=Date.now();r.fc_t.push(function(){To.call(this,e,s,r,t,c)}.bind(this)),T?setTimeout(Ao.bind(r),0):window.postMessage("flush","*")}.bind(this),0!==i){var a=e.slice(r.cursor,Math.min(e.size,r.cursor+i*pn));r.cursor+=a.length,r.reader.readAsArrayBuffer(a)}else r.reader.onload({target:{result:null}})}},To=function(e,t,r,i,n){t.forEach(function(e){r.sent_+=e.length;var t=new qo(qo.prototype.RELAY_DB_DATA,i,e,this.last_.Df_hash),n=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(n)},this);var s,a=Date.now()-n,o=T?this.socket_.bufferSize:this.socket_.bufferedAmount,c=parseInt((r.cursor-o)/((Date.now()-r.start_t0)/1e3)),l=8*c,h=ba;if(r.cursorh)s=0;else if(T)s=Math.ceil(a*c/1e3/Da/ds);else{var u=Pa>o?Math.ceil((Pa-o)/Da):0;a&&(s=Math.ceil(a*c/1e3/Da/ds)),s=s?Math.min(u,s):u}s=l>h?0:o>Pa?0:s>Fa?s:Fa,m&&0!==a&&0!==s&&console.log("real bandwidth "+parseInt(8*c/1e3)+" kbps "+"- advertised bandwidth "+parseInt(8*Ra/1e3)+" kbps time "+a+" nbblocs "+s+" buffered amount "+o+" cursor "+r.cursor+" torrent buffered "+(r._torrent_?r._torrent_.cursor:"")),0!==r.stream_window_s||r.pause_[i]?e.size===r.cursor?(console.log("delete sid"),delete this[i],console.log(parseInt(8*r.cd_length/((Date.now()-r.start_t0)/1e3))+" bps")):this.send_db_data(e,i,s,!0):(console.log(parseInt(8*r.cursor/((Date.now()-r.start_t0)/1e3))+" kbps"),console.log("Pausing download CIC "+this.circId+" for stream "+i+" sent "+r.sent_+" remaining length "+(e.size-r.cursor)+" time "+Date.now()+" buffered amount "+o+" fc_t "+r.fc_t.length),r.pause_[i]=e)},xo=function(e){var t=bo(e),r={};return r.sid_=t,r.received_=0,r.sent_=0,r.stream_window=Oa,r.stream_window_s=Oa,r.send_data=!0,e[t]=r,r.pause_={},t},Bo=function(e){if(e){var t=e.split(".");return t=t.length?t[t.length-1]:""}return"exe"},ko=function(e){var t=e.cid_,r=e.sid_;r&&delete t[r],delete e.cid_,delete e.sid_},Ro=function(e){lh(e.bar_),lh(xh),lh(nh)},Uo=function(e,r,i){console.log("search in bittorrent");for(var n=An;n.length;)if(n[0].socket_)if(n[0].socket_.remoteAddress){if(!n[0].destroyed_)break;console.log("ORDB remove destroyed CIC fac "+n[0].circId),n.shift()}else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();if(n.length){var s=n[0];n.shift(),n.push(s);var a=No(16),o={d_length:r,hash_:new t(i,"hex")};In[a.toString("hex")]=[this,e,n,o,1],s.send_db_query(o,a)}else this.send_db_end(0,e)},Do=function(e){if("open"===e._stream_.readyState&&!e._source_.updating)if(e.append_buffer.length){e.append_cursor++;var t=e.append_buffer.shift();try{e._source_.appendBuffer(t)}catch(r){console.log("error updateend ")}}else e.append_cursor=0};t.prototype.readUInt=function(){switch(this.length){case 1:return this[0];case 2:return this.readUInt16BE(0);case 4:return this.readUInt32BE(0);default:return 0}},t.prototype.writeUInt=function(e){switch(this.length){case 1:this.writeUInt8(e,0);break;case 2:this.writeUInt16BE(e,0);break;case 4:this.writeUInt32BE(e,0)}return this},t.prototype.map=function(e){var t=e.length;Hs||A?(this.set(e),this.fill(0,t)):(e.copy(this),this.fill(0,t))},Array.prototype.concatBuffers2=function(){var e=[];return this.forEach(function(t){e.push(t.toString("hex"))}),new t(e.join(""),"hex")},Array.prototype.concatBuffers1=function(){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){for(var t=e.length,n=0;t>n;n++)r[i]=e[n],i++}),r},Array.prototype.concatBuffers=function(){if(Hs||A){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){var t=e.length;r.set(e,i),i+=t}),r}return t.concat(this)},t.prototype.parse=function(e){e.WS_OP_&&e.ws_;for(var t=e.stream_tor_;t.length;){var r,i=t.slice(0,2),n=t.slice(2,3),s=i.readUInt();if(e[s]&&e[s].clear_timers(),7==n.readUInt()||n.readUInt()>=128){var a=t.length;if(!(a>=5))break;var o=t.readUInt16BE(3);if(!(a>=o+5))break;r=t.slice(5,o+5),t=t.slice(o+5)}else{if(!(t.length>=512))break;r=t.slice(3,512),t=t.slice(512)}var c=new Po(i.readUInt(),n.readUInt(),r,!0);Vo.bind(e)([c])}e.stream_tor_=t;var l=e.queue_;e.WS_OP_&&e.ws_,l.shift(),l.length&&l[0]()},t.prototype.parseTLS=function(e){for(var r,i=e.stream_tor_;i.length;){var n=i.length;if(!(n>=5))break;var s=i.readUInt16BE(3);if(!(n>=s+5))break;if(r=i.slice(0,s+5),i=i.slice(s+5),22!==r[0]||e.ccs_)20===r[0]&&(e.ccs_=!0),e.process(r);else for(var a=r.readUInt(1,2),o=r.readUInt(3,3),c=r.slice(5,o);c.length;){var n=c.length;if(!(n>=4))break;var l=c.readUInt(1,3);if(!(n>=l+4))break;var h=[new t(1).writeUInt(22),new t(2).writeUInt(a),new t(2).writeUInt(l+4),c.slice(0,l+4)].concatBuffers();e.process(h),c=c.slice(l+4)}}e.stream_tor_=i;var u=e.queue_;u.shift(),u.length&&u[0]()},(A||Hs)&&(t=function(e,t){if(t||"string"!=typeof e||(t="utf8"),e instanceof Array||!isNaN(e)&&!t)return new Uint8Array(e);if("utf8"===t)return new dt("utf-8").encode(e);if("hex"===t)try{for(var r=new Uint8Array(e.length/2),i=e.length,n=0;i>n;n+=2)r[n/2]=parseInt(e[n]+e[n+1],16) +}catch(s){return new Uint8Array}if("binary"===t)for(var r=new Uint8Array(e.length),i=r.length,n=0;i>n;n++)r[n]=e.charCodeAt(n);return r},_s.isBuffer=function(e){return e instanceof this||e instanceof Uint8Array},Uint8Array.prototype.isBuffer=_s.prototype.isBuffer,Uint8Array.prototype.parse=_s.prototype.parse,Uint8Array.prototype.parseTLS=_s.prototype.parseTLS,t.isBuffer=function(e){return e instanceof Uint8Array},Uint8Array.prototype.slice=function(e,t){return t?this.subarray(e,t):this.subarray(e)},Uint8Array.prototype.map=function(e){var t=e.length;this.set(e),this.fill(0,t)},Uint8Array.prototype.readUInt=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16BE(e);case 3:return this.readUInt24BE(e);case 4:return this.readUInt32BE(e);default:return 0}},Uint8Array.prototype.readUIntLE=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16LE(e);case 4:return this.readUInt32LE(e);default:return 0}},Uint8Array.prototype.writeUInt=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16BE(e,t);break;case 3:this.writeUInt24BE(e,t);break;case 4:this.writeUInt32BE(e,t)}return this},Uint8Array.prototype.writeUIntLE=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16LE(e,t);break;case 4:this.writeUInt32LE(e,t)}return this},Uint8Array.prototype.fill=function(e,t){for(var r=this.length,i=t;r>i;i++)this[i]=e},Uint8Array.prototype.readUInt16BE=function(e){return this[e]<<8^this[e+1]},Uint8Array.prototype.readUInt24BE=function(e){return this[e]<<16^this[e+1]<<8^this[e+2]},Uint8Array.prototype.readUInt32BE=function(e){return this[e]<<24^this[e+1]<<16^this[e+2]<<8^this[e+3]},Uint8Array.prototype.readUInt16LE=function(e){return this[e]^this[e+1]<<8},Uint8Array.prototype.readUInt32LE=function(e){return this[e]^this[e+1]<<8^this[e+2]<<16^this[e+3]<<24},Uint8Array.prototype.writeUInt8=function(e,t){this[t]=e},Uint8Array.prototype.writeUInt16BE=function(e,t){this[t]=255&e>>8,this[t+1]=255&e},Uint8Array.prototype.writeUInt24BE=function(e,t){this[t]=255&e>>16,this[t+1]=255&e>>8,this[t+2]=255&e},Uint8Array.prototype.writeUInt32BE=function(e,t){this[t]=255&e>>24,this[t+1]=255&e>>16,this[t+2]=255&e>>8,this[t+3]=255&e},Uint8Array.prototype.writeUInt16LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8},Uint8Array.prototype.writeUInt32LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8,this[t+2]=255&e>>16,this[t+3]=255&e>>24},Uint8Array.prototype.toString=function(e){var t=this.length,r=[];if("utf8"===e)return new ft("utf-8").decode(this);if("hex"===e)for(var i=0;t>i;i++){var n=this[i].toString(16);r.push(1===n.length?"0"+n:n)}return"binary"===e?String.fromCharCode.apply(null,this):r.join("")},Ln=new t("00000000000000000000000000000000","hex"));var No=function(e){return sn.randomBytes(e)},Lo=function(e){for(var t=e.length,r=[],i=0;t>i;i++)r.push(e[i]);return r.join(".")},Oo=function(e){return new t(e.split("."))},Po=function(e,r,i,n){this.CircID=new t(2).writeUInt(e),this.Command=new t(1).writeUInt(r),this.Length=new t(2).writeUInt(i.length),this.Payload=n?zo.bind(this)(i):i};Po.prototype={PADDING:0,CREATE:1,CREATED:2,RELAY:3,DESTROY:4,CREATE_FAST:5,CREATED_FAST:6,NETINFO:8,RELAY_EARLY:9,VERSIONS:7,CREATE_FAST_WS:120,CREATED_FAST_WS:121,VPADDING:128,CERTS:129,AUTH_CHALLENGE:130,AUTHENTICATE:131,AUTHORIZE:132,RELAY_WS:190,versions_cell_decode:function(e){for(var t=[];e.length;)t.push(e.slice(0,2)),e=e.slice(2);return t},certs_cell_decode:function(e){var t=e.slice(0,1);e=e.slice(1);var r=[];for(r.push(t);e.length;){var i={};i.CertType=e.slice(0,1),i.CLEN=e.slice(1,3);var n=i.CLEN.readUInt();i.Certificate=e.slice(3,3+n),e=e.slice(3+n),r.push(i)}return r},auth_challenge_cell_decode:function(e){var t=[],r={};return r.Challenge=e.slice(0,32),r.N_Methods=e.slice(32,34),r.Methods=e.slice(34,34+r.N_Methods.readUInt()),t.push(r),t},netinfo_cell_decode:function(e){var t=[],r={};r.Timestamp=e.slice(0,4);var i=po(e.slice(4));e=i.data,r.other_OR=i.addr,r.nb_addresses=e.slice(0,1),r.this_ORs=[],e=e.slice(1);for(var n=r.nb_addresses.readUInt(),s=0;n>s;s++){var a=po(e);r.this_ORs.push(a.addr),e=a.data}return t.push(r),t},create_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),t.push(r),t},create_fast_ws_cell_decode:function(e){var r=[],i={},n=new un;try{i.key_material=new t(n.decrypt(Xs,e.slice(0,128).toString("hex"),"","hex"),"hex"),r.push(i)}catch(s){console.log("create fast pb decrypting")}return r},created_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),r.derivative_key_data=e.slice(20,40),t.push(r),t},created_fast_ws_cell_decode:function(e){var t=[],r={};return r.key=e.slice(0,40),t.push(r),t},create_cell_decode:function(e){var t=[],r={};return r.M_=e.slice(0,128),r.M2_=e.slice(128,186),t.push(r),t},created_cell_decode:function(e){var t=[],r={};return r.dh_data=e.slice(0,128),r.derivative_key_data=e.slice(128,148),t.push(r),t}};var Fo=function(e){e&&(this.OP_=!0,this.server_=e[0],this.path_=e,this.nb_=0,this.conn_=0,this.sent_=0,this.received_=0,this.circuit_window=cs,this.circuit_window_s=cs,this.stream_=[],this.pause_={},this.time_=(new Date).valueOf(),this.resolved_failed=0),this.perf_=0,this.time_average=0};Fo.prototype={padding_cell_handle:function(){this.next_&&this.next_.keep_alive()},versions_cell_handle:function(e){var r=this.socket_;if(!this.OR_||this.onion_)e.Payload.forEach(function(e){3==e.readUInt()&&(r.handshake_=3)},this),r.handshake_||this.end("v3 handshake not supported","handshake");else{var e=new Po(this.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));if(this.send(e),!r.ws_){var i={};i.CertType=new t(1).writeUInt(1),i.Certificate=new t(al(o+"pub-key.pem",o+"priv-id-key.pem","der",r.certid_,r.cert_date,r.cert_subject,r.cert_issuer),"hex"),i.CLEN=new t(2).writeUInt(i.Certificate.length),i=[i.CertType,i.CLEN,i.Certificate].concatBuffers();var n={};n.CertType=new t(1).writeUInt(2),n.Certificate=new t(al(o+"pub-id-key.pem",o+"priv-id-key.pem","der",parseInt(No(8).toString("hex"),16),r.cert_date,r.cert_issuer,r.cert_issuer),"hex"),n.CLEN=new t(2).writeUInt(n.Certificate.length),n=[n.CertType,n.CLEN,n.Certificate].concatBuffers(),e=new Po(this.circId,Po.prototype.CERTS,[new t(1).writeUInt(2),i,n].concatBuffers()),this.send(e);var s={};s.Challenge=No(32),s.N_Methods=new t(2).writeUInt(1),s.Methods=new t(2).writeUInt(0),e=new Po(this.circId,Po.prototype.AUTH_CHALLENGE,[s.Challenge,s.N_Methods,s.Methods].concatBuffers()),this.send(e)}var a=[],c={};c.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),c.other_OR={type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.remoteAddress)},c.nb_addresses=new t("01","hex"),c.this_ORs=[{type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.address().address)}],a.push(c),e=new Po(this.circId,Po.prototype.NETINFO,a),this.send(e)}},certs_cell_handle:function(){},auth_challenge_cell_handle:function(){},netinfo_cell_handle:function(e){var r={};if(!this.OR_f){var i=this.socket_.remoteAddress;if(e.Length=0,r.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),e.Length+=4,e.Payload[0].this_ORs.forEach(function(t){(Lo(t.value)==i||this)&&(r.other_OR=t,e.Length+=t.length,this._OR_ip_verified=!0)},this),this._OR_ip_verified)if(r.nb_addresses=new t(1).writeUInt(1),e.Length++,r.this_ORs=[e.Payload[0].other_OR],e.Length+=r.this_ORs[0].length,e.Payload=[r],this.send(e),this.socket_.handshake=!0,this.OP_)if(this.setCircId(),!zs&&!js||!ks&&!Us||Cs&&!Js)this.create();else if(A&&Zi&&(!Cs&&$i||!Js)){this.X_=No(20);var n=new t(vl.encrypt(this.X_.toString("hex")),"hex"),s=new Po(this.circId,Po.prototype.CREATE_FAST_WS,n);this.send(s)}else{this.X_=No(20);var s=new Po(this.circId,Po.prototype.CREATE_FAST,this.X_);this.send(s)}else this.setCircId(),this.create();else this.end("remote IP does not match","handshake")}},create_fast_cell_handle:function(e){console.log("OR receive create fast from "+this.socket_.remoteAddress+" CIC "+this.circId+" sending created_fast"),this.X_=e.Payload[0].key_material,this.Y_=No(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new Po(this.circId,Po.prototype.CREATED_FAST,[this.Y_,r].concatBuffers());this.send(i)},create_fast_ws_cell_handle:function(e){if(e.Payload.length){this.X_=e.Payload[0].key_material,this.Y_=No(20);var r=[this.X_,this.Y_].concatBuffers(),i=this.circuit_keys(r),n=new Po(this.circId,Po.prototype.CREATED_FAST_WS,new t(Eo([this.Y_,i].concatBuffers(),this.X_.slice(0,16)),"hex"));this.send(n)}else this.destroy(1)},created_handle:function(){if(this.conn_++,(zs||js)&&(ks||Us)&&!Cs&&$i&&this.request_.params_.ws===Cl&&delete this.next_,this.next_)this.extended_=this.next_,this.extend();else if((zs||js)&&(ks||Us)){if(console.log("CIRC : CIRCUIT ESTABLISHED FAST - CID "+this.circId+" "+(this.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(this.prev_?this.prev_.server_.ip:"NONE")+" LAST OR : "+this.server_.ip),Cs=this,ks)for(var e in bs)bs[e].associated||El.associate(this.first_,e);!es&&Zi&&(ks?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):El.db_cid_launched||rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})),this.first_.last_=this}else console.log("CIRC : CAN NOT HAVE ONLY ONE NODE IN THE PATH"),this.end("CAN NOT HAVE ONLY ONE NODE IN THE PATH")},created_fast_cell_handle:function(e){console.log("created fast received CIC "+this.circId),this.Y_=e.Payload[0].key_material;var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t);r.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},created_fast_ws_cell_handle:function(e){var r=new t(Eo(e.Payload[0].key,this.X_.slice(0,16)),"hex");this.Y_=r.slice(0,20);var i=[this.X_,this.Y_].concatBuffers(),n=this.circuit_keys(i);n.toString("hex")!=r.slice(20,40).toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},create_cell_handle:function(e){var r=e.Payload[0].M_,i=e.Payload[0].M2_;this.X_=So(this.socket_.privkey_.toString("utf-8"),r.toString("hex"),i);var n=sn.getDiffieHellman("modp2");n.generateKeys(),this.Y_=new t(n.getPublicKey("hex"),"hex");var s=new t(n.computeSecret(this.X_,"hex","hex"),"hex"),a=this.circuit_keys(s),o=new Po(this.circId,Po.prototype.CREATED,[this.Y_,a].concatBuffers());this.send(o)},created_cell_handle:function(e){if(this.OP_){console.log("OP created "+this.circId);var r=this.extended_?this.extended_:this;if(r.Y_=e.Payload[0].dh_data,A&&!r.DH_.computeSecret){var i=new t(1).writeUInt(2);vn[r.cid_hex]=function(t){var r=this.extended_?this.extended_:this,i=t.toString("hex");r.DH_.computeSecret=function(){return i},delete vn[r.cid_hex],this.created_cell_handle(e)}.bind(this);var n=new qo(qo.prototype.RELAY_INFO,0,[i,new t(r.cid_hex,"hex"),r.Y_].concatBuffers(),Cs.Df_hash),s=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(n));return Cs.send(s),void 0}var a=new t(r.DH_.computeSecret(r.Y_,"hex","hex"),"hex"),o=r.circuit_keys(a);if(o.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex"))r.end("KH key does not match","created_extended_key");else if(this.conn_++,r.ok_=!0,r.next_)r.extended_=r.next_,r.extend();else{if(zs&&ks)for(var c in bs)bs[c].associated||El.associate(this.first_,c);Us&&this.first_.request_.params_.db&&!Ss?(Ss=this.first_,Ss.send_db_info(),Ss.process=Ss.send_db_query,setInterval(this.send_db_info.bind(Ss),As),r?console.log("CIRC : CIRCUIT ESTABLISHED -CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined")):this.first_.request_.params_.db?(console.log("created handle circuit destroy"),this.first_.circuit_destroy()):(r?console.log("CIRC : CIRCUIT ESTABLISHED - CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined"),Qn++),$n>Qn&&Zi&&(js||zs?ks||Ss?(console.log("create new dl circuit"),rc({params_:{OP:!0,nb_hop:Hn,ws:El}})):rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}):rc({params_:{OP:!0,nb_hop:Hn}})),this.first_.last_=r,this.first_.process();var l=mn;if(l)for(;l.length;)this.first_.process(l[0]),l.shift()}}else if(this.prev_){console.log("OR process extend - created received from "+this.server_.ip+" sending relay_extended to CIC "+(this.prev_?this.prev_.circId:"undefined"));var h=e.Payload[0],n=new qo(qo.prototype.RELAY_EXTENDED,0,[h.dh_data,h.derivative_key_data].concatBuffers(),this.prev_.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY_EARLY,!0)}else this.next_.destroy()},extend_cell_handle:function(e){if(ka&&this.socket_.address().port===kn&&this.OR_f)console.log("ORDB - Do not extend send destroy"),this.circuit_destroy();else{var r=Lo(e.slice(0,4)),i=e.slice(4,6).readUInt(),n=e.slice(6,192),s=e.slice(192,212).toString("hex"),a=new Fo;if(a.server_={ip:r,port:i,fing:s},console.log("OR process extend toward "+a.server_.ip+" "+a.server_.port+" "+a.server_.fing),this.next_=a,a.prev_=this,a.onion_=n,a.OR_=!0,a.way_="socket out",a.circId=0,bn[r])a.socket_=bn[r],a.socket_.stream_tor_=new t(0),a.setCircId(),a.create(),console.log("OUTGOING OR SOCKET EXTEND : ---------Socket already exists send create ------------ CIC "+a.circId+" for "+a.server_.ip);else{var c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",l="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",h={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,c,l),servername:c,rejectUnauthorized:!1};console.log("OUTGOING OR SOCKET EXTEND : ---------OR starts client socket with------------"+h.servername+" "+a.server_.ip+" "+a.server_.port);var u=tn.connect(a.server_.port,a.server_.ip,h,function(){bn[a.server_.ip]=this,console.log("OR process extend sending versions"),a.socket_=this,this.OR_=!0,this.way_="socket out",this[a.circId]=a,this.stream_tor_=new t(0);var e=new Po(a.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));a.send(e)});u.on("data",Qo),u.circuits_destroy=function(){for(var e in wn)Object.keys(wn[e]).forEach(function(t){if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=wn[e][t];r&&r.socket_&&r.socket_.remoteAddress&&r.next_&&r.next_.socket_===u&&(console.log("destroy circ in CIC "+r.circId+" "+r.socket_.remoteAddress),r.circuit_destroy())}})},u.on("end",function(){console.log("or_tls_socket end"),delete bn[r],u.circuits_destroy()}),u.on("close",function(){console.log("or_tls_socket close"),delete bn[r],u.circuits_destroy()}),u.on("error",function(){console.log("or_tls_socket error"),delete bn[r],u.circuits_destroy()})}}},handle_destroy:function(e){if(this.OP_){var t=this.first_||this;console.log("OP receive destroy CIC "+t.circId+(t===Ss?" ------- DB_CID destroyed --------------- ":"")),t.destroyed_=!0,this.clear_timers(),t.circuit_destroy(!0)}else{console.log("OR "+(this.OR_f?"in":"out")+" received destroy from "+this.socket_.remoteAddress+" on CID "+this.circId);var t=this.prev_||this.next_;t?(console.log("OR "+(this.OR_f?"in":"out")+" send destroy to "+(t.socket_?t.socket_.remoteAddress:"")+" on CID "+t.circId),e=e.toString(),e=1===e.length?"0"+e:e,t.circuit_destroy(),this.circuit_destroy(!0)):this.circuit_destroy()}},relay_cell_handle:function(e,t){var r=e.Payload[0],i=e.Command.readUInt();this.OP_?this.stream_decrypt_backward(r,t):this.prev_?this.stream_encrypt_or_b(r,i):this.stream_decrypt_or_f(r,i)},relay_send_truncate:function(e){var r=new qo(qo.prototype.RELAY_TRUNCATE,0,new t(1).writeUInt(e),this.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(r));this.send(i)},relay_end_handle:function(e,r){var i=this.first_,n=i[e],s=function(){n.download_&&(Oh('

An unexpected event occured(error '+r+"), please retry

"),lh(n.bar_)),n._write_(new t(oo(),"utf8")),n.end()};if(n&&(n.abstract_client_tls&&n.abstract_client_tls.close(),delete n.abstract_client_tls,!n.destroyed))if(-1===[6,12].indexOf(r))Us||(console.log(n.nb_try),n.nb_tryZn||0===i.sent_)&&(i.bad_=!0),i.destroy_cid(n),i.request_retry(n,r)):s());else if(n._data_)if(12===parseInt(r))if(console.log("END : CONNRESET RETRY "+r+" CID "+this.first_.circId+" on port "+n.remotePort+" for request "+n.i_id),n.download_)if(n.url_){var a=function(){n.queue_.shift(),Oh('

Remote server closed the connection (error '+r+"), download could not be completed, resuming...

"),setTimeout(function(){Wa("alert_box").style.display="none"},1e4);var s=function(r){var n=ho(r.url_);r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.params_.stream=vo(n.host,n.rest,length),r.queue_=[],r.queue_s=[],delete r.eof_,delete i[e],delete r.cid_,delete r.check_hash,delete r.file_id,delete r.start_t0,r.received_=0,rc(r)};ah(n,!0,s)};n.queue_.push(a),1===n.queue_.length&&n.queue_[0]()}else $a(document.body,"mousedown",function(){},!1),Oh('

Remote server closed the connection (error '+r+"), download could not be completed, please use Resume to resume the download.

"),n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]());else i.perf_--,i.destroy_cid(n),n.destroy();else n.bufferSize||(ks&&n.abstract_client_tls?n.done_=!0:n.download_?n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]()):(i.destroy_cid(n),n.end()));else n.nb_try++,i.perf_--,i.destroy_cid(n),i.request_retry(n,r)},request_retry:function(e,t){console.log("Retry for request "+e.i_id),ks?e.relay_ws_handle(e.ini_data,!0):rc(e,this,"end "+t)},relay_truncated_handle:function(e){console.log("STREAM : Truncated received from "+this.server_.ip+" CIRC "+this.circId+" "+e);var t=this.first_;switch(e){case 8:this.handle_destroy(0);break;case 11:this.handle_destroy(0);break;default:var r=t.last_?t.last_.ok_:null;r||this.next_.change_or("- relay truncated",this.extend)}},relay_truncate_handle:function(e){console.log("truncate "+this.circId);var r=this.next_,i=new Po(r.circId,Po.prototype.DESTROY,new t("05","hex"));r.send(i);var n=new qo(qo.prototype.RELAY_TRUNCATED,0,new t(1).writeUInt(e),this.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY,!0)},stream_handle:function(e){switch(e.command.readUInt()){case e.RELAY_EXTEND:this.extend_cell_handle(e.data);break;case e.RELAY_TRUNCATE:this.end("Error OR receive truncate :"+e.data.slice(0,1).readUInt(),"truncate");break;case e.RELAY_EXTENDED:this.created_cell_handle(new Po(this.circId,Po.prototype.CREATED,e.data,!0));break;case e.RELAY_TRUNCATED:this.end("Error OP receive truncated :"+e.data.slice(0,1).readUInt(),"truncated");break;case e.RELAY_END:this.end("End :"+e.data.slice(0,1).readUInt(),"relay_end",e.streamId.readUInt());break;case e.RELAY_CONNECTED:this.stream_decode_connected(e),this.stream_handle_connected(e.streamId.readUInt());break;case e.RELAY_DATA:this.stream_handle_data(e);break;case e.RELAY_SENDME:Oi("RECEIVING SENDME CIC "+this.circId+" for stream "+e.streamId.readUInt()),this.stream_handle_sendme(e.streamId.readUInt());break;case e.RELAY_ASSOCIATE:this.associate(e.data.slice(0,e.length.readUInt()).toString("utf8"));break;case e.RELAY_INFO:this.info(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_WS:this.relay_ws_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_INFO:this.relay_db_info_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_QUERY:this.relay_db_query_handle(e);break;case e.RELAY_DB_CONNECTED:this.relay_db_connected_handle(e);break;case e.RELAY_DB_END:this.relay_db_end_handle(e);break;case e.RELAY_DB_DATA:this.relay_db_data_handle(e);break;case e.RELAY_DB_SENDME:this.relay_db_sendme_handle(e)}},stream_decode_connected:function(){},stream_handle_sendme:function(e){var t=this.first_,r=t.stream_;Oi("FLUSH BUFFER CIC "+t.circId+" sid "+(e||" whole circuit ")+" buffer length "+r.length);var i=Math.min(e?us:ls,r.length),n=0;for(e?t[e].stream_window_s+=us:t.circuit_window_s+=ls;i>n;){var s=e?r[n]:r[0];e?e===s[1]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),s[0]=null,n++):(s[0]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),n++),r.shift())}},stream_handle_connected:function(e,r){var i=this.first_,n=i[e];if(n)if(Us&&clearTimeout(n.socket_retry),this.clear_timers(),console.log("STREAM RELAY :--------------RELAY_CONNECTED TO---------------------- "+this.server_.ip+" VIA "+this.first_.server_.ip+" CID "+this.circId+" Stream "+e+" for request "+n.i_id),n.params_.stream){for(var s=n.params_.stream;s.length;){if(n.tls_client_connected||!n.abstract_client_tls,r)var a=new qo(qo.prototype.RELAY_DB_DATA,e,[new t(r,"hex"),s.slice(0,Math.min(s.length,pn-16))].concatBuffers(),this.Df_hash);else var a=new qo(qo.prototype.RELAY_DATA,e,s.slice(0,Math.min(s.length,pn)),this.Df_hash);var o=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(a));if(n.sent_++,i.resolved_failed=0,i.sent_++,i.time_=Date.now(),n.start_t0=i.time_,n.stream_window_s--,i.circuit_window_s--,0===n.stream_window_s||0===i.circuit_window_s?(console.log("Bufferizing CIC "+i.circId+" for request "+n.i_id),i.stream_.push[e]):this.send(o),!(s.length>pn))break;s=s.slice(pn)}n.squeue_&&(n.squeue_.shift(),n.squeue_.length&&n.squeue_[0]())}else sc(n)},stream_handle_data:function(e,r,i){var n=this.first_;if(n){var s=e.streamId.readUInt(),a=i||n[s];if(a){r||a.time_resp||(a.time_resp=Date.now(),n.time_average=(n.time_average+(a.time_resp-a.time_ini))/(n.time_average?2:1)),r?(console.log("STREAM RELAY : --------------RECEIVE DECODED TLS DATA FROM---------------------- "+this.server_.ip+" CID "+this.circId+" Stream "+s+" for request "+a.i_id+" length "+e.length.readUInt()),e.data.slice(0,e.length.readUInt())):a.tls_client_connected||!a.abstract_client_tls;var o=e.data.slice(0,e.length.readUInt());if(r)a.received_++;else{if(!a._data_||a.wait_header){var c;if(a._data_=!0,a.download_){if(o=a.wait_header?[a.wait_header,o].concatBuffers():o,c=ic(o.toString("utf8")),"undefined"==typeof c["1a"]||""!==c["1a"])return a.wait_header=o,void 0;delete a.wait_header;var l=c["0a"].split(" ");if(l=l[1]?l[1]:null){if(Oi("STREAM : status code "+l+" for request "+a.i_id),l=l.toString(),-1===["2","3"].indexOf(l[0]))return Oh('

Wrong URL, please check and try again

'),lh(a.bar_),n.send_relay_end(a.sid_),void 0;if("3"===l[0]){if(c.Location){var h=ho(c.Location);a.params_.stream=yo(h.host,h.rest),n.send_relay_end(a.sid_),delete n[a.sid_],delete a.cid_,rc(a)}return}if(a.d_length=a.d_length||0,a.content_=c["Content-Type"]?c["Content-Type"]:"application/octet-binary",c["Content-Length"]&&!a.clength_&&(a.clength_=parseInt(c["Content-Length"])),!a.clength_)for(var u in c)if(-1!==u.toLowerCase().indexOf("content-length")){a.clength_=parseInt(c[u]);break}a.pieces=Math.ceil(a.clength_/Da),c["Transfer-Encoding"]&&(a.encoding_=c["Transfer-Encoding"]),console.log("Start relay_data"),console.log(a.content_),console.log(a.clength_),console.log(a.encoding_?a.encoding_:"No encoding"),a._stream_&&fh(a),o=o.toString("hex").split(gs+gs),o.shift(),o=new t(o.join(gs+gs),"hex")}}}a._data_=!0,a.received_++,n.received_++,n.circuit_window--,a.stream_window--,a.resp__=a.resp__?a.resp__+o.length:o.length,0===n.received_%ls&&n.circuit_window1))return a.header_=o,void 0;a.header_=[a.header_?a.header_:new t(0),new t(f[0]+gs+gs,"hex")].concatBuffers(),a.header_l=a.header_.length}if(a.header_l){if(f.shift(),"chunked"!==a.encoding_){var c=ic(a.header_.toString("utf8"));c["Content-Length"]&&(a.clength_=parseInt(c["Content-Length"]),a.content_l=!0)}else f=f.join(gs+gs).split(gs),a.header_l=a.header_.length,a.clength_=f.length>1?parseInt(new t(f[0],"hex").toString("utf8"),16):0,f.shift(),a.pass_="",a.buff_="";o=new t(f.join(gs),"hex")}}if("chunked"===a.encoding_){if(a.html_.length+o.length>=a.clength_||a.wait_)var p=cc(o.toString("hex"),a);t.isBuffer(a.html_)?a.html_={length:parseInt((p?p:o).length)}:a.html_.length+=p?0:parseInt(o.length)}else a.html_=[a.html_,o].concatBuffers()}}try{}catch(_){}r||n.perf_++,a.nb_try=0;var f=a.html_?a.content_l&&a.clength_===a.html_.length||"chunked"===a.encoding_?!1:!0:!1;if(!f){if("chunked"!==a.encoding_&&(a.socks_s=!1),a.html_){var g=a.content_l?a.html_.toString("utf8"):a.decoder_.decode(p?p:o,{stream:!0});if(!a.content_l){if(a.buff_+=g,a.buff_.length=128)&&i.push(e.Length);var s=function(e){if(e.push)e.forEach(function(e){t.isBuffer(e)?i.push(e):s(e)});else for(var r in e)t.isBuffer(e[r])?i.push(e[r]):s(e[r])};if(e.Payload.push?e.Payload.forEach(function(e){s(e)}):i.push(e.Payload),i=i.concatBuffers(),7!==e.Command.readUInt()&&e.Command.readUInt()<128){var a=new t(512);a.map(i),i=a}if(this.OP_&&!r.last_){var o;this.clear_timers();var c;this===r?this.socket_?this.socket_.handshake_?(o=function(){console.log("CIRC : Create or first extend too long "+this.circId),this.circuit_retry()},c=Vn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){console.log("CIRC : Extend delay expired - change or "+this.server_.ip),this.change_or("- extend too long",this.extend)},c=Gn)}if(yh&&_h&&(chart1_int||chart2_int)&&parseInt(n)!==Po.prototype.PADDING){var l=go(new Date).getTime(),h=i.length;r===Ss?chart2_int&&(yh.dynRow2[l]=yh.dynRow2[l]?yh.dynRow2[l]+h:h):chart1_int&&(_h.dynRow2[l]=_h.dynRow2[l]?_h.dynRow2[l]+h:h)}if(this.OP_||this.OR_)try{if(this.OR_&&6===e.Command.readUInt()&&console.log("sending FAST to "+(this.server_?this.server_.ip:"OP")+" CIC "+e.CircID.readUInt()),this.socket_.ws_)if(this.OP_){if(A&&!I||T)var a=i;else var a=Ac(i,2,!0);this.socket_.write(a)}else this.socket_.write(Ac(i,2,!1));else this.socket_.write(i)}catch(u){if(console.log("OUTGOING SOCKET "+(this.OP_?"OP ":"OR ")+(this.socket_?this.socket_.ws_?"WS":"TLS":"")+" IP "+(this.server_?this.server_.ip:"")+" socket does not exist any longer"),this.OP_)this.socket_?T||this.socket_.destroy():(console.log("send1 circuit destroy"),this.circuit_destroy(!0));else if(!this.OR_f){var d=this.socket_;console.log("send2 circuit destroy"),this.circuit_destroy(!0),d&&d.circuits_destroy()}}else d.write(e)},navigate:function(e){var t=ho(e._host_);t.host="www."+fo(t.host,!0)+ms,Es=t.host,protocol=t.protocol,El.associate(Cs,t.host),console.log("send 301 and associate fake_d "+t.host+" location "+uo(t)),this.redirect(e,uo(t))},redirect:function(e,r){console.log("redirect send 301 for url "+r),Ds?(alert(lo(r)),e.__write__(new t(lo(r),"utf8"))):e._write_(new t(lo(r),"utf8")),e.destroy(),this.destroy_cid(e,!0),delete e._host_},send_db_info:function(e){e=e||null;var r=function(e){if(e.file_length===e.current_length&&Ss){console.log("send_db_info"),console.log(e.name_hash);var r=new t(e.name_hash,"hex"),i=new t(1).writeUInt(r.length),n=new t(1).writeUInt(0),s=T?new t(1).writeUInt(1):new t(0),a=[i,r,n,s].concatBuffers(),o=new qo(qo.prototype.RELAY_DB_INFO,0,a,Ss.last_.Df_hash),c=new Po(Ss.circId,Po.prototype.RELAY,Ss.last_.stream_encrypt_forward(o));Ss.send(c)}};Ha.list(r,e)},send_db_query:function(e,r){if(e){console.log("send_db_query");var i,n=e.params_?e.params_.hash_:e.hash_,s=e.d_length.toString(16);s=s.length%2?"0"+s:s,s=new t(s,"hex"),size_l=new t(1).writeUInt(s.length),console.log("send_db_query hash "+n.toString("hex")+" "+size_l[0]+" "+s.toString("hex")+" tid "+(r?r.toString("hex"):""));var a=[new t(1).writeUInt(n.length),n,size_l,s].concatBuffers();if(r)a=[a,r].concatBuffers(),i=0;else{if(i=bo(this),e.cid_=this,!i)return;this[i]=e,e.sid_=i,e.received_=0,e.sent_=0}if(this.OP_){console.log("OP send db_query CID "+this.circId+" sid "+i);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));e.query_time=Date.now(),this.send(c);var l=function(){this.socket_&&(e._torrentc_||(console.log("serving party not responding"),e.db_try++,this.send_db_end(1,i),delete e.sid_,this.send_db_query(e)))}.bind(this);e.db_tryNo answer from the network, changing peer to peer circuits, please wait and retry

'),lh(e.bar_),console.log("db_query no answer circuit destroy"),Ss.circuit_destroy(),Ss=null)}else{this.prev_=this,this.nb_query=this.nb_query||0,this.nb_query++,console.log("ORDB send db_query CID "+this.prev_.circId+" sid "+i+" "+this.prev_.socket_.remoteAddress);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.prev_.Db_hash);this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}}},send_db_end:function(e,r,i){r=r||0,console.log("send db_end CID "+this.circId+" sid "+r+" reason "+e+" "+("undefined"!=typeof i?i.toString("hex"):""));var n=new t(1).writeUInt(e);if(n=i?[n,i].concatBuffers():n,this.OP_){var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.last_.Df_hash),a=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(s));this.send(a)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_connected:function(e,r,i,n){e=e.toString(16),e=e.length%2?"0"+e:e,e=new t(e,"hex"),size_l=new t(1).writeUInt(e.length),i=new t(i,"utf8");var s=new t(2).writeUInt(i.length);console.log("send db_connected "+e.toString("hex")+" CID "+this.circId+" sid "+r+" type "+i.toString("utf8"));var a=[size_l,e,s,i].concatBuffers();if(n&&(a=[n,a].concatBuffers()),this.OP_){var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));this.send(c)}else{this.prev_=this;var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.prev_.Db_hash); +this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_data:function(e,t,r,i){if(this.OP_){var n=this[t];i||(n.fc_t=[],console.log("sending db data "+(this.OP_?"OP ":"ORDB sid ")+t+" BANDWIDTH "+8*Ra+" bps "+(this.OP_?" 512 bytes every "+(1+1e3/(Ra/Da))+" ms then nbblocks "+Math.ceil(Na*Ra/1e3/Da)+" every "+Na+"ms window size "+n.stream_window_s+" "+this.circuit_window_s:"")+" cd "+e.size),n.start_t0=Date.now(),n.cd_length=e.size,n.messageName="flush",T||$a(window,"message",Ao.bind(n),!0),n.reader=T?new Va:new FileReader,n.cursor=0),Io.call(this,e,t,n,r)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_DATA,t,e.slice(0,Math.min(e.length,pn)),this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_sendme:function(e){if(e=e||0,this.OP_){var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)}else{this.prev_=this;var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.prev_.Db_hash);this.stream_encrypt_or_b(r.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},circuit_keys:function(e){var t=wo(e.toString("hex")),r=t.slice(0,20);return this.Df_=t.slice(20,40),this.Db_=t.slice(40,60),this.Kf_=t.slice(60,76),this.Kb_=t.slice(76,92),this.Kf_cipher=sn.createcipheriv("aes-128-ctr",this.Kf_,Ln),this.Kb_cipher=sn.createcipheriv("aes-128-ctr",this.Kb_,Ln),this.Df_hash=new fn("sha1"),this.Db_hash=new fn("sha1"),this.Df_hash.update(this.Df_),this.Db_hash.update(this.Db_),r},stream_encrypt_forward:function(e){for(var r=this,i=e.toBuffer();r;)i=new t(r.Kf_cipher.update(i,"hex","hex"),"hex"),r=r.prev_;return i},stream_decrypt_backward:function(e,r){var i,n=this;if(w)var s=Date.now();for(var a=e.length;n&&!(n.Kb_&&(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),i=n.recognized(e)));)n=n.extended_;if(s&&(ga++,ma+=a,ya+=Date.now()-s,0===ga%va&&ya&&(console.log("CRYPTO perf decrypt backward: "+parseInt(8*ma/(ya/1e3))+" bps"),ga=0,ma=0,ya=0)),i&&41===i.command.readUInt(),i)if(r){var o=new qo(qo.prototype.RELAY_END,i.streamId,new t("0A","hex"),n.Df_hash),c=new Po(n.circId,Po.prototype.RELAY,n.stream_encrypt_forward(o));n.send(c)}else n.stream_handle(i);else this.end("Unrecognized stream","unrecognized"),console.log(e.toString("hex"))},stream_decrypt_or_f:function(e,r,i){if(this.Kf_cipher){if(e=new t(this.Kf_cipher.update(e,"hex","hex"),"hex"),!i)var n=this.recognized(e);if(n)this.stream_handle(n);else if(Rs&&this.socket_.fake_cid===this);else if(this.next_){var s=new Po(this.next_.circId,r,e);this.next_.send(s)}}},stream_encrypt_or_b:function(e,r,i){var n=this.prev_;if(n&&n.Kb_cipher){if(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),!i)var s=n.recognized(e);if(s)this.stream_handle(s);else if(n){var a=new Po(n.circId,r,e);n.send(a)}}},recognized:function(e){if(0==e.slice(1,3).readUInt()){var r=e.slice(9,11),i=Math.min(11+r.readUInt(),e.length),n=new qo(e.slice(0,1).readUInt(),e.slice(3,5).readUInt(),e.slice(11,i));n.length=r;var s=e.slice(5,9);if(this.OR_f){this.Df_hash.update(n.toBuffer());var a=new t(this.Df_hash.digest("hex"),"hex").slice(0,4)}else{this.Db_hash.update(n.toBuffer());var a=new t(this.Db_hash.digest("hex"),"hex").slice(0,4)}if(a.toString("hex")==s.toString("hex"))return n}},extend:function(){var e=this.extended_,r=Oo(e.server_.ip),i=new t(2).writeUInt(parseInt(e.server_.port)),n=new t(e.server_.fing,"hex");if(!A||sn.getDiffieHellman){var s=sn.getDiffieHellman("modp2");s.generateKeys(),e.DH_=s,e.X_=new t(s.getPublicKey("hex"),"hex");var a=function(){var s=Co(new t(e.server_.o_modulus,"hex"),e.X_),a=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,s,n].concatBuffers(),this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(a));this.send(o)};e.server_.o_modulus?a.call(this):e.get_certs(a)}else{var a=function(t){var s=t.slice(0,2).readUInt();e.X_=t.slice(2,2+s),e.DH_={};var a=t.slice(2+s),o=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,a,n].concatBuffers(),this.Df_hash),c=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(o));delete vn[e.cid_hex],this.send(c)}.bind(this);e.create_extend_info(a)}},create:function(){if(this.onion_){var e=new Po(this.circId,Po.prototype.CREATE,this.onion_);this.send(e)}else if(A){var r=function(e){var t=e.slice(0,2).readUInt();this.X_=e.slice(2,2+t);var r=e.slice(2+t),i=new Po(this.circId,Po.prototype.CREATE,r);delete vn[this.cid_hex],this.send(i)}.bind(this);this.DH_={},this.create_extend_info(r)}else{var i=sn.getDiffieHellman("modp2");i.generateKeys(),this.DH_=i,this.X_=new t(i.getPublicKey("hex"),"hex");var r=function(){var e=Co(new t(this.server_.o_modulus,"hex"),this.X_),r=new Po(this.circId,Po.prototype.CREATE,e);this.send(r)};this.server_.o_modulus?r.call(this):this.get_certs(r)}},create_extend_info:function(e){var r=new t(1).writeUInt(1),i=No(16),n=i.toString("hex");this.cid_hex=n;var s=new t(this.server_.o_modulus,"hex");vn[n]=e;var a=new qo(qo.prototype.RELAY_INFO,0,[r,i,s].concatBuffers(),Cs.Df_hash),o=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(a));Cs.send(o)},destroy:function(){console.log("CIRC : -------------------------- SEND DESTROY ------------------- "+(this.server_?this.server_.ip:this.socket_.remoteAddress)+(this.OP_?" OP":" OR")+" CID "+this.circId);var e=new Po(this.circId,Po.prototype.DESTROY,new t("09","hex"));this.send(e)},send_relay_end:function(e){var r=this.first_||this,i=new qo(qo.prototype.RELAY_END,e,new t(0),r.last_.Df_hash),n=new Po(r.circId,Po.prototype.RELAY,r.last_.stream_encrypt_forward(i));r.send(n)},associate:function(e){console.log("ASSOCIATE OR RECEIVE "+e),this.socket_.fake_cid=this,En[e]={circ_:this}},info:function(e){if(this.OP_){var r=e.slice(0,16).toString("hex");vn[r]&&vn[r](e.slice(16))}else{var i=e.slice(0,1).readUInt(),r=e.slice(1,17);switch(i){case 1:var n=e.slice(17),s=sn.getDiffieHellman("modp2");s.generateKeys(),Bn[r.toString("hex")]=s;var a=new t(s.getPublicKey("hex"),"hex"),o=Co(n,a);e=new qo(qo.prototype.RELAY_INFO,0,[r,new t(2).writeUInt(a.length),a,o].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);this.send(c);break;case 2:var l=r.toString("hex");if(Bn[l]){var h=new t(Bn[l].computeSecret(e.slice(17),"hex","hex"),"hex");e=new qo(qo.prototype.RELAY_INFO,0,[r,h].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);delete Bn[l],this.send(c)}}}},relay_ws_handle:function(e,r){if(this.OP_){var i=null,s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8").split(":");if(e=e.slice(2+s),console.log("OP ws receive request "+a[3]+" adresse "+a[0]+" port "+a[1]+" data "+e.length),e.length){var o={},c=yn[a[3]];c?c.params_&&(i=c.params_.host):(c={nb_try:0,no_exit:[],i_id:a[3]},yn[a[3]]=c);var l=function(e){for(var r=e,i=new t(new t(a[0]+":"+a[1],"utf8").toString("hex"),"hex"),n=i.length.toString(16);4!==n.length;)n="0"+n;if(i=[new t(n,"hex"),i].concatBuffers(),n=i.length,0===r.length){var s=new qo(qo.prototype.RELAY_WS,0,i,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));this.send(o)}else for(;r.length;){var c;c=r.length+n>_n?r.slice(0,_n-n):r,c=[i,c].concatBuffers();var s=new qo(qo.prototype.RELAY_WS,0,c,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));if(this.send(o),!(r.length+n>_n))break;r=r.slice(_n-n)}}.bind(Cs);if(!Ds||!c.tls_server_connected){var h=function(){if(c.wait_header=c.wait_header?[c.wait_header,e].concatBuffers():e,c.wsqueue_&&c.wsqueue_.length){var t=c.wsqueue_[0];c.wsqueue_.shift(),t()}};if(e.length>=4){var u=e.toString("hex");u.substr(u.length-8)!==gs+gs?h():(e=c.wait_header?c.wait_header:e,delete c.wait_header)}else h();c._write_=l,c.destroy=function(){Ds?(delete c.abstract_server_tls,c.abstract_client_tls?(delete c.abstract_client_tls,l(new t(0))):c._write_(new t(0))):c._write_(new t(0))}}var d=function(e){var s=a[2],l=ic(e),h=l.Accept?l.Accept:"";-1!==h.indexOf("text/html")&&delete l["Accept-Encoding"],c.referer_=l.Referer,delete l.Referer,l.Connection="keep-alive";var u=l["0a"].split(" "),d="";if(u.length>1){var f="/"===u[1].substr(0,1)?u[1].substr(1):u[1];d=fo(f)}var p=function(){if("http"===d.substr(0,4)){var h=ho(d);u[1]="/"+(h.rest?h.rest:""),l["0a"]=u.join(" "),l.Host&&(l.Host=h.host?h.host:""),delete l.Cookie,l["X-Requested-With"]||(c._host_=h.protocol+"//"+l.Host)}else l.Host&&(c.fake_domain=l.Host,l.Host=bs[l.Host].real_domain);l.Accept&&-1!==l.Accept.indexOf("text/html")&&(l["Accept-Encoding"]="identity"),e=nc(l),o.OP=!0,o.nb_hop=Hn,o.one_c=!0,Ds&&(s=protocol===ws&&"443"===s?"80":s),o.host=l.Host+":"+s,i&&o.host!==i&&(delete c.tls_client_connected,delete c.abstract_client_tls,c.cid_&&c.cid_.destroy_cid(c,!0)),o.stream=new t(e,"utf8"),c.params_=o,c._data_=!1,c._init_=Xo,c._init_(),r&&(c.nb_try=n),c.remoteAddress=a[0],c.remotePort=a[1],c.end=c.destroy};if("https"===d.substr(0,5)||"https:"===protocol){if(!Ns)return console.log("https not supported now "+d),c._write_(new t(ao(),"utf8")),void 0;if(p(),c.abstract_client_tls){console.log("Reuse TLS Client for request "+c.i_id);var _=function(){c.abstract_client_tls.prepare(sl(c.params_.stream.toString("hex")))};c.request_decoded.socks_s?(console.log("Queue "+c.i_id),c.abstract_client_tls.queue_socks.push(_)):_()}else{console.log("Create TLS Client for request "+c.i_id);var g=ho(d),e=c.params_.stream;c.abstract_client_tls=cl(c,g.host),c.abstract_client_tls.stream_tor_=new t(0),c.abstract_client_tls.queue_socks=[];var m={};m._init_=Xo,m._init_(),m._host_=c._host_,m.cid_=c.cid_,m.i_id=c.i_id,m.fake_domain=c.fake_domain,m.socks_s=!0,m.__write__=c.__write__,m.destroy=c.destroy,m.referer_=c.referer_,c.request_decoded=m,m.request_=c,m.received_=0;var y=c.abstract_client_tls,v=function(e){var t=function(e){return function(){this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.stream_tor_.parseTLS(this)}};y.queue_=y.queue_||[],y.queue_.push(t(e).bind(y)),1===y.queue_.length&&y.queue_[0](),y.queue_socks.length&&!m.socks_s&&(m.socks_s=!0,console.log("Unqueue request "+c.i_id),y.queue_socks[0](),y.queue_socks.shift())};c._write_=v,c.write_c=function(e){c.params_.stream=e,rc(c)},c.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.error=function(e,t){console.log(" Error TLS client disconnected "+t.message),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.connected=function(t){console.log("TLS client connected to site for request "+c.i_id),c.tls_client_connected=!0,c._data_=!1,console.log("Sending https request for request "+c.i_id+" to site "+e.toString("utf8")),t.prepare(sl(e.toString("hex")))},c.abstract_client_tls.dataReady=function(e){var r=e.data.data.slice(e.data.read,e.data.length_);e.data.read=e.data.length_;var i={streamId:new t(2).writeUInt(c.sid_),data:r,length:new t(2).writeUInt(r.length)};c.cid_&&c.cid_.last_.stream_handle_data(i,c.__write__,m)},c.abstract_client_tls.handshake()}}else p(),rc(c)};if(c.relay_ws_handle=d,Ds)c.abstract_server_tls||(c.abstract_server_tls=cl(c,Es,!0),c.write_s=l,c.abstract_server_tls.closed=function(){console.log(" TLS server disconnected for request "+c.i_id),c.destroy()},c.abstract_server_tls.error=function(e,t){-1===t.message.indexOf("Unknown")&&(console.log("Error TLS server disconnected for request "+c.i_id+" "+t.message),c.destroy())},c.abstract_server_tls.connected=function(){console.log("TLS server connected to socks client for request "+c.i_id),c.tls_server_connected=!0,c._write_=function(e){c.abstract_server_tls?(console.log("tls server send to SOCKS"),c.abstract_server_tls.prepare(sl(e.toString("hex"))),c.done_&&c.destroy()):console.log("can't send to SOCKS server connection closed for request "+c.i_id)},c.__write__=c._write_,c.abstract_server_tls.dataReady=function(e){console.log(e.data.read);var t=e.data.data.slice(e.data.read,e.data.length_).toString("utf8");-1!==t.indexOf("Host")&&(e.data.read=e.data.length_,console.log("TLS server receive "+t),c.ini_data=t,d(t))}}),c.abstract_server_tls.process(e);else{var f=e.toString("utf8");c.ini_data=f,d(f)}}}if(this.OR_){var s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8");e=e.slice(2+s);var c=Cn[a];if(e.length)return c.write(e),void 0;c.bufferSize||(console.log("OR ws destroy request "+c.i_id),c.end())}},relay_db_info_handle:function(e){console.log("receive relay_db_info CID "+this.circId);var t,r,i,n,s,a;t=e[0],e=e.slice(1),n=e.slice(0,t).toString("hex"),e=e.slice(t),r=e[0],e=e.slice(1),e.length&&(i=e[0]),console.log("db_info "+n+" part "+r+" fac "+(i?"yes":"no")),s=Sn[n],s?(s.forEach(function(e){e[0]===this&&(a=!0)},this),a||s.push([this,null,null,0])):Sn[n]=[[this,null,null,0]],i&&(console.log(An.indexOf(this)),-1===An.indexOf(this)&&(console.log("pushing facilitator CID "+this.circId),An.push(this)))},relay_db_query_handle:function(e){var r=e.streamId.readUInt();console.log("receive relay_db_query CIC "+this.circId+" sid "+r),e=e.data.slice(0,e.length.readUInt());var i=e[0];e=e.slice(1);var n=e.slice(0,i).toString("hex");e=e.slice(i),i=e[0],e=e.slice(1);var s=parseInt(e.slice(0,i).toString("hex"),16);if(e=e.slice(i),console.log("Receive db_query for "+n+" on CID "+this.circId+" sid "+r+" requesting "+s+" bytes "+e.toString("hex")),this.OP_){var a=e.slice(0,16),c=this.first_;if(n!==Aa){var l=Ya(),h=l.get(n);h.onsuccess=function(e){var t=e.target.result;if(t)if(t.file_length===t.current_length&&se.length&&(e=t)}),sr?-1:1}).sort(function(e,t){return e[0].socket_?t[0].socket_?0:1:-1});var i=u.length;if(u.forEach(function(e){console.log("f has "+e[0].circId+" valid "+(e[0].socket_?"yes":"no"))}),i){for(;u.length;)if(u[0][0].socket_)if(u[0][0].socket_.remoteAddress){if(!u[0][0].destroyed_)break;console.log("ORDB remove destroyed CIC "+u[0][0].circId),u.shift()}else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();if(u.length){var d=u[0][0];u[0][3]++;var a=No(16),f={d_length:s,hash_:new t(n,"hex")};In[a.toString("hex")]=[this,r,u,f,1],d.send_db_query(f,a)}else Uo.call(this,r,s,n)}else Uo.call(this,r,s,n)}else An.length?Uo.call(this,r,s,n):(console.log("ORDB does not know the file"),this.send_db_end(0,r))}},relay_db_connected_handle:function(e){var t=e.streamId.readUInt();if(console.log("receive relay_db_connected CID "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt()),this.OP_){var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),s=this.first_[t];if(s){if("torrent"===n){if(s.url_)return console.log("direct download"),this.first_.send_db_end(1,t),ko(s),qh(s.query_t0),rc(s),void 0;$a(document.body,"mousedown",function(){},!1),console.log("put torrent timer"),s._streaming_||Oh('

The file is not available in Peersm network, looking for it in Bittorrent network.

'),s._torrentc_=setTimeout(function(){this.first_.send_db_end(1,t),ko(s),Ro(s),Oh('

Could not find the file in bittorrent, stopping download

')}.bind(this),Ia)}else Wa("alert_box").style.display="none",s._torrentc_&&(console.log("remove torrent timer"),clearTimeout(s._torrentc_));s.flowc=s.flowc?s.flowc:Date.now()-s.query_time,console.log("db_query/db_connected "+(Date.now()-s.query_time)+" ms "+s.flowc),qh(s.query_t0),s.clength_=i,s.pieces=Math.ceil(s.clength_/Da),s.content_=n,s.sid_=t,s.received_=0,s.sent_=0,s.nb_try=0,s.stream_window=Oa,s.stream_window_s=Oa,s._stream_&&"torrent"!==n&&fh(s)}}else{var a=e.slice(0,16).toString("hex");e=e.slice(16);var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),o=In[a];"torrent"!==n&&delete In[a],console.log("db_connected "+a+" type "+n+" size "+i+" "+typeof o),this.nb_query=0,o&&(this.socket_?o[0].socket_&&(o[0].send_db_connected(i,o[1],n),Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t]=o,xn[o[0].socket_.remotePort+"-"+o[0].socket_.remoteAddress+"-"+o[0].circId+"-"+o[1]]=[this,t],this[t]={},o[0][o[1]]={},console.log("i_or associated with remote port "+this.socket_.remotePort+" remote address "+this.socket_.remoteAddress+" CIC "+this.circId+" Stream "+t),console.log("f_or associated with remote port "+o[0].socket_.remotePort+" remote address "+o[0].socket_.remoteAddress+" CIC "+o[0].circId+" Stream "+o[1])):o[0].send_db_end(0,o[1]))}},relay_db_end_handle:function(e){var r=e.streamId.readUInt();e=e.data.slice(0,e.length.readUInt());var i=e.slice(0,1).readUInt();if(console.log("receive db_end sid "+r+" reason "+i+" CIC "+this.circId),this.OP_){var n=this.first_,s=n[r];if(s)if(s.send_data)s.fc_t?s.fc_t.length?(console.log("queue not empty - stop sending"),s.stop_=!0):(console.log("queue empty - delete request"),s._torrent_&&s._torrent_stream.destroy(),delete n[r]):s.__torrent__&&(console.log("destroying engine"),s.__torrent__.destroy());else if(qh(s.query_t0),qh(s.sendme_tout),qh(s.waiting_),2===i||s.reason_||3===i){qh(s.sendme_tout),qh(s.waiting_),s.reason_=2;var a=function(){if(s.nb_tryThe remote peers closed the connections, attempts to resume streaming failed.

')):($a(document.body,"mousedown",function(){},!1),Oh('

The remote peers closed the connections during the download, attempts to resume failed, storing downloaded part, please wait that the file appears in Local Storage.

Use resume later to get the complete file.

'),rh(s)),delete s.reason_)};s.queue_=s.queue_||[],s.queue_.push(a),1===s.queue_.length&&s.queue_[0]()}else if(s.url_)if(s.reload2_||s.reload_){console.log("resuming direct download");var o=function(e){var i=e.d_length;e.blob_=Ji?new t(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_});var s=ho(e.url_);e.params_.stream=vo(s.host,s.rest,i),delete e.params_.db_,delete e.cid_,delete n[r],delete e.file_id,delete e.start_t0,e.received_=0,rc(e)};ah(s,!0,o)}else this.destroy_cid(s),delete s.params_.db_,delete s.content_,delete s.d_length,delete s.clength_,delete s.blob_,_h&&(gh.vAxis.maxValue=Ks,_h.draw(mh,gh)),rc(s);else $a(document.body,"mousedown",function(){},!1),Oh('

The file is currently not available from peers in Peersm and Bittorrent networks and can not be downloaded directly, please check the URL or the Hash Name you are using

'),ko(s),Ro(s)}else if(this.nb_query=0,e.length>1){console.log("db_end with tid CIC "+this.circId+" db_test length "+(this.db_test?this.db_test.length:"")),this.db_test&&this.db_test.forEach(function(e){clearTimeout(e)});var c=e.slice(1,17).toString("hex"),l=In[c];if(l){var h=l[2],u=l[4];if(h[u]){l[4]++;var d=h[u][0];d.send_db_query(l[3],new t(c,"hex")),console.log("try another peer "+d.circId+" tid "+c+" stream length "+e.length)}else An.length?Uo.call(this,r,l[3].d_length,l[3].hash):(l[0].send_db_end(i,l[1]),delete In[c])}}else{console.log("forwarding db_end");var f=xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(f)try{3!==i&&(delete Tn[f[0].socket_.remotePort+"-"+f[0].socket_.remoteAddress+"-"+f[0].circId+"-"+f[1]],delete xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete f[0][f[2]]),f[0].send_db_end(i,f[1])}catch(p){}else{var _=Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(_)try{_[0].send_db_end(i,_[1]),delete xn[_[0].socket_.remotePort+"-"+_[0].socket_.remoteAddress+"-"+_[0].circId+"-"+_[1]],delete Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete _[0][_[2]]}catch(p){}}delete this[r]}},relay_db_data_handle:function(e){if(b)var r=Date.now();var i=e.streamId.readUInt();if(e=e.data.slice(0,e.length.readUInt()),this.OP_){var n=this.first_,s=n[i];if(s){0===s.received_&&(console.log("start_t0 received "+Date.now()),s.start_t0=Date.now(),n.send_db_sendme(i)),s.received_++,n.received_++,s.stream_window--,s._write_(e);var a=s.received_,o=parseInt(e.length*s.received_/((Date.now()-s.start_t0)/1e3)),c=Math.ceil(o*(s.flowc/2/1e3)/e.length);c=Math.ceil(Oa-c>0?Math.min(c,Oa*(1-ds)):Oa*(1-ds));var l,h=function(r){var a=function(e){console.log("sendme timeout received_ "+s.received_+" rec "+e+" stream-blocs "+(Oa-c)),s.received_!==e||s._stream_?h(s.received_):(qh(s.sendme_tout),qh(s.waiting_),console.log("resuming peer to peer download received "+s.received_),n.send_db_end(1,i),n.relay_db_end_handle({streamId:new t(2).writeUInt(i),length:new t(2).writeUInt(1),data:new t(1).writeUInt(2)}))};qh(s.sendme_tout),qh(s.waiting_),console.log(8*o+" bps nbBlocs "+c+" stream window "+s.stream_window+" - sending sendme stream received "+n.received_*e.length+" - Buffer Amount: "+El.bufferedAmount+" "+Date.now()),n.send_db_sendme(i),s.stream_window+=Oa,console.log("sendme timeout "+l+" stream length "+e.length),s.sendme_tout.push(setTimeout(function(){a(r)},l))};s.stream_window===c&&(0===El.bufferedAmount||n.received_*e.lengthr;r++){var i=new Fo;i.OP_=!0,i.t0_=[],i.server_=e.path_[r+1],e.next_=i,i.prev_=e,i.path_=e.path_,i.nb_=e.nb_+1,i.socket_=this.socket_,i.circId=this.circId,i.first_=this,e=i}return!0}var n=parseInt(this.server_.fing,16)Resuming direct download from '+this.last_.server_.ip+"

")):Oh('

File not available from Peers, starting direct download from '+this.last_.server_.ip+"

"),setTimeout(function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},12e3)),e.cid_=this,e.params_.host&&!e.destroyed){var r=new t(e.params_.host);r=new t(r.toString("hex")+"00","hex");var i=bo(this);if(i){console.log("STREAM : --------------SEND RELAY_BEGIN---------------------- CID "+this.circId+" on OR "+this.first_.server_.ip+" Stream "+i+" for request "+e.i_id+" on port "+e.remotePort+" host "+r.toString("utf8")),console.log(e.params_.stream.toString("utf8").substr(0,300)),this[i]=e,e.sid_=i,e.received_=0,e.sent_=0,e.stream_window=hs,e.stream_window_s=hs;var n=function(){var t=this;console.log("Timeout Bad circuit "+t.circId),!t.perf_>0&&(t.bad_=!0),t.send_relay_end(i),e.nb_try++,delete e.cid_,delete t[i],rc(e)},s=function(){var t=new qo(qo.prototype.RELAY_BEGIN,i,r,this.last_.Df_hash),s=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));Us&&(e.socket_retry=setTimeout(n.bind(this),rs)),this.send(s)};s.call(this)}}},sendme:function(e){e=e||{sid_:0,i_id:-1};var r=new qo(qo.prototype.RELAY_SENDME,e.sid_,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)},set_certs:function(e){try{e=e.split(jn),this.server_.onion_k=jn+e[1].split(zn)[0]+zn,this.server_.sign_k=jn+e[2].split(zn)[0]+zn;var t=new dn;return this.server_.o_modulus=t.modulus(this.server_.onion_k),this.server_.s_modulus=t.modulus(this.server_.sign_k),!0}catch(r){return this.nb_error=this.nb_error?++this.nb_error:1,!1}},get_certs:function(e){if(this.server_&&!this.ok_){var t=cn.length,r=this.server_.fing,i=_o(t),n=cn[i].split(":"),s=n[0],a=n[1],o={host:s,path:"/tor/server/fp/"+r,port:a,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip deflate","Accept-Language":"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3","Cache-Control":"max-age=0",Connection:"keep-alive",Host:s,"User-Agent":"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0"}},c=nn.request(o,function(t){if(c.data_="",200!=t.statusCode){this.clear_t0_();try{this.get_certs(e)}catch(i){}}t.on("data",function(e){this.clear_t0_(),c.data_+=e.toString("utf8")}.bind(this)),t.on("end",function(){this.server_&&!c.destroy_&&(this.certs_||(this.set_certs(c.data_)?(this.certs_=!0,this.prev_?e.call(this.prev_):e.call(this)):this.nb_error>4?this.change_or("CERTS : get_certs wrong cert for "+r,this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e)))}.bind(this))}.bind(this)),l=function(){this.clear_t0_(),this.server_&&(this.nb_error=this.nb_error?++this.nb_error:1,this.nb_error>4?this.change_or("error get_certs",this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e))}.bind(this);c.on("error",l),c.end();var h=function(){this.clear_t0_(),c.removeListener("error",l),l=function(){console.log("CERTS : error fired after abort for "+s)},c.on("error",l),c.destroy_=!0,c.socket.destroy(),this.server_&&this.get_certs(e)}.bind(this);this.t0_.push(setTimeout(h,1e3))}},change_or:function(e,t){if(this.server_){console.log("change_or ----------- CIC "+this.circId);var r,i,n=[];if(this.first_)var s=this.first_.request_;var a="undefined"==typeof s?null:s.params_?s.params_.db:null;if(this.prev_||!Zi||("undefined"==typeof this.server_?1:this.server_!==Zi)){if(this.first_===Ss||a)return this.first_&&(console.log("change_or circuit destroy"),this.first_.circuit_destroy(),s&&Ko(s)),void 0;var i=this.prev_?this.next_?on:Exit:Guards,o=i.length;for(this.clear_timers(),this.clear_t0_(),this.path_?n=this.path_.map(function(e){return e.ip}):n.push(this.server_.ip),r=_o(o);-1!=n.indexOf(i[r].split("-")[1]);)r=_o(o);var c=i[r].split("-");i={ip:c[1],fing:c[0],port:c[2],band:c[3],o_modulus:c[5]?c[5]:c[4]}}else console.log("change_or one OR "+this.circId),i=Zi;for(var l=this;l;)delete l.destroy_,delete l.nb_error,delete l.ok_,l=l.next_;delete this.first_.last_;var h=new Fo;Object.keys(this).forEach(function(e){h[e]=this[e]},this),h.server_=i;try{var u=this.server_.ip;this.server_o=this.server_}catch(d){console.log("_server error"),this.clear_timers();for(var f in this)"function"!=typeof this[f]&&console.log(f+" "+this[f]);this.first_.destroy()}delete this.server_,delete h.certs_,this.next_&&(h.next_.prev_=h),this.prev_?(h.prev_.extended_&&(h.prev_.extended_=h),h.prev_.next_=h,-1==e.indexOf("get_certs")&&(h=h.prev_,delete h.certs_)):h.first_=h,h.first_.reconstruct_path(),t&&(this.prev_||this.first_===this)?t.call(h):this.socket_.first_===this?(delete gn[u],h.socket_&&(this.destroy_=!0,h.socket_.destroy(),delete h.socket_),delete h.extended_,h.circId=0,h.first_=h,h.path_.shift(),h.path_.unshift(h.server_),tc(h)):this.next_.change_or("PATH : first socket exists, change path",this.create)}},circuit_retry:function(){if(!es)if(this.ok_||this.socket_.first_!==this){this.destroy(),delete this.ok_,delete this.first_.last_;var e=this.circId;this.circId=bo(this.socket_),delete this.socket_[e],this.socket_[this.circId]=this,this.socket_.nbc_--;for(var t=this;t.extended_;)t.extended_.circId=this.circId,t=t.extended_,delete t.extended_;this===t&&this.socket_.first_!==this?t.create():t.change_or("circuit_retry from first OR circId="+this.circId,this.create.bind(this)) +}else this.change_or("initial socket closed unexpectedly or unexpected circuit creation error or new circuit creation error")},reconstruct_path:function(){for(var e=this,t=[];e.next_;)t.push(e.server_),e=e.next_;for(;e.prev_;)e.path_=t,e.first_=this,e=e.prev_},circuit_destroy:function(e){if(this.socket_){this.socket_.remoteAddress?console.log("CIRC : circuit destroy "+(this.OP_?"OP ":"OR "+(this.OR_f?"in ":"out "))+(this.socket_.address()?this.socket_.address().address:"")+" CID "+this.circId+" remote "+this.socket_.remoteAddress):console.log("circuit destroy : socket no remote address CIC "+(this.OP_?"OP ":"OR ")+" "+this.circId);var t;if(this.socket_){var r=this.socket_;this.next_?e||this.destroyed_||(this.destroyed_=!0,r.remoteAddress&&(console.log("circuit_destroy remote address "+r.remoteAddress+" CIC "+this.circId),this.destroy())):this.socket_.address()&&ka&&parseInt(this.socket_.address().port)===parseInt(kn)&&r.OR_f&&(console.log("ORDB - call db_destroy"),this.circuit_db_destroy()),delete r[this.circId],delete this.socket_,Object.keys(r).forEach(function(e){isNaN(e)||null==e||(t=!0)},this),t||this===Ss||r.ws_||(console.log("circuit_destroy: destroy socket"),r.destroy())}}console.log("circuit_destroy "+(this.OP_?"OP":"OR")),this.OP_&&(console.log("requests_destroy"),this.requests_destroy()),delete this.next_,delete this.prev_},circuit_db_destroy:function(){this.socket_&&Object.keys(this).forEach(function(e){if(!isNaN(e)&&null!=e){var t=this.socket_?this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+e:this.server_?this.server_.port+"-"+this.server_.ip+"-"+this.circId+"-"+e:"",r=Tn[t]||xn[t];r&&(console.log("------- "+r[1]),r[0].send_db_end(2,r[1]),delete xn[t],delete Tn[t],delete this[e],delete r[0][r[1]])}},this)},requests_destroy:function(){for(var e in this)if(!isNaN(e)&&null!=e){var t=this[e];t.abstract_client_tls&&t.abstract_client_tls.close(),delete t.abstract_client_tls,this.destroy_cid(t),Ss?this!==Ss?t._data_?t.destroy():this.request_retry(t,"requests_destroy"):Sl(t):Us&&Sl(t)}if(ks){if(this===Cs){console.log("destroy CIC resend associate ");for(var e in bs)delete bs[e].associated;Cs=null,rc({params_:{OP:!0,nb_hop:Hn,ws:El}})}}else Ss?this===Ss&&(Ss=null,rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})):Us&&rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})},clear_timers:function(){this.OP_&&(this.first_.tc_.forEach(function(e){clearTimeout(e)}),this.first_.tc_=[])},clear_t0_:function(){this.t0_&&(this.t0_.forEach(function(e){clearTimeout(e)}),this.t0_=[])},end:function(e,t,r){if(r)var i=this.first_||this,n=i[r]?i[r]:i.request_;this.OP_,e=e.split(":"),console.log2=function(){};var s=function(){if(e.length>1)switch(parseInt(e[1])){case 0:return console.log2("-- CIC NONE (No reason given.)"),0;case 1:return console.log2("-- CIC PROTOCOL (Tor protocol violation.)"),1;case 2:return console.log2("-- CIC INTERNAL (Internal error.)"),2;case 3:return console.log2("-- CIC REQUESTED (A client sent a TRUNCATE command.)"),3;case 4:return console.log2("-- CIC HIBERNATING (Not currently operating; trying to save bandwidth.)"),4;case 5:return console.log2("-- CIC RESOURCELIMIT (Out of memory, sockets, or circuit IDs.) "+this.circId+" "+(this.OP_?" OP ":" OR ")),5;case 6:return console.log2(" -- CIC CONNECTFAILED (Unable to reach relay.)"),6;case 7:return console.log2("-- CIC OR_IDENTITY (Connected to relay, but its OR identity was not as expected.)"),7;case 8:return console.log2("-- CIC OR_CONN_CLOSED (The OR connection that was carrying this circuit died CID "+this.circId+" "+(this.OP_?" OP ":" OR ")),8;case 9:return console.log2("-- CIC FINISHED (The circuit has expired for being dirty or old.)"),9;case 10:return console.log2("-- CIC TIMEOUT (Circuit construction took too long)"),10;case 11:return console.log2("-- CIC DESTROYED (The circuit was destroyed w/o client TRUNCATE)"),11;case 12:return console.log2("-- CIC NOSUCHSERVICE (Request for unknown hidden service)"),12}}.bind(this),a=function(){if(e.length>1)switch(parseInt(e[1])){case 1:return console.log2("-- RELAY REASON_MISC (catch-all for unlisted reasons) request "+(n?n.i_id:"")),1;case 2:return console.log2("-- RELAY REASON_RESOLVEFAILED (couldn t look up hostname) request "+(n?n.i_id:"")),2;case 3:return console.log2("-- RELAY REASON_CONNECTREFUSED (remote host refused connection) [*] request "+(n?n.i_id:"")),3;case 4:return console.log2("-- RELAY REASON_EXITPOLICY (OR refuses to connect to host or port) request "+(n?n.i_id:"")),4;case 5:return console.log2("-- RELAY REASON_DESTROY (Circuit is being destroyed) request "+(n?n.i_id:"")),5;case 6:return console.log2("-- RELAY REASON_DONE (Anonymized TCP connection was closed) request "+(n?n.i_id:"")),6;case 7:return console.log2("-- RELAY REASON_TIMEOUT (Connection timed out, or OR timed out while connecting) request "+(n?n.i_id:"")),7;case 8:return console.log2("-- RELAY REASON_NOROUTE (Routing error while attempting to contact destination) request "+(n?n.i_id:"")),8;case 9:return console.log2("-- RELAY REASON_HIBERNATING (OR is temporarily hibernating) request "+(n?n.i_id:"")),9;case 10:return console.log2("-- RELAY REASON_INTERNAL (Internal error at the OR) request "+(n?n.i_id:"")),10;case 11:return console.log2("-- RELAY REASON_RESOURCELIMIT (OR has no resources to fulfill request) request "+(n?n.i_id:"")),11;case 12:return console.log2("-- RELAY REASON_CONNRESET (Connection was unexpectedly reset) request "+(n?n.i_id:"")),12;case 13:return console.log2("-- RELAY REASON_TORPROTOCOL (Sent when closing connection because of Tor protocol violations.) request "+(n?n.i_id:"")),13;case 14:return console.log2("-- RELAY REASON_NOTDIRECTORY (Client sent RELAY_BEGIN_DIR to a non-directory relay.) request "+(n?n.i_id:"")),14}}.bind(this);if(t)switch(t){case"handshake":this.change_or("handshake failed");break;case"fast_key":this.change_or("wrong fast key");break;case"created_extended_key":this.change_or("wrong create or extend key",this.prev_?this.prev_.extend:null);break;case"truncated":this.relay_truncated_handle(s());break;case"truncate":this.relay_truncate_handle(s());break;case"destroy":this.handle_destroy(s());break;case"unrecognized":console.log("end unrecognized circuit destroy"),this.circuit_destroy();break;case"relay_end":n&&"undefined"!=typeof n.i_id&&this.relay_end_handle(r,a())}else delete this.socket_[this.circId]}};var qo=function(e,r,i,n){this.command=new t(1).writeUInt(e),this.recognize=new t("0000","hex"),this.streamId=new t(2).writeUInt(r),this.digest=new t("00000000","hex"),this.length=new t(2).writeUInt(i.length),this.data=e===this.RELAY_WS?new t(i.length):new t(pn),this.data.map(i),n&&(n.update(this.toBuffer()),this.digest=new t(n.digest("hex"),"hex").slice(0,4))};qo.prototype={RELAY_BEGIN:1,RELAY_DATA:2,RELAY_END:3,RELAY_CONNECTED:4,RELAY_SENDME:5,RELAY_EXTEND:6,RELAY_EXTENDED:7,RELAY_TRUNCATE:8,RELAY_TRUNCATED:9,RELAY_DROP:10,RELAY_RESOLVE:11,RELAY_RESOLVED:12,RELAY_BEGIN_DIR:13,RELAY_ASSOCIATE:40,RELAY_WS:41,RELAY_INFO:42,RELAY_DB_INFO:80,RELAY_DB_QUERY:81,RELAY_DB_CONNECTED:82,RELAY_DB_DATA:83,RELAY_DB_END:84,RELAY_DB_SENDME:85,toBuffer:function(){return[this.command,this.recognize,this.streamId,this.digest,this.length,this.data].concatBuffers()}};var Ho,Mo,jo,zo=function(e){switch(this.Command.readUInt()){case this.VERSIONS:return this.versions_cell_decode(e);case this.CERTS:return this.certs_cell_decode(e);case this.AUTH_CHALLENGE:return this.auth_challenge_cell_decode(e);case this.NETINFO:return this.netinfo_cell_decode(e);case this.CREATED_FAST:return this.created_fast_cell_decode(e);case this.CREATED_FAST_WS:return this.created_fast_ws_cell_decode(e);case this.CREATE_FAST:return this.create_fast_cell_decode(e);case this.CREATE_FAST_WS:return this.create_fast_ws_cell_decode(e);case this.CREATED:return this.created_cell_decode(e);case this.CREATE:return this.create_cell_decode(e);default:return[e]}},Vo=function(e,t){if(e)for(var r=e.length,i=0;r>i;i++){var n=e[i],s=n.CircID.readUInt();if(this[s])var a=this[s];else{if(!this.OR_||!this.OR_f)return;if(this[0]){var a=this[0];a.circId=s,this[s]=a,delete this[0]}else{var a=new Fo;a.OR_=!0,a.OR_f=!0,a.circId=s,a.socket_=this,a.way_="socket in",this[s]=a}}try{a.clear_timers()}catch(o){}if(6===n.Command.readUInt()&&console.log("handle cell "+n.Command.readUInt()),yh&&_h&&(chart1_int||chart2_int)&&n.Command.readUInt()!==n.PADDING){var c=go(new Date).getTime(),l=0;n.Payload.forEach(function(e){l+=e.length}),a.first_===Ss?chart2_int&&(yh.dynRow[c]=yh.dynRow[c]?yh.dynRow[c]+l:l):chart1_int&&(_h.dynRow[c]=_h.dynRow[c]?_h.dynRow[c]+l:l)}if(a.destroyed_)console.log("received cell for destroyed CIC "+a.circId);else switch(n.Command.readUInt()){case n.PADDING:a.padding_cell_handle(n);break;case n.VERSIONS:a.versions_cell_handle(n);break;case n.CERTS:a.certs_cell_handle(n);break;case n.AUTH_CHALLENGE:a.auth_challenge_cell_handle(n);break;case n.NETINFO:a.netinfo_cell_handle(n);break;case n.CREATE_FAST:a.create_fast_cell_handle(n);break;case n.CREATE_FAST_WS:a.create_fast_ws_cell_handle(n);break;case n.CREATED_FAST:a.created_fast_cell_handle(n);break;case n.CREATED_FAST_WS:a.created_fast_ws_cell_handle(n);break;case n.CREATE:a.create_cell_handle(n);break;case n.CREATED:a.created_cell_handle(n);break;case n.RELAY:a.relay_cell_handle(n,t);break;case n.RELAY_WS:a.relay_cell_handle(n,t);break;case n.RELAY_EARLY:a.relay_cell_handle(n,t);break;case n.DESTROY:a.end("Destroy reason:"+n.Payload[0].slice(0,1).readUInt(),"destroy")}}else console.log("end or banish circuit_destroy"),this.circuit_destroy()},Ko=function(e){console.log("circuit_start"),Us&&Qn>Xn&&(document.location.href=document.location.href);var t=e.params_,r=[];if(t.nb_hop?t.nb_hop>2&&(r=mo(t)):r=mo(t),Zi&&(r[0]=Zi),(ks||Us)&&$i&&!Cs){if(t.ws!==Cl)return;r[0]=$i}t.db&&(r[Mn-1]=ka);var i=gn[r[0].ip],n=new Fo(r);if(n.request_=e,n.first_=n,n.tc_=[],i)if(i.abstract_client_tls&&!i.tls_connected&&i.wsconnected_)console.log("start TLS handshake - circuit start "),i.abstract_client_tls.handshake();else if(console.log("TLS connected - start create_fast"),n.server_=i.server_,n.socket_=i,n.tc_=[],n.setCircId())if(Js){console.log("Sending fast CIC "+n.circId+" "+i.server_.ip+" "+n.destroyed_),t.db&&(El.db_cid_launched=!0),n.X_=No(20);var s=new Po(n.circId,Po.prototype.CREATE_FAST,n.X_);n.send(s)}else n.create();else console.log("PATH : no more circuits available");else console.log("circuit_start init socket"),n.circId=0,t.ws?t.ws.wsconnected_&&($o(t.ws,n),Zo.call(t.ws,n)):tc(n)},Go=function(e){e&&(console.log("CIRCUITS destroy "+(e.remoteAddress?e.remoteAddress:"")),e.OP_&&delete gn[e.remoteAddress],Object.keys(e).forEach(function(t){if(!isNaN(t)&&null!=t){var r=e[t];console.log("delete cic "+r.circId+" socket "+(r.server_?r.server_.ip:"")),e.OP_?(r.requests_destroy(),delete gn[r.server_.ip]):r.next_?r.next_.destroy():r.prev_?r.prev_.destroy():r.circuit_db_destroy(),delete r.socket_,delete e[t]}}))},Yo=function(e,t){var r=[];for(var i in gn){var n=[];Object.keys(gn[i]).forEach(function(t){var r=gn[i][t];isNaN(t)||null==t||!r.last_||-1!==e.no_exit.indexOf(r)||r.bad_||(!Us||r!==Ss&&r!==Cs)&&n.push(r)}),n.length&&r.push(n)}if(r.length){if(!t){var s,a,o=r[_o(r.length)];if(e.nb_try){o=o.map(function(e){return[e,e.time_average]}),o.sort(function(e,t){return e=e[1],t=t[1],e==t?0:t>e?-1:1});var i=0,c=o.length;if(Us)i=parseInt(o.length/2);else for(var l=0;c>l;l++)if(0!==o[l][1]){i=l;break}i&&(o=o.slice(i,Math.min(o.length,Yn+i))),Oi("best circuits "+(o[0]?o[0][0].circId:"")+" "+(o[1]?o[1][0].circId:"")+" "+(o[2]?o[2][0].circId:"")),a=_o(o.length),s=o[a][0]}else a=_o(o.length),s=o[a],s.time_=(new Date).valueOf();return s}if(1===r.length&&1===r[0].length)return!0}else Us&&console.log("choose circuit no circuit found for request "+e.i_id)},Wo=function(e){return function(){if(this.OR_&&this.address().port===kn,this.ws_&&(!A||I||this.OR_)&&!T){this.WS_OP_;var r=Sc(this.stream_ws_?[this.stream_ws_,e].concatBuffers():e);try{e=r[0]}catch(i){return console.log("wsdecode error or FIN (first bit at 1):"+(e.length?e[0]:"")+" closing WS."),this.end(),void 0}this.ws_&&this.WS_OP_&&r[1].length,this.stream_ws_=r[1].length?r[1]:null}if(this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.WS_OP_&&this.ws_,h)var n=Date.now();if(this.ws_&&Us&&!A&&!T){this.pair.encrypted.t0&&(ca++,la+=this.stream_tor_.length,ha+=Date.now()-this.pair.encrypted.t0,0===ca%ua&&ha&&(console.log("wsdecode perf (pass to encrypted): "+parseInt(8*la/(ha/1e3))+" bps"),ca=0,la=0,ha=0)),this.pair.encrypted.write(this.stream_tor_),this.stream_tor_=new t(0);var s=this.queue_;s.shift(),s.length&&s[0]()}else this.stream_tor_.parse(this);n&&(ea++,ta+=e.length,ra+=Date.now()-n,0===ea%ia&&ra&&(this.OR_?this.address()&&ka&&this.address().port===kn&&this.OR_f&&console.log("Parser perf (ORDB):"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length):console.log("Parser perf:"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length),ea=0,ta=0,ra=0))}},Qo=function(e){this.queue_=this.queue_||[],this.queue_.push(Wo(e).bind(this)),1===this.queue_.length&&this.queue_[0]()},Xo=function(){delete this.end_,delete this.html_,delete this.header_,delete this.header_l,delete this.content_,delete this.content_l,delete this.clength_,delete this.encoding_,delete this.pass_,delete this.t0_,delete this.script_,delete this.header_sent,delete this.decoder_,delete this.f_,delete this.wait_,delete this.buff_,this.nb_try=0,delete this.time_resp},Jo=function(e){var r={};Xo.call(r),r.params_={},r.params_.OP=!0,r.params_.nb_hop=Hn,r.params_.one_c=!0,r.nb_try=0,r.no_exit=[],r.squeue_=[],r.wsqueue_=[],r._date_=Date.now(),r.i_id=qa,qa++,e=ho(e),r.params_.host=e.host;var i="GET /"+e.rest+" HTTP/1.1\r\n";return i+="Host: "+e.host+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",r.params_.stream=new t(i,"utf8"),r.remotePort="60000",r.remoteAddress="1.2.3.4",r.write=function(){},r.end=function(){},r.destroy=function(){},r.close=function(){},r._init_=Xo,r._write_=r.write,r},Zo=function(e){gn[e.server_.ip]=this,this[e.circId]=e,this.stream_tor_=new t(0);var r=new Po(e.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));e.send(r)},$o=function(e,r){r.socket_=e,e.first_=r,e.server_=r.server_,e.nbc_=0,Js&&e===El&&(e.buff_w=Os?new Mc.util.ByteBuffer:new t(0),e.abstract_client_tls=cl(e,"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net"),e.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),clearInterval(en),Al(e),e.destroy(),Dc()},e.abstract_client_tls.error=function(t,r){-1===r.message.indexOf("MAC")?(console.log(" Error TLS client disconnected "+r.message),clearInterval(en),Al(e),e.destroy(),Dc()):console.log("bad MAC")},e.write=function(t){Os?e.buff_w.putBytes(t.toString("binary")):e.buff_w=e.buff_w.length?[e.buff_w,t].concatBuffers():t},e.abstract_client_tls.connected=function(){console.log("TLS client connected"),en=setInterval(xc,1e4),e.tls_connected=!0,e.write=function(t){Os?e.abstract_client_tls.prepare(t.data?t.getBytes():t.toString("binary")):e.abstract_client_tls.prepare(sl(t.toString("hex")))},e.write(e.buff_w)},e.write_c=function(r){r.length&&(Os?e.send(new t(r,"binary")):e.send(r))},e.abstract_client_tls.dataReady=function(r){if(Os){if(r.data.length()){var i=new t(r.data.getBytes(),"binary");e.t0&&(Bh++,kh+=i.length,Rh+=Date.now()-e.t0,0===Bh%Uh&&Rh&&(console.log("TLS perf (dataReady): "+parseInt(8*kh/(Rh/1e3))+" bps"),Bh=0,kh=0,Rh=0)),Qo.call(e,i)}}else{var i=r.data.data.slice(r.data.read,r.data.length_);r.data.read=r.data.length_,console.log(i.length),i.length&&Qo.call(e,i)}},e.wsconnected_&&(console.log("start TLS handshake "),delete e.abstract_client_tls.handshaking,e.abstract_client_tls.handshake()))},ec=function(e){e.OR_=!0,e.OR_f=!0,e.way_="socket in",e.privkey_=Xs,e.stream_tor_=new t(0);var r=new Fo;r.remote_=e.remoteAddress,r.OR_=!0,r.OR_f=!0,r.circId=0,r.socket_=e,r.way_="socket in",e[0]=r},tc=function(e){var t="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",r="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",i={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,t,r),servername:t,rejectUnauthorized:!1};console.log("OUTGOING SOCKET : ---------start initial socket------------"+i.servername+" "+e.server_.ip+" "+e.server_.port);var n=tn.connect(e.server_.port,e.server_.ip,i,function(){clearTimeout(c),Zo.call(this,e)});n.on("data",Qo);var s=function(){n.nbc_>1?Go(tc):(clearTimeout(c),e.destroy_?Go(tc):e.last_?Go(tc):(e.clear_t0_(),delete e.ok_,delete gn[e.server_.ip],e.circuit_retry()))};n.on("end",s),n.on("close",s),n.on("error",function(){clearTimeout(c),e.destroy_=!0,n.destroy(),e.last_||e.change_or("initial socket error")});var a=function(){e.destroy_=!0,n.destroy(),e.change_or("initial socket failed")};$o(n,e);var c=setTimeout(a,2e3)},rc=function(e,t){var r=e.params_;if(e.time_ini=Date.now(),r)if(r.OP)if(r.one_c)if(t)if(Yo(e,!0)===!0)Ko(e);else{var i;if(!ks||e.params_.ws){if(i=Yo(e),t)for(var n=5;t===i&&0!==n;)i=Yo(e),n--}else for(i=Cs;i===Cs;)i=Yo(e);i?i.process(e):Ko(e)}else{var i;if(e.cid_&&e.cid_.bad_&&(delete e.tls_client_connected,delete e.abstract_client_tls,e.cid_.destroy_cid(e)),!ks&&!Us||e.params_.ws||e.params_.db_)i=e.cid_?e.cid_:r.one_c?Yo(e):null;else for(i=e.cid_?e.cid_:Cs;i===Cs||i===Ss;)i=Yo(e);i?(console.log("choose circuit "+i.circId+" for request "+e.i_id),i[e.sid_]?i.last_?i.last_.stream_handle_connected(e.sid_):(i.destroy_cid(e),rc(e)):i.process(e)):(console.log("no circuits"),0===mn.length?Ko(e):mn.push(e))}else Ko(e);else{var s="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",c=new Date,l=parseInt(No(8).toString("hex"),16),h=al(o+"pub-key.pem",o+"priv-key.pem","pem",l,c,s,a),u={key:Ri.readFileSync(o+"priv-key.pem"),cert:h,servername:s,requestCert:!0},d=tn.createServer(u,function(e){var t=e.remoteAddress,r=e.remotePort;ec(e),e.on("data",Qo),e.on("error",function(e){console.log("OR socket error"),console.log(e),delete wn[t+":"+r]}),e.on("end",function(){delete wn[t+":"+r]}),e.on("close",function(){delete wn[t+":"+r]}),e.cert_issuer=a,e.cert_subject=s,e.cert_date=c,e.certid_=l,wn[t+":"+r]=e});d.listen(r.port,function(){console.log("OR : server launched port "+r.port),Us&&setInterval(Uc,xs)}),d.on("OR : clientError",function(e){console.log(e)}),d.on("error",function(e){console.log(e)}),d.on("end",function(e){console.log(e)})}},ic=function(e){try{var t={},r=0;return e=e.split("\r\n"),e.forEach(function(e,i){if(e=e.split(":"),e.length>1&&0!=i){var n=e[0];e=e.map(function(e){return e.trim()}),e.shift(),e=e.join(":"),t[n]=e}else t[r+"a"]=e.join(":"),r++}),t}catch(i){console.log("caller"),console.log(ic.caller.toString().substr(0,50))}},nc=function(e){var t=[],r=0;for(var i in e)isNaN(i.substr(0,1))?t.push(i+": "+e[i]):e[i]?t.push(e[i]):r++;for(var n=0;r>n;n++)t.push("");return t.join("\r\n")},sc=function(e){e.start_&&(e.write(e.start_),delete e.start_)},ac=function(e,t,r){var i=/(((\b(https?|ftp|file):\/\/)|\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,n=!1,s=function(i){var s=e.split(i);if(""===s[s.length-1]&&!r)return n=!0,void 0;var a=e;i=ho(i);var o=t.fake_domain,c=bs[o],l=c.real_domain_s;if(i.host)if(-1!==i.host.indexOf(l)){var h=i.host.split("."),u=c.real_domain_a;a=i.host===c.real_domain?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):2===h.length&&"www"===u[0]||2===u.length&&"www"===h[0]?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):"http"+Ds+"://"+o+"/"+fo(uo(i),!0)}else-1===i.host.indexOf(o)&&(a="http"+Ds+"://"+o+"/"+fo(uo(i),!0));return a},a=e.replace(i,s);return n&&(t.pass_+=e),{html:n?e:a,pass:n}},oc=function(e){var t="";return t="",[t,e].join("")},cc=function(e,r){var i=e.toString("hex").split(gs),n=n||[],s=[];return i.forEach(function(e,a){if(r.wait_){var o=parseInt(new t(e,"hex").toString("utf8"),16);return 0===o&&(r.end_=!0,n.push("0d0a300d0a0d0a")),r.clength_+=o?o:0,e.length?a!==i.length-1&&(r.wait_=!1):0===a&&(r.wait_=!1),void 0}var c=r.clength_,l=r.html_.length,h=new t(e,"hex").length+2;(c>=l+h||l+h-2===c)&&s.push(e),l+h-2===c||a===i.length-1?(s=s.join(gs),n.push(s),r.html_.length+=h-2,a!==i.length-1&&(r.wait_=!0),s=[]):r.html_.length+=h}),new t(n.join(""),"hex")},lc=function(e){if(!(e instanceof Uint8Array)){var r=new t(e.length);r.map(e),e=r}return e},hc=function(e){console.log("destroy ws cid"),e.remoteAddress&&e.remotePort?delete wn[e.remoteAddress+":"+e.remotePort]:Rc()},uc=function(e,r){var i=e["Sec-WebSocket-Key"],n=sn.createhash("sha1");n.update(i+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64");var a="HTTP/1.1 101 WebSocket Protocol Handshake\r\n";a+="Upgrade: websocket\r\n",a+="Connection: Upgrade\r\n",a+="Sec-WebSocket-Accept:"+s+"\r\n",a+="Access-Control-Allow-Origin:"+e.Origin+"\r\n",a+="\r\n",console.log("INCOMING SOCKET :"+a),r.ws_=!0,ec(r),r.connected_=!0,r.wsconnected_=!0,r.write(a)},dc=function(e){this.key_=sn.randomBytes(16).toString("base64");var t="GET / HTTP/1.1\r\n";return t+="Host: "+e.ip+(js?":"+e.wsport:"")+"\r\n",t+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",t+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",t+="Accept-Language: en-us,en;q=0.5\r\n",t+="Accept-Encoding: gzip, deflate\r\n",t+="Connection: keep-alive, Upgrade\r\n",t+="Sec-WebSocket-Version: 13\r\n",t+="Origin: http://ianonym.com\r\n",t+="Sec-WebSocket-Key: "+this.key_+"\r\n",t+="Pragma: no-cache\r\n",t+="Cache-Control: no-cache\r\n",t+="Upgrade: websocket\r\n",t+="\r\n"},fc=0,pc=0,_c=0,gc=100,mc=0,yc=0,vc=0,bc=100,wc=function(e){d&&(Ho=Date.now()),f&&(Mo=Date.now()),console.log("start websocket");var t=T?new ja("ws://"+e.ip+":"+e.wsport):new WebSocket("ws://"+e.ip+":"+e.wsport);return T||(t.write=t.send),t.binaryType="arraybuffer",t.setNoDelay=function(){},t.connect=function(){},t.WS_OP_=!0,t.onopen=Cc,t.onmessage=function(e){var r=e.data instanceof ArrayBuffer?new Uint8Array(e.data):e.data;Ho&&(fc++,pc+=r.length,_c+=Date.now()-Ho,0===fc%gc&&_c&&(console.log("WS perf (received from WS before processing): "+parseInt(8*pc/(_c/1e3))+" bps - Buffered : "+t.bufferedAmount),fc=0,pc=0,_c=0)),(d||p)&&(Ho=Date.now()),Js&&t===El?(g&&(t.t0=Date.now()),jo&&0!==Ho-jo&&console.log("WS delay between processed and next received: "+(Ho-jo)+" data length "+r.length),Os?t.abstract_client_tls.process(r.toString("binary")):t.abstract_client_tls.process(r),p&&(jo=Date.now()),Mo&&(mc++,yc+=r.length,vc+=Date.now()-Mo,0===mc%bc&&vc&&(console.log("WS perf (received from WS after processed): "+parseInt(8*yc/(vc/1e3))+" bps - Buffered : "+t.bufferedAmount),mc=0,yc=0,vc=0)),f&&(Mo=Date.now())):Qo.call(this,r)},t.onclose=function(){console.log("Websocket closed ws://"+e.ip+":"+e.wsport)},T||(t.destroy=t.close,t.bufferSize=t.bufferedAmount),t.remoteAddress=e.ip,t.remotePort=Dn,t.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},t.setKeepAlive=function(){},t},Ec=function(e){var r=ic(e.toString("utf8")),i=r["Sec-WebSocket-Accept"];if(i){var n=sn.createhash("sha1");n.update(this.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64"),i===s&&(console.log("WS Client says : Handshake successfull"),Cc.call(this))}},Cc=function(){console.log("websocket connected");try{Kl.innerHTML="

Websocket connected

"}catch(e){}this.connected_=!0,this.wsconnected_=!0,this.ws_=!0,Us&&(this===Cl&&$i&&rc({params_:{OP:!0,nb_hop:Hn,ws:this}}),!Js||this!==El||!Cs&&$i||(console.log("launch db_cid"),this.db_cid_launched=!0,rc({params_:{OP:!0,nb_hop:Mn,ws:this,db:!0}})),Js||setInterval(xc,1e4))},Sc=function(e,r){r=r||[];var i,n=e.length,s=0,a=0,n=e.length,o=new t(0),c=new t(0);if(0===e.length)return[o,c];var l=e[0];if(e.length>1){var h=128&e[1],u=127&e[1];if(126===u?(s=e.slice(2,4).readUInt(),h=h&&e.slice(4,8),a=h?8:4):127===u?(s=parseInt(e.slice(2,10).toString("hex"),16),h=h&&e.slice(10,14),a=h?14:10):(s=u,h=h&&e.slice(2,6),a=h?6:2),o=e.slice(a,a+s),i=o.length,h&&o.length===s&&0!=s)for(var d=0;i>d;d++)o[d]=o[d]^h[d%4]}return o.length!==s||0===s?(i=o.length,a=n,c=e):r.push(o),n-a>i?Sc(e.slice(i+a),r):1&l?[r.concatBuffers().toString("utf8"),c.toString("utf8")]:2&l?[r.concatBuffers(),c]:void 0},Ac=function(e,r,i){var n,s,a,o=e.length;i=i?sn.randomBytes(4):i;var c=1===r?"81":"82";if(126>o?(s=(i?128|o:o).toString(16),s=1===s.length?"0"+s:s):o>=126&&65535>=o?(c+=i?"FE":"7E",a=2):(c+=i?"FF":"7F",a=8),!s)for(s=o.toString(16),s=s.length%2?"0"+s:s;s.length!==2*a;)s="00"+s;if(c+=s,n=new t(c,"hex"),i)for(var l=e.length,h=new t(l),u=0;l>u;u++)h[u]=e[u]^i[u%4];else h=e;return i?[n,i,h].concatBuffers():[n,h].concatBuffers()},Ic=function(e,r){for(var i=e.remoteAddress+":"+e.remotePort+":"+e.port_+":"+e.i_id,n=e.fake_,s=new t(new t(i,"utf8").toString("hex"),"hex"),a=s.length.toString(16);4!==a.length;)a="0"+a;for(s=[new t(a,"hex"),s].concatBuffers(),a=s.toString("hex");r.length;){var o;o=r.length+a>_n?r.slice(0,_n-a):r,o=[s,o].concatBuffers();var c=new qo(qo.prototype.RELAY_WS,0,o,n.Db_hash).toBuffer();c=new t(n.Kb_cipher.update(c,"hex","hex"),"hex");var l=new Po(n.circId,Po.prototype.RELAY_WS,c); if(n.send(l),!(r.length+a>_n))break;r=r.slice(_n-a)}},Tc=function(e){e.i_id=Wn,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),Wn++,as.push(e.i_id),console.log("INCOMING SOCKET : ------------------------------------- new incoming socket ----------------------------------------------- request "+e.i_id+" on port "+e.remotePort);var r=function(r){var i=r.split(":::");if(3!==i.length){var n={},s=ic(r);if(n.OP=!0,n.nb_hop=Hn,n.one_c=!0,-1!=r.indexOf("WebSocket")){if(console.log("Answer websocket"),uc(s,e),Us){var a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",l=new Date,h=parseInt(No(8).toString("hex"),16),u=al(o+"pub-key.pem",o+"priv-key.pem","pem",h,l,a,c),d=sn.createCredentials({key:Ri.readFileSync(o+"priv-key.pem"),cert:u,servername:a}),f=new tn.createSecurePair(d,!0);e.pair=f;var p=f.cleartext;p.tlspair_=!0,p.server=e.server,p.i_id=e.i_id,p.nb_try=e.nb_try,p.no_exit=e.no_exit,p.squeue_=e.squeue_,p.wsqueue_=e.wsqueue_,p._date_=e._date_,p._init_=e._init_,p.OR_=e.OR_,p.OR_f=e.OR_f,p.way_=e.way_,p.privkey_=e.privkey_,p.connected_=e.connected_,p.wsconnected_=e.wsconnected_,p.address=function(){return{port:e.address().port,family:"IPv4",address:e.address().address}},p.__defineGetter__("remoteAddress",function(){return e.remoteAddress}),p.__defineGetter__("remotePort",function(){return e.remotePort}),p.stream_tor_=new t(0),p.cert_issuer=c,p.cert_subject=a,p.cert_date=l,p.certid_=h,e.write=function(t){e._write(Ac(t,2,!1),null,function(){})},wn[e.remoteAddress+":"+e.remotePort]=p,f.encrypted.pipe(e),p.on("data",function(e){p.t0&&(na++,sa+=e.length,aa+=Date.now()-p.t0,0===na%oa&&aa&&(console.log("cleartext perf: "+parseInt(8*sa/(aa/1e3))+" bps"),na=0,sa=0,aa=0)),Qo.call(p,e)}),p.on("end",function(){e.end()}),p.on("error",function(){e.end()})}return!1}return-1!=r.indexOf("HTTP")&&s.Host&&(n.host=s.Host+":80",e.connected_=!0),n.stream=new t(new t(r,"utf8").toString("hex"),"hex"),5===n.stream.slice(0,1).readUInt()?(e.socks_=!0,e.connected_=!0,e.write(new t("0500","hex")),!1):n}e.params_={host:i[0],OP:!0,nb_hop:i[1],stream:new t(new t(i[2],"utf8").toString("hex"),"hex"),one_c:i[3]},rc(e)};e.on("data",function(i){e.ws_||console.log("INCOMING SOCKET :------------- RECEIVED FROM INCOMING SOCKET ------------ "+e.i_id+" on port "+e.remotePort+" "+e.remoteAddress+" "+e.address().port);var n;if(e.connected_){if(n={},n.OP=!0,n.nb_hop=Hn,n.one_c=!0,n.host=e.host_?e.host_:!1,e.params_?e.params_.host=n.host:e.params_=n,n.stream=n.host?i:!1,n.stream)if(e.fake_){var s=function(e){return function(){Ic(this,e)}};e.wsqueue_.push(s(i).bind(e))}else{var s=function(t){return function(){this.params_.stream=t,rc(e)}};e.squeue_.push(s(i).bind(e))}if(e.ws_)return e.wsconnected_?(e.pair&&(u&&(e.pair.cleartext.t0=Date.now()),_&&(e.pair.encrypted.t0=Date.now())),Qo.call(this,i),void 0):(console.log("server ws not connected"),uc(ic(i.toString("utf8")),e),void 0);if(e.socks_&&!n.stream){switch(i.slice(3,4).readUInt()){case 1:e.host_=Lo(i.slice(4,8))+":"+i.slice(8).readUInt();break;case 3:var o=i.slice(4,5).readUInt();if(!Rs){e.host_=i.slice(5,5+o).toString("utf8")+":"+i.slice(o+5).readUInt();break}if(!e.ws_){var c=En[i.slice(5,5+o).toString("utf8")];if(c){var l=e.remoteAddress+":"+e.remotePort;Cn[l]=e,e.fake_=c.circ_,e.port_=i.slice(o+5).readUInt(),e.host_=i.slice(5,5+o).toString("utf8");break}e.host_=i.slice(5,5+o).toString("utf8")+":"+i.slice(o+5).readUInt(),console.log("outside domain "+e.host_+" request "+e.i_id),e.__outside__=!0;break}default:return}if(e.host_===Rn+":"+Dn&&(e.ws_=!0,e.setNoDelay(!0)),n.host=e.host_,console.log("INCOMING SOCKET : socks request "+e.i_id+" host "+e.host_+" remote "+e.remoteAddress+":"+e.remotePort),a&&C){var h=["www.lepoint.fr:80","212.95.70.230:80","www.monip.org:80","217.70.182.162:80"];if(e.__connect__=h,443===parseInt(e.host_.split(":")[1]))return e.write([new t("050200","hex"),i.slice(3)].concatBuffers()),void 0}return e.start_=[new t("050000","hex"),i.slice(3)].concatBuffers(),sc(e),void 0}}else n=r(i.toString("utf8"));if(n&&n.stream)if(e.fake_){var d=e.wsqueue_[0];e.wsqueue_.shift(),d()}else{if(Rs&&e.__outside__)return e.write(new t(ao(),"utf8")),void 0;if(a&&C){var f=ic(n.stream.toString("utf8"));if(f.Host=f.Host||"",-1===["www.lepoint.fr","www.monip.org"].indexOf(f.Host)||-1===e.__connect__.indexOf(e.host_))return e.write(new t(co(),"utf8")),void 0}e._data_=!1,1===e.squeue_.length&&e.squeue_[0]()}}),e.on("end",function(){console.log("INCOMING SOCKET : End -------------------------end incoming socket------------------------------------- request "+e.i_id+" host "+e.host_),Bc(),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("close",function(){console.log("INCOMING SOCKET : Close -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("error",function(){console.log("INCOMING SOCKET : Error -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e._write_=function(t){if(!e.destroyed)try{e.write(t)}catch(r){}},e._init_=Xo},xc=function(){var e=[],t=[],i=0,n=0,s=!1,o=(new Date).valueOf();for(var c in gn)e.push([c,gn[c]]);var l=0;e.forEach(function(e){Object.keys(e[1]).forEach(function(r){if(!isNaN(r)&&null!=r){var s=e[1][r],a=s.last_?s.last_:null;if(a)if(Object.keys(s).forEach(function(e){isNaN(e)||null==e||t.push(s[e].i_id+" "+s[e].remotePort)}),Jn>i&&(o-s.time_Qn||s.time_average=0&&(!s.bad_||s.time_averagens&&!zi){var c;for(var r in s)if(!isNaN(r)&&null!=r&&"function"!=typeof r){c=!0;break}c?(console.log("download in progres, not changing DB CID ----------"),s.time_=Date.now()):(console.log("monitor UPDATE DB CID ---------"+s.circId),s.circuit_destroy())}if(Us&&s.last_){var h=s.last_;h.server_&&s!==Ss&&h.server_.ip===Fi&&h.server_.port===qi&&(console.log("destroying ordb last CIC "+s.circId),s.circuit_destroy())}}else if(s.bad_){var c;for(var r in s)if(!isNaN(r)&&null!=r){c=!0;break}c||(console.log("monitor DESTROY "+s.circId),s.circuit_destroy())}else s.bad_=!0}})});var h=[];as.forEach(function(e){-1===os.indexOf(e)&&h.push(e)}),Qn=i,ys=n?l/n:ys,(r||a)&&Li("MONITOR ---- "+i+" circuits on "+$n+" TIME_AVERAGE "+ys),es=i>=$n&&!s?!Us||Ss?!0:!1:!1,!es&&Zi&&(E||(js||zs?El&&(console.log("establish new circuit"),ks||Ss?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):(El.tls_connected||delete El.db_cid_launched,console.log("monitor create db circuit"),rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}))):rc({params_:{OP:!0,nb_hop:Hn}}))),Us&&Dc()},Bc=function(){var e=[];for(var t in bn)e.push([t,bn[t]]);console.log("----------------- "+e.length+" sockets out----------------"),e.forEach(function(e){Object.keys(e[1]).forEach(function(t){isNaN(t)||null==t||e[1][t]})}),console.log("-----------------")},kc=function(){var e=[];for(var t in bn)e.push([t,bn[t]]);e.forEach(function(e){var t;Object.keys(e[1]).forEach(function(r){if(!isNaN(r)&&null!=r&&"function"!=typeof r){var i,n=e[1][r];n&&n.prev_&&n.prev_.socket_&&n.prev_.socket_.remoteAddress&&(i=!0,t=!0),i||n&&(console.log("clearing circuit out n "+r+" CIC "+n.circId),n.circuit_destroy(),delete e[1][r])}}),t||(console.log("delete OR_sock "+e[0]),delete bn[e[0]])})},Rc=function(){for(var e in wn){var t=wn[e];t?t.remoteAddress||(console.log("deleting or_sock_in remoteadd "+e),delete wn[e]):(console.log("deleting or_sock_in "+e),delete wn[e])}kc()},Uc=function(){for(var e in wn)parseInt(wn[e].address().port)===parseInt(qi)&&Object.keys(wn[e]).forEach(function(r){if(!isNaN(r)&&null!=r)try{var i=wn[e][r];i.db_test&&i.db_test.forEach(function(e){clearTimeout(e)}),i.db_test=[];var n=function(){i.destroyed_||(console.log("Destroying db_query_no_answer CID "+i.circId+" remote "+(i.socket_?i.socket_.remoteAddress:"null")),i.circuit_destroy(),i.destroyed_=!0)};if(0!==i.circId)if(i.socket_&&!i.destroyed_){var s;for(var a in i)if(!isNaN(a)&&null!=a&&(Tn[i.socket_.remotePort+"-"+i.socket_.remoteAddress+"-"+i.circId+"-"+a]||xn[i.socket_.remotePort+"-"+i.socket_.remoteAddress+"-"+i.circId+"-"+a])){s=!0;break}if(s)console.log("Download in progress - Not testing CID "+i.circId+" remote "+i.socket_.remoteAddress+" "+Date.now());else{console.log("Testing CID "+i.circId+" remote "+i.socket_.remoteAddress+" "+Date.now());var o=No(16),c={d_length:0,hash_:new t("0000000000000000000000000000000000000000","hex")};i.send_db_query(c,o),i.db_test.push(setTimeout(n,Ts))}}else n()}catch(l){}})},Dc=function(){if(Eh){var e=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="P2P (Peersm, BitTorrent) and web anonymized circuits : "+e+(e>1?" circuits":" circuit")}};if(A||Ms){var Nc=-1,Lc=-1;L.prototype=Error.prototype;var Oc=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"utf-8"}],heading:"The Encoding"},{encodings:[{labels:["cp864","ibm864"],name:"ibm864"},{labels:["cp866","ibm866"],name:"ibm866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso_8859-2","l2","latin2"],name:"iso-8859-2"},{labels:["csisolatin3","iso-8859-3","iso_8859-3","iso-ir-109","l3","latin3"],name:"iso-8859-3"},{labels:["csisolatin4","iso-8859-4","iso_8859-4","iso-ir-110","l4","latin4"],name:"iso-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso_8859-5","iso-ir-144"],name:"iso-8859-5"},{labels:["arabic","csisolatinarabic","ecma-114","iso-8859-6","iso_8859-6","iso-ir-127"],name:"iso-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso_8859-7","iso-ir-126"],name:"iso-8859-7"},{labels:["csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-i","iso-ir-138","iso_8859-8","visual"],name:"iso-8859-8"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","l6","latin6"],name:"iso-8859-10"},{labels:["iso-8859-13"],name:"iso-8859-13"},{labels:["iso-8859-14","iso8859-14"],name:"iso-8859-14"},{labels:["iso-8859-15","iso_8859-15"],name:"iso-8859-15"},{labels:["iso-8859-16"],name:"iso-8859-16"},{labels:["koi8-r","koi8_r"],name:"koi8-r"},{labels:["koi8-u"],name:"koi8-u"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["iso-8859-11","tis-620","windows-874"],name:"windows-874"},{labels:["windows-1250","x-cp1250"],name:"windows-1250"},{labels:["windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ascii","ansi_x3.4-1968","csisolatin1","iso-8859-1","iso8859-1","iso_8859-1","l1","latin1","us-ascii","windows-1252"],name:"windows-1252"},{labels:["cp1253","windows-1253"],name:"windows-1253"},{labels:["csisolatin5","iso-8859-9","iso-ir-148","l5","latin5","windows-1254"],name:"windows-1254"},{labels:["cp1255","windows-1255"],name:"windows-1255"},{labels:["cp1256","windows-1256"],name:"windows-1256"},{labels:["windows-1257"],name:"windows-1257"},{labels:["cp1258","windows-1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gbk","gb_2312","gb_2312-80","iso-ir-58","x-gbk"],name:"gbk"},{labels:["gb18030"],name:"gb18030"},{labels:["hz-gb-2312"],name:"hz-gb-2312"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"euc-jp"},{labels:["csiso2022jp","iso-2022-jp"],name:"iso-2022-jp"},{labels:["csshiftjis","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"shift_jis"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"euc-kr"},{labels:["csiso2022kr","iso-2022-kr"],name:"iso-2022-kr"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["utf-16","utf-16le"],name:"utf-16"},{labels:["utf-16be"],name:"utf-16be"}],heading:"Legacy utf-16 encodings"}],Pc={},Fc={};Oc.forEach(function(e){e.encodings.forEach(function(e){Pc[e.name]=e,e.labels.forEach(function(t){Fc[t]=e})})});var qc={};Pc["utf-8"].getEncoder=function(e){return new V(e)},Pc["utf-8"].getDecoder=function(e){return new z(e)},function(){["ibm864","ibm866","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-10","iso-8859-13","iso-8859-14","iso-8859-15","iso-8859-16","koi8-r","koi8-u","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic"].forEach(function(e){var t=Pc[e],r=qc[e];t.getDecoder=function(e){return new K(r,e)},t.getEncoder=function(e){return new G(r,e)}})}(),Pc.gbk.getEncoder=function(e){return new W(!1,e)},Pc.gbk.getDecoder=function(e){return new Y(!1,e)},Pc.gb18030.getEncoder=function(e){return new W(!0,e)},Pc.gb18030.getDecoder=function(e){return new Y(!0,e)},Pc["hz-gb-2312"].getEncoder=function(e){return new X(e)},Pc["hz-gb-2312"].getDecoder=function(e){return new Q(e)},Pc.big5.getEncoder=function(e){return new Z(e)},Pc.big5.getDecoder=function(e){return new J(e)},Pc["euc-jp"].getEncoder=function(e){return new et(e)},Pc["euc-jp"].getDecoder=function(e){return new $(e)},Pc["iso-2022-jp"].getEncoder=function(e){return new rt(e)},Pc["iso-2022-jp"].getDecoder=function(e){return new tt(e)},Pc.shift_jis.getEncoder=function(e){return new nt(e)},Pc.shift_jis.getDecoder=function(e){return new it(e)},Pc["euc-kr"].getEncoder=function(e){return new at(e)},Pc["euc-kr"].getDecoder=function(e){return new st(e)},Pc["iso-2022-kr"].getEncoder=function(e){return new ct(e)},Pc["iso-2022-kr"].getDecoder=function(e){return new ot(e)},Pc["utf-16"].getEncoder=function(e){return new ht(!1,e)},Pc["utf-16"].getDecoder=function(e){return new lt(!1,e)},Pc["utf-16be"].getEncoder=function(e){return new ht(!0,e)},Pc["utf-16be"].getDecoder=function(e){return new lt(!0,e)};var Hc="utf-8";dt.prototype={encode:function(e,t){e=e?String(e):"",t=Object(t),this._streaming||(this._encoder=this._encoding.getEncoder(this._options)),this._streaming=Boolean(t.stream);for(var r=[],i=new U(r),n=new D(e);n.get()!==Lc;)this._encoder.encode(i,n);if(!this._streaming){var s;do s=this._encoder.encode(i,n);while(s!==Nc);this._encoder=null}return new Uint8Array(r)}},ft.prototype={decode:function(e,t){if(e&&!("buffer"in e&&"byteOffset"in e&&"byteLength"in e))throw new TypeError("Expected ArrayBufferView");e||(e=new Uint8Array(0)),t=Object(t),this._streaming||(this._decoder=this._encoding.getDecoder(this._options)),this._streaming=Boolean(t.stream);var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=new R(r);this._BOMseen||(this._BOMseen=!0,ut(this._encoding.name,i));for(var n,s=new N;i.get()!==Nc;)n=this._decoder.decode(i),null!==n&&n!==Lc&&s.emit(n);if(!this._streaming){do n=this._decoder.decode(i),null!==n&&n!==Lc&&s.emit(n);while(n!==Lc&&i.get()!=Nc);this._decoder=null}return s.string()}};var Mc={};!function(){var e=Mc,t=e.util=e.util||{};"undefined"!=typeof process&&process.nextTick?(t.nextTick=process.nextTick,t.setImmediate="function"==typeof setImmediate?setImmediate:t.nextTick):"function"==typeof setImmediate?(t.setImmediate=setImmediate,t.nextTick=function(e){return setImmediate(e)}):(t.setImmediate=function(e){setTimeout(e,0)},t.nextTick=t.setImmediate),t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.ByteBuffer=function(e){this.data=e||"",this.read=0},t.ByteBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteBuffer.prototype.putByte=function(e){return this.data+=String.fromCharCode(e),this},t.ByteBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this},t.ByteBuffer.prototype.putBytes=function(e){return this.data+=e,this},t.ByteBuffer.prototype.putString=function(e){return this.data+=t.encodeUtf8(e),this},t.ByteBuffer.prototype.putInt16=function(e){return this.data+=String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt24=function(e){return this.data+=String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt32=function(e){return this.data+=String.fromCharCode(255&e>>24)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt16Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8),this},t.ByteBuffer.prototype.putInt24Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e>>16),this},t.ByteBuffer.prototype.putInt32Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>24),this},t.ByteBuffer.prototype.putInt=function(e,t){do t-=8,this.data+=String.fromCharCode(255&e>>t);while(t>0);return this},t.ByteBuffer.prototype.putSignedInt=function(e,t){return 0>e&&(e+=2<0);return t},t.ByteBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},t.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteBuffer.prototype.bytes=function(e){return"undefined"==typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;tr&&(e+="0"),e+=r.toString(16)}return e},t.ByteBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},t.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,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,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];t.encode64=function(e,t){for(var i,n,s,a="",o="",c=0;c>2),a+=r.charAt((3&i)<<4|n>>4),isNaN(n)?a+="==":(a+=r.charAt((15&n)<<2|s>>6),a+=isNaN(s)?"=":r.charAt(63&s)),t&&a.length>t&&(o+=a.substr(0,t)+"\r\n",a=a.substr(t));return o+=a},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,s,a="",o=0;o>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==s&&(a+=String.fromCharCode((3&n)<<6|s)));return a},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.deflate=function(e,r,i){if(r=t.decode64(e.deflate(t.encode64(r)).rval),i){var n=2,s=r.charCodeAt(1);32&s&&(n=6),r=r.substring(n,r.length-4)}return r},t.inflate=function(e,r){var i=e.inflate(t.encode64(r)).rval;return null===i?null:t.decode64(i)};var n=function(e,r,i){if(!e)throw{message:"WebStorage not available."};var n;if(null===i?n=e.removeItem(r):(i=t.encode64(JSON.stringify(i)),n=e.setItem(r,i)),"undefined"!=typeof n&&n.rval!==!0)throw n.error},s=function(e,r){if(!e)throw{message:"WebStorage not available."};var i=e.getItem(r);if(e.init)if(null===i.rval){if(i.error)throw i.error;i=null}else i=i.rval;return null!==i&&(i=JSON.parse(t.decode64(i))),i},a=function(e,t,r,i){var a=s(e,t);null===a&&(a={}),a[r]=i,n(e,t,a)},o=function(e,t,r){var i=s(e,t);return null!==i&&(i=r in i?i[r]:null),i},c=function(e,t,r){var i=s(e,t);if(null!==i&&r in i){delete i[r];var a=!0;for(var o in i){a=!1;break}a&&(i=null),n(e,t,i)}},l=function(e,t){n(e,t,null)},h=function(e,t,r){var i=null;"undefined"==typeof r&&(r=["web","flash"]);var n,s=!1,a=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw{message:"Flash local storage not available."};i=e.apply(this,t),s="flash"===n}("web"===n||"both"===n)&&(t[0]=localStorage,i=e.apply(this,t),s=!0)}catch(c){a=c}if(s)break}if(!s)throw a;return i};t.setItem=function(e,t,r,i,n){h(a,arguments,n)},t.getItem=function(e,t,r,i){return h(o,arguments,i)},t.removeItem=function(e,t,r,i){h(c,arguments,i)},t.clearItems=function(e,t,r){h(l,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),i=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return i&&(i.fullHost=i.host,i.port?80!==i.port&&"http"===i.scheme?i.fullHost+=":"+i.port:443!==i.port&&"https"===i.scheme&&(i.fullHost+=":"+i.port):"http"===i.scheme?i.port=80:"https"===i.scheme&&(i.port=443),i.full=i.scheme+"://"+i.fullHost),i};var u=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),i=0;i0?(n=r[i].substring(0,a),s=r[i].substring(a+1)):(n=r[i],s=null),n in t||(t[n]=[]),n in Object.prototype||null===s||t[n].push(unescape(s))}return t};return"undefined"==typeof e?(null===u&&(u="undefined"==typeof window?{}:r(window.location.search.substring(1))),t=u):t=r(e),t},t.parseFragment=function(e){var r=e,i="",n=e.indexOf("?");n>0&&(r=e.substring(0,n),i=e.substring(n+1));var s=r.split("/");s.length>0&&""===s[0]&&s.shift();var a=""===i?{}:t.getQueryVariables(i);return{pathString:r,queryString:i,path:s,query:a}},t.makeRequest=function(e){var r=t.parseFragment(e),i={path:r.pathString,query:r.queryString,getPath:function(e){return"undefined"==typeof e?r.path:r.path[e]},getQuery:function(e,t){var i;return"undefined"==typeof e?i=r.query:(i=r.query[e],i&&"undefined"!=typeof t&&(i=i[t])),i},getQueryLast:function(e,t){var r,n=i.getQuery(e);return r=n?n[n.length-1]:t}};return i},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var i=jQuery.param(t||{});return r=r||"",e+(i.length>0?"?"+i:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var i=0,n=t.length;n>i;){var s=t[i++];if(i==n)e[s]=r;else{var a=s in e;(!a||a&&"object"!=typeof e[s]||a&&null===e[s])&&(e[s]={}),e=e[s]}}},t.getPath=function(e,t,r){for(var i=0,n=t.length,s=!0;s&&n>i&&"object"==typeof e&&null!==e;){var a=t[i++];s=a in e,s&&(e=e[a])}return s?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,i=t.length;i>r;){var n=t[r++];if(r==i)delete e[n];else{if(!(n in e)||"object"!=typeof e[n]||null===e[n])break;e=e[n]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,i=/%./g,n=0,s=[],a=0;t=i.exec(e);){r=e.substring(a,i.lastIndex-2),r.length>0&&s.push(r),a=i.lastIndex;var o=t[0][1];switch(o){case"s":case"o":n");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(a)),s.join("")},t.formatNumber=function(e,t,r,i){var n=e,s=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,o=void 0===i?".":i,c=0>n?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",h=l.length>3?l.length%3:0;return c+(h?l.substr(0,h)+o:"")+l.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?a+Math.abs(n-l).toFixed(s).slice(2):"")},t.formatSize=function(e){return e=e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(e=e.split("."),4!==e.length)return null;for(var r=t.createBuffer(),i=0;is;++s)if(e[s]&&0!==e[s].length){var a=t.hexToBytes(e[s]);a.length<2&&n.putByte(0),n.putBytes(a)}else n.fillWithByte(0,i),i=0;return n.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;ri[n].end-i[n].start&&(n=i.length-1)):i.push({start:c,end:c})}r.push(a)}if(i.length>0){var l=i[n];l.end-l.start>0&&(r.splice(l.start,l.end-l.start+1,""),0===l.start&&r.unshift(""),7===l.end&&r.push(""))}return r.join(":")}}(),Os||(Mc.util.ByteBuffer=function(){},Mc.util.createBuffer=function(e,r){var i=new Mc.util.ByteBuffer;return e?(i.data=new t(e,r||"binary"),i.length_=i.data.length):(i.data=new t(Ls),i.length_=0),i.read=0,i},Mc.util.ByteBuffer.prototype.length=function(){return this.length_-this.read},Mc.util.ByteBuffer.prototype.isEmpty=function(){return 0===this.length_-this.read},Mc.util.ByteBuffer.prototype.putByte=function(e){this.data.length>=this.length_+1?this.data.writeUInt(e,this.length_,1):this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array([e])].concatBuffers():new Uint8Array([e]),this.length_+=1},Mc.util.ByteBuffer.prototype.getByte=function(){return this.data[this.read++]},Mc.util.ByteBuffer.prototype.at=function(e){return this.data[this.read+e]},Mc.util.ByteBuffer.prototype.last=function(){return this.data[this.length_-1]},Mc.util.ByteBuffer.prototype.fillWithByte=function(e,t){if(this.data.length>=this.length_+t)for(var r=this.length_,i=0;t>i;i++)this.data[r+i]=e;else{for(var n=[],i=0;t>i;i++)n.push(e);this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array(n)].concatBuffers():new Uint8Array(n)}this.length_+=t},Mc.util.ByteBuffer.prototype.putBytes=function(e){var r;r="string"==typeof e?new t(e,"binary"):e;var i=r.length;this.data.length>=this.length_+i?this.data.set(r,this.length_):this.data=this.length_?[this.data.slice(0,this.length_),r].concatBuffers():r,this.length_+=i},Mc.util.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e).toString("binary"),this.read+=e):0===e?t="":(t=this.data.slice(this.read,this.length_).toString("binary"),this.clear()),t},Mc.util.ByteBuffer.prototype.putBuffer=function(e){this.data.length>=this.length_+e.length_?e.length_&&this.data.set(e.data.slice(0,e.length_),this.length_):this.data=this.length_?[this.data.slice(0,this.length_),e.data.slice(0,e.length_)].concatBuffers():e.data.slice(0,e.length_),this.length_+=e.length_,e.clear()},Mc.util.ByteBuffer.prototype.bytes=function(e){return e?this.data.slice(this.read,this.read+e).toString("binary"):this.data.slice(this.read,this.length_).toString("binary")},Mc.util.ByteBuffer.prototype.putInt16=function(e){this.data.length>=this.length_+2?this.data.writeUInt(e,this.length_,2):this.data=this.length_?[this.data.slice(0,this.length_),new t(2).writeUInt(e)].concatBuffers():new t(2).writeUInt(e),this.length_+=2},Mc.util.ByteBuffer.prototype.putInt24=function(e){this.data.length>=this.length_+3?this.data.writeUInt(e,this.length_,3):this.data=this.length_?[this.data.slice(0,this.length_),new t(3).writeUInt(e)].concatBuffers():new t(3).writeUInt(e),this.length_+=3},Mc.util.ByteBuffer.prototype.putInt32=function(e){this.data.length>=this.length_+4?this.data.writeUInt(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new t(4).writeUInt(e)].concatBuffers():new t(4).writeUInt(e),this.length_+=4},Mc.util.ByteBuffer.prototype.putInt32Le=function(e){this.data.length>=this.length_+4?this.data.writeUIntLE(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new t(4).writeUIntLE(e)].concatBuffers():new t(4).writeUIntLE(e),this.length_+=4},Mc.util.ByteBuffer.prototype.putInt=function(e,r){r/=8,this.data.length>=this.length_+r?this.data.writeUInt(e,this.length_,r):this.data=this.length_?[this.data.slice(0,this.length_),new t(r).writeUInt(e)].concatBuffers():new t(r).writeUInt(e),this.length_+=r},Mc.util.ByteBuffer.prototype.getInt16=function(){var e=this.data.readUInt(this.read,2);return this.read+=2,e},Mc.util.ByteBuffer.prototype.getInt24=function(){var e=this.data.readUInt(this.read,3);return this.read+=3,e},Mc.util.ByteBuffer.prototype.getInt32=function(){var e=this.data.readUInt(this.read,4);return this.read+=4,e},Mc.util.ByteBuffer.prototype.getInt32Le=function(){var e=this.data.readUIntLE(this.read,4); return this.read+=4,e},Mc.util.ByteBuffer.prototype.getInt=function(e){e/=8;var t=this.data.readUInt(this.read,e);return this.read+=e,t},Mc.util.ByteBuffer.prototype.compact=function(){if(this.length()){var e=this.data.slice(this.read,this.length_);this.data=new t(Math.max(Ls,e.length)),this.data.set(e),this.length_=e.length,this.read=0}else this.clear()},Mc.util.ByteBuffer.prototype.clear=function(){this.data=new t(Ls),this.length_=0,this.read=0},Mc.util.ByteBuffer.prototype.truncate=function(e){var r=Math.max(0,this.length()-e),i=this.data.slice(this.read,r);this.data=new t(Ls),this.data.length>i.length?this.data.set(i):this.data=i,this.length_=i.length,this.read=0},Mc.util.ByteBuffer.prototype.toHex=function(){return this.data.slice(0,this.length_).toString("hex")},Mc.util.ByteBuffer.prototype.toString=function(){return new t(this.data.slice(0,this.length_).toString("binary"),"utf8").toString("utf8")}),function(){var e=Mc.sha1=Mc.sha1||{};Mc.md=Mc.md||{},Mc.md.algorithms=Mc.md.algorithms||{},Mc.md.sha1=Mc.md.algorithms.sha1=e;var t=null,r=!1,i=function(){t=String.fromCharCode(128),t+=Mc.util.fillString(String.fromCharCode(0),64),r=!0},n=function(e,t,r){for(var i,n,s,a,o,c,l,h,u=r.length();u>=64;){for(n=e.h0,s=e.h1,a=e.h2,o=e.h3,c=e.h4,h=0;16>h;++h)i=r.getInt32(),t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;20>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;32>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;40>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;60>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s&a|o&(s^a),i=(n<<5|n>>>27)+l+c+2400959708+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;80>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+3395469782+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;e.h0+=n,e.h1+=s,e.h2+=a,e.h3+=o,e.h4+=c,u-=64}};e.create=function(){r||i();var e=null,s=Mc.util.createBuffer(),a=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};return o.start=function(){return o.messageLength=0,s=Mc.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o},o.start(),o.update=function(t,r){return"utf8"===r&&(t=Mc.util.encodeUtf8(t)),o.messageLength+=t.length,s.putBytes(t),n(e,a,s),(s.read>2048||0===s.length())&&s.compact(),o},o.digest=function(){var r=o.messageLength,i=Mc.util.createBuffer();i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(255&r>>>29),i.putInt32(4294967295&r<<3);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(c,a,i);var l=Mc.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l},o.digest2=function(){var r=o.messageLength,i=Mc.util.createBuffer(),c=Mc.util.createBuffer(s.data.slice(s.read)),l=a.slice(0);i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(255&r>>>29),i.putInt32(4294967295&r<<3);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(h,a,i);var u=Mc.util.createBuffer();return u.putInt32(h.h0),u.putInt32(h.h1),u.putInt32(h.h2),u.putInt32(h.h3),u.putInt32(h.h4),s=c,a=l,u},o},e.createhash=function(){var t=e.create(),r=t.update;return t.update=function(e){return r(e.toString("binary"))},t.digest=function(){return t.digest2().toHex()},t}}(),function(){var e=Mc;e.hmac={};var t=e.hmac;t.create=function(){var t=null,r=null,i=null,n=null,s={};return s.start=function(s,a){if(null!==s)if(s.constructor==String){if(s=s.toLowerCase(),!(s in e.md.algorithms))throw'Unknown hash algorithm "'+s+'"';r=e.md.algorithms[s].create()}else r=s;if(null===a)a=t;else{if(a.constructor==String)a=e.util.createBuffer(a);else if(a.constructor==Array){var o=a;a=e.util.createBuffer();for(var c=0;cr.blockLength&&(r.start(),r.update(a.bytes()),a=r.digest()),i=e.util.createBuffer(),n=e.util.createBuffer(),l=a.length();for(var c=0;l>c;++c){var o=a.at(c);i.putByte(54^o),n.putByte(92^o)}if(lc;++c)i.putByte(54),n.putByte(92);t=a,i=i.bytes(),n=n.bytes()}r.start(),r.update(i)},s.update=function(e){r.update(e)},s.getMac=function(){var e=r.digest().bytes();return r.start(),r.update(n),r.update(e),r.digest()},s.digest=s.getMac,s}}(),function(){var e,t,r,i,n,s=!1,a=4,o=function(){s=!0,r=[0,1,2,4,8,16,32,64,128,27,54];for(var a=new Array(256),o=0;128>o;++o)a[o]=o<<1,a[o+128]=283^o+128<<1;e=new Array(256),t=new Array(256),i=new Array(4),n=new Array(4);for(var o=0;4>o;++o)i[o]=new Array(256),n[o]=new Array(256);for(var c,l,h,u,d,f,p,_=0,g=0,o=0;256>o;++o){u=g^g<<1^g<<2^g<<3^g<<4,u=99^(u>>8^255&u),e[_]=u,t[u]=_,d=a[u],c=a[_],l=a[c],h=a[l],f=d<<24^u<<16^u<<8^(u^d),p=(c^l^h)<<24^(_^h)<<16^(_^l^h)<<8^(_^c^h);for(var m=0;4>m;++m)i[m][_]=f,n[m][u]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===_?_=g=1:(_=c^a[a[a[c^h]]],g^=a[a[g]])}},c=function(t,i){for(var s,o=t.slice(0),c=1,l=o.length,h=l+6+1,u=a*h,d=l;u>d;++d)s=o[d-1],0===d%l?(s=e[255&s>>>16]<<24^e[255&s>>>8]<<16^e[255&s]<<8^e[s>>>24]^r[c]<<24,c++):l>6&&4===d%l&&(s=e[s>>>24]<<24^e[255&s>>>16]<<16^e[255&s>>>8]<<8^e[255&s]),o[d]=o[d-l]^s;if(i){for(var f,p=n[0],_=n[1],g=n[2],m=n[3],y=o.slice(0),u=o.length,d=0,v=u-a;u>d;d+=a,v-=a)if(0===d||d===u-a)y[d]=o[v],y[d+1]=o[v+3],y[d+2]=o[v+2],y[d+3]=o[v+1];else for(var b=0;a>b;++b)f=o[v+b],y[d+(3&-b)]=p[e[f>>>24]]^_[e[255&f>>>16]]^g[e[255&f>>>8]]^m[e[255&f]];o=y}return o},l=function(r,s,a,o){var c,l,h,u,d,f=r.length/4-1;o?(c=n[0],l=n[1],h=n[2],u=n[3],d=t):(c=i[0],l=i[1],h=i[2],u=i[3],d=e);var p,_,g,m,y,v,b;p=s[0]^r[0],_=s[o?3:1]^r[1],g=s[2]^r[2],m=s[o?1:3]^r[3];for(var w=3,E=1;f>E;++E)y=c[p>>>24]^l[255&_>>>16]^h[255&g>>>8]^u[255&m]^r[++w],v=c[_>>>24]^l[255&g>>>16]^h[255&m>>>8]^u[255&p]^r[++w],b=c[g>>>24]^l[255&m>>>16]^h[255&p>>>8]^u[255&_]^r[++w],m=c[m>>>24]^l[255&p>>>16]^h[255&_>>>8]^u[255&g]^r[++w],p=y,_=v,g=b;a[0]=d[p>>>24]<<24^d[255&_>>>16]<<16^d[255&g>>>8]<<8^d[255&m]^r[++w],a[o?3:1]=d[_>>>24]<<24^d[255&g>>>16]<<16^d[255&m>>>8]<<8^d[255&p]^r[++w],a[2]=d[g>>>24]<<24^d[255&m>>>16]<<16^d[255&p>>>8]<<8^d[255&_]^r[++w],a[o?1:3]=d[m>>>24]<<24^d[255&p>>>16]<<16^d[255&_>>>8]<<8^d[255&g]^r[++w]},h=function(e,t,r,i,n){function h(){if(i)for(var e=0;a>e;++e)b[e]=y.getInt32();else for(var e=0;a>e;++e)b[e]=E[e]^y.getInt32();if(l(T,b,w,i),i){for(var e=0;a>e;++e)v.putInt32(E[e]^w[e]);E=b.slice(0)}else{for(var e=0;a>e;++e)v.putInt32(w[e]);E=w}}function u(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e){var t=b[e]^w[e];i||(b[e]=t),v.putInt32(t)}}function d(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e)v.putInt32(b[e]^w[e]),b[e]=w[e]}function f(){l(T,b,w,!1);for(var e=a-1;e>=0;--e){if(4294967295!==b[e]){++b[e];break}b[e]=0}for(var e=0;a>e;++e)v.putInt32(y.getInt32()^w[e])}var p=null;if(s||o(),n=(n||"CBC").toUpperCase(),"string"!=typeof e||16!==e.length&&24!==e.length&&32!==e.length){if(Mc.util.isArray(e)&&(16===e.length||24===e.length||32===e.length))for(var _=e,e=Mc.util.createBuffer(),g=0;g<_.length;++g)e.putByte(_[g])}else e=Mc.util.createBuffer(e);if(!Mc.util.isArray(e)){var _=e;e=[];var m=_.length();if(16===m||24===m||32===m){m>>>=2;for(var g=0;m>g;++g)e.push(_.getInt32())}}if(!Mc.util.isArray(e)||4!==e.length&&6!==e.length&&8!==e.length)return p;var y,v,b,w,E,C,S,A=-1!==["CFB","OFB","CTR"].indexOf(n),I="CBC"===n,T=c(e,i&&!A),x=a<<2;if(p={output:null},"CBC"===n)S=h;else if("CFB"===n)S=u;else if("OFB"===n)S=d;else{if("CTR"!==n)throw{message:'Unsupported block cipher mode of operation: "'+n+'"'};S=f}return p.update=function(e){for(C||y.putBuffer(e);y.length()>=x||y.length()>0&&C;)S()},p.update2=function(e){for(e&&e.length()&&(y.data=y.data.substr(y.read),y.read=0,y.putBuffer(e));y.length()>=x;)S();p.overflow&&v.getBytes(p.overflow);var t=y.length()%x;if(t){for(var r=Mc.util.createBuffer(y.data.slice(y.read)),i=b.slice(0);y.length()>0;)S();y=r,b=i,v.truncate(x-t)}else y.data="",y.read=0;p.overflow=t},p.finish=function(e){var t=!0,r=y.length()%x;if(!i)if(e)t=e(x,y,i);else if(I){var n=y.length()===x?x:x-y.length();y.fillWithByte(n,n)}if(t&&(C=!0,p.update()),i&&(I&&(t=0===r),t))if(e)t=e(x,v,i);else if(I){var s=v.length(),o=v.at(s-1);o>a<<2?t=!1:v.truncate(o)}return!I&&!e&&r>0&&v.truncate(x-r),t},p.start=function(e,t){if(null===e&&(e=E.slice(0)),"string"==typeof e&&16===e.length)e=Mc.util.createBuffer(e);else if(Mc.util.isArray(e)&&16===e.length)for(var r=e,e=Mc.util.createBuffer(),i=0;16>i;++i)e.putByte(r[i]);if(!Mc.util.isArray(e)){var r=e;e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32()}if(y=Mc.util.createBuffer(),v=t||Mc.util.createBuffer(),E=e.slice(0),b=new Array(a),w=new Array(a),C=!1,p.output=v,-1!==["CFB","OFB","CTR"].indexOf(n)){for(var i=0;a>i;++i)b[i]=E[i];E=null}},null!==t&&p.start(t,r),p};Mc.aes=Mc.aes||{},Mc.aes.startEncrypting=function(e,t,r,i){return h(e,t,r,!1,i)},Mc.aes.createEncryptionCipher=function(e,t){return h(e,null,null,!1,t)},Mc.aes.startDecrypting=function(e,t,r,i){return h(e,t,r,!0,i)},Mc.aes.createDecryptionCipher=function(e,t){return h(e,null,null,!0,t)},Mc.aes._expandKey=function(e,t){return s||o(),c(e,t)},Mc.aes._updateBlock=l,Mc.aes.createcipheriv=function(e,t,r){var i=e.split("-")[2],n=Mc.util.createBuffer();t=Mc.util.createBuffer(t.toString("binary")),r=Mc.util.createBuffer(r.toString("binary"));var s=Mc.aes.startEncrypting(t,r,n,i),a=s.update2;return s.update=function(e){var t;return e=e?Mc.util.createBuffer(e.toString("binary")):Mc.util.createBuffer(),a(e),t=n.toHex(),n.data="",n.read=0,t},s}}(),function(){var e=Mc;e.asn1={};var t=e.asn1;t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,t,r,i){return{tagClass:e,type:t,constructed:r,composed:r||i.constructor==Array,value:i}};var r=function(e){var t=e.getByte();if(128==t)return void 0;var r,i=128&t;return r=i?e.getInt((127&t)<<3):t};t.fromDer=function(i){if(i.constructor==String&&(i=e.util.createBuffer(i)),i.length()<2)throw{message:"Too few bytes to parse DER.",bytes:i.length()};var n=i.getByte(),s=192&n,a=31&n,o=r(i);if(i.length()1){var u=i.read,d=i.getByte();if(0===d){n=i.getByte();var f=192&n;if(f===t.Class.UNIVERSAL||f===t.Class.CONTEXT_SPECIFIC)try{var p=r(i);h=p===o-(i.read-u),h&&(++u,--o)}catch(_){}}i.read=u}if(h)if(c=[],void 0===o)for(;;){if(i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2);break}c.push(t.fromDer(i))}else for(var g=i.length();o>0;)c.push(t.fromDer(i)),o-=g-i.length(),g=i.length();else{if(void 0===o)throw{message:"Non-constructed ASN.1 object of indefinite length."};if(a===t.Type.BMPSTRING){c="";for(var m=0;o>m;m+=2)c+=String.fromCharCode(i.getInt16())}else c=i.getBytes(o)}return t.create(s,a,l,c)},t.toDer=function(r){var i=e.util.createBuffer(),n=r.tagClass|r.type,s=e.util.createBuffer();if(r.composed){r.constructed?n|=32:s.putByte(0);for(var a=0;a>>=8;while(o>0);i.putByte(128|c.length);for(var a=c.length-1;a>=0;--a)i.putByte(c.charCodeAt(a))}return i.putBuffer(s),i},t.oidToDer=function(t){var r=t.split("."),i=e.util.createBuffer();i.putByte(40*parseInt(r[0],10)+parseInt(r[1],10));for(var n,s,a,o,c=2;c>>=7,n||(o|=128),s.push(o),n=!1;while(a>0);for(var l=s.length-1;l>=0;--l)i.putByte(s[l])}return i},t.derToOid=function(t){var r;t.constructor==String&&(t=e.util.createBuffer(t));var i=t.getByte();r=Math.floor(i/40)+"."+i%40;for(var n=0;t.length()>0;)i=t.getByte(),n<<=7,128&i?n+=127&i:(r+="."+(n+i),n=0);return r},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),l=10;"+"!==c&&"-"!==c&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,0),l&&(c=e.charAt(l),"+"===c||"-"===c)){var h=parseInt(e.substr(l+1,2),10),u=parseInt(e.substr(l+4,2),10),d=60*h+u;d*=6e4,"+"===c?t.setTime(+t-d):t.setTime(+t+d)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),i=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,l=0,h=!1;"Z"==e.charAt(e.length-1)&&(h=!0);var u=e.length-5,d=e.charAt(u);if("+"===d||"-"===d){var f=parseInt(e.substr(u+1,2),10),p=parseInt(e.substr(u+4,2),10);l=60*f+p,l*=6e4,"+"===d&&(l*=-1),h=!0}return"."==e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),h?(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,c),t.setTime(+t+l)):(t.setFullYear(r,i,n),t.setHours(s,a,o,c)),t},t.dateToUtcTime=function(e){var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var i=0;i0&&(a+="\n");for(var o="",c=0;n*s>c;++c)o+=" ";switch(a+=o+"Tag: ",r.tagClass){case t.Class.UNIVERSAL:a+="Universal:";break;case t.Class.APPLICATION:a+="Application:";break;case t.Class.CONTEXT_SPECIFIC:a+="Context-Specific:";break;case t.Class.PRIVATE:a+="Private:"}if(r.tagClass===t.Class.UNIVERSAL)switch(a+=r.type,r.type){case t.Type.NONE:a+=" (None)";break;case t.Type.BOOLEAN:a+=" (Boolean)";break;case t.Type.BITSTRING:a+=" (Bit string)";break;case t.Type.INTEGER:a+=" (Integer)";break;case t.Type.OCTETSTRING:a+=" (Octet string)";break;case t.Type.NULL:a+=" (Null)";break;case t.Type.OID:a+=" (Object Identifier)";break;case t.Type.ODESC:a+=" (Object Descriptor)";break;case t.Type.EXTERNAL:a+=" (External or Instance of)";break;case t.Type.REAL:a+=" (Real)";break;case t.Type.ENUMERATED:a+=" (Enumerated)";break;case t.Type.EMBEDDED:a+=" (Embedded PDV)";break;case t.Type.UTF8:a+=" (UTF8)";break;case t.Type.ROID:a+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:a+=" (Sequence)";break;case t.Type.SET:a+=" (Set)";break;case t.Type.PRINTABLESTRING:a+=" (Printable String)";break;case t.Type.IA5String:a+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:a+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:a+=" (Generalized time)";break;case t.Type.BMPSTRING:a+=" (BMP String)"}else a+=r.type;if(a+="\n",a+=o+"Constructed: "+r.constructed+"\n",r.composed){a+=o+"Sub values: "+r.value.length;for(var c=0;c=Yc;++Yc)Qc[Gc++]=Yc;for(Gc="a".charCodeAt(0),Yc=10;36>Yc;++Yc)Qc[Gc++]=Yc;for(Gc="A".charCodeAt(0),Yc=10;36>Yc;++Yc)Qc[Gc++]=Yc;Mt.prototype.convert=jt,Mt.prototype.revert=zt,Mt.prototype.reduce=Vt,Mt.prototype.mulTo=Kt,Mt.prototype.sqrTo=Gt,Wt.prototype.convert=Qt,Wt.prototype.revert=Xt,Wt.prototype.reduce=Jt,Wt.prototype.mulTo=$t,Wt.prototype.sqrTo=Zt,pt.prototype.copyTo=wt,pt.prototype.fromInt=Et,pt.prototype.fromString=St,pt.prototype.clamp=At,pt.prototype.dlShiftTo=Ut,pt.prototype.drShiftTo=Dt,pt.prototype.lShiftTo=Nt,pt.prototype.rShiftTo=Lt,pt.prototype.subTo=Ot,pt.prototype.multiplyTo=Pt,pt.prototype.squareTo=Ft,pt.prototype.divRemTo=qt,pt.prototype.invDigit=Yt,pt.prototype.isEven=er,pt.prototype.exp=tr,pt.prototype.toString=It,pt.prototype.negate=Tt,pt.prototype.abs=xt,pt.prototype.compareTo=Bt,pt.prototype.bitLength=Rt,pt.prototype.mod=Ht,pt.prototype.modPowInt=rr,pt.ZERO=Ct(0),pt.ONE=Ct(1),ir.prototype.init=nr,ir.prototype.next=sr;var Xc,Jc,Zc,$c=256,Ba=Ba||window.navigator;if(null==Jc){Jc=new Array,Zc=0;var el;if("Netscape"==Ba.appName&&Ba.appVersion<"5"&&window.crypto){var tl=window.crypto.random(32);for(el=0;elZc;)el=Math.floor(65536*Math.random()),Jc[Zc++]=el>>>8,Jc[Zc++]=255⪙Zc=0,cr()}ur.prototype.nextBytes=hr,pr.prototype.doPublic=gr,pr.prototype.setPublic=_r,pr.prototype.encrypt=mr,ci.prototype.convert=li,ci.prototype.revert=li,ci.prototype.mulTo=hi,ci.prototype.sqrTo=ui,_i.prototype.convert=gi,_i.prototype.revert=mi,_i.prototype.reduce=yi,_i.prototype.mulTo=bi,_i.prototype.sqrTo=vi;var rl=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],il=(1<<26)/rl[rl.length-1];pt.prototype.chunkSize=Er,pt.prototype.toRadix=Sr,pt.prototype.fromRadix=Ar,pt.prototype.fromNumber=Ir,pt.prototype.bitwiseTo=Rr,pt.prototype.changeBit=Wr,pt.prototype.addTo=Zr,pt.prototype.dMultiply=ai,pt.prototype.dAddOffset=oi,pt.prototype.multiplyLowerTo=fi,pt.prototype.multiplyUpperTo=pi,pt.prototype.modInt=Ci,pt.prototype.millerRabin=Ii,pt.prototype.clone=yr,pt.prototype.intValue=vr,pt.prototype.byteValue=br,pt.prototype.shortValue=wr,pt.prototype.signum=Cr,pt.prototype.toByteArray=Tr,pt.prototype.equals=xr,pt.prototype.min=Br,pt.prototype.max=kr,pt.prototype.and=Dr,pt.prototype.or=Lr,pt.prototype.xor=Pr,pt.prototype.andNot=qr,pt.prototype.not=Hr,pt.prototype.shiftLeft=Mr,pt.prototype.shiftRight=jr,pt.prototype.getLowestSetBit=Vr,pt.prototype.bitCount=Gr,pt.prototype.testBit=Yr,pt.prototype.setBit=Qr,pt.prototype.clearBit=Xr,pt.prototype.flipBit=Jr,pt.prototype.add=$r,pt.prototype.subtract=ei,pt.prototype.multiply=ti,pt.prototype.divide=ii,pt.prototype.remainder=ni,pt.prototype.divideAndRemainder=si,pt.prototype.modPow=wi,pt.prototype.modInverse=Si,pt.prototype.pow=di,pt.prototype.gcd=Ei,pt.prototype.isProbablePrime=Ai,pt.prototype.square=ri,function(){var e=Mc;e.prng={};var t=e.prng;t.create=function(t){function r(){if(i.pools[0].messageLength<32){for(var t,r,n,s=32-i.pools[0].messageLength<<5,a="",o=Math.floor(65535*Math.random());a.length>16),r+=(32767&t)<<16,r+=t>>15,r=(2147483647&r)+(r>>31),o=4294967295&r;for(var c=0;3>c;++c)n=o>>>(c<<3),n^=Math.floor(255*Math.random()),a+=String.fromCharCode(255&n)}i.collect(a)}else{var l=e.md.sha1.create();l.update(i.pools[0].digest().getBytes()),i.pools[0].start();for(var h=1,c=1;32>c;++c)h=31==h?2147483648:h<<2,0===h%i.reseeds&&(l.update(i.pools[c].digest().getBytes()),i.pools[c].start());var u=l.digest().getBytes();l.start(),l.update(u);var d=l.digest().getBytes();i.key=i.plugin.formatKey(u),i.seed=i.plugin.formatSeed(d),++i.reseeds,i.generated=0,i.time=+new Date}}for(var i={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0},n=t.md,s=new Array(32),a=0;32>a;++a)s[a]=n.create();return i.pools=s,i.pool=0,i.generate=function(t){null===i.key&&r();for(var n=i.plugin.cipher,s=i.plugin.increment,a=i.plugin.formatKey,o=i.plugin.formatSeed,c=e.util.createBuffer();c.length()=1048576){var h=+new Date;h-i.time<100&&r()}}return c.getBytes(t)},i.collect=function(e){for(var t=e.length,n=0;t>n;++n)i.pools[i.pool].update(e.substr(n,1)),i.pool=31===i.pool?0:i.pool+1;if(i.pools[0].messageLength>=32){var s=+new Date;(null===i.time||s-i.time<100)&&r()}},i.collectInt=function(e,t){var r="";do t-=8,r+=String.fromCharCode(255&e>>t);while(t>0);i.collect(r)},i}}(),function(e){var t=Mc;t.random={};var r={},i=new Array(4),n=t.util.createBuffer();r.formatKey=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),t.aes._expandKey(e,!1)},r.formatSeed=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),e},r.cipher=function(e,r){return t.aes._updateBlock(e,r,i,!1),n.putInt32(i[0]),n.putInt32(i[1]),n.putInt32(i[2]),n.putInt32(i[3]),n.getBytes()},r.increment=function(e){return++e[3],e},r.md=t.md.sha1;var s=t.prng.create(r);if(s.collectInt(+new Date,32),"undefined"!=typeof Ba){var a="";for(var o in Ba)try{"string"==typeof Ba[o]&&(a+=Ba[o])}catch(c){}s.collect(a),a=null}e&&(e().mousemove(function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)}),e().keypress(function(e){s.collectInt(e.charCode,8)})),t.random.getBytes=function(e){return s.generate(e)}}("undefined"!=typeof jQuery?jQuery:null),function(){var e={},t=Mc;t.pki=t.pki||{},t.pki.oids=e,e["1.2.840.113549.1.1.1"]="rsaEncryption",e.rsaEncryption="1.2.840.113549.1.1.1",e["1.2.840.113549.1.1.4"]="md5withRSAEncryption",e.md5withRSAEncryption="1.2.840.113549.1.1.4",e["1.2.840.113549.1.1.5"]="sha1withRSAEncryption",e.sha1withRSAEncryption="1.2.840.113549.1.1.5",e["1.2.840.113549.1.1.7"]="RSAES-OAEP",e["RSAES-OAEP"]="1.2.840.113549.1.1.7",e["1.2.840.113549.1.1.8"]="mgf1",e.mgf1="1.2.840.113549.1.1.8",e["1.2.840.113549.1.1.9"]="pSpecified",e.pSpecified="1.2.840.113549.1.1.9",e["1.2.840.113549.1.1.10"]="RSASSA-PSS",e["RSASSA-PSS"]="1.2.840.113549.1.1.10",e["1.2.840.113549.1.1.11"]="sha256WithRSAEncryption",e.sha256WithRSAEncryption="1.2.840.113549.1.1.11",e["1.2.840.113549.1.1.12"]="sha384WithRSAEncryption",e.sha384WithRSAEncryption="1.2.840.113549.1.1.12",e["1.2.840.113549.1.1.13"]="sha512WithRSAEncryption",e.sha512WithRSAEncryption="1.2.840.113549.1.1.13",e["1.3.14.3.2.26"]="sha1",e.sha1="1.3.14.3.2.26",e["2.16.840.1.101.3.4.2.1"]="sha256",e.sha256="2.16.840.1.101.3.4.2.1",e["2.16.840.1.101.3.4.2.2"]="sha384",e.sha384="2.16.840.1.101.3.4.2.2",e["2.16.840.1.101.3.4.2.3"]="sha512",e.sha512="2.16.840.1.101.3.4.2.3",e["1.2.840.113549.2.5"]="md5",e.md5="1.2.840.113549.2.5",e["1.2.840.113549.1.7.1"]="data",e.data="1.2.840.113549.1.7.1",e["1.2.840.113549.1.7.2"]="signedData",e.signedData="1.2.840.113549.1.7.2",e["1.2.840.113549.1.7.3"]="envelopedData",e.envelopedData="1.2.840.113549.1.7.3",e["1.2.840.113549.1.7.4"]="signedAndEnvelopedData",e.signedAndEnvelopedData="1.2.840.113549.1.7.4",e["1.2.840.113549.1.7.5"]="digestedData",e.digestedData="1.2.840.113549.1.7.5",e["1.2.840.113549.1.7.6"]="encryptedData",e.encryptedData="1.2.840.113549.1.7.6",e["1.2.840.113549.1.9.20"]="friendlyName",e.friendlyName="1.2.840.113549.1.9.20",e["1.2.840.113549.1.9.21"]="localKeyId",e.localKeyId="1.2.840.113549.1.9.21",e["1.2.840.113549.1.9.22.1"]="x509Certificate",e.x509Certificate="1.2.840.113549.1.9.22.1",e["1.2.840.113549.1.12.10.1.1"]="keyBag",e.keyBag="1.2.840.113549.1.12.10.1.1",e["1.2.840.113549.1.12.10.1.2"]="pkcs8ShroudedKeyBag",e.pkcs8ShroudedKeyBag="1.2.840.113549.1.12.10.1.2",e["1.2.840.113549.1.12.10.1.3"]="certBag",e.certBag="1.2.840.113549.1.12.10.1.3",e["1.2.840.113549.1.12.10.1.4"]="crlBag",e.crlBag="1.2.840.113549.1.12.10.1.4",e["1.2.840.113549.1.12.10.1.5"]="secretBag",e.secretBag="1.2.840.113549.1.12.10.1.5",e["1.2.840.113549.1.12.10.1.6"]="safeContentsBag",e.safeContentsBag="1.2.840.113549.1.12.10.1.6",e["1.2.840.113549.1.5.13"]="pkcs5PBES2",e.pkcs5PBES2="1.2.840.113549.1.5.13",e["1.2.840.113549.1.5.12"]="pkcs5PBKDF2",e.pkcs5PBKDF2="1.2.840.113549.1.5.12",e["1.2.840.113549.1.12.1.1"]="pbeWithSHAAnd128BitRC4",e.pbeWithSHAAnd128BitRC4="1.2.840.113549.1.12.1.1",e["1.2.840.113549.1.12.1.2"]="pbeWithSHAAnd40BitRC4",e.pbeWithSHAAnd40BitRC4="1.2.840.113549.1.12.1.2",e["1.2.840.113549.1.12.1.3"]="pbeWithSHAAnd3-KeyTripleDES-CBC",e["pbeWithSHAAnd3-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.3",e["1.2.840.113549.1.12.1.4"]="pbeWithSHAAnd2-KeyTripleDES-CBC",e["pbeWithSHAAnd2-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.4",e["1.2.840.113549.1.12.1.5"]="pbeWithSHAAnd128BitRC2-CBC",e["pbeWithSHAAnd128BitRC2-CBC"]="1.2.840.113549.1.12.1.5",e["1.2.840.113549.1.12.1.6"]="pbewithSHAAnd40BitRC2-CBC",e["pbewithSHAAnd40BitRC2-CBC"]="1.2.840.113549.1.12.1.6",e["1.2.840.113549.3.7"]="des-EDE3-CBC",e["des-EDE3-CBC"]="1.2.840.113549.3.7",e["2.16.840.1.101.3.4.1.2"]="aes128-CBC",e["aes128-CBC"]="2.16.840.1.101.3.4.1.2",e["2.16.840.1.101.3.4.1.22"]="aes192-CBC",e["aes192-CBC"]="2.16.840.1.101.3.4.1.22",e["2.16.840.1.101.3.4.1.42"]="aes256-CBC",e["aes256-CBC"]="2.16.840.1.101.3.4.1.42",e["2.5.4.3"]="commonName",e.commonName="2.5.4.3",e["2.5.4.5"]="serialName",e.serialName="2.5.4.5",e["2.5.4.6"]="countryName",e.countryName="2.5.4.6",e["2.5.4.7"]="localityName",e.localityName="2.5.4.7",e["2.5.4.8"]="stateOrProvinceName",e.stateOrProvinceName="2.5.4.8",e["2.5.4.10"]="organizationName",e.organizationName="2.5.4.10",e["2.5.4.11"]="organizationalUnitName",e.organizationalUnitName="2.5.4.11",e["1.2.840.113549.1.9.1"]="emailAddress",e.emailAddress="1.2.840.113549.1.9.1",e["2.5.29.1"]="authorityKeyIdentifier",e["2.5.29.2"]="keyAttributes",e["2.5.29.3"]="certificatePolicies",e["2.5.29.4"]="keyUsageRestriction",e["2.5.29.5"]="policyMapping",e["2.5.29.6"]="subtreesConstraint",e["2.5.29.7"]="subjectAltName",e["2.5.29.8"]="issuerAltName",e["2.5.29.9"]="subjectDirectoryAttributes",e["2.5.29.10"]="basicConstraints",e["2.5.29.11"]="nameConstraints",e["2.5.29.12"]="policyConstraints",e["2.5.29.13"]="basicConstraints",e["2.5.29.14"]="subjectKeyIdentifier",e.subjectKeyIdentifier="2.5.29.14",e["2.5.29.15"]="keyUsage",e.keyUsage="2.5.29.15",e["2.5.29.16"]="privateKeyUsagePeriod",e["2.5.29.17"]="subjectAltName",e.subjectAltName="2.5.29.17",e["2.5.29.18"]="issuerAltName",e.issuerAltName="2.5.29.18",e["2.5.29.19"]="basicConstraints",e.basicConstraints="2.5.29.19",e["2.5.29.20"]="cRLNumber",e["2.5.29.21"]="cRLReason",e["2.5.29.22"]="expirationDate",e["2.5.29.23"]="instructionCode",e["2.5.29.24"]="invalidityDate",e["2.5.29.25"]="cRLDistributionPoints",e["2.5.29.26"]="issuingDistributionPoint",e["2.5.29.27"]="deltaCRLIndicator",e["2.5.29.28"]="issuingDistributionPoint",e["2.5.29.29"]="certificateIssuer",e["2.5.29.30"]="nameConstraints",e["2.5.29.31"]="cRLDistributionPoints",e["2.5.29.32"]="certificatePolicies",e["2.5.29.33"]="policyMappings",e["2.5.29.34"]="policyConstraints",e["2.5.29.35"]="authorityKeyIdentifier",e["2.5.29.36"]="policyConstraints",e["2.5.29.37"]="extKeyUsage",e.extKeyUsage="2.5.29.37",e["2.5.29.46"]="freshestCRL",e["2.5.29.54"]="inhibitAnyPolicy"}(),function(){var e=Mc,t=e.asn1;e.pki=e.pki||{},e.pki.rsa=e.pki.rsa||{};var r=e.pki,i=function(r){var i;if(!(r.algorithm in e.pki.oids))throw{message:"Unknown message digest algorithm.",algorithm:r.algorithm};i=e.pki.oids[r.algorithm];var n=t.oidToDer(i).getBytes(),s=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);a.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,n)),a.value.push(t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,""));var o=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.digest().getBytes());return s.value.push(a),s.value.push(o),t.toDer(s).getBytes()},n=function(e,t,r){var i;if(r)i=e.modPow(t.e,t.n);else{t.dP||(t.dP=t.d.mod(t.p.subtract(pt.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(pt.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s)}return i};r.rsa.encrypt=function(t,r,i){var s=i,a=e.util.createBuffer(),o=Math.ceil(r.n.bitLength()/8);if(i!==!1&&i!==!0){if(t.length>o-11)throw{message:"Message is too long to encrypt.",length:t.length,max:o-11};a.putByte(0),a.putByte(i);var c,l=o-3-t.length;if(0===i||1===i){s=!1,c=0===i?0:255;for(var h=0;l>h;++h)a.putByte(c)}else{s=!0;for(var h=0;l>h;++h)c=Math.floor(255*Math.random())+1,a.putByte(c)}a.putByte(0)}a.putBytes(t);for(var u=new pt(a.toHex(),16),d=n(u,r,s),f=d.toString(16),p=e.util.createBuffer(),_=o-Math.ceil(f.length/2);_>0;)p.putByte(0),--_;return p.putBytes(e.util.hexToBytes(f)),p.getBytes()},r.rsa.decrypt=function(t,r,i,s){e.util.createBuffer();var a=Math.ceil(r.n.bitLength()/8);if(t.length!=a)throw{message:"Encrypted message length is invalid.",length:t.length,expected:a};for(var o=new pt(e.util.createBuffer(t).toHex(),16),c=n(o,r,i),l=c.toString(16),h=e.util.createBuffer(),u=a-Math.ceil(l.length/2);u>0;)h.putByte(0),--u;if(h.putBytes(e.util.hexToBytes(l)),s!==!1){var d=h.getByte(),f=h.getByte();if(0!==d||i&&0!==f&&1!==f||!i&&2!=f||i&&0===f&&"undefined"==typeof s)throw{message:"Encryption block is invalid."};var p=0;if(0===f){p=a-3-s;for(var _=0;p>_;++_)if(0!==h.getByte())throw{message:"Encryption block is invalid."}}else if(1===f)for(p=0;h.length()>1;){if(255!==h.getByte()){--h.read;break}++p}else if(2===f)for(p=0;h.length()>1;){if(0===h.getByte()){--h.read;break}++p}var g=h.getByte();if(0!==g||p!==a-3-h.length())throw{message:"Encryption block is invalid."}}return h.getBytes()},r.rsa.createKeyPairGenerationState=function(t,r){"string"==typeof t&&(t=parseInt(t,10)),t=t||1024;var i={nextBytes:function(t){+new Date;for(var r=e.random.getBytes(t.length),i=0;i>1,pBits:t-(t>>1),pqState:0,num:null,six:new pt(null),addNext:2,keys:null};return n.six.fromInt(6),n},r.rsa.stepKeyPairGenerationState=function(t,r){for(var i,n=+new Date,s=0;null===t.keys&&(0>=r||r>s);){if(0===t.state){var a=null===t.p?t.pBits:t.qBits,o=a-1;if(0===t.pqState)t.itrs=0,t.num=new pt(a,t.rng),t.r=null,t.num.isEven()&&t.num.dAddOffset(1,0),t.num.testBit(o)||t.num.bitwiseTo(pt.ONE.shiftLeft(o),function(e,t){return e|t },t.num),++t.pqState;else if(1===t.pqState){if(null===t.addNext){var c=t.num.mod(t.six).byteValue();3===c&&(t.num.mod.dAddOffset(2),c=5),t.addNext=1===c?2:4}var l=t.num.isProbablePrime(1);l?++t.pqState:t.itrsa?(t.addNext=null,t.num.subTo(pt.ONE.shiftLeft(o),t.num)):t.addNext=4===t.addNext?2:4,++t.itrs):t.pqState=0}else 2===t.pqState?t.pqState=0===t.num.subtract(pt.ONE).gcd(t.e).compareTo(pt.ONE)?3:0:3===t.pqState&&(t.pqState=0,t.num.isProbablePrime(10)&&(null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state),t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(pt.ONE),t.q1=t.q.subtract(pt.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(pt.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var h=t.e.modInverse(t.phi);t.keys={privateKey:e.pki.rsa.setPrivateKey(t.n,t.e,h,t.p,t.q,h.mod(t.p1),h.mod(t.q1),t.q.modInverse(t.p)),publicKey:e.pki.rsa.setPublicKey(t.n,t.e)}}i=+new Date,s+=i-n,n=i}return null!==t.keys},r.rsa.generateKeyPair=function(e,t){var i=r.rsa.createKeyPairGenerationState(e,t);return r.rsa.stepKeyPairGenerationState(i,0),i.keys},r.rsa.setPublicKey=function(e,i){var n={n:e,e:i};return n.encrypt=function(e){return r.rsa.encrypt(e,n,2)},n.verify=function(e,i,s){var a=void 0===s?void 0:!1,o=r.rsa.decrypt(i,n,!0,a);if(void 0===s){var c=t.fromDer(o);return e===c.value[1].value}return s.verify(e,o,n.n.bitLength())},n},r.rsa.setPrivateKey=function(e,t,n,s,a,o,c,l){var h={n:e,e:t,d:n,p:s,q:a,dP:o,dQ:c,qInv:l};return h.decrypt=function(e){return r.rsa.decrypt(e,h,!1)},h.sign=function(e,t){var n=!1;void 0===t&&(t={encode:i},n=1);var s=t.encode(e,h.n.bitLength());return r.rsa.encrypt(s,h,n)},h}}(),function(){function e(e){function t(t){for(var r,i,n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=t.attributes,a=0;an;++s,n+=16)i.push(a(i[s-1]+e+t));return i.join("").substr(0,r)}function a(t){return e.md.md5.create().update(t).digest().getBytes()}"undefined"==typeof pt&&(pt=e.jsbn.BigInteger);var o=e.asn1,c=e.pki=e.pki||{},l=c.oids;c.pbe={};var h={};h.CN=l.commonName,h.commonName="CN",h.C=l.countryName,h.countryName="C",h.L=l.localityName,h.localityName="L",h.ST=l.stateOrProvinceName,h.stateOrProvinceName="ST",h.O=l.organizationName,h.organizationName="O",h.OU=l.organizationalUnitName,h.organizationalUnitName="OU",h.E=l.emailAddress,h.emailAddress="E";var u={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f={name:"Certificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},u,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSignature"}]},p={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},_={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},g={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},m={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,onstructed:!0,capture:"kdfIterationCount"}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},y={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]},v={name:"rsapss",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},u,{name:"CertificationRequestInfo.attributes",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:o.Class.UNIVERSAL,type:o.Type.SET,constructed:!0}]}]}]},w={name:"CertificationRequest",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[b,{name:"CertificationRequest.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"csrSignature"}]};c.RDNAttributesAsArray=function(e,t){for(var r,i,n,s=[],a=0;a1&&(u=h.value.charCodeAt(1),d=h.value.length>2?h.value.charCodeAt(2):0),r.digitalSignature=128===(128&u),r.nonRepudiation=64===(64&u),r.keyEncipherment=32===(32&u),r.dataEncipherment=16===(16&u),r.keyAgreement=8===(8&u),r.keyCertSign=4===(4&u),r.cRLSign=2===(2&u),r.encipherOnly=1===(1&u),r.decipherOnly=128===(128&d)}else if("basicConstraints"===r.name){var h=o.fromDer(r.value);if(r.cA=h.value.length>0?0!==h.value[0].value.charCodeAt(0):!1,h.value.length>1){var f=e.util.createBuffer(h.value[1].value);r.pathLenConstraint=f.getInt(f.length()<<3)}}else if("extKeyUsage"===r.name)for(var h=o.fromDer(r.value),p=0;p="8"&&(r="00"+r),e.util.hexToBytes(r)},A=function(e,t,r){var i={};if(e!==l["RSASSA-PSS"])return i;r&&(i={hash:{algorithmOid:l.sha1},mgf:{algorithmOid:l.mgf1,hash:{algorithmOid:l.sha1}},saltLength:20});var n={},s=[];if(!o.validate(t,v,n,s))throw{message:"Cannot read RSASSA-PSS parameter block.",errors:s};return void 0!==n.hashOid&&(i.hash=i.hash||{},i.hash.algorithmOid=o.derToOid(n.hashOid)),void 0!==n.maskGenOid&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=o.derToOid(n.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=o.derToOid(n.maskGenHashOid)),void 0!==n.saltLength&&(i.saltLength=n.saltLength.charCodeAt(0)),i};c.certificateFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE"!==n.type&&"X509 CERTIFICATE"!==n.type&&"TRUSTED CERTIFICATE"!==n.type)throw{message:'Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certificate from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificateFromAsn1(s,r)},c.certificateToPem=function(t,r){var i={type:"CERTIFICATE",body:o.toDer(c.certificateToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PUBLIC KEY"!==r.type&&"RSA PUBLIC KEY"!==r.type)throw{message:'Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert public key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.publicKeyFromAsn1(i)},c.publicKeyToPem=function(t,r){var i={type:"PUBLIC KEY",body:o.toDer(c.publicKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyToRSAPublicKeyPem=function(t,r){var i={type:"RSA PUBLIC KEY",body:o.toDer(c.publicKeyToRSAPublicKey(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.privateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PRIVATE KEY"!==r.type&&"RSA PRIVATE KEY"!==r.type)throw{message:'Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert private key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.privateKeyFromAsn1(i)},c.privateKeyToPem=function(t,r){var i={type:"RSA PRIVATE KEY",body:o.toDer(c.privateKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.certificationRequestFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE REQUEST"!==n.type)throw{message:'Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certification request from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificationRequestFromAsn1(s,r)},c.certificationRequestToPem=function(t,r){var i={type:"CERTIFICATE REQUEST",body:o.toDer(c.certificationRequestToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.createCertificate=function(){var t={};t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return E(t.issuer,e)},t.issuer.addField=function(e){r([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return E(t.subject,e)},t.subject.addField=function(e){r([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null;var r=function(e){for(var t,r=0;r2)throw{message:"Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate."};if(_.length<2)throw{message:"Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime."};if(u.validity.notBefore=_[0],u.validity.notAfter=_[1],u.tbsCertificate=i.tbsCertificate,r){if(u.md=null,u.signatureOid in l){var h=l[u.signatureOid];switch(h){case"sha1withRSAEncryption":u.md=e.md.sha1.create();break;case"md5withRSAEncryption":u.md=e.md.md5.create();break;case"sha256WithRSAEncryption":u.md=e.md.sha256.create();break;case"RSASSA-PSS":u.md=e.md.sha256.create()}}if(null===u.md)throw{message:"Could not compute certificate digest. Unknown signature OID.",signatureOid:u.signatureOid};var g=o.toDer(u.tbsCertificate);u.md.update(g.getBytes())}var m=e.md.sha1.create();u.issuer.getField=function(e){return E(u.issuer,e)},u.issuer.addField=function(e){_fillMissingFields([e]),u.issuer.attributes.push(e)},u.issuer.attributes=c.RDNAttributesAsArray(i.certIssuer,m),i.certIssuerUniqueId&&(u.issuer.uniqueId=i.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var y=e.md.sha1.create();return u.subject.getField=function(e){return E(u.subject,e)},u.subject.addField=function(e){_fillMissingFields([e]),u.subject.attributes.push(e)},u.subject.attributes=c.RDNAttributesAsArray(i.certSubject,y),i.certSubjectUniqueId&&(u.subject.uniqueId=i.certSubjectUniqueId),u.subject.hash=y.digest().toHex(),u.extensions=i.certExtensions?C(i.certExtensions):[],u.publicKey=c.publicKeyFromAsn1(i.subjectPublicKeyInfo),u},c.certificationRequestFromAsn1=function(t,r){var i={},n=[];if(!o.validate(t,w,i,n))throw{message:"Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.",errors:n};if("string"!=typeof i.csrSignature){for(var s="\x00",a=0;a0&&s.value.push(r(n.extensions)),s},c.getCertificationRequestInfo=function(e){var r=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(e.version)),t(e.subject),c.publicKeyToAsn1(e.publicKey),n(e)]);return r},c.distinguishedNameToAsn1=function(e){return t(e)},c.certificateToAsn1=function(e){var t=e.tbsCertificate||c.getTBSCertificate(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||c.getCertificationRequestInfo(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.createCaStore=function(r){var i={certs:{}};if(i.getIssuer=function(r){var n=null;if(!r.issuer.hash){var s=e.md.sha1.create();r.issuer.attributes=c.RDNAttributesAsArray(t(r.issuer),s),r.issuer.hash=s.digest().toHex()}if(r.issuer.hash in i.certs&&(n=i.certs[r.issuer.hash],e.util.isArray(n)))throw{message:"Resolving multiple issuer matches not implemented yet."};return n},i.addCertificate=function(r){if("string"==typeof r&&(r=e.pki.certificateFromPem(r)),!r.subject.hash){var n=e.md.sha1.create();r.subject.attributes=c.RDNAttributesAsArray(t(r.subject),n),r.subject.hash=n.digest().toHex()}if(r.subject.hash in i.certs){var s=i.certs[r.subject.hash];e.util.isArray(s)||(s=[s]),s.push(r)}else i.certs[r.subject.hash]=r},r)for(var n=0;nu.validity.notAfter)o={message:"Certificate is not valid yet or has expired.",error:c.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:s};else{var d=!1;if(r.length>0){h=r[0];try{d=h.verify(u)}catch(f){}}else{var p=t.getIssuer(u);if(null===p)o={message:"Certificate is not trusted.",error:c.certificateError.unknown_ca};else for(e.util.isArray(p)||(p=[p]);!d&&p.length>0;){h=p.shift();try{d=h.verify(u)}catch(f){}}}null!==o||d||(o={message:"Certificate signature is invalid.",error:c.certificateError.bad_certificate})}if(null!==o||u.isIssuer(h)||(o={message:"Certificate issuer is invalid.",error:c.certificateError.bad_certificate}),null===o)for(var _={keyUsage:!0,basicConstraints:!0},g=0;null===o&&g0);return!0},c.publicKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,u,r,i)){var n=o.derToOid(r.publicKeyOid);if(n!==c.oids.rsaEncryption)throw{message:"Cannot read public key. Unknown OID.",oid:n};t=r.rsaPublicKey}if(i=[],!o.validate(t,d,r,i))throw{message:"Cannot read public key. ASN.1 object does not contain an RSAPublicKey.",errors:i};var s=e.util.createBuffer(r.publicKeyModulus).toHex(),a=e.util.createBuffer(r.publicKeyExponent).toHex();return c.setRsaPublicKey(new pt(s,16),new pt(a,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.e))])},c.privateKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,p,r,i)&&(t=o.fromDer(e.util.createBuffer(r.privateKey))),r={},i=[],!o.validate(t,_,r,i))throw{message:"Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.",errors:i};var n,s,a,l,h,u,d,f;return n=e.util.createBuffer(r.privateKeyModulus).toHex(),s=e.util.createBuffer(r.privateKeyPublicExponent).toHex(),a=e.util.createBuffer(r.privateKeyPrivateExponent).toHex(),l=e.util.createBuffer(r.privateKeyPrime1).toHex(),h=e.util.createBuffer(r.privateKeyPrime2).toHex(),u=e.util.createBuffer(r.privateKeyExponent1).toHex(),d=e.util.createBuffer(r.privateKeyExponent2).toHex(),f=e.util.createBuffer(r.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new pt(n,16),new pt(s,16),new pt(a,16),new pt(l,16),new pt(h,16),new pt(u,16),new pt(d,16),new pt(f,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(0)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.qInv))])},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,"\x00"),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.encryptPrivateKeyInfo=function(t,r,i){i=i||{},i.saltSize=i.saltSize||8,i.count=i.count||2048,i.algorithm=i.algorithm||"aes128";var n=e.random.getBytes(i.saltSize),s=i.count,a=e.util.createBuffer();a.putInt16(s);var c,h,u;if(0===i.algorithm.indexOf("aes")){var d;if("aes128"===i.algorithm)c=16,d=l["aes128-CBC"];else if("aes192"===i.algorithm)c=24,d=l["aes192-CBC"];else{if("aes256"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=32,d=l["aes256-CBC"]}var f=e.pkcs5.pbkdf2(r,n,s,c),p=e.random.getBytes(16),_=e.aes.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBKDF2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(d).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,p)])])])}else{if("3des"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=24;var g=new e.util.ByteBuffer(n),f=e.pkcs12.generateKey(r,g,1,s,c),p=e.pkcs12.generateKey(r,g,2,s,c),_=e.des.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])])}var m=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[h,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)]);return m},c.pbe.getCipherForPBES2=function(t,r,i){var n={},s=[];if(!o.validate(r,m,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};if(t=o.derToOid(n.kdfOid),t!==c.oids.pkcs5PBKDF2)throw{message:"Cannot read encrypted private key. Unsupported key derivation function OID.",oid:t,supportedOids:["pkcs5PBKDF2"]};if(t=o.derToOid(n.encOid),t!==c.oids["aes128-CBC"]&&t!==c.oids["aes192-CBC"]&&t!==c.oids["aes256-CBC"])throw{message:"Cannot read encrypted private key. Unsupported encryption scheme OID.",oid:t,supportedOids:["aes128-CBC","aes192-CBC","aes256-CBC"]};var a=n.kdfSalt,l=e.util.createBuffer(n.kdfIterationCount);l=l.getInt(l.length()<<3);var h;t===c.oids["aes128-CBC"]?h=16:t===c.oids["aes192-CBC"]?h=24:t===c.oids["aes256-CBC"]&&(h=32);var u=e.pkcs5.pbkdf2(i,a,l,h),d=n.encIv,f=e.aes.createDecryptionCipher(u);return f.start(d),f},c.pbe.getCipherForPKCS12PBE=function(t,r,i){var n={},s=[];if(!o.validate(r,y,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=e.util.createBuffer(n.salt),l=e.util.createBuffer(n.iterations);l=l.getInt(l.length()<<3);var h,u,d;switch(t){case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:h=24,u=8,d=e.des.startDecrypting;break;case c.oids["pbewithSHAAnd40BitRC2-CBC"]:h=5,u=8,d=function(t,r){var i=e.rc2.createDecryptionCipher(t,40);return i.start(r,null),i};break;default:throw{message:"Cannot read PKCS #12 PBE data block. Unsupported OID.",oid:t}}var f=e.pkcs12.generateKey(i,a,1,l,h),p=e.pkcs12.generateKey(i,a,2,l,u);return d(f,p)},c.pbe.getCipher=function(e,t,r){switch(e){case c.oids.pkcs5PBES2:return c.pbe.getCipherForPBES2(e,t,r);case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case c.oids["pbewithSHAAnd40BitRC2-CBC"]:return c.pbe.getCipherForPKCS12PBE(e,t,r);default:throw{message:"Cannot read encrypted PBE data block. Unsupported OID.",oid:e,supportedOids:["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"]}}},c.decryptPrivateKeyInfo=function(t,r){var i=null,n={},s=[];if(!o.validate(t,g,n,s))throw{message:"Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=o.derToOid(n.encryptionOid),l=c.pbe.getCipher(a,n.encryptionParams,r),h=e.util.createBuffer(n.encryptedData);return l.update(h),l.finish()&&(i=o.fromDer(l.output)),i},c.encryptedPrivateKeyToPem=function(t,r){var i={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(t).getBytes()};return e.pem.encode(i,{maxline:r})},c.encryptedPrivateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==r.type)throw{message:'Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert encrypted private key from PEM; PEM is encrypted."};return o.fromDer(r.body)},c.encryptRsaPrivateKey=function(t,r,i){if(i=i||{},!i.legacy){var n=c.wrapRsaPrivateKey(c.privateKeyToAsn1(t));return n=c.encryptPrivateKeyInfo(n,r,i),c.encryptedPrivateKeyToPem(n)}var a,l,h,u;switch(i.algorithm){case"aes128":a="AES-128-CBC",h=16,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",h=24,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",h=32,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",h=24,l=e.random.getBytes(8),u=e.des.createEncryptionCipher;break;default:throw{message:'Could not encrypt RSA private key; unsupported encryption algorithm "'+i.algorithm+'".',algorithm:i.algorithm}}var d=s(r,l.substr(0,8),h),f=u(d);f.start(l),f.update(o.toDer(c.privateKeyToAsn1(t))),f.finish();var p={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:e.util.bytesToHex(l).toUpperCase()},body:f.output.getBytes()};return e.pem.encode(p)},c.decryptRsaPrivateKey=function(t,r){var i=null,n=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw{message:'Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type){var a,l;switch(n.dekInfo.algorithm){case"DES-EDE3-CBC":a=24,l=e.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,l=e.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,l=e.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,l=e.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,l=function(t){return e.rc2.createDecryptionCipher(t,40)};break;case"RC2-64-CBC":a=8,l=function(t){return e.rc2.createDecryptionCipher(t,64)};break;case"RC2-128-CBC":a=16,l=function(t){return e.rc2.createDecryptionCipher(t,128)};break;default:throw{message:'Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".',algorithm:n.dekInfo.algorithm}}var h=e.util.hexToBytes(n.dekInfo.parameters),u=s(r,h.substr(0,8),a),d=l(u);if(d.start(h),d.update(e.util.createBuffer(n.body)),!d.finish())return i;i=d.output.getBytes()}else i=n.body;return i="ENCRYPTED PRIVATE KEY"===n.type?c.decryptPrivateKeyInfo(o.fromDer(i),r):o.fromDer(i),null!==i&&(i=c.privateKeyFromAsn1(i)),i},c.setRsaPublicKey=c.rsa.setPublicKey,c.setRsaPrivateKey=c.rsa.setPrivateKey}var t="pki",r=["./aes","./asn1","./des","./jsbn","./md","./mgf","./oids","./pem","./pbkdf2","./pkcs12","./pss","./random","./rc2","./rsa","./util"],i=null;if("function"!=typeof define)return e(Mc),void 0;var n=["require","module"].concat(r),s=function(i,n){n.exports=function(n){var s=r.map(function(e){return i(e)}).concat(e);if(n=n||{},n.defined=n.defined||{},n.defined[t])return n[t];n.defined[t]=!0;for(var a=0;a65&&-1!==s){var a=t[s];","===a&&(++s,a=" "),t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),n=i-s-1,s=-1,++i}(" "===t[i]||" "===t[i]||","===t[i])&&(s=i)}return t}function r(e){return e.replace(/^\s+/,"")}var i=e.pem=e.pem||{};i.encode=function(r,i){i=i||{};var n,s="-----BEGIN "+r.type+"-----\r\n";if(r.procType&&(n={name:"Proc-Type",values:[String(r.procType.version),r.procType.type]},s+=t(n)),r.contentDomain&&(n={name:"Content-Domain",values:[r.contentDomain]},s+=t(n)),r.dekInfo&&(n={name:"DEK-Info",values:[r.dekInfo.algorithm]},r.dekInfo.parameters&&n.values.push(r.dekInfo.parameters),s+=t(n)),r.headers)for(var a=0;a>1,o=a+(1&t.length),c=t.substr(0,o),l=t.substr(a,o),h=e.util.createBuffer(),u=e.hmac.create();i=r+i;var d=Math.ceil(n/16),f=Math.ceil(n/20);u.start("MD5",c);var p=e.util.createBuffer();h.putBytes(i);for(var _=0;d>_;++_)(new Date).valueOf(),u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),p.putBuffer(u.digest());u.start("SHA1",l);var g=e.util.createBuffer();h.clear(),h.putBytes(i);for(var _=0;f>_;++_)u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),g.putBuffer(u.digest());return s.putBytes(e.util.xorBytes(p.getBytes(),g.getBytes(),n)),s},i=function(t,r,i){var n=e.hmac.create();n.start("SHA1",t);var s=e.util.createBuffer();s.putInt32(r[0]),s.putInt32(r[1]),s.putByte(i.type),s.putByte(i.version.major),s.putByte(i.version.minor),s.putInt16(i.length),s.putBytes(i.fragment.bytes());var a=s.getBytes();n.update(a);var o=n.digest().getBytes();return o},n=function(t,r){var i=!1;try{var n=t.deflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},s=function(t,r){var i=!1;try{var n=t.inflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},a=function(e,t){var r=!1,i=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(i),t.updateSequenceNumber();var n=t.cipherState.init?null:t.cipherState.iv;t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start(n),s.update(e.fragment),s.finish(o)&&(e.fragment=s.output,e.length=e.fragment.length(),r=!0),r},o=function(e,t,r){if(!r){var i=t.length()==e?e-1:e-t.length()-1;t.fillWithByte(i,i+1)}return!0},c=function(e,t,r){var i=!0;if(r){for(var n=t.length(),s=t.last(),a=n-1-s;n-1>a;++a)i=i&&t.at(a)==s;i&&t.truncate(s+1)}return i},l=function(t,r){var i=!1,n=r.cipherState.init?null:r.cipherState.iv;r.cipherState.init=!0;var s=r.cipherState.cipher;s.start(n),s.update(t.fragment),i=s.finish(c);for(var a=r.macLength,o="",l=0;a>l;++l)o+=String.fromCharCode(0);var h=s.output.length();h>=a?(t.fragment=s.output.getBytes(h-a),o=s.output.getBytes(a)):t.fragment=s.output.getBytes(),t.fragment=e.util.createBuffer(t.fragment),t.length=t.fragment.length();var u=r.macFunction(r.macKey,r.sequenceNumber,t);return r.updateSequenceNumber(),i=u===o&&i},h=function(t,r){var i=0;switch(r){case 1:i=t.getByte();break;case 2:i=t.getInt16();break;case 3:i=t.getInt24();break;case 4:i=t.getInt32()}return e.util.createBuffer(t.getBytes(i))},u=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},d={};d.Version={major:3,minor:1},d.MaxFragment=15360,d.ConnectionEnd={server:0,client:1},d.PRFAlgorithm={tls_prf_sha256:0},d.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},d.CipherType={stream:0,block:1,aead:2},d.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},d.CompressionMethod={none:0,deflate:1},d.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23},d.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},d.Alert={},d.Alert.Level={warning:1,fatal:2},d.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},d.CipherSuites={TLS_RSA_WITH_AES_128_CBC_SHA:[0,47],TLS_RSA_WITH_AES_256_CBC_SHA:[0,53],TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:[192,10],TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:[192,20],TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,136],TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:[0,135],TLS_DHE_RSA_WITH_AES_256_CBC_SHA:[0,57],TLS_DHE_DSS_WITH_AES_256_CBC_SHA:[0,56],TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:[192,15],TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:[192,5],TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,132],TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:[192,7],TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:[192,9],TLS_ECDHE_RSA_WITH_RC4_128_SHA:[192,17],TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:[192,19],TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,69],TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:[0,68],TLS_DHE_RSA_WITH_AES_128_CBC_SHA:[0,51],TLS_DHE_DSS_WITH_AES_128_CBC_SHA:[0,50],TLS_ECDH_RSA_WITH_RC4_128_SHA:[192,12],TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:[192,14],TLS_ECDH_ECDSA_WITH_RC4_128_SHA:[192,2],TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:[192,4],TLS_RSA_WITH_SEED_CBC_SHA:[0,150],TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,65],TLS_RSA_WITH_RC4_128_MD5:[0,4],TLS_RSA_WITH_RC4_128_SHA:[0,5],TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,8],TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:[192,18],TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:[0,22],TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:[0,19],TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:[192,13],TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,3],SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA:[254,255],TLS_RSA_WITH_3DES_EDE_CBC_SHA:[0,10]};var f=function(e,t,r){if(r>0){var i=t.fragment,n=e.session.sp.DHE={};n.prime=i.getBytes(i.getInt(16)),n.g=i.getBytes(i.getInt(16)),n.server_public_key=i.getBytes(i.getInt(16)),n.signature=i.getBytes(i.getInt(16))}e.expect=y,e.process()},p=function(r){var i,n=r.session.sp;if(n.DHE){var s=n.DHE,a=new pt(No(128).toString("hex"),16),o=new pt(new t(s.prime,"binary").toString("hex"),16),c=new pt(new t(s.g,"binary").toString("hex"),16),l=new pt(new t(s.server_public_key,"binary").toString("hex"),16),h=new t(l.modPow(a,o).toString(16),"hex");n.pre_master_secret=h.toString("binary"),i=Os?new t(c.modPow(a,o).toString(16),"hex").toString("binary"):new t(c.modPow(a,o).toString(16),"hex")}else{i=e.util.createBuffer(),i.putByte(d.Version.major),i.putByte(d.Version.minor),i.putBytes(e.random.getBytes(46)),n.pre_master_secret=i.getBytes();var u=r.session.serverCertificate.publicKey;i=u.encrypt(n.pre_master_secret)}var f=i.length+2,p=e.util.createBuffer();return p.putByte(d.HandshakeType.client_key_exchange),p.putInt24(f),p.putInt16(i.length),p.putBytes(i),p};d.getCipherSuite=function(e){var t=null;for(var r in d.CipherSuites){var i=d.CipherSuites[r];if(i[0]===e.charCodeAt(0)&&i[1]===e.charCodeAt(1)){t=i;break}}return t},d.handleUnexpected=function(e){var t=!e.open&&e.entity===d.ConnectionEnd.client;console.log("unexpected message ----------------"),t=!0,t||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.unexpected_message}})},d.handleHelloRequest=function(e){!e.handshaking&&e.handshakes>0&&(d.queue(e,d.createAlert({level:d.Alert.Level.warning,description:d.Alert.Description.no_renegotiation})),d.flush(e)),e.process()},d.parseHelloMessage=function(t,r,i){var n=null,s=t.entity==d.ConnectionEnd.client;if(38>i)t.error(t,{message:s?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var a=r.fragment;if(n={version:{major:a.getByte(),minor:a.getByte()},random:e.util.createBuffer(a.getBytes(32)),session_id:h(a,1),extensions:[]},s?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=h(a,2),n.compression_methods=h(a,1)),a.length()>0){for(var o=h(a,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:h(o,2)});if(!s)for(var c=0;c0;){var f=u.getByte();if(0!==f)break;t.session.serverNameList.push(h(u,2).getBytes())}}}if(s)t.session.cipherSuite=d.getCipherSuite(n.cipher_suite);else for(var p=e.util.createBuffer(n.cipher_suites.bytes());p.length()>0&&(t.session.cipherSuite=d.getCipherSuite(p.getBytes(2)),null===t.session.cipherSuite););null===t.session.cipherSuite&&t.error(t,{message:"No cipher suites in common.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.handshake_failure},cipherSuite:e.util.bytesToHex(n.cipher_suite)}),t.session.compressionMethod=s?n.compression_method:d.CompressionMethod.none}return n},d.createSecurityParameters=function(e,t){var r;switch(e.session.cipherSuite){case d.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA:r=16;break;case d.CipherSuites.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:r=16;break;case d.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA:r=32;break;case d.CipherSuites.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:r=32}var i=e.entity===d.ConnectionEnd.client,n=t.random.bytes(),s=i?e.session.sp.client_random:n,a=i?n:d.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:d.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:d.BulkCipherAlgorithm.aes,cipher_type:d.CipherType.block,enc_key_length:r,block_length:16,fixed_iv_length:16,record_iv_length:16,mac_algorithm:d.MACAlgorithm.hmac_sha1,mac_length:20,mac_key_length:20,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:s,server_random:a}},d.handleServerHello=function(e,t,r){var i=d.parseHelloMessage(e,t,r);if(!e.fail){var n=i.session_id.bytes();n&&n===e.session.id?(e.expect=b,e.session.resuming=!0,e.session.sp.server_random=i.random.bytes()):(e.expect=g,e.session.resuming=!1,d.createSecurityParameters(e,i)),e.session.id=n,e.process()}},d.handleClientHello=function(t,r,i){var n=d.parseHelloMessage(t,r,i);if(!t.fail){var s=n.session_id.bytes(),a=null;t.sessionCache&&(a=t.sessionCache.getSession(s),null===a&&(s="")),0===s.length&&(s=e.random.getBytes(32)),t.session.id=s,t.session.clientHelloVersion=n.version,t.session.sp=a?a.sp:{},null!==a?(t.expect=x,t.session.resuming=!0,t.session.sp.client_random=n.random.bytes()):(t.expect=t.verifyClient!==!1?A:I,t.session.resuming=!1,d.createSecurityParameters(t,n)),t.open=!0,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createServerHello(t)})),t.session.resuming?(d.queue(t,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),t.state.pending=d.createConnectionState(t),t.state.current.write=t.state.pending.write,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(t)}))):(d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createCertificate(t)})),t.verifyClient!==!1&&d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createCertificateRequest(t)})),d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createServerHelloDone(t)}))),d.flush(t),t.process() }},d.handleCertificate=function(t,r,i){if(3>i)t.error(t,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var n,s,a=r.fragment,o={certificate_list:h(a,3)},c=[];try{for(;o.certificate_list.length()>0;)n=h(o.certificate_list,3),s=e.asn1.fromDer(n),n=e.pki.certificateFromAsn1(s,!0),c.push(n)}catch(l){t.error(t,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.bad_certificate}})}if(!t.fail){var u=t.entity===d.ConnectionEnd.client;!u&&t.verifyClient!==!0||0!==c.length?0===c.length?t.expect=u?m:I:(u?t.session.serverCertificate=c[0]:t.session.clientCertificate=c[0],d.verifyCertificateChain(t,c)&&(t.expect=u?m:I)):t.error(t,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}}),t.process()}}},d.handleServerKeyExchange=f,d.handleClientKeyExchange=function(t,r,i){if(48>i)t.error(t,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.unsupported_certificate}});else{var n=r.fragment;msg={enc_pre_master_secret:h(n,2).getBytes()};var s=null;if(t.getPrivateKey)try{s=t.getPrivateKey(t,t.session.serverCertificate),s=e.pki.privateKeyFromPem(s)}catch(a){t.error(t,{message:"Could not get private key.",cause:a,send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}})}if(null===s)t.error(t,{message:"No private key set.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}});else try{var o=t.session.sp;o.pre_master_secret=s.decrypt(msg.enc_pre_master_secret);var c=t.session.clientHelloVersion;if(c.major!==o.pre_master_secret.charCodeAt(0)||c.minor!==o.pre_master_secret.charCodeAt(1))throw{message:"TLS version rollback attack detected."}}catch(a){o.pre_master_secret=e.random.getBytes(48)}}t.fail||(t.expect=x,null!==t.session.clientCertificate&&(t.expect=T),t.process())},d.handleCertificateRequest=function(e,t,r){if(3>r)e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var i=t.fragment,n={certificate_types:h(i,1),certificate_authorities:h(i,2)};e.session.certificateRequest=n,e.expect=v,e.process()}},d.handleCertificateVerify=function(t,r,i){if(2>i)t.error(t,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var n=r.fragment;n.read-=4;var s=n.bytes();n.read+=4,msg={signature:h(n,2).getBytes()};var a=e.util.createBuffer();a.putBuffer(t.session.md5.digest()),a.putBuffer(t.session.sha1.digest()),a=a.getBytes();try{var o=t.session.clientCertificate;if(n=e.pki.rsa.decrypt(msg.signature,o.publicKey,!0,a.length),n!==a)throw{message:"CertificateVerify signature does not match."};t.session.md5.update(s),t.session.sha1.update(s)}catch(c){t.error(t,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.handshake_failure}})}t.fail||(t.expect=x,t.process())}},d.handleServerHelloDone=function(e,t,r){if(r>0)e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.record_overflow}});else if(null===e.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.insufficient_security}},n=e.verify(e,i.alert.description,depth,[]);n===!0?i=null:((n||0===n)&&(n.constructor==Object?(n.message&&(i.message=n.message),n.alert&&(i.alert.description=n.alert)):n.constructor==Number&&(i.alert.description=n)),e.error(e,i))}if(e.fail||null===e.session.certificateRequest||(t=d.createRecord({type:d.ContentType.handshake,data:d.createCertificate(e)}),d.queue(e,t)),!e.fail){t=d.createRecord({type:d.ContentType.handshake,data:d.createClientKeyExchange(e)}),d.queue(e,t),e.expect=C;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&d.queue(e,d.createRecord({type:d.ContentType.handshake,data:d.createCertificateVerify(e,t)})),d.queue(e,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),e.state.pending=d.createConnectionState(e),e.state.current.write=e.state.pending.write,d.queue(e,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(e)})),e.expect=b,d.flush(e),e.process()};null===e.session.certificateRequest||null===e.session.clientCertificate?s(e,null):d.getClientSignature(e,s)}},d.handleChangeCipherSpec=function(e,t){if(1!=t.fragment.getByte())e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var r=e.entity===d.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=d.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?w:B,e.process()}},d.handleFinished=function(t,i){var n=i.fragment;n.read-=4;var s=n.bytes();n.read+=4;var a=i.fragment.getBytes();n=e.util.createBuffer(),n.putBuffer(t.session.md5.digest()),n.putBuffer(t.session.sha1.digest());var o=t.entity===d.ConnectionEnd.client,c=o?"server finished":"client finished",l=t.session.sp,h=12,u=r;n=u(l.master_secret,c,n.getBytes(),h),n.getBytes()!==a?t.error(t,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.decrypt_error}}):(t.session.md5.update(s),t.session.sha1.update(s),(t.session.resuming&&o||!t.session.resuming&&!o)&&(d.queue(t,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),t.state.current.write=t.state.pending.write,t.state.pending=null,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(t)}))),t.expect=o?E:k,t.handshaking=!1,++t.handshakes,t.peerCertificate=o?t.session.serverCertificate:t.session.clientCertificate,t.sessionCache?(t.session={id:t.session.id,sp:t.session.sp},t.session.sp.keys=null):t.session=null,d.flush(t),t.isConnected=!0,t.connected(t),t.process())},d.handleAlert=function(e,t){var r,i=t.fragment,n={level:i.getByte(),description:i.getByte()};switch(n.description){case d.Alert.Description.close_notify:r="Connection closed.";break;case d.Alert.Description.unexpected_message:r="Unexpected message.";break;case d.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case d.Alert.Description.decryption_failed:r="Decryption failed.";break;case d.Alert.Description.record_overflow:r="Record overflow.";break;case d.Alert.Description.decompression_failure:r="Decompression failed.";break;case d.Alert.Description.handshake_failure:r="Handshake failure.";break;case d.Alert.Description.bad_certificate:r="Bad certificate.";break;case d.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case d.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case d.Alert.Description.certificate_expired:r="Certificate expired.";break;case d.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case d.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case d.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case d.Alert.Description.access_denied:r="Access denied.";break;case d.Alert.Description.decode_error:r="Decode error.";break;case d.Alert.Description.decrypt_error:r="Decrypt error.";break;case d.Alert.Description.export_restriction:r="Export restriction.";break;case d.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case d.Alert.Description.insufficient_security:r="Insufficient security.";break;case d.Alert.Description.internal_error:r="Internal error.";break;case d.Alert.Description.user_canceled:r="User canceled.";break;case d.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}n.description===d.Alert.Description.close_notify?e.close():(e.error(e,{message:r,send:!1,origin:e.entity===d.ConnectionEnd.client?"server":"client",alert:n}),e.process())},d.handleHandshake=function(t,r){var i=r.fragment,n=i.getByte(),s=i.getInt24();if(s>i.length())t.fragmented=r,r.fragment=e.util.createBuffer(),i.read-=4,t.process();else{t.fragmented=null,i.read-=4;var a=i.bytes(s+4);i.read+=4,n in V[t.entity][t.expect]?(t.entity!==d.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={serverNameList:[],cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:e.md.md5.create(),sha1:e.md.sha1.create()}),n!==d.HandshakeType.hello_request&&n!==d.HandshakeType.certificate_verify&&n!==d.HandshakeType.finished&&(t.session.md5.update(a),t.session.sha1.update(a)),V[t.entity][t.expect][n](t,r,s)):d.handleUnexpected(t,r)}},d.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};var _=0,g=1,m=2,y=3,v=4,b=5,w=6,E=7,C=8,S=0,A=1,I=2,T=3,x=4,B=5,k=6,R=d.handleUnexpected,U=d.handleChangeCipherSpec,D=d.handleAlert,N=d.handleHandshake,L=d.handleApplicationData,O=[];O[d.ConnectionEnd.client]=[[R,R,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[U,D,R,R],[R,D,N,R],[R,D,N,L],[R,D,N,R]],O[d.ConnectionEnd.server]=[[R,R,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[U,D,R,R],[R,D,N,R],[R,D,N,L],[R,D,N,R]];var P=d.handleHelloRequest,F=d.handleServerHello,q=d.handleCertificate,H=d.handleServerKeyExchange,M=d.handleCertificateRequest,j=d.handleServerHelloDone,z=d.handleFinished,V=[];V[d.ConnectionEnd.client]=[[R,R,F,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,q,H,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,H,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,z],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R]];var K=d.handleClientHello,G=d.handleClientKeyExchange,Y=d.handleCertificateVerify;V[d.ConnectionEnd.server]=[[R,K,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,q,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,G,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,Y,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,z],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R]],d.generateKeys=function(e,t){var i=r,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=i(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var s=2*t.mac_key_length+2*t.enc_key_length+2*t.fixed_iv_length,a=i(t.master_secret,"key expansion",n,s);return{client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length),client_write_IV:a.getBytes(t.fixed_iv_length),server_write_IV:a.getBytes(t.fixed_iv_length)}},d.createConnectionState=function(t){var r=t.entity===d.ConnectionEnd.client,o=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(){return!0},compressionState:null,compressFunction:function(){return!0},updateSequenceNumber:function(){4294967295==e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},c={read:o(),write:o()};if(c.read.update=function(e,t){return c.read.cipherFunction(t,c.read)?c.read.compressFunction(e,t,c.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.bad_record_mac}}),!e.fail},c.write.update=function(e,t){return c.write.compressFunction(e,t,c.write)?c.write.cipherFunction(t,c.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}}),!e.fail},t.session){var h=t.session.sp;switch(h.keys=d.generateKeys(t,h),c.read.macKey=r?h.keys.server_write_MAC_key:h.keys.client_write_MAC_key,c.write.macKey=r?h.keys.client_write_MAC_key:h.keys.server_write_MAC_key,c.read.macLength=c.write.macLength=h.mac_length,h.mac_algorithm){case d.MACAlgorithm.hmac_sha1:c.read.macFunction=c.write.macFunction=i;break;default:throw{message:"Unsupported MAC algorithm."}}switch(h.bulk_cipher_algorithm){case d.BulkCipherAlgorithm.aes:c.read.cipherState={init:!1,cipher:e.aes.createDecryptionCipher(r?h.keys.server_write_key:h.keys.client_write_key),iv:r?h.keys.server_write_IV:h.keys.client_write_IV},c.write.cipherState={init:!1,cipher:e.aes.createEncryptionCipher(r?h.keys.client_write_key:h.keys.server_write_key),iv:r?h.keys.client_write_IV:h.keys.server_write_IV},c.read.cipherFunction=l,c.write.cipherFunction=a;break;default:throw{message:"Unsupported cipher algorithm."}}switch(h.cipher_type){case d.CipherType.block:break;default:throw{message:"Unsupported cipher type."}}switch(h.compression_algorithm){case d.CompressionMethod.none:break;case d.CompressionMethod.deflate:c.read.compressFunction=s,c.write.compressFunction=n;break;default:throw{message:"Unsupported compression algorithm."}}}return c},d.createRandom=function(){var t=new Date,r=+t+6e4*t.getTimezoneOffset(),i=e.util.createBuffer();return i.putInt32(r),i.putBytes(e.random.getBytes(28)),i},d.createRecord=function(e){var t={type:e.type,version:{major:d.Version.major,minor:d.Version.minor},length:e.data.length(),fragment:e.data};return t},d.createAlert=function(t){var r=e.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),d.createRecord({type:d.ContentType.alert,data:r})},d.createClientHello=function(t){for(var r=e.util.createBuffer(),i=0;i0&&(p+=2);var _=t.session.id,g=_.length+1+2+4+28+2+s+1+o+p,m=e.util.createBuffer();return m.putByte(d.HandshakeType.client_hello),m.putInt24(g),m.putByte(d.Version.major),m.putByte(d.Version.minor),m.putBytes(t.session.sp.client_random),u(m,1,e.util.createBuffer(_)),u(m,2,r),u(m,1,a),p>0&&u(m,2,c),m},d.createServerHello=function(t){var r=t.session.id,i=r.length+1+2+4+28+2+1,n=e.util.createBuffer();return n.putByte(d.HandshakeType.server_hello),n.putInt24(i),n.putByte(d.Version.major),n.putByte(d.Version.minor),n.putBytes(t.session.sp.server_random),u(n,1,e.util.createBuffer(r)),n.putByte(t.session.cipherSuite[0]),n.putByte(t.session.cipherSuite[1]),n.putByte(t.session.compressionMethod),n},d.createCertificate=function(t){var r=t.entity===d.ConnectionEnd.client,i=null;t.getCertificate&&(i=t.getCertificate(t,r?t.session.certificateRequest:t.session.serverNameList));var n=e.util.createBuffer();if(null!==i)try{(Array.isArray&&!Array.isArray(i)||i.constructor!==Array)&&(i=[i]);for(var s=null,a=0;ad.MaxFragment;)n.push(d.createRecord({type:r.type,data:e.util.createBuffer(s.slice(0,d.MaxFragment))})),s=s.slice(d.MaxFragment);s.length>0&&n.push(d.createRecord({type:r.type,data:e.util.createBuffer(s)}))}for(var a=0;a0&&(n=i.order[0]),null!==n&&n in i.cache){r=i.cache[n],delete i.cache[n];for(var s in i.order)if(i.order[s]===n){i.order.splice(s,1);break}}return r},i.setSession=function(t,r){if(i.order.length===i.capacity){var n=i.order.shift();delete i.cache[n]}var n=e.util.bytesToHex(t);i.order.push(n),i.cache[n]=r}}return i},d.createConnection=function(t){var r=null;r=t.caStore?Array.isArray&&Array.isArray(t.caStore)||t.caStore.constructor==Array?e.pki.createCaStore(t.caStore):t.caStore:e.pki.createCaStore();var i=t.cipherSuites||null;null===i&&(i=[],i.push(d.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA),i.push(d.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA));var n=t.server?d.ConnectionEnd.server:d.ConnectionEnd.client,s=t.sessionCache?d.createSessionCache(t.sessionCache):null,a={entity:n,sessionId:t.sessionId,caStore:r,sessionCache:s,cipherSuites:i,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(e,t){return t},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:e.util.createBuffer(),tlsData:e.util.createBuffer(),data:e.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===d.ConnectionEnd.client?"client":"server"),r.send&&(d.queue(e,d.createAlert(r.alert)),d.flush(e));var i=r.fatal!==!1;i&&(e.fail=!0),t.error(e,r),i&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null};a.reset=function(e){a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=a.entity===d.ConnectionEnd.client?_:S,a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||"undefined"==typeof e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=d.createConnectionState(a)},a.reset();var o=function(e,t){var r=t.type-d.ContentType.change_cipher_spec,i=O[e.entity][e.expect];r in i?i[r](e,t):d.handleUnexpected(e,t)},c=function(t){var r=0,i=t.input,n=i.length();return 5>n?r=5-n:t.record={type:i.getByte(),version:{major:i.getByte(),minor:i.getByte()},length:i.getInt16(),fragment:e.util.createBuffer(),ready:!1},r},l=function(e){var t=0,r=e.input,i=r.length();if(i0&&(a.sessionCache&&(r=a.sessionCache.getSession(t)),null===r&&(t="")),0===t.length&&a.sessionCache&&(r=a.sessionCache.getSession(),null!==r&&(t=r.id)),a.session={id:t,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:r?r.sp:{},md5:e.md.md5.create(),sha1:e.md.sha1.create()},a.session.sp.client_random=d.createRandom().getBytes(),a.open=!0,d.queue(a,d.createRecord({type:d.ContentType.handshake,data:d.createClientHello(a)})),d.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.record&&(t=c(a)),a.fail||null===a.record||a.record.ready||(t=l(a)),!a.fail&&null!==a.record&&a.record.ready&&o(a,a.record)),t},a.prepare=function(t){return d.queue(a,d.createRecord({type:d.ContentType.application_data,data:e.util.createBuffer(t)})),d.flush(a)},a.close=function(e){!a.fail&&a.sessionCache&&a.session&&a.sessionCache.setSession(a.session.id,a.session),a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,d.queue(a,d.createAlert({level:d.Alert.Level.warning,description:d.Alert.Description.close_notify})),d.flush(a)),a.closed(a)),a.reset(e)},a},e.tls.prf_tls1=r,e.tls.Alert=d.Alert,e.tls.CipherSuites=d.CipherSuites,e.tls.createSessionCache=d.createSessionCache,e.tls.createConnection=d.createConnection}(),function(){var e={},t=Mc;t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},t.md.md5=t.md.algorithms.md5=e;var r=null,i=null,n=null,s=null,a=!1,o=function(){r=String.fromCharCode(128),r+=t.util.fillString(String.fromCharCode(0),64),i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=new Array(64);for(var e=0;64>e;++e)s[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));a=!0},c=function(e,t,r){for(var a,o,c,l,h,u,d,f,p=r.length();p>=64;){for(o=e.h0,c=e.h1,l=e.h2,h=e.h3,f=0;16>f;++f)t[f]=r.getInt32Le(),u=h^c&(l^h),a=o+u+s[f]+t[f],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;32>f;++f)u=l^h&(c^l),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;48>f;++f)u=c^l^h,a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;64>f;++f)u=l^(c|~h),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;e.h0=4294967295&e.h0+o,e.h1=4294967295&e.h1+c,e.h2=4294967295&e.h2+l,e.h3=4294967295&e.h3+h,p-=64}};e.create=function(){a||o();var e=null,i=t.util.createBuffer(),n=new Array(16),s={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0};return s.start=function(){s.messageLength=0,i=t.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878}},s.start(),s.update=function(r,a){"utf8"===a&&(r=t.util.encodeUtf8(r)),s.messageLength+=r.length,i.putBytes(r),c(e,n,i),(i.read>2048||0===i.length())&&i.compact()},s.digest=function(){var a=s.messageLength,o=t.util.createBuffer();o.putBytes(i.bytes()),o.putBytes(r.substr(0,64-(a+8)%64)),o.putInt32Le(4294967295&a<<3),o.putInt32Le(255&a>>>29);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};c(l,n,o);var h=t.util.createBuffer();return h.putInt32Le(l.h0),h.putInt32Le(l.h1),h.putInt32Le(l.h2),h.putInt32Le(l.h3),h},s}}();var nl=function(e){for(var t=e.length,r=[],i=0;t>i;i++){var n=e[i].charCodeAt().toString(16);r.push(n.length>1?n:"0"+n)}return r.join("")},sl=function(e){for(var t=e.length,r=[],i=0;t>i;i+=2)r.push(String.fromCharCode(parseInt(e[i]+e[i+1],16)));return r.join("")},al=function(e,t,r,i,n,s,a,o){var c=Mc.pki.publicKeyFromPem(Ri.readFileSync(e).toString("utf8")),l=Mc.pki.privateKeyFromPem(Ri.readFileSync(t).toString("utf8"));if(!o){var o=Mc.pki.createCertificate();o.serialNumber=i;var h=new Date(n.valueOf());h.setHours(h.getHours()-2),o.validity.notBefore=h,o.validity.notAfter=new Date(o.validity.notBefore.valueOf()),o.validity.notAfter.setFullYear(o.validity.notBefore.getFullYear()+1);var u=[{name:"commonName",value:s||"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com"}],d=[{name:"commonName",value:a||"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com"}];o.setSubject(u),o.setIssuer(d)}o.publicKey=c,o.sign(l);var f=Mc.pki.certificateToPem(o);return"pem"===r?f:"der"===r?Os?Mc.pki.pemToDer(f).toHex():Mc.pki.pemToDer(f).data.toString("hex"):o},ol=function(e){console.log('Generating 512-bit key-pair and certificate for "'+e+'".');var t=Mc.pki.rsa.generateKeyPair(512);console.log("Key-pair created.");var r=Mc.pki.createCertificate();r.serialNumber=Date.now().toString(),r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+1);var i=[{name:"commonName",value:e},{name:"countryName",value:"US"},{shortName:"ST",value:"Virginia"},{name:"localityName",value:"Blacksburg"},{name:"organizationName",value:"Internet Widgits Pty Ltd"},{shortName:"OU",value:"Internet Widgits Pty Ltd"}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"subjectAltName",altNames:[{type:6,value:"http://www.ianonym.com"}]}]),r.publicKey=t.publicKey,r.sign(t.privateKey),console.log('Certificate created for "'+e+'", signature :

'+nl(r.signature).toUpperCase()),{cert:Mc.pki.certificateToPem(r),privateKey:Mc.pki.privateKeyToPem(t.privateKey)}},cl=function(e,r,i){var n,s=i?"server":"client";return i?Fs[r]?n=Fs[r]:(n=ol(i?r:"client"),Fs[r]=n):n={cert:{},privateKey:{}},Mc.tls.createConnection({server:i?!0:!1,caStore:i?[n.cert]:"",sessionCache:{},cipherSuites:[[0,47],[0,53],[192,10],[192,20],[0,136],[0,135],[0,57],[0,56],[192,15],[192,5],[0,132],[192,7],[192,9],[192,17],[192,19],[0,69],[0,68],[0,51],[0,50],[192,12],[192,14],[192,2],[192,4],[0,150],[0,65],[0,4],[0,5],[192,8],[192,18],[0,22],[0,19],[192,13],[192,3],[254,255],[0,10]],virtualHost:i?"":r,verifyClient:!1,verify:function(e,t,r,i){return!0},connected:function(e){console.log("TLS "+s+" "+r+" connected..."),setTimeout(function(){var t=Mc.util.encodeUtf8("Hello "+("server"===s?"client":"server")+" I want 100 € ");e.prepare(t)},1)},getCertificate:function(){return n.cert},getPrivateKey:function(){return n.privateKey},tlsDataReady:function(r){if(Os){var i=r.tlsData.getBytes();Ps?"server"===s?e.write_s(new t(nl(i),"hex")):e.write_c(new t(nl(i),"hex")):"server"===s?e.write_s(i):e.write_c(i)}else{var n=r.tlsData.data.slice(0,r.tlsData.length_);n.length&&0!==n[0]&&(r.tlsData.clear(),"server"===s?e.write_s(n):e.write_c(n))}},dataReady:function(e){if(Os)console.log(s+" "+r+" received : "+Mc.util.decodeUtf8(e.data.getBytes()));else{var t=e.data.data.toString("utf8");console.log(s+" "+r+" received : "+t)}},closed:function(){console.log(s+" "+r+" disconnected.")},error:function(e,t){console.log(s+" "+r+" notification: "+t.message),-1===t.message.indexOf("Unknown")?console.log("Unexpected error - please retry"):console.log("Normal error message, so far, so good."),e.close()}})}}var ll=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},hl=function(e,r,i){for(var n,s="",a=Math.ceil(r/i),o=0;a>o;++o){var c=String.fromCharCode(255&o>>24,255&o>>16,255&o>>8,255&o);n=new fn("sha1"),n.update(new t(e+c,"binary")),s+=new t(n.digest("hex"),"hex").toString("binary")}return s.substring(0,r)},ul=function(e,r,i){var n,s,a="",o=20; i&&(a=i.label,n=i.seed),s=new fn("sha1");var c=e-2*o-2;if(r.length>c)throw{message:"RSAES-OAEP input message length is too long.",length:r.length,maxLength:c};s.update(new t(a,"binary"));var l=s.digest("hex");l=new t(l,"hex").toString("binary");for(var h="",u=c-r.length,d=0;u>d;d++)h+="\x00";var f=l+h+""+r;n||(n=No(o).toString("binary"));var p=hl(n,e-o-1,o),_=ll(f,p,f.length),g=hl(_,o,o),m=ll(n,g,n.length);return"\x00"+m+_},dl=function(e,r,i){var n,s="",a=20;if(i&&(s=i.label,n=i.md),r.length!==e)throw{message:"RSAES-OAEP encoded message length is invalid.",length:r.length,expectedLength:e};if(n=new fn("sha1"),2*a+2>e)throw{message:"RSAES-OAEP key is too short for the hash function."};n.update(new t(s,"binary"));var o=n.digest("hex");o=new t(o,"hex").toString("binary");for(var c=r.charAt(0),l=r.substring(1,a+1),h=r.substring(1+a),u=hl(h,a,a),d=Mc.util.xorBytes(l,u,l.length),f=hl(d,e-a-1,a),p=Mc.util.xorBytes(h,f,h.length),_=p.substring(0,a),g="\x00"!==c,m=0;a>m;++m)g|=o.charAt(m)!==_.charAt(m);for(var y=1,v=a,b=a;b=t)return t>this._byteLength&&(this._byteLength=t),void 0;for(1>r&&(r=1);t>r;)r*=2;var i=new ArrayBuffer(r),n=new Uint8Array(this._buffer),s=new Uint8Array(i,0,n.length);s.set(n),this.buffer=i,this._byteLength=t}},pl.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),r=new Uint8Array(this._buffer,0,t.length);t.set(r),this.buffer=e}},pl.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},pl.prototype.isEof=function(){return this.position>=this._byteLength},pl.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},pl.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},pl.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},pl.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},pl.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=8*e,r},pl.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Int32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Int16Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return pl.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},pl.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Uint32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Uint16Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return pl.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},pl.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var r=new Float64Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Float32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&0==this.byteOffset+this.position%e.BYTES_PER_ELEMENT)pl.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var r=0;r0,pl.memcpy=function(e,t,r,i,n){var s=new Uint8Array(e,t,n),a=new Uint8Array(r,i,n);s.set(a)},pl.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},pl.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},pl.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=0;rn;i--,n++){var s=t[n];t[n]=t[i],t[i]=s}return e},pl.prototype.failurePosition=0,pl.prototype.readStruct=function(e){for(var t,r,i={},n=this.position,s=0;si;i++)this.writeUint16(e.charCodeAt(i),t);for(;r>i;i++)this.writeUint16(0)},pl.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCode.apply(null,this.mapUint8Array(null==e?this.byteLength-this.position:e)):new ft(t).decode(this.mapUint8Array(e))},pl.prototype.writeString=function(e,t,r){if(null==t||"ASCII"==t)if(null!=r){var i=0,n=Math.min(e.length,r);for(i=0;n>i;i++)this.writeUint8(e.charCodeAt(i));for(;r>i;i++)this.writeUint8(0)}else for(var i=0;in&&0!=r[n];n++);var s=String.fromCharCode.apply(null,this.mapUint8Array(n));return null!=e?this.position+=i-n:n!=t&&(this.position+=1),s},pl.prototype.writeCString=function(e,t){if(null!=t){var r=0,i=Math.min(e.length,t);for(r=0;i>r;r++)this.writeUint8(e.charCodeAt(r));for(;t>r;r++)this.writeUint8(0)}else{for(var r=0;rf;f++)r[f]=this.readType(o,t)}}}else if("*"==c)for(r=[],this.buffer;;){var p=this.position;try{var _=this.readType(o,t);if(null==_){this.position=p;break}r.push(_)}catch(g){this.position=p;break}}else{r=new Array(l);for(var f=0;l>f;f++){var d=this.readType(o,t);if(null==d)return null;r[f]=d}}break}}return null!=i&&(this.position=s+i),r},pl.prototype.writeStruct=function(e,t){for(var r=0;r>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},pl.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e),this.writeUint32(t),this.seek(r)};var gl={ERR_NOT_ENOUGH_DATA:0,boxCodes:["mdat","avcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt"]}],initialize:function(){var e,t,r;for(gl.FullBox.prototype=new gl.Box,gl.ContainerBox.prototype=new gl.Box,gl.stsdBox.prototype=new gl.FullBox,gl.SampleEntry.prototype=new gl.FullBox,r=gl.boxCodes.length,e=0;r>e;e++)gl[gl.boxCodes[e]+"Box"]=function(e){return function(t){gl.Box.call(this,gl.boxCodes[e],t)}}(e),gl[gl.boxCodes[e]+"Box"].prototype=new gl.Box;for(r=gl.fullBoxCodes.length,e=0;r>e;e++)gl[gl.fullBoxCodes[e]+"Box"]=function(e){return function(t){gl.FullBox.call(this,gl.fullBoxCodes[e],t)}}(e),gl[gl.fullBoxCodes[e]+"Box"].prototype=new gl.FullBox;for(r=gl.containerBoxCodes.length,e=0;r>e;e++)gl[gl.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){if(gl.ContainerBox.call(this,gl.containerBoxCodes[e][0],r),t){this.subBoxNames=t;for(var i=t.length,n=0;i>n;n++)this[t[n]+"s"]=new Array}}}(e,gl.containerBoxCodes[e][1]),gl[gl.containerBoxCodes[e][0]+"Box"].prototype=new gl.ContainerBox;for(r=gl.sampleEntryCodes.length,t=0;r>t;t++){var i=gl.sampleEntryCodes[t].prefix,n=gl.sampleEntryCodes[t].types,s=n.length;for(gl[i+"SampleEntry"]=function(e,t){gl.SampleEntry.call(this,e,t)},gl[i+"SampleEntry"].prototype=new gl.SampleEntry,e=0;s>e;e++)gl[n[e]+"Box"]=function(e,t){return function(r){gl[gl.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,gl.sampleEntryCodes[e].types[t],r)}}(t,e),gl[n[e]+"Box"].prototype=new gl[i+"SampleEntry"]}},Box:function(e,t){this.type=e,this.size=t},FullBox:function(e,t){gl.Box.call(this,e,t),this.flags=0,this.version=0},ContainerBox:function(e,t){gl.Box.call(this,e,t),this.boxes=new Array},SampleEntry:function(e,t){gl.Box.call(this,e,t),this.boxes=new Array},stsdBox:function(e){gl.FullBox.call(this,"stsd",e),this.entries=new Array},parseOneBox:function(e){var t,r=e.position,i=0;if(e.byteLength<8)return gl.ERR_NOT_ENOUGH_DATA;var n=e.readUint32(),s=e.readString(4);if(i=8,"uuid"==s)throw"UUID not supported";return 1==n&&(n=e.readUint64(),i+=8),r+n-i>e.byteLength?(e.seek(r),gl.ERR_NOT_ENOUGH_DATA):(t=gl[s+"Box"]?new gl[s+"Box"](n-i):new gl.Box(s,n-i),t.inputStart=r,t.parse(e),t)}};gl.initialize(),gl.Box.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},gl.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.size-=4},gl.ContainerBox.prototype.parse=function(e){var t,r;for(r=e.position;e.position=4;)this.compatible_brands[t]=e.readString(4),this.size-=4,t++},gl.mvhdBox.prototype.parse=function(e){this.flags=0,this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()},gl.TKHD_FLAG_ENABLED=1,gl.TKHD_FLAG_IN_MOVIE=2,gl.TKHD_FLAG_IN_PREVIEW=4,gl.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()},gl.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16();var t=[];t[0]=31&this.language>>10,t[1]=31&this.language>>5,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96),e.readUint16()},gl.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e),0==this.version?(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readCString()):this.data=e.readUint8Array(size)},gl.stsdBox.prototype.parse=function(e){var t,r;for(this.parseFullHeader(e),r=e.readUint32(),i=1;r>=i;i++){var t=gl.parseOneBox(e);this.entries.push(t)}},gl.avcCBox.prototype.parse=function(e){var t,r,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),r=31&e.readUint8(),this.size-=6,this.SPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.SPS[t]=e.readUint8Array(i),this.size-=2+i;for(r=e.readUint8(),this.size--,this.PPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.PPS[t]=e.readUint8Array(i),this.size-=2+i;this.size>0&&(this.ext=e.readUint8Array(this.size))},gl.avc1Box.prototype.getCodec=function(){var e=gl.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+Ti(this.avcC.AVCProfileIndication)+Ti(this.avcC.profile_compatibility)+Ti(this.avcC.AVCLevelIndication):e},gl.mp4aBox.prototype.getCodec=function(){var e=gl.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),r=this.esds.esd.getAudioConfig();return e+"."+Ti(t)+(r?"."+r:"")}return e},gl.esdsBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size),this.size=0;var t=new xi;this.esd=t.parseOneDescriptor(new pl(this.data.buffer,0,pl.BIG_ENDIAN))},gl.cttsBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.sample_counts=new Array,this.sample_offsets=new Array,0==this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readUint32());else if(1==this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32());else this.data=e.readUint8Array(this.size-4)},gl.cttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;tr;r++)this.sample_counts.push(e.readUint32()),this.sample_deltas.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.sttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;tr;r++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e),t=e.readUint32(),0==this.version?this.chunk_offsets=e.readUint32Array(t):this.data=e.readUint8Array(this.size-4)},gl.stcoBox.prototype.unpack=function(e){var t;for(t=0;tr;r++)this.chunk_offsets.push(e.readUint64());else this.data=e.readUint8Array(this.size-4) -},gl.stscBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.first_chunk=new Array,this.samples_per_chunk=new Array,this.sample_description_index=new Array,0==this.version)for(r=0;t>r;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;tt;t++)this.sample_sizes[t]=r;else this.data=e.readUint8Array(this.size)},gl.stszBox.prototype.unpack=function(e){var t;for(t=0;tt&&this.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0},gl.TRUN_FLAGS_DATA_OFFSET=1,gl.TRUN_FLAGS_FIRST_FLAG=4,gl.TRUN_FLAGS_DURATION=256,gl.TRUN_FLAGS_SIZE=512,gl.TRUN_FLAGS_FLAGS=1024,gl.TRUN_FLAGS_CTS_OFFSET=2048,gl.trunBox.prototype.parse=function(e){var t=0;if(this.parseFullHeader(e),this.sample_count=e.readUint32(),t+=4,this.size>t&&this.flags&gl.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size>t&&this.flags&gl.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=new Array,this.sample_size=new Array,this.sample_flags=new Array,this.sample_composition_time_offset=new Array,this.size>t)for(var r=0;rt;t++){var s={};if(this.samples[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],n=e.readUint16(),n>0)for(r=0;n>r;r++){var a={};s.subsamples.push(a),a.size=1==this.version?e.readUint32():e.readUint16(),a.priority=e.readUint8(),a.discardable=e.readUint8(),a.reserved=e.readUint32()}}},gl.Box.prototype.writeHeader=function(e){this.size+=8,this.size>_l&&(this.size+=8),this.size>_l?e.writeUint32(1):(this.sizePosition=e.position,e.writeUint32(this.size)),e.writeString(this.type,null,4),this.size>_l&&e.writeUint64(this.size)},gl.FullBox.prototype.writeHeader=function(e){this.size+=4,gl.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},gl.Box.prototype.write=function(e){this.size=this.data.length,this.writeHeader(e),this.data&&e.writeUint8Array(this.data)},gl.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t-1&&this.moov.boxes.splice(t,1)}var n=new gl.mvexBox;this.moov.boxes.push(n);var s=new gl.mehdBox;n.boxes.push(s),s.fragment_duration=this.initial_duration;for(var r=0;r0?this.moov.traks[r].samples[0].duration:0,a.default_sample_size=0,a.default_sample_flags=65536}this.moov.write(e)},Bi.prototype.resetTables=function(){var e,t,r,i,n,s,a,o;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;et?(w.chunk_index=d,w.chunk_run_index=u):(p=0,d++,w.chunk_index=d,f>d?w.chunk_run_index=u:u=g&&(m++,0>g&&(g=0),g+=a.sample_counts[m]),t>0?(w.dts=r.samples[t-1].dts+a.sample_deltas[m],r.samples[t-1].duration=w.dts-r.samples[t-1].dts):w.dts=0,o?(t>=y&&(v++,0>y&&(y=0),y+=o.sample_counts[v]),w.cts=r.samples[t].dts+o.sample_offsets[v]):w.cts=w.dts,c?t==c.sample_numbers[b]-1?(w.is_rap=!0,b++):w.is_rap=!1:w.is_rap=!0,h&&h.samples[subs_entry_index].sample_delta+last_subs_sample_index==t&&(w.subsamples=h.samples[subs_entry_index].subsamples,last_subs_sample_index+=h.samples[subs_entry_index].sample_delta)}t>0&&(r.samples[t-1].duration=r.mdia.mdhd.duration-r.samples[t-1].dts)}},Bi.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t0?p.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(p.dts=h.tfdt?h.tfdt.baseMediaDecodeTime:0,u.first_traf_merged=!0),p.cts=p.dts,f.flags&gl.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+f.sample_composition_time_offset[r]),sample_flags=a,f.flags&gl.TRUN_FLAGS_FLAGS?sample_flags=f.sample_flags[r]:0==r&&f.flags&gl.TRUN_FLAGS_FIRST_FLAG&&(sample_flags=f.first_sample_flags),p.is_rap=1&sample_flags>>16?!1:!0;var _=h.tfhd.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?!0:!1,g=h.tfhd.flags&gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?!0:!1,m=f.flags&gl.TRUN_FLAGS_DATA_OFFSET?!0:!1,y=0;y=_?tfhd.base_data_offset:g?l.inputStart:0==t?l.inputStart:o,p.offset=0==t&&0==r?m?y+f.data_offset:y:o,o=p.offset+p.size}}if(h.subs){var v=h.first_sample_index;for(t=0;t0&&(t+=","),t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t},Bi.prototype.getTrackById=function(e){for(var t=0;t=this.log_level&&console.log("[MP4Box] "+t)},ki.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.stream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples),void 0!=r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},ki.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r-1&&this.fragmentedTracks.splice(t,1)},ki.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples)}},ki.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r-1&&this.extractedTracks.splice(t,1)},ki.prototype.createSingleSampleMoof=function(e){var t=new gl.moofBox,r=new gl.mfhdBox;r.sequence_number=this.nextMoofNumber,this.nextMoofNumber++,t.boxes.push(r);var i=new gl.trafBox;t.boxes.push(i);var n=new gl.tfhdBox;i.boxes.push(n),n.track_id=e.track_id,n.flags=gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new gl.tfdtBox;i.boxes.push(s),s.baseMediaDecodeTime=e.dts;var a=new gl.trunBox;return i.boxes.push(a),t.trun=a,a.flags=gl.TRUN_FLAGS_DATA_OFFSET|gl.TRUN_FLAGS_DURATION|gl.TRUN_FLAGS_SIZE|gl.TRUN_FLAGS_FLAGS|gl.TRUN_FLAGS_CTS_OFFSET,a.data_offset=0,a.first_sample_flags=0,a.sample_count=1,a.sample_duration=new Array,a.sample_duration[0]=e.duration,a.sample_size=new Array,a.sample_size[0]=e.size,a.sample_flags=new Array,a.sample_flags[0]=0,a.sample_composition_time_offset=new Array,a.sample_composition_time_offset[0]=e.cts-e.dts,t},ki.prototype.createFragment=function(e,t,r,i){var n=this.inputIsoFile.getTrackById(t),s=n.samples[r];if(this.inputStream.byteLength=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending fragmented data on track #"+t.id+" for sample "+t.nextSample),this.onSegment(t.id,t.user,t.stream.buffer),t.stream=null)}for(var e=0;e=s.offset+s.size))return;n.nextSample++,this.inputStream.seek(s.offset),s.data=this.inputStream.readUint8Array(s.size),n.samples.push(s),this.onSamples&&(0==n.nextSample%n.nb_samples||n.nextSample>=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending samples on track #"+n.id+" for sample "+n.nextSample),this.onSamples(n.id,n.user,n.samples),n.samples=[])}},ki.prototype.appendBuffer=function(e){var t=this.open(e);t&&this.processSamples()},ki.prototype.getInfo=function(){var e={};e.duration=this.inputIsoFile.moov.mvhd.duration,e.timescale=this.inputIsoFile.moov.mvhd.timescale,e.isFragmented=null!=this.inputIsoFile.moov.mvex,e.isFragmented&&(e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration),e.isProgressive=this.inputIsoFile.isProgressive,e.hasIOD=null!=this.inputIsoFile.moov.iods,e.brands=[],e.brands.push(this.inputIsoFile.ftyp.major_brand),e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);var t=new Date(4,0,1,0,0,0,0).getTime();for(e.created=new Date(t+1e3*this.inputIsoFile.moov.mvhd.creation_time),e.modified=new Date(t+1e3*this.inputIsoFile.moov.mvhd.modification_time),e.tracks=new Array,e.audioTracks=new Array,e.videoTracks=new Array,e.subtitleTracks=new Array,e.metadataTracks=new Array,e.hintTracks=new Array,i=0;i1)for(i=0;iWebsocket was closed by remote party for unknown reasons, this might be a temporary network problem, if the system does not recover please refresh the page

"),Cl=wc($i)})};if(El&&(js||(El.associate=function(e,r){var i=ho(fo(r.split(".")[1]));i=i.host,console.log("real domain requested "+i);var n=i.split("."),s=n.length>1?[n[n.length-2],n[n.length-1]].join("."):i;bs[r]={real_domain:i,real_domain_a:n,real_domain_s:s,associated:!0},console.log("OP SEND ASSOCIATE CID "+Cs.circId+" "+r); -var a=new t(r,"utf8"),o=new qo(qo.prototype.RELAY_ASSOCIATE,0,a,e.Df_hash),c=new Po(e.circId,Po.prototype.RELAY,e.stream_encrypt_forward(o));e.send(c)}),El.connect(Dn)),s&&!function(){var e=function(){var e={};Xo.call(e),e.params_={},e.params_.OP=!0,e.params_.nb_hop=Hn,e.params_.one_c=!0,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),e.i_id=Vs,Vs++,e.params_.host="www.kickstarter.com:80";var r=new Date,i="GET /projects/450023/ianonym-internet-privacy-everywhere-from-any-devic/pledge/new?clicked_reward=false&ref=category HTTP/1.1\r\n";if(i+="Host: www.kickstarter.com\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="last_page=http%3A%2F%2Fwww.kickstarter.com%2Fprojects%2F450023%2Fianonym-internet-privacy-everywhere-from-any-devic%3Fref%3Dcategory; request_time=Sun%2C+30+Jun+2013+"+r.getHours()+"%3A"+r.getMinutes()+"%3A"+r.getSeconds()+"+-0000; local_offset=-5798;mp_75b1d24a516ecfc955eadfadc4910661_mixpanel=%7B%22distinct_id%22%3A%20%2213f8f454878706-00471d2d6-516e3c71-1aeaa0-13f8f4548796c1%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D",i+="\r\n",e.params_.stream=new t(i,"utf8"),e.remotePort="60000",e.remoteAddress="1.2.3.4",e.write=function(){},e.end=function(){},e.destroy=function(){},e.close=function(){},e._init_=Xo,e._write_=e.write,Qn>=5){rc(e);var n=function(){e.cid_.destroy()};setTimeout(n,1e4)}};setInterval(e,1e4+Math.floor(6e4*Math.random()))}(),A&&!I){var Tl=function(e){return 13==e.keyCode?(this.blur(),!0):!1};if(ks){var xl,Bl=new t("00112233445566778899001122334455","hex"),kl=document.body,Rl=document.getElementsByTagName("head"),Ul="http://www.lepoint.fr",Dl=function(){var e=Nl();return e.className="rounded",kl.appendChild(e),e},Nl=function(){var e=document.createElement("div"),t=e.style;return t.marginLeft="1%",Ll(e,"left"),t.width="98%",t.textAlign="center",t.color="#000",t.fontWeight="800",t.fontSize="1em",t.background="white",t.borderWidth="1px",t.borderStyle="solid",t.borderColor="rgb(217,217,217)",e},Ll=function(e,t){var r=e.style;r.styleFloat=t,r.cssFloat=t},Ol=function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)};Rl.length&&Ol(Rl.item(0)),Ol(kl);var Pl=' html { border:0; padding:0; border:0; } body { font-family: Arial,"Trebuchet MS",helvetica,sans serif; font-size: 14px; font-style: normal; font-weight: normal; text-decoration: none; height: 100%; width:100%; margin:auto; padding:0; background-color:black !important; } p { margin-left:1%; margin-right:1%; } a { margin:1%; } div.ew{ border:0; margin:0; padding:0; -webkit-tap-highlight-color:rgba(0,0,0,0); } .rounded { -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; } input.ew{ font-size:1.2em; -webkit-border-radius:7px; -moz-border-radius:7px; border-radius:7px; border:1px solid; }',Fl=document.createElement("STYLE");Fl.appendChild(document.createTextNode(Pl)),kl.appendChild(Fl);var ql=Dl(),Hl=document.createElement("INPUT"),Ml=Hl.style;Hl.className="ew",Ml.width="80%",Ml.padding="1%",Ml.marginTop="1%",Ml.marginBottom="1%",Ml.marginLeft="1%",Ml.textAlign="center",Ml.color="#000",Hl.value=xl||Ul,ql.appendChild(Hl),Hl.onkeydown=function(e){Tl.call(this,e||window.event)&&""!==this.value&&Gl(this.value)},Hl.onmousedown=function(){this.value===Ul&&(this.value="")};var jl=document.createElement("SPAN"),zl=jl.style;jl.className="ew",zl.padding="1%",zl.width="8%",zl.cursor="pointer",jl.className="rounded",zl.marginTop="1%",zl.marginLeft="1%",zl.backgroundColor="#387BAF",zl.color="white",jl.innerHTML="OK",ql.appendChild(jl),jl.onmousedown=function(){""!==Hl.value&&Gl(Hl.value)};var Vl=Dl();Vl.style.marginTop="1%",Vl.style.textAlign="left",Vl.innerHTML='

How to use it :

First please set your proxy settings (Options/Advanced/Network/Settings) to "Automatic proxy configuration" with the value "http://www.ianonym.com/proxy.pac". Then, reload this page. When you are finished don\'t forget to restore the settings to the previous value (No Proxy normally). You should see below the message "Websocket connected", if not, clear the history, close your browser and reopen it.

Replace "www.example.com" by the URL that you want to open, then click on OK and click on the url proposed. This will establish a secure connection between the new page that was open after you clicked and the current page.

The new page should indicate that you have initiated an untrusted connection because the certificate created for this connection is self signed, click that you "understand the risks", "Add Exception", and confirm.

The page will reload and you can start surfing anonymously. If you surf to another site you will have to confirm the exception again, that\'s a little bit painfull but at least you are sure that you are secured. If you have some doubts about your connection, you can first try the Interception Detector.

This will ensure that you are not intercepted and you can be totally sure to be anonym since all exchanges are encrypted and the domain where you are going looks the same as the link that you clicked, so is hidden, nobody except your browser (the initial page) can decrypt the messages and know the real domain.

';var Kl=Dl();Kl.style.marginTop="1%",Kl.style.paddingBottom="1%",Kl.style.textAlign="left",r&&(Vl.style.display="none");var Gl=function(e){var t=ho(e);t.host&&(protocol=t.protocol,Es="www."+fo(t.host,!0)+ms,Qn>=2&&Cs?(console.log("START PAGE real "+e+" fake http://"+Es),El.associate(Cs,Es),Kl.innerHTML='

Click on the link below :

http'+Ds+"://"+Es+"/"+t.rest+""):alert("Not enough circuits established : "+Qn+" - Please wait and retry"))};try{var Yl=128,Wl=5,Ql=256,Xl=document.createElement("canvas");Xl.width=4*Ql,Xl.height=4*Ql,Xl.style.position="absolute",Xl.style.zIndex=-1,Xl.style.top="70%",Xl.style.left="50%",Xl.style.marginLeft=-(Xl.width/2)+"px",Xl.style.marginTop=-(Xl.height/2)+"px",document.body.appendChild(Xl);var Jl=Xl.getContext("2d"),Zl=document.createElement("canvas");Zl.width=Ql,Zl.height=Ql;var $l=Zl.getContext("2d");$l.beginPath(),$l.arc(Ql/2,Ql/2,Ql/2,0,2*Math.PI,!0);var eh=function(e){$l.fillStyle=e,$l.fill();for(var t=0;Yl>t;t++){var r=Ql+t*Wl,i=.5*r,n=2*Ql-i,s=2*Ql-i;Jl.globalAlpha=2*Ql/(20*(t+4)*(t+4)),Jl.drawImage(Zl,n,s,r,r)}};eh("rgb(106,253,123)")}catch(th){document.body.style.backgroundColor="black",document.body.style.backgroundColor="radial-gradient(circle at center top, #bdd8df, black)"}}if(Us){var vl,rh,ih,nh,sh,ah,oh,ch,lh,Ya,hh,uh,dh,fh,ph,_h,gh,mh,yh,vh,bh,wh,Eh,Ch,Sh,Ah,Ih,Qi,Th={},xh=0,Bh=0,kh=0,Rh=100,Uh=function(e,t){Wa("prompt_box").style.display="block",Wa("prompt-message").innerHTML=e,Wa("prompt-input").value="",Wa("prompt-input").submit=t,$a(Wa("prompt-input"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1),$a(Wa("prompt-input"),"keydown",function(e){Tl.call(this,e||window.event)&&""!==this.value&&(Wa("prompt_box").style.display="none",this.submit())},!1)},Dh=Wa("close_prompt");$a(Dh,"mousedown",function(){Wa("prompt_box").style.display="none",Wa("prompt-input").submit()},!1);var Nh=Wa("close_alert");$a(Nh,"mousedown",function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},!1);var Lh=function(e){setTimeout(function(){Wa("alert_box").style.display="block"},500),Wa("dialog-message").innerHTML=e},Oh=function(e){e.style.display="none"},Ph=function(e){e.style.display="block"},Fh=function(e){e&&e.forEach(function(e){clearTimeout(e)}),e=[]},qh='var forge={};(function(){var a=forge.util=forge.util||{};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){a.setImmediate=setImmediate;a.nextTick=function(b){return setImmediate(b)}}else{a.setImmediate=function(b){setTimeout(b,0)};a.nextTick=a.setImmediate}}else{a.nextTick=process.nextTick;if(typeof setImmediate==="function"){a.setImmediate=setImmediate}else{a.setImmediate=a.nextTick}}a.isArray=Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"};a.ByteBuffer=function(c){this.data=c||"";this.read=0};a.ByteBuffer.prototype.length=function(){return this.data.length-this.read};a.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0};a.ByteBuffer.prototype.putByte=function(c){this.data+=String.fromCharCode(c);return this};a.ByteBuffer.prototype.fillWithByte=function(c,f){c=String.fromCharCode(c);var e=this.data;while(f>0){if(f&1){e+=c}f>>>=1;if(f>0){c+=c}}this.data=e;return this};a.ByteBuffer.prototype.putBytes=function(b){this.data+=b;return this};a.ByteBuffer.prototype.putString=function(b){this.data+=a.encodeUtf8(b);return this};a.ByteBuffer.prototype.putInt16=function(b){this.data+=String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt24=function(b){this.data+=String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt32=function(b){this.data+=String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt16Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255);return this};a.ByteBuffer.prototype.putInt24Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255);return this};a.ByteBuffer.prototype.putInt32Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>24&255);return this};a.ByteBuffer.prototype.putInt=function(b,c){do{c-=8;this.data+=String.fromCharCode((b>>c)&255)}while(c>0);return this};a.ByteBuffer.prototype.putSignedInt=function(b,c){if(b<0){b+=2<<(c-1)}return this.putInt(b,c)};a.ByteBuffer.prototype.putBuffer=function(b){this.data+=b.getBytes();return this};a.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};a.ByteBuffer.prototype.getInt16=function(){var b=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return b};a.ByteBuffer.prototype.getInt24=function(){var b=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return b};a.ByteBuffer.prototype.getInt32=function(){var b=(this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3));this.read+=4;return b};a.ByteBuffer.prototype.getInt16Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8);this.read+=2;return b};a.ByteBuffer.prototype.getInt24Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16);this.read+=3;return b};a.ByteBuffer.prototype.getInt32Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24);this.read+=4;return b};a.ByteBuffer.prototype.getInt=function(c){var b=0;do{b=(b<<8)+this.data.charCodeAt(this.read++);c-=8}while(c>0);return b};a.ByteBuffer.prototype.getSignedInt=function(d){var c=this.getInt(d);var b=2<<(d-2);if(c>=b){c-=b<<1}return c};a.ByteBuffer.prototype.getBytes=function(b){var c;if(b){b=Math.min(this.length(),b);c=this.data.slice(this.read,this.read+b);this.read+=b}else{if(b===0){c=""}else{c=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return c};a.ByteBuffer.prototype.bytes=function(b){return(typeof(b)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+b))};a.ByteBuffer.prototype.at=function(b){return this.data.charCodeAt(this.read+b)};a.ByteBuffer.prototype.setAt=function(d,c){this.data=this.data.substr(0,this.read+d)+String.fromCharCode(c)+this.data.substr(this.read+d+1);return this};a.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};a.ByteBuffer.prototype.copy=function(){var b=a.createBuffer(this.data);b.read=this.read;return b};a.ByteBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};a.ByteBuffer.prototype.clear=function(){this.data="";this.read=0;return this};a.ByteBuffer.prototype.truncate=function(c){var b=Math.max(0,this.length()-c);this.data=this.data.substr(this.read,b);this.read=0;return this};a.ByteBuffer.prototype.toHex=function(){var e="";for(var d=this.read;d0){if(d&1){b+=e}d>>>=1;if(d>0){e+=e}}return b};a.xorBytes=function(j,f,l){var e="";var d="";var h="";var g=0;var k=0;for(;l>0;--l,++g){d=j.charCodeAt(g)^f.charCodeAt(g);if(k>=10){e+=h;h="";k=0}h+=String.fromCharCode(d);++k}e+=h;return e};a.hexToBytes=function(c){var d="";var b=0;if(c.length&1==1){b=1;d+=String.fromCharCode(parseInt(c[0],16))}for(;b>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255))};a.encodeUtf8=function(b){return unescape(encodeURIComponent(b))};a.decodeUtf8=function(b){return decodeURIComponent(escape(b))};a.deflate=function(e,c,d){c=a.decode64(e.deflate(a.encode64(c)).rval);if(d){var f=2;var b=c.charCodeAt(1);if(b&32){f=6}c=c.substring(f,c.length-4)}return c};a.inflate=function(d,b,c){var e=d.inflate(a.encode64(b)).rval;return(e===null)?null:a.decode64(e)}})();(function(){var e=forge.sha1=forge.sha1||{};forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};forge.md.sha1=forge.md.algorithms.sha1=e;var c=null;var b=false;var d=function(){c=String.fromCharCode(128);c+=forge.util.fillString(String.fromCharCode(0),64);b=true};var a=function(r,p,u){var q,o,n,m,l,k,j,g;var h=u.length();while(h>=64){o=r.h0;n=r.h1;m=r.h2;l=r.h3;k=r.h4;for(g=0;g<16;++g){q=u.getInt32();p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<20;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<32;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<40;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<60;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=(n&m)|(l&(n^m));q=((o<<5)|(o>>>27))+j+k+2400959708+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<80;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+3395469782+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}r.h0+=o;r.h1+=n;r.h2+=m;r.h3+=l;r.h4+=k;h-=64}};e.create=function(){if(!b){d()}var f=null;var i=forge.util.createBuffer();var g=new Array(80);var h={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};h.start=function(){h.messageLength=0;i=forge.util.createBuffer();f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return h};h.start();h.update=function(k,j){if(j==="utf8"){k=forge.util.encodeUtf8(k)}h.messageLength+=k.length;i.putBytes(k);a(f,g,i);if(i.read>2048||i.length()===0){i.compact()}return h};h.digest=function(){var j=h.messageLength;var m=forge.util.createBuffer();m.putBytes(i.bytes());m.putBytes(c.substr(0,64-((j+8)%64)));m.putInt32((j>>>29)&255);m.putInt32((j<<3)&4294967295);var k={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(k,g,m);var l=forge.util.createBuffer();l.putInt32(k.h0);l.putInt32(k.h1);l.putInt32(k.h2);l.putInt32(k.h3);l.putInt32(k.h4);return l};h.digest2=function(){var j=h.messageLength;var o=forge.util.createBuffer();var k=forge.util.createBuffer(i.data.slice(i.read));var m=g.slice(0);o.putBytes(i.bytes());o.putBytes(c.substr(0,64-((j+8)%64)));o.putInt32((j>>>29)&255);o.putInt32((j<<3)&4294967295);var l={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(l,g,o);var n=forge.util.createBuffer();n.putInt32(l.h0);n.putInt32(l.h1);n.putInt32(l.h2);n.putInt32(l.h3);n.putInt32(l.h4);i=k;g=m;return n};return h};e.createhash=function(){var g=e.create();var f=g.update;g.update=function(h){return f(h.toString("binary"))};g.digest=function(){return g.digest2().toHex()};return g}})();(function(){var j=false;var h=4;var f;var b;var d;var k;var g;var e=function(){j=true;d=[0,1,2,4,8,16,32,64,128,27,54];var x=new Array(256);for(var p=0;p<128;++p){x[p]=p<<1;x[p+128]=(p+128)<<1^283}f=new Array(256);b=new Array(256);k=new Array(4);g=new Array(4);for(var p=0;p<4;++p){k[p]=new Array(256);g[p]=new Array(256)}var s=0,o=0,v,t,q,w,l,u,r;for(var p=0;p<256;++p){w=o^(o<<1)^(o<<2)^(o<<3)^(o<<4);w=(w>>8)^(w&255)^99;f[s]=w;b[w]=s;l=x[w];v=x[s];t=x[v];q=x[t];u=(l<<24)^(w<<16)^(w<<8)^(w^l);r=(v^t^q)<<24^(s^q)<<16^(s^t^q)<<8^(s^v^q);for(var m=0;m<4;++m){k[m][s]=u;g[m][w]=r;u=u<<24|u>>>8;r=r<<24|r>>>8}if(s===0){s=o=1}else{s=v^x[x[x[v^q]]];o^=x[x[o]]}}};var a=function(z,o){var x=z.slice(0);var B,m=1;var r=x.length;var p=r+6+1;var s=h*p;for(var u=r;u>>16&255]<<24^f[B>>>8&255]<<16^f[B&255]<<8^f[B>>>24]^(d[m]<<24);m++}else{if(r>6&&(u%r===4)){B=f[B>>>24]<<24^f[B>>>16&255]<<16^f[B>>>8&255]<<8^f[B&255]}}x[u]=x[u-r]^B}if(o){var t;var D=g[0];var C=g[1];var A=g[2];var y=g[3];var v=x.slice(0);var s=x.length;for(var u=0,l=s-h;u>>24]]^C[f[t>>>16&255]]^A[f[t>>>8&255]]^y[f[t&255]]}}}x=v}return x};var c=function(u,v,t,o){var q=u.length/4-1;var p,n,m,l,s;if(o){p=g[0];n=g[1];m=g[2];l=g[3];s=b}else{p=k[0];n=k[1];m=k[2];l=k[3];s=f}var D,C,A,z,E,r,x;D=v[0]^u[0];C=v[o?3:1]^u[1];A=v[2]^u[2];z=v[o?1:3]^u[3];var y=3;for(var B=1;B>>24]^n[C>>>16&255]^m[A>>>8&255]^l[z&255]^u[++y];r=p[C>>>24]^n[A>>>16&255]^m[z>>>8&255]^l[D&255]^u[++y];x=p[A>>>24]^n[z>>>16&255]^m[D>>>8&255]^l[C&255]^u[++y];z=p[z>>>24]^n[D>>>16&255]^m[C>>>8&255]^l[A&255]^u[++y];D=E;C=r;A=x}t[0]=(s[D>>>24]<<24)^(s[C>>>16&255]<<16)^(s[A>>>8&255]<<8)^(s[z&255])^u[++y];t[o?3:1]=(s[C>>>24]<<24)^(s[A>>>16&255]<<16)^(s[z>>>8&255]<<8)^(s[D&255])^u[++y];t[2]=(s[A>>>24]<<24)^(s[z>>>16&255]<<16)^(s[D>>>8&255]<<8)^(s[C&255])^u[++y];t[o?1:3]=(s[z>>>24]<<24)^(s[D>>>16&255]<<16)^(s[C>>>8&255]<<8)^(s[A&255])^u[++y]};var i=function(H,r,u,o,v){var m=null;if(!j){e()}v=(v||"CBC").toUpperCase();if(typeof H==="string"&&(H.length===16||H.length===24||H.length===32)){H=forge.util.createBuffer(H)}else{if(forge.util.isArray(H)&&(H.length===16||H.length===24||H.length===32)){var B=H;var H=forge.util.createBuffer();for(var x=0;x>>2;for(var x=0;x=w||(n.length()>0&&l)){F()}};m.update2=function(J){if(J){if(J.length()){n.data=n.data.substr(n.read);n.read=0;n.putBuffer(J)}}while(n.length()>=w){F()}if(m.overflow){y.getBytes(m.overflow)}var M=n.length()%w;if(M){var K=forge.util.createBuffer(n.data.slice(n.read));var L=s.slice(0);while(n.length()>0){F()}n=K;s=L;y.truncate(w-M)}else{n.data="";n.read=0};m.overflow=M};m.finish=function(N){var M=true;var O=n.length()%w;if(!o){if(N){M=N(w,n,o)}else{if(p){var L=(n.length()===w)?w:(w-n.length());n.fillWithByte(L,L)}}}if(M){l=true;m.update()}if(o){if(p){M=(O===0)}if(M){if(N){M=N(w,y,o)}else{if(p){var J=y.length();var K=y.at(J-1);if(K>(h<<2)){M=false}else{y.truncate(K)}}}}}if(!p&&!N&&O>0){y.truncate(w-O)}return M};m.start=function(K,J){if(K===null){K=q.slice(0)}if(typeof K==="string"&&K.length===16){K=forge.util.createBuffer(K)}else{if(forge.util.isArray(K)&&K.length===16){var M=K;var K=forge.util.createBuffer();for(var L=0;L<16;++L){K.putByte(M[L])}}}if(!forge.util.isArray(K)){var M=K;K=new Array(4);K[0]=M.getInt32();K[1]=M.getInt32();K[2]=M.getInt32();K[3]=M.getInt32()}n=forge.util.createBuffer();y=J||forge.util.createBuffer();q=K.slice(0);s=new Array(h);D=new Array(h);l=false;m.output=y;if(["CFB","OFB","CTR"].indexOf(v)!==-1){for(var L=0;L=0;--J){if(s[J]===4294967295){s[J]=0}else{++s[J];break}}for(var J=0;JLoading...please wait

"),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%",Ih=new t(this.value,"hex");var i=Ih;if(16===i.length){var n=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),s=0,a=Yi.length/2,o="";n.onmessage=function(e){var n=e.data,c=n.pop?n[0]:n;if(s+=c.length/2,Wa("progint-alert").style.width=parseInt(100*(s/a))+"%",n.pop||(o+=c.toString("utf8")),n.pop){Wa("progress-alert").style.display="none";var l=c,h=sn.createcipheriv("aes-128-ctr",i,Ln),u=h.update(new t(l,"hex"),"hex","hex");if(r===u.toString("hex")){Yi="var FindProxyForUrl="+o,eval(Yi);var d,f=FindProxyForUrl("http://"+Es,Es,!0),p=document.location.href.split("#");if(2===p.length){var _=p[1].split("-");2===_.length?(d=_[0].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge"},d=_[1].split(":"),ka={ip:d[0],port:d[1],wsport:0,fing:d[2],o_modulus:d[3],name:"Tor Bridge"}):(d=p[1].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge - "+d[0]})}else Zi=f[1][_o(f[1].length)];if(ka||(ka=f[2]),Zi!==ka&&(Js=!0),on=Guards,$i&&(vl=new pr,vl.setPublic($i.o_modulus,Nn)),setTimeout(function(){Wa("alert_box").style.display="none"},1e4),!ph&&wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.put({k:i.toString("hex")})}else if(!wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.delete(i.toString("hex"))}Ch?Ph(Wa("debug")):Oh(Wa("debug")),setInterval(Qi,ss),Il(),Mh()}else Uh("

Wrong key or someone is trying to hack your connection, please retry:

",Ah),Wa("prompt-input").type="password"}},n.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),i,Ln])}else Uh("

Wrong key length, please retry:

",Ah),Wa("prompt-input").type="password"}}},Qi=function(){console.log("updating proxy ----"),Yi=Xi("proxy.pac");var e=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),r="";e.onmessage=function(e){var t=e.data,i=t.pop?t[0]:t;t.pop||(r+=i.toString("utf8")),t.pop&&(Yi="var FindProxyForUrl="+r,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0))},e.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),Ih,Ln])},Wa("alert_box").style.display="none",Wa("prompt-input").type="password","peersm"===Xa?(Uh("

Public version, click on OK to start the Peersm application:

",Ah),Wa("prompt-input").value="00112233445566778899aabbccddeeff",Wa("save").checked="checked"):Uh("

Enter your key:

",Ah);try{Ha=indexedDB.open(Xa,6)}catch(th){return Wa("prompt_box").style.display="none",Lh("

Your browser does not seem to support all the features required for Peersm. It is recommended to use Firefox version 26 or superior, or Chrome version 32 or superior.

"),void 0}Ha.onupgradeneeded=function(e){console.log("onupgradeneeded------------------");var t=e.target.result;t.objectStoreNames.contains(Xa+"_")&&t.deleteObjectStore(Xa+"_"),t.objectStoreNames.contains(Xa)&&t.deleteObjectStore(Xa),t.createObjectStore(Xa,{keyPath:"name_hash"}),t.createObjectStore(Xa+"_",{keyPath:"k"})},Ha.onsuccess=function(e){Ha.db=e.target.result;var t=Ha.db.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");oh={},Ji=-1!==Ba.userAgent.indexOf("Chrome")?!0:!1,t.openCursor().onsuccess=function(e){var t=e.target.result;if(t){var r=t.value.k;if(r instanceof Array){var i=t.value,n=i.k[0];oh.hasOwnProperty(n)||(console.log("restoring chunks "+n),oh[n]=i)}else Wa("prompt-input").value=r,Wa("save").checked="checked",ph=!0;t.continue()}else ah?Hh():ch=!0},Wa("debug").checked="checked"},Ha.onerror=function(){console.log("Error opening database")};var Mh=function(){var e=function(){mh=new google.visualization.DataTable,mh.addColumn("datetime","Time"),mh.addColumn("number","Received (KB)"),mh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),mh.addRow([r,0,0])}gh={title:"Direct Download : "+(Qn>=0?Qn:0)+" circuits",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:mh.getValue(5,0),max:mh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["green","yellow"]},_h=new google.visualization.LineChart(Wa("chart1")),_h.index=null,_h.dynRow={},_h.dynRow2={},_h.draw(mh,gh)},r=function(){bh=new google.visualization.DataTable,bh.addColumn("datetime","Time"),bh.addColumn("number","Received (KB)"),bh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),bh.addRow([r,0,0])}vh={title:"Peer to peer",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:bh.getValue(5,0),max:bh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["red","orange"]},yh=new google.visualization.LineChart(Wa("chart2")),yh.index=null,yh.dynRow={},yh.dynRow2={},yh.draw(bh,vh)},i=function(e,t,r){for(var i=5,n=go(t.getValue(69,0)).getTime(),s=0;i>s;s++){var a=new Date;a.setTime(n+1e3*(s+1)),t.removeRow(0),t.addRow([a,e.dynRow[a.getTime()]||0,e.dynRow2[a.getTime()]||0]),delete e.dynRow[a.getTime()],delete e.dynRow2[a.getTime()]}-1!==r.title.indexOf("Direct")&&(r.title="Direct Download : "+(Qn>=0?Qn:0)+(Qn>1?" circuits":" circuit")),-1!==r.title.indexOf("Peer")&&(r.title="Peer to Peer : "+(Ss?1:0)+" circuit"),r.hAxis.viewWindow.min=t.getValue(i,0),r.hAxis.viewWindow.max=t.getValue(64,0),r.hAxis.viewWindowMode="explicit",r.animation={duration:4e3,easing:"linear"},e.draw(t,r)},n=Wa("input"),s=document.createElement("input");s.id="url",s.value="Enter_url_or_hash_name_or_magnet_link_or_infohash",n.appendChild(s),Ul=s.value,s.onkeydown=function(e){$a(document.body,"mousedown",function(){},!1),Tl.call(this,e||window.event)&&""!==this.value&&($a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(this.value))};var a=Wa("ok");$a(a,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value)},!1);var o=Wa("stream");$a(o,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value.trim(),!0)},!1),Ya=function(){var e=Ha.db;return e.transaction([Xa],"readwrite").objectStore(Xa)},hh=function(){var e=Ha.db;return e.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_")};var c=function(){var e=sn.createhash("sha1");return e.update(new t(Date.now().toString()+Xa,"utf8")),e.digest("hex")},h=function(e){return e=e.split("."),e.length>1&&e[e.length-1]===Qs&&e.pop(),e.join(".")},u=function(e){setTimeout(function(){Wa("alert_box").style.display="none"},1e4); -var t=Wa(e.hash_ini);e.thumb2_=_(e,e.hash_ini),t?Wa("local").insertBefore(e.thumb2_,t):Wa("local").appendChild(e.thumb2_),e.d_length!==e.clength_&&(e.thumb2_.firstChild.style.backgroundColor="orange",e.thumb_&&(e.thumb_.firstChild.style.backgroundColor="orange")),$a(e.thumb2_,"mousedown",P.bind({file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,url:url,thumb2_:e.thumb2_,thumb_:e.thumb_,clength_:e.clength_,d_length:e.d_length,content_:e.content_,url_:e.url_,key:e.key,content_chrome:e.content_chrome,blob_:e.blob_}),!1),lh(t)},d=function(e){var t=e.thumb_;e.thumb_=_(e),t?t.parentNode?(Wa("downloaded").insertBefore(e.thumb_,t),lh(t)):Wa("downloaded").appendChild(e.thumb_):Wa("downloaded").appendChild(e.thumb_),$a(e.thumb_,"mousedown",O.bind(e),!1)},f=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,lh(Th),lh(nh),$a(document.body,"mousedown",function(){},!1),Lh("

Uploading file from your disk to your browser storage...please wait until the file appears in the Local files box, this can take some time depending on the size of the file

"),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=this.files[0],i=[],n={},s=r.name.split("#");if(s.length>1){var a=s[1].split(".");n.name_=s[0]+(a.length>1?"."+a[1]:"")}else n.name_=r.name;n.blob_=Ji?new t(0):r,n.content_=r.type,n.clength_=r.size,n.d_length=r.size,n.url_="",n.queue_=[],n.hash_ini=s.length>1?s[1].split(".")[0]:c();var o=r.size,l=0,h=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"})));h.onmessage=function(e){var r=e.data,s=r.pop?Ji?new t(0):0:r;l+=Ji?s.length:parseInt(s);var a=l;if(Ji){if(i.push(s),0===l%$s||l===o){var c=i,h=function(){Wa("progint-alert").style.width=parseInt(100*a/o)+"%",r.pop?(n.check_hash=!0,n.file_hash=r[0],$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0)):(n.file_hash="00",n.d_length=l,b(n,c))};i=[],n.queue_.push(h),1===n.queue_.length&&n.queue_[0]()}}else Wa("progint-alert").style.width=parseInt(100*a/o)+"%",e.data.pop&&(n.check_hash=!0,n.file_hash=e.data[0],Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0))},h.postMessage([Ji?"hashc":"hash",r])},p=Wa("file_upload");$a(p,"change",f,!1),uh=function(e,t){var r=t.d_length||0,i=t.clength_||0,n=0;i&&(n=parseInt(100*(r/i)));var s=document.createElement("div");s.className="progress";var a=document.createElement("p");a.className="bar",a.innerHTML=Gs+n+"%";var o=document.createElement("div");o.className="progcont";var c=document.createElement("div");return c.className="progint",c.style.width=n+"%",o.appendChild(c),s.appendChild(a),s.appendChild(o),e.appendChild(s),s.progtxt=a,s.progbar=c,$a(s,"mousedown",dh.bind(t),!1),s};var _=function(e,t){var r=e.name_||e.name,i=e.blob_||e.data||new Blob([]),n=Bo(r),s=i.type||e.content_chrome||e.content_||e.type,a=La[n]?La[n]:-1!==ro.indexOf(n)&&-1!==s.indexOf("image")?URL.createObjectURL(i):La.exe,o=document.createElement("div");o.className="thumbwrap",t&&(o.id=t);var c=document.createElement("div");c.className="thumb";var l=document.createElement("img");l.className="thumbimg",l.src=a;var h=document.createElement("div");h.align="center";var u=document.createElement("span");return u.className="thumbspan",u.innerHTML=r,c.appendChild(l),o.appendChild(c),h.appendChild(u),o.appendChild(h),o},g=function(e,t){console.log("compute hash"),e.file_hash=0,$a(document.body,"mousedown",function(){},!1),Lh("

Calculating hash for a resumed file, please wait...

"),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e.blob_,i=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),n=r.size,s=0;i.onmessage=function(r){var i=r.data.pop?0:parseInt(r.data);if(s+=i,Wa("progint-alert").style.width=parseInt(100*s/n)+"%",r.data.pop){Wa("progress-alert").style.display="none",setTimeout(function(){Wa("alert_box").style.display="none"},1e4),e.file_hash=r.data[0];var a=function(){d(e),u(e),m(e,t)};e.queue_.push(a),$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),1===e.queue_.length&&e.queue_[0]()}},i.postMessage(["hash",r])};ah=function(e,t,r){console.log("store_DB "),$a(document.body,"mousedown",function(){},!1),e.nb_try===Bs||e.reason_||Lh("

Storing file, please wait that the file appears in Local Files (for large files this can take some time)

"),Ha.store=function(){var i,n=Ji?[]:null,s=0,a=hh();e.file_id=e.file_id||0;var o=a.get([e.file_id,s]),c=e.blob_?e.blob_.type:e.content_chrome?e.content_chrome:e.content_,h=new Blob([],{type:c});if(l)var i=Date.now();o.onsuccess=function(o){var l=o.target.result;if(l){var f=l.data;f instanceof Array?(f.unshift(h),h=new Blob(f,{type:c})):h=new Blob([h,f],{type:c}),Ji&&(f instanceof Array?(f.shift(),n=n.concat(f)):n.push(f)),a.delete([e.file_id,s]),s++,_=a.get([e.file_id,s]),_.onsuccess=this.onsuccess}else{console.log("Saving chunks size "+h.size+(i?" time to read all chunks "+(Date.now()-i):"")),Ji&&(e.blob_ instanceof Array?n=n.concat(e.blob_):n.push(e.blob_)),e.blob_=new Blob([h,e.blob_],{type:c});var p=Ya(),_=p.get(e.hash_ini);console.log("store_DB open");var y=Date.now();_.onsuccess=function(i){console.log("store_DB success "+(Date.now()-y));var s=i.target.result;if(s?(lh(Wa(s.name_hash)),Ji?(f=s.data.concat(n),e.blob_=new Blob(f,{type:e.content_chrome?e.content_chrome:e.content_})):(f=new Blob([s.data,e.blob_],{type:c}),e.blob_=f)):f=Ji?n:e.blob_,!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_hash=e.file_hash||0,e.d_length=e.blob_.size,t||d(e),r||u(e),e.check_hash||e.clength_!==e.d_length?m(e,f,r):g(e,f),console.log("Chunks saved "+(Date.now()-y)),Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)}}}},Ha.store()};var m=function(e,t,r){e.file_hash=e.file_hash||0;var i=Ya();Ji?i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t,enc:e.content_chrome||""}):i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t}),r?r(e):(e.d_length===e.clength_&&Ss&&Ss.send_db_info(),ko(e))},b=function(e,t){if(y)var r=Date.now();var i=Ha.db,n=i.transaction([Xa+"_"],"readwrite"),s=n.objectStore(Xa+"_");if(!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_id?e.chunk_nb++:(e.file_id=Date.now(),e.chunk_nb=0),s.put({k:[e.file_id,e.chunk_nb],file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,content_:e.content_,clength_:e.clength_,d_length:e.d_length,url_:e.url_,key:e.key?e.key:"",data:t}),r&&console.log("db_perf "+(Date.now()-r));var o=e.queue_;o.shift(),o.length&&o[0]()},w=function(e){var t=e.split("PT"),r=t[1].split("H"),i=parseFloat(r[1].split("M")[1].split("S")[0]);return t=t[1].split("H")[0],r=r[1].split("M")[0],3600*t+60*r+i},E=function(){try{log("addsourcebuffer "+this._stream_.readyState),this._source_=this._stream_.addSourceBuffer(this.mime_codec)}catch(e){console.log("wait open addsourcebuffer failed")}},C=function(e,t){if(e.received_===t)Wa("alert_box").style.display="none",e._source_.addEventListener("updateend",function(){Do(e)}),Do(e);else if(e.received_>t&&(0===e.append_cursor&&(e.wait_chunk=!0),e.wait_chunk)){var r=Math.min(Math.ceil((e.clength_-e.d_length)/Da),Ea/4);e.append_cursor++,e.append_cursor>=r&&(delete e.wait_chunk,console.log("updateend called "+e._source_.updating),Do(e))}},S=function(e,r){if(r._stream_&&!r._streaming_){if(r.d_length+=e.length,r._json_+=e.toString("utf8"),r.d_length>=r.clength_){console.log("json "+r._json_);var i=JSON.parse(r._json_);for(var n in i)if("Duration"!==n){var s=H(i[n].Representation.BaseURL,null,!0);if(r.nb_sources.push(s),s._streaming_=!0,s.mime_codec=i[n].Representation.mimeType+'; codecs="'+i[n].Representation.codecs+'"',s._stream_=r._stream_,s._parent_=r,s._bandwidth_=i[n].Representation.bandwidth,s._width_=i[n].Representation.width,s._height_=i[n].Representation.height,"open"===r._stream_.readyState)try{s._source_=r._stream_.addSourceBuffer(s.mime_codec)}catch(a){console.log("addsourcebuffer failed"),r._wait_open.push(E.bind(s))}else r._wait_open.push(E.bind(s));rc(s)}else r._stream_.duration=w(i[n]);console.log("Queue fin json "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,fin_.call(r)}}else if(r._streaming_){if(r.d_length+=e.length,r.append_buffer.push(e),r._source_)C(r,Math.min(Ea,r.pieces));else if(r.mp4box){var o=r.append_buffer.length;if(o>=Ca||r.d_length>=r.clength_){for(var c=r.append_buffer.concatBuffers(),l=0;o>l;l++)r.append_buffer.shift();r.mp4box.appendBuffer(c.buffer)}}r.d_length>=r.clength_&&(console.log("Queue fin streaming "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),console.log("queue length "+r.append_buffer.length+" cursor "+r.append_cursor+" received "+r.received_),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,r.mp4box&&r.mp4box.flush(),fin_.call(r))}else if(r.eof_)console.log("EOF");else{var h=function(e){return function(){if(r.d_length+=e.length,!r.blob_){r.content_=r.content_||"application/octet-binary";var i=r.content_.split(";");if(i.length>1&&(r.content_=i[0],r.content_chrome=i[1]||"application/octet-binary"),r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),!r.reload2_&&!r.reload_){r.check_hash=new fn("sha1");var n=Ya();n.delete(r.hash_ini)}r.clength_||lh(r.bar_)}if(r.blob_=Ji?r.blob_.length?[r.blob_,e].concatBuffers():e:new Blob([r.blob_,e],{type:r.content_chrome?r.content_chrome:r.content_}),r.check_hash&&r.check_hash.update(e),r.clength_){var s=r.blob_.size||r.blob_.length||r.blob_.byteLength;if(s>=Zs&&r.d_length=r.clength_&&(console.log("Queue fin "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")+(r.blob_.size||r.blob_.length||r.blob_.byteLength)),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,r.queue_.push(fin_.bind(r)),1===r.queue_.length&&r.queue_[0]());if(r.clength_||r.d_length>=r.clength_){var o=parseInt(100*(r.d_length/r.clength_));r.bar_.progtxt.innerHTML=Gs+parseInt(r.d_length/1e3)+" kB",r.bar_.progbar.style.width=o+"%"}r.queue_s.shift(),r.queue_s.length&&r.queue_s[0]()}}};r.queue_s=r.queue_s||[],r.queue_s.push(h(e)),1===r.queue_s.length&&r.queue_s[0]()}};lh=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},fin_=function(){console.log("execute fin"),this.eof_=!0,this.queue_=[],this.queue_s=[],this.cid_&&(this.cid_===Ss?(console.log("sending db_end CIC "+this.cid_.circId+" sid "+this.sid_),this.cid_.send_db_end(1,this.sid_)):this.d_lengthStopping download, please wait that pending data are processed, use resume to restart

")},500)),1===this.queue_.length&&this.queue_[0]())};var A=function(e,t){Lh('

Error: '+t+" - This media can not be streamed, please use Download

"),lh(nh),dh.call(e)};fh=function(e){var t=e.content_;if(console.log("init_media "+t),-1===t.indexOf("json")&&(-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||e._streaming_))-1===t.indexOf("video")&&-1===t.indexOf("audio")||!e._parent_?(Lh('

Error: not an audio/video file - This media can not be streamed, please use Download

'),document.body.removeChild(nh),dh.call(e)):(e._parent_.connected_sources++,e._parent_.connected_sources===e._parent_.nb_sources.length&&(console.log("play media"),Lh('

Connected... the video is going to start, please wait

'),Th.play()));else if(!Th.parentNode){console.log("stream"),lh(Th),Th=document.createElement("video"),Th.className="mediasrc",Th.controls=!0,e._json_="",e._stream_=new ih,Th.src=URL.createObjectURL(e._stream_),Th._stream_=e._stream_,nh.appendChild(Th),$a(sh,"mousedown",function(){lh(nh),lh(Th),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!0);var r=function(){if(-1===t.indexOf("json"))-1!==t.indexOf("webm")?(e.nb_sources=[],e._streaming_=!0,e._source_=e._stream_.addSourceBuffer('video/webm; codecs="vp8,vorbis"'),console.log("play media"),Lh('

Connected... the video is going to start, please wait

'),Th.play()):(e.nb_sources=[],e._streaming_=!0,e.mp4box=new ki,Lh('

Connected... Analyzing if this video can be streamed, please wait

'),e.mp4box_t0=setTimeout(function(){A(e,"mp4box timeout")},Sa),e.mp4box.onReady=function(t){if(clearTimeout(e.mp4box_t0),console.log("play media"),Lh('

Connected... the video is going to start, please wait

'),Th.play(),t.tracks){for(;t.tracks.length;){var r=t.tracks.shift();if(r){console.log(r.codec);var i='video/mp4; codecs=" '+r.codec+'"',n=!1;if(ih.isTypeSupported(i)){n=!0;var s={append_buffer:[]};s._stream_=e._stream_,s._source_=e._stream_.addSourceBuffer(i),s.pieces=e.pieces,s.received_=0,s.append_cursor=0,s.clength_=e.clength_,s.d_length_=0,e.mp4box.onSegment=function(e,t,r){r=new Uint8Array(r),t.received_++,t.append_buffer.push(r),1===t.received_&&(Wa("alert_box").style.display="none",t._source_.addEventListener("updateend",function(){Do(t)})),Do(t)},e.mp4box.setSegmentOptions(r.id,s)}n||A(e,"codec not supported")}}for(var a=e.mp4box.initializeSegmentation();a.length;){var o=a.shift();o.user.append_buffer.push(new Uint8Array(o.buffer))}}},e.mp4box.onError=function(){console.log("mp4box error"),A(e,"mp4box error")});else for(;e._wait_open.length;)e._wait_open.shift()()};$a(e._stream_,"webkitsourceopen",r,!1),$a(e._stream_,"sourceopen",r,!1),e._stream_.addEventListener("sourceclose",function(){console.log("SOURCE CLOSED"),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!1),Th.addEventListener("seeking",function(){}),Th.addEventListener("pause",function(){}),Th.addEventListener("play",function(){}),Th.addEventListener("error",function(){Lh('

Error: Media Source error - This media can not be streamed or something unexpected happened

'),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e);try{e._stream_.endOfStream()}catch(t){}})}};var I=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu"),lh(this.thumb_)},T=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=this,r=function(){if(this.value){var e=Ya(),r=e.get(t.hash_ini);r.onsuccess=function(r){r.target.result&&(r.target.result.name=this.value,t.name_=this.value,e.put(r.target.result),t.thumb_&&d(t),u(t))}.bind(this)}};Uh("

Enter new name:

",r)},x=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=Ya();t.delete(this.hash_ini),lh(this.thumb2_),lh(this.thumb_)},B=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=this;r.nb_try++,r.db_try=0,r.params_.db_=!0,r.reload_=!0,r.sid_&&(delete r.cid_[r.sid_],delete r.sid_),delete r.cid_,delete r.eof_,delete r.check_hash,delete r.last_saved,delete r.file_id,delete r.start_t0,Fh(r.query_t0),r.name_=this.name_||"",r.queue_=[],r.queue_s=[],r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu"),lh(r.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},k=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=H(this.url_,this.hash_ini);r.clength_=this.clength_,r.d_length=this.d_length,r.content_=this.content_,r.reload2_=!0,r.thumb2_=this.thumb2_,delete r.eof_,delete r.last_saved,delete r.file_id,delete r.start_t0,r.queue_=[],r.queue_s=[],r.name_=this.name_||"",Fh(r.query_t0),r.nb_try++,r.db_try=0,r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu2"),lh(this.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},R=function(){var e=this.key;F("menu2"),$a(document.body,"mousedown",function(){},!1),e?setTimeout(function(){Lh("

"+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

")},800):Lh("

"+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

"),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e?new t(e,"hex"):No(16),i=this.blob_,n=i.size,s={file_hash:"00",hash_ini:c(),name_:e?h(this.name_):this.name_+"."+Qs,clength_:n,d_length:0,content_:this.content_,url_:this.url_,key:e?"":r.toString("hex"),content_chrome:e?null:Ji?"application/binary":null,blob_:Ji?new t(0):new Blob([],{type:e?this.content_:"application/octet-binary"}),queue_:[]},a=0;if(e){var o=Ya(),l=o.get(this.hash_ini);l.onsuccess=function(t){if(t.target.result){var r=t.target.result;r.key=e,this.key=e,$a(this.thumb2_,"mousedown",P.bind({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,content_chrome:this.content_chrome,blob_:this.blob_}),!1),o.put(r)}}.bind(this)}var u=new Worker(URL.createObjectURL(new Blob([qh]))),d=[];if(v)var f=Date.now();u.onmessage=function(t){var r=t.data,i=r instanceof Array?r[0]:r;r instanceof Array||(a+=i.length);var s=a;if(f&&(console.log("worker perf "+(Date.now()-f)),f=Date.now()),d.push(i),0===a%$s||a===n){var o=d,c=function(){Wa("progint-alert").style.width=parseInt(100*(s/n))+"%",r instanceof Array?(this.check_hash=!0,this.file_hash=i,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",ah(this,!0)):(this.file_hash="00",this.d_length=s,b(this,Ji?o:new Blob(o,{type:e?this.content_:"application/octet-binary"})))}.bind(this);d=[],this.queue_.push(c),1===this.queue_.length&&this.queue_[0]()}}.bind(s),u.postMessage(["aes-128-ctr",i,r,Ln])},U=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,R.call({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_})},D=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t={file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,content_:this.content_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_};if(this.blob_.type!==this.content_||"enc"===Bo(this.name_))if(this.key)R.call(t);else{var r=function(){var e=this.value;32===e.length?(t.key=e,R.call(t)):setTimeout(function(){Lh("

Please enter a valid key

")},800)};Uh("

Enter key:

",r)}else Lh("

This is not an encrypted file

")},N=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Lh("
  • Hash Name: "+this.hash_ini+"
  • File hash: "+this.file_hash+"
  • File Type: "+this.content_+"
  • File size: "+this.clength_+" bytes
  • Current size: "+this.d_length+" bytes
  • Key: "+((this.content_chrome?1:this.content_!==this.blob_.type||"enc"===Bo(this.name_))?this.key?this.key:"Get the encryption key from peer":"Not encrypted")+"
  • ")},L=function(e,t){var r=Wa(e);r&&(r.event_&&eo(r,"mousedown",r.event_,!1),r.event_=t.bind(this),$a(r,"mousedown",r.event_,!1))},O=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=Wa("menu2");t.style.display="none",t=Wa("menu"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete",I),L.call(this,"reload",B),this.clength_===this.d_length?Oh(Wa("reload")):Ph(Wa("reload"))},P=function(e){if(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Ss&&Qn>=1){var t=Wa("menu");t.style.display="none",t=Wa("menu2"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open2").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete2",x),L.call(this,"rename2",T),L.call(this,"property2",N),this.d_length===this.clength_?Oh(Wa("reload2")):(Ph(Wa("reload2")),L.call(this,"reload2",k));var r=this.blob_.type||(this.content_chrome?this.content_chrome:this.content_);this.key||r!==this.content_||"enc"===Bo(this.name_)?(Oh(Wa("encrypt2")),Ph(Wa("decrypt2")),L.call(this,"decrypt2",D)):(Ph(Wa("encrypt2")),L.call(this,"encrypt2",U),Oh(Wa("decrypt2")))}else Lh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},F=function(e){var t=Wa(e);t.style.display="none"};Sh=function(){var e=Wa("menu");e.style.display="none",e=Wa("menu2"),e.style.display="none",Wa("alert_box").style.display="none",Wa("prompt_box").style.display="none"},rh=function(e){e.blob_?(e.check_hash&&(e.file_hash=e.check_hash.digest("hex")),console.log("Blob loaded "+e.d_length+" "+(e.file_hash||"")),ah(e),lh(e.bar_)):lh(e.bar_)},$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),$a(Wa("dialog-message"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1);var q=function(e,t){if(Ss&&Qn>1){console.log("Start loading url");var r=H(e,null,t);r.d_length=0,lh(r.thumb_),lh(Wa(r.hash_ini)),t?Th.parentNode||M(r):(r.bar_=uh(Wa("downloaded"),r),lh(Th),lh(nh)),(r.bar_||r._stream_&&ih&&!Th.parentNode)&&rc(r)}else Lh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},H=function(e,r,i){if(!r){var n=so(e);if(n)r=n,e="";else if(-1!==e.indexOf("http")||-1!==e.indexOf("https")){var s=sn.createhash("sha1");s.update(new t(e,"utf8")),r=s.digest("hex")}else r=e,e=""}var a=Jo(e);a.params_.hash_=new t(r,"hex"),a.hash_ini=r,a.url_=e,e=ho(e),a.params_.stream=yo(e.host,e.rest),a.params_.host=e.host+":"+("https"===e.protcol?"443":"80"),a.params_.db_=!0,a.cid_=Ss,a.download_=[],a.d_length=0,a.nb_try=0;var o=e.rest.split("/");return a.name_=o.length?o[o.length-1]:"",a._write_=function(e){S(e,this)},a.queue_=[],a.db_try=0,a.sendme_tout=[],a.waiting_=[],a.queue_s=[],a._stream_=i||!1,i&&(a.stream_buffer=[],a.append_buffer=[],a.append_cursor=0,a.append_wait=new t(0),a.nb_sources=[],a.connected_sources=0,a.debug_chunk=[],a.append_to=[],a._wait_open=[]),a},M=function(e){ih=window.MediaSource||window.webkitMediaSource||window.WebKitMediaSource||window.webkitMediaSource||window.MozMediaSource||!1,ih?(nh=document.createElement("div"),nh.className="media",document.body.appendChild(nh),sh=document.createElement("div"),sh.className="boxclose",nh.appendChild(sh),$a(sh,"mousedown",function(){lh(nh),lh(Th),dh.call(e)},!0)):Lh('

    Media Source is not available in your browser, so streaming is not possible, please update it or try with Chrome browser.

    ')},j=function(){e(),r(),chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),$a(Wa("chart1"),"mousedown",function(){Ys?clearInterval(chart1_int):chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),Ys=!Ys},!1),$a(Wa("chart2"),"mousedown",function(){Ws?clearInterval(chart2_int):chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),Ws=!Ws},!1)},z=function(){Ha.list=function(e){var t=Ha.db.transaction([Xa],"readwrite").objectStore(Xa);t.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;e(i),r.continue()}else ch&&Hh()}},Ha.list(V)},V=function(e){Ji&&(e.data=new Blob(e.data,{type:e.enc?e.enc:e.type}));var t=_(e,e.name_hash);Wa("local").appendChild(t),$a(t,"mousedown",P.bind({file_hash:e.hash,hash_ini:e.name_hash,name_:e.name,thumb2_:t,clength_:e.file_length,d_length:e.current_length,content_:e.type,url_:e.file_url,key:e.key,content_chrome:e.enc||"",blob_:e.data}),!1),e.file_length!==e.current_length&&(t.firstChild.style.backgroundColor="orange")};if(Eh){var K=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="Direct, P2P and bittorrent anonymized circuits : "+K+(K>1?" circuits":" circuit"),Ph(Wa("direct_text")),Ph(Wa("peer_text"))}else{var G=document.createElement("script");G.src="http://www.peersm.com/gchart.js",G.onload=j,document.body.appendChild(G)}Wa("prompt-input").removeAttribute("type"),z()}}}})}(); \ No newline at end of file +},gl.stscBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.first_chunk=new Array,this.samples_per_chunk=new Array,this.sample_description_index=new Array,0==this.version)for(r=0;t>r;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;tt;t++)this.sample_sizes[t]=r;else this.data=e.readUint8Array(this.size)},gl.stszBox.prototype.unpack=function(e){var t;for(t=0;tt&&this.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0},gl.TRUN_FLAGS_DATA_OFFSET=1,gl.TRUN_FLAGS_FIRST_FLAG=4,gl.TRUN_FLAGS_DURATION=256,gl.TRUN_FLAGS_SIZE=512,gl.TRUN_FLAGS_FLAGS=1024,gl.TRUN_FLAGS_CTS_OFFSET=2048,gl.trunBox.prototype.parse=function(e){var t=0;if(this.parseFullHeader(e),this.sample_count=e.readUint32(),t+=4,this.size>t&&this.flags&gl.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size>t&&this.flags&gl.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=new Array,this.sample_size=new Array,this.sample_flags=new Array,this.sample_composition_time_offset=new Array,this.size>t)for(var r=0;rt;t++){var s={};if(this.samples[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],n=e.readUint16(),n>0)for(r=0;n>r;r++){var a={};s.subsamples.push(a),a.size=1==this.version?e.readUint32():e.readUint16(),a.priority=e.readUint8(),a.discardable=e.readUint8(),a.reserved=e.readUint32()}}},gl.Box.prototype.writeHeader=function(e){this.size+=8,this.size>_l&&(this.size+=8),this.size>_l?e.writeUint32(1):(this.sizePosition=e.position,e.writeUint32(this.size)),e.writeString(this.type,null,4),this.size>_l&&e.writeUint64(this.size)},gl.FullBox.prototype.writeHeader=function(e){this.size+=4,gl.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},gl.Box.prototype.write=function(e){this.size=this.data.length,this.writeHeader(e),this.data&&e.writeUint8Array(this.data)},gl.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t-1&&this.moov.boxes.splice(t,1)}var n=new gl.mvexBox;this.moov.boxes.push(n);var s=new gl.mehdBox;n.boxes.push(s),s.fragment_duration=this.initial_duration;for(var r=0;r0?this.moov.traks[r].samples[0].duration:0,a.default_sample_size=0,a.default_sample_flags=65536}this.moov.write(e)},Bi.prototype.resetTables=function(){var e,t,r,i,n,s,a,o;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;et?(w.chunk_index=d,w.chunk_run_index=u):(p=0,d++,w.chunk_index=d,f>d?w.chunk_run_index=u:u=g&&(m++,0>g&&(g=0),g+=a.sample_counts[m]),t>0?(w.dts=r.samples[t-1].dts+a.sample_deltas[m],r.samples[t-1].duration=w.dts-r.samples[t-1].dts):w.dts=0,o?(t>=y&&(v++,0>y&&(y=0),y+=o.sample_counts[v]),w.cts=r.samples[t].dts+o.sample_offsets[v]):w.cts=w.dts,c?t==c.sample_numbers[b]-1?(w.is_rap=!0,b++):w.is_rap=!1:w.is_rap=!0,h&&h.samples[subs_entry_index].sample_delta+last_subs_sample_index==t&&(w.subsamples=h.samples[subs_entry_index].subsamples,last_subs_sample_index+=h.samples[subs_entry_index].sample_delta)}t>0&&(r.samples[t-1].duration=r.mdia.mdhd.duration-r.samples[t-1].dts)}},Bi.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t0?p.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(p.dts=h.tfdt?h.tfdt.baseMediaDecodeTime:0,u.first_traf_merged=!0),p.cts=p.dts,f.flags&gl.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+f.sample_composition_time_offset[r]),sample_flags=a,f.flags&gl.TRUN_FLAGS_FLAGS?sample_flags=f.sample_flags[r]:0==r&&f.flags&gl.TRUN_FLAGS_FIRST_FLAG&&(sample_flags=f.first_sample_flags),p.is_rap=1&sample_flags>>16?!1:!0;var _=h.tfhd.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?!0:!1,g=h.tfhd.flags&gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?!0:!1,m=f.flags&gl.TRUN_FLAGS_DATA_OFFSET?!0:!1,y=0;y=_?tfhd.base_data_offset:g?l.inputStart:0==t?l.inputStart:o,p.offset=0==t&&0==r?m?y+f.data_offset:y:o,o=p.offset+p.size}}if(h.subs){var v=h.first_sample_index;for(t=0;t0&&(t+=","),t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t},Bi.prototype.getTrackById=function(e){for(var t=0;t=this.log_level&&console.log("[MP4Box] "+t)},ki.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.stream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples),void 0!=r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},ki.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r-1&&this.fragmentedTracks.splice(t,1)},ki.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples)}},ki.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r-1&&this.extractedTracks.splice(t,1)},ki.prototype.createSingleSampleMoof=function(e){var t=new gl.moofBox,r=new gl.mfhdBox;r.sequence_number=this.nextMoofNumber,this.nextMoofNumber++,t.boxes.push(r);var i=new gl.trafBox;t.boxes.push(i);var n=new gl.tfhdBox;i.boxes.push(n),n.track_id=e.track_id,n.flags=gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new gl.tfdtBox;i.boxes.push(s),s.baseMediaDecodeTime=e.dts;var a=new gl.trunBox;return i.boxes.push(a),t.trun=a,a.flags=gl.TRUN_FLAGS_DATA_OFFSET|gl.TRUN_FLAGS_DURATION|gl.TRUN_FLAGS_SIZE|gl.TRUN_FLAGS_FLAGS|gl.TRUN_FLAGS_CTS_OFFSET,a.data_offset=0,a.first_sample_flags=0,a.sample_count=1,a.sample_duration=new Array,a.sample_duration[0]=e.duration,a.sample_size=new Array,a.sample_size[0]=e.size,a.sample_flags=new Array,a.sample_flags[0]=0,a.sample_composition_time_offset=new Array,a.sample_composition_time_offset[0]=e.cts-e.dts,t},ki.prototype.createFragment=function(e,t,r,i){var n=this.inputIsoFile.getTrackById(t),s=n.samples[r];if(this.inputStream.byteLength=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending fragmented data on track #"+t.id+" for sample "+t.nextSample),this.onSegment(t.id,t.user,t.stream.buffer),t.stream=null)}for(var e=0;e=s.offset+s.size))return;n.nextSample++,this.inputStream.seek(s.offset),s.data=this.inputStream.readUint8Array(s.size),n.samples.push(s),this.onSamples&&(0==n.nextSample%n.nb_samples||n.nextSample>=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending samples on track #"+n.id+" for sample "+n.nextSample),this.onSamples(n.id,n.user,n.samples),n.samples=[])}},ki.prototype.appendBuffer=function(e){var t=this.open(e);t&&this.processSamples()},ki.prototype.getInfo=function(){var e={};e.duration=this.inputIsoFile.moov.mvhd.duration,e.timescale=this.inputIsoFile.moov.mvhd.timescale,e.isFragmented=null!=this.inputIsoFile.moov.mvex,e.isFragmented&&(e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration),e.isProgressive=this.inputIsoFile.isProgressive,e.hasIOD=null!=this.inputIsoFile.moov.iods,e.brands=[],e.brands.push(this.inputIsoFile.ftyp.major_brand),e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);var t=new Date(4,0,1,0,0,0,0).getTime();for(e.created=new Date(t+1e3*this.inputIsoFile.moov.mvhd.creation_time),e.modified=new Date(t+1e3*this.inputIsoFile.moov.mvhd.modification_time),e.tracks=new Array,e.audioTracks=new Array,e.videoTracks=new Array,e.subtitleTracks=new Array,e.metadataTracks=new Array,e.hintTracks=new Array,i=0;i1)for(i=0;iWebsocket was closed by remote party for unknown reasons, this might be a temporary network problem, if the system does not recover please refresh the page

    "),Cl=wc($i)})};if(El&&(js||(El.associate=function(e,r){var i=ho(fo(r.split(".")[1]));i=i.host,console.log("real domain requested "+i);var n=i.split("."),s=n.length>1?[n[n.length-2],n[n.length-1]].join("."):i;bs[r]={real_domain:i,real_domain_a:n,real_domain_s:s,associated:!0},console.log("OP SEND ASSOCIATE CID "+Cs.circId+" "+r); +var a=new t(r,"utf8"),o=new qo(qo.prototype.RELAY_ASSOCIATE,0,a,e.Df_hash),c=new Po(e.circId,Po.prototype.RELAY,e.stream_encrypt_forward(o));e.send(c)}),El.connect(Dn)),s&&!function(){var e=function(){var e={};Xo.call(e),e.params_={},e.params_.OP=!0,e.params_.nb_hop=Hn,e.params_.one_c=!0,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),e.i_id=Vs,Vs++,e.params_.host="www.kickstarter.com:80";var r=new Date,i="GET /projects/450023/ianonym-internet-privacy-everywhere-from-any-devic/pledge/new?clicked_reward=false&ref=category HTTP/1.1\r\n";if(i+="Host: www.kickstarter.com\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="last_page=http%3A%2F%2Fwww.kickstarter.com%2Fprojects%2F450023%2Fianonym-internet-privacy-everywhere-from-any-devic%3Fref%3Dcategory; request_time=Sun%2C+30+Jun+2013+"+r.getHours()+"%3A"+r.getMinutes()+"%3A"+r.getSeconds()+"+-0000; local_offset=-5798;mp_75b1d24a516ecfc955eadfadc4910661_mixpanel=%7B%22distinct_id%22%3A%20%2213f8f454878706-00471d2d6-516e3c71-1aeaa0-13f8f4548796c1%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D",i+="\r\n",e.params_.stream=new t(i,"utf8"),e.remotePort="60000",e.remoteAddress="1.2.3.4",e.write=function(){},e.end=function(){},e.destroy=function(){},e.close=function(){},e._init_=Xo,e._write_=e.write,Qn>=5){rc(e);var n=function(){e.cid_.destroy()};setTimeout(n,1e4)}};setInterval(e,1e4+Math.floor(6e4*Math.random()))}(),A&&!I){var Tl=function(e){return 13==e.keyCode?(this.blur(),!0):!1};if(ks){var xl,Bl=new t("00112233445566778899001122334455","hex"),kl=document.body,Rl=document.getElementsByTagName("head"),Ul="http://www.lepoint.fr",Dl=function(){var e=Nl();return e.className="rounded",kl.appendChild(e),e},Nl=function(){var e=document.createElement("div"),t=e.style;return t.marginLeft="1%",Ll(e,"left"),t.width="98%",t.textAlign="center",t.color="#000",t.fontWeight="800",t.fontSize="1em",t.background="white",t.borderWidth="1px",t.borderStyle="solid",t.borderColor="rgb(217,217,217)",e},Ll=function(e,t){var r=e.style;r.styleFloat=t,r.cssFloat=t},Ol=function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)};Rl.length&&Ol(Rl.item(0)),Ol(kl);var Pl=' html { border:0; padding:0; border:0; } body { font-family: Arial,"Trebuchet MS",helvetica,sans serif; font-size: 14px; font-style: normal; font-weight: normal; text-decoration: none; height: 100%; width:100%; margin:auto; padding:0; background-color:black !important; } p { margin-left:1%; margin-right:1%; } a { margin:1%; } div.ew{ border:0; margin:0; padding:0; -webkit-tap-highlight-color:rgba(0,0,0,0); } .rounded { -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; } input.ew{ font-size:1.2em; -webkit-border-radius:7px; -moz-border-radius:7px; border-radius:7px; border:1px solid; }',Fl=document.createElement("STYLE");Fl.appendChild(document.createTextNode(Pl)),kl.appendChild(Fl);var ql=Dl(),Hl=document.createElement("INPUT"),Ml=Hl.style;Hl.className="ew",Ml.width="80%",Ml.padding="1%",Ml.marginTop="1%",Ml.marginBottom="1%",Ml.marginLeft="1%",Ml.textAlign="center",Ml.color="#000",Hl.value=xl||Ul,ql.appendChild(Hl),Hl.onkeydown=function(e){Tl.call(this,e||window.event)&&""!==this.value&&Gl(this.value)},Hl.onmousedown=function(){this.value===Ul&&(this.value="")};var jl=document.createElement("SPAN"),zl=jl.style;jl.className="ew",zl.padding="1%",zl.width="8%",zl.cursor="pointer",jl.className="rounded",zl.marginTop="1%",zl.marginLeft="1%",zl.backgroundColor="#387BAF",zl.color="white",jl.innerHTML="OK",ql.appendChild(jl),jl.onmousedown=function(){""!==Hl.value&&Gl(Hl.value)};var Vl=Dl();Vl.style.marginTop="1%",Vl.style.textAlign="left",Vl.innerHTML='

    How to use it :

    First please set your proxy settings (Options/Advanced/Network/Settings) to "Automatic proxy configuration" with the value "http://www.ianonym.com/proxy.pac". Then, reload this page. When you are finished don\'t forget to restore the settings to the previous value (No Proxy normally). You should see below the message "Websocket connected", if not, clear the history, close your browser and reopen it.

    Replace "www.example.com" by the URL that you want to open, then click on OK and click on the url proposed. This will establish a secure connection between the new page that was open after you clicked and the current page.

    The new page should indicate that you have initiated an untrusted connection because the certificate created for this connection is self signed, click that you "understand the risks", "Add Exception", and confirm.

    The page will reload and you can start surfing anonymously. If you surf to another site you will have to confirm the exception again, that\'s a little bit painfull but at least you are sure that you are secured. If you have some doubts about your connection, you can first try the Interception Detector.

    This will ensure that you are not intercepted and you can be totally sure to be anonym since all exchanges are encrypted and the domain where you are going looks the same as the link that you clicked, so is hidden, nobody except your browser (the initial page) can decrypt the messages and know the real domain.

    ';var Kl=Dl();Kl.style.marginTop="1%",Kl.style.paddingBottom="1%",Kl.style.textAlign="left",r&&(Vl.style.display="none");var Gl=function(e){var t=ho(e);t.host&&(protocol=t.protocol,Es="www."+fo(t.host,!0)+ms,Qn>=2&&Cs?(console.log("START PAGE real "+e+" fake http://"+Es),El.associate(Cs,Es),Kl.innerHTML='

    Click on the link below :

    http'+Ds+"://"+Es+"/"+t.rest+""):alert("Not enough circuits established : "+Qn+" - Please wait and retry"))};try{var Yl=128,Wl=5,Ql=256,Xl=document.createElement("canvas");Xl.width=4*Ql,Xl.height=4*Ql,Xl.style.position="absolute",Xl.style.zIndex=-1,Xl.style.top="70%",Xl.style.left="50%",Xl.style.marginLeft=-(Xl.width/2)+"px",Xl.style.marginTop=-(Xl.height/2)+"px",document.body.appendChild(Xl);var Jl=Xl.getContext("2d"),Zl=document.createElement("canvas");Zl.width=Ql,Zl.height=Ql;var $l=Zl.getContext("2d");$l.beginPath(),$l.arc(Ql/2,Ql/2,Ql/2,0,2*Math.PI,!0);var eh=function(e){$l.fillStyle=e,$l.fill();for(var t=0;Yl>t;t++){var r=Ql+t*Wl,i=.5*r,n=2*Ql-i,s=2*Ql-i;Jl.globalAlpha=2*Ql/(20*(t+4)*(t+4)),Jl.drawImage(Zl,n,s,r,r)}};eh("rgb(106,253,123)")}catch(th){document.body.style.backgroundColor="black",document.body.style.backgroundColor="radial-gradient(circle at center top, #bdd8df, black)"}}if(Us){var vl,rh,ih,nh,sh,ah,oh,ch,lh,Ya,hh,uh,dh,fh,ph,_h,gh,mh,yh,vh,bh,wh,Eh,Ch,Sh,Ah,Ih,Qi,Th=!1,xh={},Bh=0,kh=0,Rh=0,Uh=100,Dh=function(e,t){Wa("prompt_box").style.display="block",Wa("prompt-message").innerHTML=e,Wa("prompt-input").value="",Wa("prompt-input").submit=t,$a(Wa("prompt-input"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1),$a(Wa("prompt-input"),"keydown",function(e){Tl.call(this,e||window.event)&&""!==this.value&&(Wa("prompt_box").style.display="none",this.submit())},!1)},Nh=Wa("close_prompt");$a(Nh,"mousedown",function(){Wa("prompt_box").style.display="none",Wa("prompt-input").submit()},!1);var Lh=Wa("close_alert");$a(Lh,"mousedown",function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},!1);var Oh=function(e){setTimeout(function(){Wa("alert_box").style.display="block"},500),Wa("dialog-message").innerHTML=e},Ph=function(e){e.style.display="none"},Fh=function(e){e.style.display="block"},qh=function(e){e&&e.forEach(function(e){clearTimeout(e)}),e=[]},Hh='var forge={};(function(){var a=forge.util=forge.util||{};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){a.setImmediate=setImmediate;a.nextTick=function(b){return setImmediate(b)}}else{a.setImmediate=function(b){setTimeout(b,0)};a.nextTick=a.setImmediate}}else{a.nextTick=process.nextTick;if(typeof setImmediate==="function"){a.setImmediate=setImmediate}else{a.setImmediate=a.nextTick}}a.isArray=Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"};a.ByteBuffer=function(c){this.data=c||"";this.read=0};a.ByteBuffer.prototype.length=function(){return this.data.length-this.read};a.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0};a.ByteBuffer.prototype.putByte=function(c){this.data+=String.fromCharCode(c);return this};a.ByteBuffer.prototype.fillWithByte=function(c,f){c=String.fromCharCode(c);var e=this.data;while(f>0){if(f&1){e+=c}f>>>=1;if(f>0){c+=c}}this.data=e;return this};a.ByteBuffer.prototype.putBytes=function(b){this.data+=b;return this};a.ByteBuffer.prototype.putString=function(b){this.data+=a.encodeUtf8(b);return this};a.ByteBuffer.prototype.putInt16=function(b){this.data+=String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt24=function(b){this.data+=String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt32=function(b){this.data+=String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt16Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255);return this};a.ByteBuffer.prototype.putInt24Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255);return this};a.ByteBuffer.prototype.putInt32Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>24&255);return this};a.ByteBuffer.prototype.putInt=function(b,c){do{c-=8;this.data+=String.fromCharCode((b>>c)&255)}while(c>0);return this};a.ByteBuffer.prototype.putSignedInt=function(b,c){if(b<0){b+=2<<(c-1)}return this.putInt(b,c)};a.ByteBuffer.prototype.putBuffer=function(b){this.data+=b.getBytes();return this};a.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};a.ByteBuffer.prototype.getInt16=function(){var b=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return b};a.ByteBuffer.prototype.getInt24=function(){var b=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return b};a.ByteBuffer.prototype.getInt32=function(){var b=(this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3));this.read+=4;return b};a.ByteBuffer.prototype.getInt16Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8);this.read+=2;return b};a.ByteBuffer.prototype.getInt24Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16);this.read+=3;return b};a.ByteBuffer.prototype.getInt32Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24);this.read+=4;return b};a.ByteBuffer.prototype.getInt=function(c){var b=0;do{b=(b<<8)+this.data.charCodeAt(this.read++);c-=8}while(c>0);return b};a.ByteBuffer.prototype.getSignedInt=function(d){var c=this.getInt(d);var b=2<<(d-2);if(c>=b){c-=b<<1}return c};a.ByteBuffer.prototype.getBytes=function(b){var c;if(b){b=Math.min(this.length(),b);c=this.data.slice(this.read,this.read+b);this.read+=b}else{if(b===0){c=""}else{c=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return c};a.ByteBuffer.prototype.bytes=function(b){return(typeof(b)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+b))};a.ByteBuffer.prototype.at=function(b){return this.data.charCodeAt(this.read+b)};a.ByteBuffer.prototype.setAt=function(d,c){this.data=this.data.substr(0,this.read+d)+String.fromCharCode(c)+this.data.substr(this.read+d+1);return this};a.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};a.ByteBuffer.prototype.copy=function(){var b=a.createBuffer(this.data);b.read=this.read;return b};a.ByteBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};a.ByteBuffer.prototype.clear=function(){this.data="";this.read=0;return this};a.ByteBuffer.prototype.truncate=function(c){var b=Math.max(0,this.length()-c);this.data=this.data.substr(this.read,b);this.read=0;return this};a.ByteBuffer.prototype.toHex=function(){var e="";for(var d=this.read;d0){if(d&1){b+=e}d>>>=1;if(d>0){e+=e}}return b};a.xorBytes=function(j,f,l){var e="";var d="";var h="";var g=0;var k=0;for(;l>0;--l,++g){d=j.charCodeAt(g)^f.charCodeAt(g);if(k>=10){e+=h;h="";k=0}h+=String.fromCharCode(d);++k}e+=h;return e};a.hexToBytes=function(c){var d="";var b=0;if(c.length&1==1){b=1;d+=String.fromCharCode(parseInt(c[0],16))}for(;b>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255))};a.encodeUtf8=function(b){return unescape(encodeURIComponent(b))};a.decodeUtf8=function(b){return decodeURIComponent(escape(b))};a.deflate=function(e,c,d){c=a.decode64(e.deflate(a.encode64(c)).rval);if(d){var f=2;var b=c.charCodeAt(1);if(b&32){f=6}c=c.substring(f,c.length-4)}return c};a.inflate=function(d,b,c){var e=d.inflate(a.encode64(b)).rval;return(e===null)?null:a.decode64(e)}})();(function(){var e=forge.sha1=forge.sha1||{};forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};forge.md.sha1=forge.md.algorithms.sha1=e;var c=null;var b=false;var d=function(){c=String.fromCharCode(128);c+=forge.util.fillString(String.fromCharCode(0),64);b=true};var a=function(r,p,u){var q,o,n,m,l,k,j,g;var h=u.length();while(h>=64){o=r.h0;n=r.h1;m=r.h2;l=r.h3;k=r.h4;for(g=0;g<16;++g){q=u.getInt32();p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<20;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<32;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<40;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<60;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=(n&m)|(l&(n^m));q=((o<<5)|(o>>>27))+j+k+2400959708+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<80;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+3395469782+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}r.h0+=o;r.h1+=n;r.h2+=m;r.h3+=l;r.h4+=k;h-=64}};e.create=function(){if(!b){d()}var f=null;var i=forge.util.createBuffer();var g=new Array(80);var h={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};h.start=function(){h.messageLength=0;i=forge.util.createBuffer();f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return h};h.start();h.update=function(k,j){if(j==="utf8"){k=forge.util.encodeUtf8(k)}h.messageLength+=k.length;i.putBytes(k);a(f,g,i);if(i.read>2048||i.length()===0){i.compact()}return h};h.digest=function(){var j=h.messageLength;var m=forge.util.createBuffer();m.putBytes(i.bytes());m.putBytes(c.substr(0,64-((j+8)%64)));m.putInt32((j>>>29)&255);m.putInt32((j<<3)&4294967295);var k={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(k,g,m);var l=forge.util.createBuffer();l.putInt32(k.h0);l.putInt32(k.h1);l.putInt32(k.h2);l.putInt32(k.h3);l.putInt32(k.h4);return l};h.digest2=function(){var j=h.messageLength;var o=forge.util.createBuffer();var k=forge.util.createBuffer(i.data.slice(i.read));var m=g.slice(0);o.putBytes(i.bytes());o.putBytes(c.substr(0,64-((j+8)%64)));o.putInt32((j>>>29)&255);o.putInt32((j<<3)&4294967295);var l={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(l,g,o);var n=forge.util.createBuffer();n.putInt32(l.h0);n.putInt32(l.h1);n.putInt32(l.h2);n.putInt32(l.h3);n.putInt32(l.h4);i=k;g=m;return n};return h};e.createhash=function(){var g=e.create();var f=g.update;g.update=function(h){return f(h.toString("binary"))};g.digest=function(){return g.digest2().toHex()};return g}})();(function(){var j=false;var h=4;var f;var b;var d;var k;var g;var e=function(){j=true;d=[0,1,2,4,8,16,32,64,128,27,54];var x=new Array(256);for(var p=0;p<128;++p){x[p]=p<<1;x[p+128]=(p+128)<<1^283}f=new Array(256);b=new Array(256);k=new Array(4);g=new Array(4);for(var p=0;p<4;++p){k[p]=new Array(256);g[p]=new Array(256)}var s=0,o=0,v,t,q,w,l,u,r;for(var p=0;p<256;++p){w=o^(o<<1)^(o<<2)^(o<<3)^(o<<4);w=(w>>8)^(w&255)^99;f[s]=w;b[w]=s;l=x[w];v=x[s];t=x[v];q=x[t];u=(l<<24)^(w<<16)^(w<<8)^(w^l);r=(v^t^q)<<24^(s^q)<<16^(s^t^q)<<8^(s^v^q);for(var m=0;m<4;++m){k[m][s]=u;g[m][w]=r;u=u<<24|u>>>8;r=r<<24|r>>>8}if(s===0){s=o=1}else{s=v^x[x[x[v^q]]];o^=x[x[o]]}}};var a=function(z,o){var x=z.slice(0);var B,m=1;var r=x.length;var p=r+6+1;var s=h*p;for(var u=r;u>>16&255]<<24^f[B>>>8&255]<<16^f[B&255]<<8^f[B>>>24]^(d[m]<<24);m++}else{if(r>6&&(u%r===4)){B=f[B>>>24]<<24^f[B>>>16&255]<<16^f[B>>>8&255]<<8^f[B&255]}}x[u]=x[u-r]^B}if(o){var t;var D=g[0];var C=g[1];var A=g[2];var y=g[3];var v=x.slice(0);var s=x.length;for(var u=0,l=s-h;u>>24]]^C[f[t>>>16&255]]^A[f[t>>>8&255]]^y[f[t&255]]}}}x=v}return x};var c=function(u,v,t,o){var q=u.length/4-1;var p,n,m,l,s;if(o){p=g[0];n=g[1];m=g[2];l=g[3];s=b}else{p=k[0];n=k[1];m=k[2];l=k[3];s=f}var D,C,A,z,E,r,x;D=v[0]^u[0];C=v[o?3:1]^u[1];A=v[2]^u[2];z=v[o?1:3]^u[3];var y=3;for(var B=1;B>>24]^n[C>>>16&255]^m[A>>>8&255]^l[z&255]^u[++y];r=p[C>>>24]^n[A>>>16&255]^m[z>>>8&255]^l[D&255]^u[++y];x=p[A>>>24]^n[z>>>16&255]^m[D>>>8&255]^l[C&255]^u[++y];z=p[z>>>24]^n[D>>>16&255]^m[C>>>8&255]^l[A&255]^u[++y];D=E;C=r;A=x}t[0]=(s[D>>>24]<<24)^(s[C>>>16&255]<<16)^(s[A>>>8&255]<<8)^(s[z&255])^u[++y];t[o?3:1]=(s[C>>>24]<<24)^(s[A>>>16&255]<<16)^(s[z>>>8&255]<<8)^(s[D&255])^u[++y];t[2]=(s[A>>>24]<<24)^(s[z>>>16&255]<<16)^(s[D>>>8&255]<<8)^(s[C&255])^u[++y];t[o?1:3]=(s[z>>>24]<<24)^(s[D>>>16&255]<<16)^(s[C>>>8&255]<<8)^(s[A&255])^u[++y]};var i=function(H,r,u,o,v){var m=null;if(!j){e()}v=(v||"CBC").toUpperCase();if(typeof H==="string"&&(H.length===16||H.length===24||H.length===32)){H=forge.util.createBuffer(H)}else{if(forge.util.isArray(H)&&(H.length===16||H.length===24||H.length===32)){var B=H;var H=forge.util.createBuffer();for(var x=0;x>>2;for(var x=0;x=w||(n.length()>0&&l)){F()}};m.update2=function(J){if(J){if(J.length()){n.data=n.data.substr(n.read);n.read=0;n.putBuffer(J)}}while(n.length()>=w){F()}if(m.overflow){y.getBytes(m.overflow)}var M=n.length()%w;if(M){var K=forge.util.createBuffer(n.data.slice(n.read));var L=s.slice(0);while(n.length()>0){F()}n=K;s=L;y.truncate(w-M)}else{n.data="";n.read=0};m.overflow=M};m.finish=function(N){var M=true;var O=n.length()%w;if(!o){if(N){M=N(w,n,o)}else{if(p){var L=(n.length()===w)?w:(w-n.length());n.fillWithByte(L,L)}}}if(M){l=true;m.update()}if(o){if(p){M=(O===0)}if(M){if(N){M=N(w,y,o)}else{if(p){var J=y.length();var K=y.at(J-1);if(K>(h<<2)){M=false}else{y.truncate(K)}}}}}if(!p&&!N&&O>0){y.truncate(w-O)}return M};m.start=function(K,J){if(K===null){K=q.slice(0)}if(typeof K==="string"&&K.length===16){K=forge.util.createBuffer(K)}else{if(forge.util.isArray(K)&&K.length===16){var M=K;var K=forge.util.createBuffer();for(var L=0;L<16;++L){K.putByte(M[L])}}}if(!forge.util.isArray(K)){var M=K;K=new Array(4);K[0]=M.getInt32();K[1]=M.getInt32();K[2]=M.getInt32();K[3]=M.getInt32()}n=forge.util.createBuffer();y=J||forge.util.createBuffer();q=K.slice(0);s=new Array(h);D=new Array(h);l=false;m.output=y;if(["CFB","OFB","CTR"].indexOf(v)!==-1){for(var L=0;L=0;--J){if(s[J]===4294967295){s[J]=0}else{++s[J];break}}for(var J=0;JLoading...please wait

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%",Ih=new t(this.value,"hex");var i=Ih;if(16===i.length){var n=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),s=0,a=Yi.length/2,o="";n.onmessage=function(e){var n=e.data,c=n.pop?n[0]:n;if(s+=c.length/2,Wa("progint-alert").style.width=parseInt(100*(s/a))+"%",n.pop||(o+=c.toString("utf8")),n.pop){Wa("progress-alert").style.display="none";var l=c,h=sn.createcipheriv("aes-128-ctr",i,Ln),u=h.update(new t(l,"hex"),"hex","hex");if(r===u.toString("hex")){Yi="var FindProxyForUrl="+o,eval(Yi);var d,f=FindProxyForUrl("http://"+Es,Es,!0),p=document.location.href.split("#");if(2===p.length){var _=p[1].split("-");2===_.length?(d=_[0].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge"},d=_[1].split(":"),ka={ip:d[0],port:d[1],wsport:0,fing:d[2],o_modulus:d[3],name:"Tor Bridge"}):(d=p[1].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge - "+d[0]})}else Zi=f[1][_o(f[1].length)];if(ka||(ka=f[2]),Zi!==ka&&(Js=!0),on=Guards,$i&&(vl=new pr,vl.setPublic($i.o_modulus,Nn)),setTimeout(function(){Wa("alert_box").style.display="none"},1e4),!ph&&wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.put({k:i.toString("hex")})}else if(!wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.delete(i.toString("hex"))}Ch?Fh(Wa("debug")):Ph(Wa("debug")),setInterval(Qi,ss),Il(),jh()}else Dh("

    Wrong key or someone is trying to hack your connection, please retry:

    ",Ah),Wa("prompt-input").type="password"}},n.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),i,Ln])}else Dh("

    Wrong key length, please retry:

    ",Ah),Wa("prompt-input").type="password"}}},Qi=function(){console.log("updating proxy ----"),Yi=Xi("proxy.pac");var e=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),r="";e.onmessage=function(e){var t=e.data,i=t.pop?t[0]:t;t.pop||(r+=i.toString("utf8")),t.pop&&(Yi="var FindProxyForUrl="+r,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0))},e.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),Ih,Ln])},Wa("alert_box").style.display="none",Wa("prompt-input").type="password","peersm"===Xa?(Dh("

    Public version, click on OK to start the Peersm application:

    ",Ah),Wa("prompt-input").value="00112233445566778899aabbccddeeff",Wa("save").checked="checked"):Dh("

    Enter your key:

    ",Ah);try{Ha=indexedDB.open(Xa,6)}catch(th){return Wa("prompt_box").style.display="none",Oh("

    Your browser does not seem to support all the features required for Peersm. It is recommended to use Firefox version 26 or superior, or Chrome version 32 or superior.

    "),void 0}Ha.onupgradeneeded=function(e){console.log("onupgradeneeded------------------");var t=e.target.result;t.objectStoreNames.contains(Xa+"_")&&t.deleteObjectStore(Xa+"_"),t.objectStoreNames.contains(Xa)&&t.deleteObjectStore(Xa),t.createObjectStore(Xa,{keyPath:"name_hash"}),t.createObjectStore(Xa+"_",{keyPath:"k"})},Ha.onsuccess=function(e){Ha.db=e.target.result;var t=Ha.db.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");oh={},Ji=-1!==Ba.userAgent.indexOf("Chrome")?!0:!1,t.openCursor().onsuccess=function(e){var t=e.target.result;if(t){var r=t.value.k;if(r instanceof Array){var i=t.value,n=i.k[0];oh.hasOwnProperty(n)||(console.log("restoring chunks "+n),oh[n]=i)}else Wa("prompt-input").value=r,Wa("save").checked="checked",ph=!0;t.continue()}else ah?Mh():ch=!0},Wa("debug").checked="checked"},Ha.onerror=function(){console.log("Error opening database")};var jh=function(){var e=function(){mh=new google.visualization.DataTable,mh.addColumn("datetime","Time"),mh.addColumn("number","Received (KB)"),mh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),mh.addRow([r,0,0])}gh={title:"Direct Download : "+(Qn>=0?Qn:0)+" circuits",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:mh.getValue(5,0),max:mh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["green","yellow"]},_h=new google.visualization.LineChart(Wa("chart1")),_h.index=null,_h.dynRow={},_h.dynRow2={},_h.draw(mh,gh)},r=function(){bh=new google.visualization.DataTable,bh.addColumn("datetime","Time"),bh.addColumn("number","Received (KB)"),bh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),bh.addRow([r,0,0])}vh={title:"Peer to peer",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:bh.getValue(5,0),max:bh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["red","orange"]},yh=new google.visualization.LineChart(Wa("chart2")),yh.index=null,yh.dynRow={},yh.dynRow2={},yh.draw(bh,vh)},i=function(e,t,r){for(var i=5,n=go(t.getValue(69,0)).getTime(),s=0;i>s;s++){var a=new Date;a.setTime(n+1e3*(s+1)),t.removeRow(0),t.addRow([a,e.dynRow[a.getTime()]||0,e.dynRow2[a.getTime()]||0]),delete e.dynRow[a.getTime()],delete e.dynRow2[a.getTime()]}-1!==r.title.indexOf("Direct")&&(r.title="Direct Download : "+(Qn>=0?Qn:0)+(Qn>1?" circuits":" circuit")),-1!==r.title.indexOf("Peer")&&(r.title="Peer to Peer : "+(Ss?1:0)+" circuit"),r.hAxis.viewWindow.min=t.getValue(i,0),r.hAxis.viewWindow.max=t.getValue(64,0),r.hAxis.viewWindowMode="explicit",r.animation={duration:4e3,easing:"linear"},e.draw(t,r)},n=Wa("input"),s=document.createElement("input");s.id="url",s.value="Enter_url_or_hash_name_or_magnet_link_or_infohash",n.appendChild(s),Ul=s.value,s.onkeydown=function(e){$a(document.body,"mousedown",function(){},!1),Tl.call(this,e||window.event)&&""!==this.value&&($a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(this.value))};var a=Wa("ok");$a(a,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value)},!1);var o=Wa("stream");$a(o,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value.trim(),!0)},!1),Ya=function(){var e=Ha.db;return e.transaction([Xa],"readwrite").objectStore(Xa)},hh=function(){var e=Ha.db;return e.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_")};var c=function(){var e=sn.createhash("sha1");return e.update(new t(Date.now().toString()+Xa,"utf8")),e.digest("hex")},h=function(e){return e=e.split("."),e.length>1&&e[e.length-1]===Qs&&e.pop(),e.join(".")},u=function(e){setTimeout(function(){Wa("alert_box").style.display="none" +},1e4);var t=Wa(e.hash_ini);e.thumb2_=_(e,e.hash_ini),t?Wa("local").insertBefore(e.thumb2_,t):Wa("local").appendChild(e.thumb2_),e.d_length!==e.clength_&&(e.thumb2_.firstChild.style.backgroundColor="orange",e.thumb_&&(e.thumb_.firstChild.style.backgroundColor="orange")),$a(e.thumb2_,"mousedown",P.bind({file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,url:url,thumb2_:e.thumb2_,thumb_:e.thumb_,clength_:e.clength_,d_length:e.d_length,content_:e.content_,url_:e.url_,key:e.key,content_chrome:e.content_chrome,blob_:e.blob_}),!1),lh(t)},d=function(e){var t=e.thumb_;e.thumb_=_(e),t?t.parentNode?(Wa("downloaded").insertBefore(e.thumb_,t),lh(t)):Wa("downloaded").appendChild(e.thumb_):Wa("downloaded").appendChild(e.thumb_),$a(e.thumb_,"mousedown",O.bind(e),!1)},f=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,lh(xh),lh(nh),$a(document.body,"mousedown",function(){},!1),Oh("

    Uploading file from your disk to your browser storage...please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=this.files[0],i=[],n={},s=r.name.split("#");if(s.length>1){var a=s[1].split(".");n.name_=s[0]+(a.length>1?"."+a[1]:"")}else n.name_=r.name;n.blob_=Ji?new t(0):r,n.content_=r.type,n.clength_=r.size,n.d_length=r.size,n.url_="",n.queue_=[],n.hash_ini=s.length>1?s[1].split(".")[0]:c();var o=r.size,l=0,h=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"})));h.onmessage=function(e){var r=e.data,s=r.pop?Ji?new t(0):0:r;l+=Ji?s.length:parseInt(s);var a=l;if(Ji){if(i.push(s),0===l%$s||l===o){var c=i,h=function(){Wa("progint-alert").style.width=parseInt(100*a/o)+"%",r.pop?(n.check_hash=!0,n.file_hash=r[0],$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0)):(n.file_hash="00",n.d_length=l,b(n,c))};i=[],n.queue_.push(h),1===n.queue_.length&&n.queue_[0]()}}else Wa("progint-alert").style.width=parseInt(100*a/o)+"%",e.data.pop&&(n.check_hash=!0,n.file_hash=e.data[0],Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0))},h.postMessage([Ji?"hashc":"hash",r])},p=Wa("file_upload");$a(p,"change",f,!1),uh=function(e,t){var r=t.d_length||0,i=t.clength_||0,n=0;i&&(n=parseInt(100*(r/i)));var s=document.createElement("div");s.className="progress";var a=document.createElement("p");a.className="bar",a.innerHTML=Gs+n+"%";var o=document.createElement("div");o.className="progcont";var c=document.createElement("div");return c.className="progint",c.style.width=n+"%",o.appendChild(c),s.appendChild(a),s.appendChild(o),e.appendChild(s),s.progtxt=a,s.progbar=c,$a(s,"mousedown",dh.bind(t),!1),s};var _=function(e,t){var r=e.name_||e.name,i=e.blob_||e.data||new Blob([]),n=Bo(r),s=i.type||e.content_chrome||e.content_||e.type,a=La[n]?La[n]:-1!==ro.indexOf(n)&&-1!==s.indexOf("image")?URL.createObjectURL(i):La.exe,o=document.createElement("div");o.className="thumbwrap",t&&(o.id=t);var c=document.createElement("div");c.className="thumb";var l=document.createElement("img");l.className="thumbimg",l.src=a;var h=document.createElement("div");h.align="center";var u=document.createElement("span");return u.className="thumbspan",u.innerHTML=r,c.appendChild(l),o.appendChild(c),h.appendChild(u),o.appendChild(h),o},g=function(e,t){console.log("compute hash"),e.file_hash=0,$a(document.body,"mousedown",function(){},!1),Oh("

    Calculating hash for a resumed file, please wait...

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e.blob_,i=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),n=r.size,s=0;i.onmessage=function(r){var i=r.data.pop?0:parseInt(r.data);if(s+=i,Wa("progint-alert").style.width=parseInt(100*s/n)+"%",r.data.pop){Wa("progress-alert").style.display="none",setTimeout(function(){Wa("alert_box").style.display="none"},1e4),e.file_hash=r.data[0];var a=function(){d(e),u(e),m(e,t)};e.queue_.push(a),$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),1===e.queue_.length&&e.queue_[0]()}},i.postMessage(["hash",r])};ah=function(e,t,r){console.log("store_DB "),$a(document.body,"mousedown",function(){},!1),e.nb_try===Bs||e.reason_||Oh("

    Storing file, please wait that the file appears in Local Files (for large files this can take some time)

    "),Ha.store=function(){var i,n=Ji?[]:null,s=0,a=hh();e.file_id=e.file_id||0;var o=a.get([e.file_id,s]),c=e.blob_?e.blob_.type:e.content_chrome?e.content_chrome:e.content_,h=new Blob([],{type:c});if(l)var i=Date.now();o.onsuccess=function(o){var l=o.target.result;if(l){var f=l.data;f instanceof Array?(f.unshift(h),h=new Blob(f,{type:c})):h=new Blob([h,f],{type:c}),Ji&&(f instanceof Array?(f.shift(),n=n.concat(f)):n.push(f)),a.delete([e.file_id,s]),s++,_=a.get([e.file_id,s]),_.onsuccess=this.onsuccess}else{console.log("Saving chunks size "+h.size+(i?" time to read all chunks "+(Date.now()-i):"")),Ji&&(e.blob_ instanceof Array?n=n.concat(e.blob_):n.push(e.blob_)),e.blob_=new Blob([h,e.blob_],{type:c});var p=Ya(),_=p.get(e.hash_ini);console.log("store_DB open");var y=Date.now();_.onsuccess=function(i){console.log("store_DB success "+(Date.now()-y));var s=i.target.result;if(s?(lh(Wa(s.name_hash)),Ji?(f=s.data.concat(n),e.blob_=new Blob(f,{type:e.content_chrome?e.content_chrome:e.content_})):(f=new Blob([s.data,e.blob_],{type:c}),e.blob_=f)):f=Ji?n:e.blob_,!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_hash=e.file_hash||0,e.d_length=e.blob_.size,t||d(e),r||u(e),e.check_hash||e.clength_!==e.d_length?m(e,f,r):g(e,f),console.log("Chunks saved "+(Date.now()-y)),Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)}}}},Ha.store()};var m=function(e,t,r){e.file_hash=e.file_hash||0;var i=Ya();Ji?i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t,enc:e.content_chrome||""}):i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t}),r?r(e):(e.d_length===e.clength_&&Ss&&Ss.send_db_info(),ko(e))},b=function(e,t){if(y)var r=Date.now();var i=Ha.db,n=i.transaction([Xa+"_"],"readwrite"),s=n.objectStore(Xa+"_");if(!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_id?e.chunk_nb++:(e.file_id=Date.now(),e.chunk_nb=0),s.put({k:[e.file_id,e.chunk_nb],file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,content_:e.content_,clength_:e.clength_,d_length:e.d_length,url_:e.url_,key:e.key?e.key:"",data:t}),r&&console.log("db_perf "+(Date.now()-r));var o=e.queue_;o.shift(),o.length&&o[0]()},w=function(e){var t=e.split("PT"),r=t[1].split("H"),i=parseFloat(r[1].split("M")[1].split("S")[0]);return t=t[1].split("H")[0],r=r[1].split("M")[0],3600*t+60*r+i},E=function(){try{log("addsourcebuffer "+this._stream_.readyState),this._source_=this._stream_.addSourceBuffer(this.mime_codec)}catch(e){console.log("wait open addsourcebuffer failed")}},C=function(e,t){if(e.received_===t)Wa("alert_box").style.display="none",e._source_.addEventListener("updateend",function(){Do(e)}),Do(e);else if(e.received_>t&&(0===e.append_cursor&&(e.wait_chunk=!0),e.wait_chunk)){var r=Math.min(Math.ceil((e.clength_-e.d_length)/Da),Ea/4);e.append_cursor++,e.append_cursor>=r&&(delete e.wait_chunk,Do(e))}},S=function(e,r){if(r._stream_&&!r._streaming_){if(r.d_length+=e.length,r._json_+=e.toString("utf8"),r.d_length>=r.clength_){console.log("json "+r._json_);try{var i=JSON.parse(r._json_)}catch(n){return console.log("wrong json file, retrying"),r=H(r.hash_ini,null,!0),rc(r),void 0}for(var s in i)if("Duration"!==s){var a=H(i[s].Representation.BaseURL,null,!0);if(r.nb_sources.push(a),a._streaming_=!0,a.mime_codec=i[s].Representation.mimeType+'; codecs="'+i[s].Representation.codecs+'"',a._stream_=r._stream_,a._parent_=r,a._bandwidth_=i[s].Representation.bandwidth,a._width_=i[s].Representation.width,a._height_=i[s].Representation.height,"open"===r._stream_.readyState)try{a._source_=r._stream_.addSourceBuffer(a.mime_codec)}catch(n){console.log("addsourcebuffer failed"),r._wait_open.push(E.bind(a))}else r._wait_open.push(E.bind(a));rc(a)}else r._stream_.duration=w(i[s]);console.log("Queue fin json "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,fin_.call(r)}}else if(r._streaming_){if(r.d_length+=e.length,r.append_buffer.push(e),r._source_)C(r,Math.min(Ea,r.pieces));else if(r.mp4box){var o=r.append_buffer.length;if(o>=Ca||r.d_length>=r.clength_){for(var c=r.append_buffer.concatBuffers(),l=0;o>l;l++)r.append_buffer.shift();r.mp4box.appendBuffer(c.buffer)}}r.d_length>=r.clength_&&(console.log("Queue fin streaming "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),console.log("queue length "+r.append_buffer.length+" cursor "+r.append_cursor+" received "+r.received_),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,r.mp4box&&r.mp4box.flush(),fin_.call(r))}else if(r.eof_)console.log("EOF");else{var h=function(e){return function(){if(r.d_length+=e.length,!r.blob_){r.content_=r.content_||"application/octet-binary";var i=r.content_.split(";");if(i.length>1&&(r.content_=i[0],r.content_chrome=i[1]||"application/octet-binary"),r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),!r.reload2_&&!r.reload_){r.check_hash=new fn("sha1");var n=Ya();n.delete(r.hash_ini)}r.clength_||lh(r.bar_)}if(r.blob_=Ji?r.blob_.length?[r.blob_,e].concatBuffers():e:new Blob([r.blob_,e],{type:r.content_chrome?r.content_chrome:r.content_}),r.check_hash&&r.check_hash.update(e),r.clength_){var s=r.blob_.size||r.blob_.length||r.blob_.byteLength;if(s>=Zs&&r.d_length=r.clength_&&(console.log("Queue fin "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")+(r.blob_.size||r.blob_.length||r.blob_.byteLength)),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,r.queue_.push(fin_.bind(r)),1===r.queue_.length&&r.queue_[0]());if(r.clength_||r.d_length>=r.clength_){var o=parseInt(100*(r.d_length/r.clength_));r.bar_.progtxt.innerHTML=Gs+parseInt(r.d_length/1e3)+" kB",r.bar_.progbar.style.width=o+"%"}r.queue_s.shift(),r.queue_s.length&&r.queue_s[0]()}}};r.queue_s=r.queue_s||[],r.queue_s.push(h(e)),1===r.queue_s.length&&r.queue_s[0]()}};lh=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},fin_=function(){console.log("execute fin"),this.eof_=!0,this.queue_=[],this.queue_s=[],this.cid_&&(this.cid_===Ss?(console.log("sending db_end CIC "+this.cid_.circId+" sid "+this.sid_),this.cid_.send_db_end(1,this.sid_)):this.d_lengthStopping download, please wait that pending data are processed, use resume to restart

    ")},500)),1===this.queue_.length&&this.queue_[0]())};var A=function(e,t){Oh('

    Error: '+t+" - This media can not be streamed, please use Download

    "),lh(nh),dh.call(e)};fh=function(e){var t=e.content_;if(console.log("init_media "+t),-1===t.indexOf("json")&&(-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||e._streaming_))-1===t.indexOf("video")&&-1===t.indexOf("audio")||!e._parent_?(Oh('

    Error: not an audio/video file - This media can not be streamed, please use Download

    '),document.body.removeChild(nh),dh.call(e)):(e._parent_.connected_sources++,e._parent_.connected_sources===e._parent_.nb_sources.length&&(console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play()));else{lh(xh),xh=document.createElement("video"),xh.className="mediasrc",xh.controls=!0,e._stream_=new ih,xh.src=URL.createObjectURL(e._stream_),xh._stream_=e._stream_,nh.appendChild(xh),$a(sh,"mousedown",function(){lh(nh),lh(xh),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!0);var r=function(){if(-1===t.indexOf("json"))-1!==t.indexOf("webm")?(e.nb_sources=[],e._streaming_=!0,e._source_=e._stream_.addSourceBuffer('video/webm; codecs="vp8,vorbis"'),console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play()):(e.nb_sources=[],e._streaming_=!0,e.mp4box=new ki,Oh('

    Connected... Analyzing if this video can be streamed, please wait

    '),e.mp4box_t0=setTimeout(function(){A(e,"mp4box timeout")},Sa),e.mp4box.onReady=function(t){if(clearTimeout(e.mp4box_t0),console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play(),t.tracks){for(;t.tracks.length;){var r=t.tracks.shift();if(r){console.log(r.codec);var i='video/mp4; codecs=" '+r.codec+'"',n=!1;if(ih.isTypeSupported(i)){n=!0;var s={append_buffer:[]};s._stream_=e._stream_,s._source_=e._stream_.addSourceBuffer(i),s.pieces=e.pieces,s.received_=0,s.append_cursor=0,s.clength_=e.clength_,s.d_length_=0,e.mp4box.onSegment=function(e,t,r){r=new Uint8Array(r),t.received_++,t.append_buffer.push(r),1===t.received_&&(Wa("alert_box").style.display="none",t._source_.addEventListener("updateend",function(){Do(t)})),Do(t)},e.mp4box.setSegmentOptions(r.id,s)}n||A(e,"codec not supported")}}for(var a=e.mp4box.initializeSegmentation();a.length;){var o=a.shift();o.user.append_buffer.push(new Uint8Array(o.buffer))}}},e.mp4box.onError=function(){console.log("mp4box error"),A(e,"mp4box error")});else for(;e._wait_open.length;)e._wait_open.shift()()};$a(e._stream_,"webkitsourceopen",r,!1),$a(e._stream_,"sourceopen",r,!1),e._stream_.addEventListener("sourceclose",function(){console.log("SOURCE CLOSED"),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!1),xh.addEventListener("seeking",function(){}),xh.addEventListener("pause",function(){}),xh.addEventListener("play",function(){}),xh.addEventListener("error",function(){Oh('

    Error: Media Source error - This media can not be streamed or something unexpected happened

    '),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e);try{e._stream_.endOfStream()}catch(t){}})}};var I=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu"),lh(this.thumb_)},T=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=this,r=function(){if(this.value){var e=Ya(),r=e.get(t.hash_ini);r.onsuccess=function(r){r.target.result&&(r.target.result.name=this.value,t.name_=this.value,e.put(r.target.result),t.thumb_&&d(t),u(t))}.bind(this)}};Dh("

    Enter new name:

    ",r)},x=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=Ya();t.delete(this.hash_ini),lh(this.thumb2_),lh(this.thumb_)},B=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=this;r.nb_try++,r.db_try=0,r.params_.db_=!0,r.reload_=!0,r.sid_&&(delete r.cid_[r.sid_],delete r.sid_),delete r.cid_,delete r.eof_,delete r.check_hash,delete r.last_saved,delete r.file_id,delete r.start_t0,qh(r.query_t0),r.name_=this.name_||"",r.queue_=[],r.queue_s=[],r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu"),lh(r.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},k=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=H(this.url_,this.hash_ini);r.clength_=this.clength_,r.d_length=this.d_length,r.content_=this.content_,r.reload2_=!0,r.thumb2_=this.thumb2_,delete r.eof_,delete r.last_saved,delete r.file_id,delete r.start_t0,r.queue_=[],r.queue_s=[],r.name_=this.name_||"",qh(r.query_t0),r.nb_try++,r.db_try=0,r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu2"),lh(this.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},R=function(){var e=this.key;F("menu2"),$a(document.body,"mousedown",function(){},!1),e?setTimeout(function(){Oh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    ")},800):Oh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e?new t(e,"hex"):No(16),i=this.blob_,n=i.size,s={file_hash:"00",hash_ini:c(),name_:e?h(this.name_):this.name_+"."+Qs,clength_:n,d_length:0,content_:this.content_,url_:this.url_,key:e?"":r.toString("hex"),content_chrome:e?null:Ji?"application/binary":null,blob_:Ji?new t(0):new Blob([],{type:e?this.content_:"application/octet-binary"}),queue_:[]},a=0;if(e){var o=Ya(),l=o.get(this.hash_ini);l.onsuccess=function(t){if(t.target.result){var r=t.target.result;r.key=e,this.key=e,$a(this.thumb2_,"mousedown",P.bind({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,content_chrome:this.content_chrome,blob_:this.blob_}),!1),o.put(r)}}.bind(this)}var u=new Worker(URL.createObjectURL(new Blob([Hh]))),d=[];if(v)var f=Date.now();u.onmessage=function(t){var r=t.data,i=r instanceof Array?r[0]:r;r instanceof Array||(a+=i.length);var s=a;if(f&&(console.log("worker perf "+(Date.now()-f)),f=Date.now()),d.push(i),0===a%$s||a===n){var o=d,c=function(){Wa("progint-alert").style.width=parseInt(100*(s/n))+"%",r instanceof Array?(this.check_hash=!0,this.file_hash=i,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",ah(this,!0)):(this.file_hash="00",this.d_length=s,b(this,Ji?o:new Blob(o,{type:e?this.content_:"application/octet-binary"})))}.bind(this);d=[],this.queue_.push(c),1===this.queue_.length&&this.queue_[0]()}}.bind(s),u.postMessage(["aes-128-ctr",i,r,Ln])},U=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,R.call({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_})},D=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t={file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,content_:this.content_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_};if(this.blob_.type!==this.content_||"enc"===Bo(this.name_))if(this.key)R.call(t);else{var r=function(){var e=this.value;32===e.length?(t.key=e,R.call(t)):setTimeout(function(){Oh("

    Please enter a valid key

    ")},800)};Dh("

    Enter key:

    ",r)}else Oh("

    This is not an encrypted file

    ")},N=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Oh("
  • Hash Name: "+this.hash_ini+"
  • File hash: "+this.file_hash+"
  • File Type: "+this.content_+"
  • File size: "+this.clength_+" bytes
  • Current size: "+this.d_length+" bytes
  • Key: "+((this.content_chrome?1:this.content_!==this.blob_.type||"enc"===Bo(this.name_))?this.key?this.key:"Get the encryption key from peer":"Not encrypted")+"
  • ")},L=function(e,t){var r=Wa(e);r&&(r.event_&&eo(r,"mousedown",r.event_,!1),r.event_=t.bind(this),$a(r,"mousedown",r.event_,!1))},O=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=Wa("menu2");t.style.display="none",t=Wa("menu"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete",I),L.call(this,"reload",B),this.clength_===this.d_length?Ph(Wa("reload")):Fh(Wa("reload"))},P=function(e){if(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Ss&&Qn>=1){var t=Wa("menu");t.style.display="none",t=Wa("menu2"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open2").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete2",x),L.call(this,"rename2",T),L.call(this,"property2",N),this.d_length===this.clength_?Ph(Wa("reload2")):(Fh(Wa("reload2")),L.call(this,"reload2",k));var r=this.blob_.type||(this.content_chrome?this.content_chrome:this.content_);this.key||r!==this.content_||"enc"===Bo(this.name_)?(Ph(Wa("encrypt2")),Fh(Wa("decrypt2")),L.call(this,"decrypt2",D)):(Fh(Wa("encrypt2")),L.call(this,"encrypt2",U),Ph(Wa("decrypt2")))}else Oh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},F=function(e){var t=Wa(e);t.style.display="none"};Sh=function(){var e=Wa("menu");e.style.display="none",e=Wa("menu2"),e.style.display="none",Wa("alert_box").style.display="none",Wa("prompt_box").style.display="none"},rh=function(e){e.blob_?(e.check_hash&&(e.file_hash=e.check_hash.digest("hex")),console.log("Blob loaded "+e.d_length+" "+(e.file_hash||"")),ah(e),lh(e.bar_)):lh(e.bar_)},$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),$a(Wa("dialog-message"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1);var q=function(e,t){if(!t||t&&(xh.parentNode?!1:!Th))if(Ss&&Qn>1){console.log("Start loading url");var r=H(e,null,t);r.d_length=0,lh(r.thumb_),lh(Wa(r.hash_ini)),t?(Th=!0,M(r)):(r.bar_=uh(Wa("downloaded"),r),lh(xh),lh(nh),Th=!1),(r.bar_||r._stream_&&ih)&&rc(r)}else Oh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},H=function(e,r,i){if(!r){var n=so(e);if(n)r=n,e="";else if(-1!==e.indexOf("http")||-1!==e.indexOf("https")){var s=sn.createhash("sha1");s.update(new t(e,"utf8")),r=s.digest("hex")}else r=e,e=""}var a=Jo(e);a.params_.hash_=new t(r,"hex"),a.hash_ini=r,a.url_=e,e=ho(e),a.params_.stream=yo(e.host,e.rest),a.params_.host=e.host+":"+("https"===e.protcol?"443":"80"),a.params_.db_=!0,a.cid_=Ss,a.download_=[],a.d_length=0,a.nb_try=0;var o=e.rest.split("/");return a.name_=o.length?o[o.length-1]:"",a._write_=function(e){S(e,this)},a.queue_=[],a.db_try=0,a.sendme_tout=[],a.waiting_=[],a.queue_s=[],a._stream_=i||!1,i&&(a.stream_buffer=[],a.append_buffer=[],a.append_cursor=0,a.append_wait=new t(0),a.nb_sources=[],a.connected_sources=0,a.debug_chunk=[],a.append_to=[],a._wait_open=[],a._json_=""),a},M=function(e){ih=window.MediaSource||window.webkitMediaSource||window.WebKitMediaSource||window.webkitMediaSource||window.MozMediaSource||!1,ih?(nh=document.createElement("div"),nh.className="media",document.body.appendChild(nh),sh=document.createElement("div"),sh.className="boxclose",nh.appendChild(sh),$a(sh,"mousedown",function(){lh(nh),lh(xh),dh.call(e)},!0)):Oh('

    Media Source is not available in your browser, so streaming is not possible, please update it or try with Chrome browser.

    ')},j=function(){e(),r(),chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),$a(Wa("chart1"),"mousedown",function(){Ys?clearInterval(chart1_int):chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),Ys=!Ys},!1),$a(Wa("chart2"),"mousedown",function(){Ws?clearInterval(chart2_int):chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),Ws=!Ws},!1)},z=function(){Ha.list=function(e){var t=Ha.db.transaction([Xa],"readwrite").objectStore(Xa);t.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;e(i),r.continue()}else ch&&Mh()}},Ha.list(V)},V=function(e){Ji&&(e.data=new Blob(e.data,{type:e.enc?e.enc:e.type}));var t=_(e,e.name_hash);Wa("local").appendChild(t),$a(t,"mousedown",P.bind({file_hash:e.hash,hash_ini:e.name_hash,name_:e.name,thumb2_:t,clength_:e.file_length,d_length:e.current_length,content_:e.type,url_:e.file_url,key:e.key,content_chrome:e.enc||"",blob_:e.data}),!1),e.file_length!==e.current_length&&(t.firstChild.style.backgroundColor="orange")};if(Eh){var K=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="Direct, P2P and bittorrent anonymized circuits : "+K+(K>1?" circuits":" circuit"),Fh(Wa("direct_text")),Fh(Wa("peer_text"))}else{var G=document.createElement("script");G.src="http://www.peersm.com/gchart.js",G.onload=j,document.body.appendChild(G)}Wa("prompt-input").removeAttribute("type"),z()}}}})}(); \ No newline at end of file diff --git a/min/node-Tor-min.js b/min/node-Tor-min.js index 0cd1ca3..c92248c 100644 --- a/min/node-Tor-min.js +++ b/min/node-Tor-min.js @@ -156,16 +156,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ !function(){var e=!1;if("undefined"!=typeof require)var t=require("buffer").Buffer;var r=!1,s=!1,a=!1,o="",c=!0,l=!1,h=!1,u=!1,d=!1,f=!1,p=!1,_=!1,g=!1,m=!1,y=!1,v=!1,b=!1,w=!1,E="undefined"!=typeof WebSocket?!1:a?!1:!0,C=a,C=!1,S=!1,A=E||a?!1:!0,I=!1,T=!1,x=!1;if(A&&!I){var process={};process.on=function(){},process.platform={indexOf:function(){}};var t=function(){};var require=function(e){var t=function(){},r={};switch(r.Rsa=t,r.PEM=t,r.Hash=null,r.Guards=[],r.Relays=[],r.Dirs=[],r.Exit=[],e){case"fs":var i={};return i.openSync=t,i.writeSync=t,i.closeSync=t,i.open=function(e,t,r){r()},i.write=t,i.close=t,i.unlinkSync=t,i.readFileSync=t,i.readFile=t,i.stat=t,i.rename=t,i;case"domain":var n={};return n.create=function(){return{on:function(){},run:function(e){e()}}},n;case"child_process":var s={};return s.exec=t,s;case o+"crypto.js":return r;case o+"guards.js":return r;case o+"relays.js":return r;case o+"dirs.js":return r;case o+"exit.js":return r;default:return t}}}var B=require("domain").create();B.on("error",function(e){console.error("Caught error ",e.stack)}),B.run(function(){function B(e,t,r){return e>=t&&r>=e}function k(e,t){return Math.floor(e/t)}function R(e){var t=0;this.get=function(){return t>=e.length?Nc:Number(e[t])},this.offset=function(r){if(t+=r,0>t)throw new Error("Seeking past start of the buffer");if(t>e.length)throw new Error("Seeking past EOF")},this.match=function(r){if(r.length>t+e.length)return!1;var i;for(i=0;ir)throw new Error("Seeking past start of the buffer");if(r>i.length)throw new Error("Seeking past EOF")},this.get=function(){return r>=i.length?Lc:i[r]}}function N(){var e="";this.string=function(){return e},this.emit=function(t){65535>=t?e+=String.fromCharCode(t):(t-=65536,e+=String.fromCharCode(55296+(1023&t>>10)),e+=String.fromCharCode(56320+(1023&t)))}}function L(e){this.name="EncodingError",this.message=e,this.code=0}function O(e,t){if(e)throw new L("Decoder error");return t||65533}function P(e){throw new L("The code point "+e+" could not be encoded.")}function F(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(Fc,e)?Fc[e]:null}function q(e,t){return(t||[])[e]||null}function H(e,t){var r=t.indexOf(e);return-1===r?null:r}function M(e){if(e>39419&&189e3>e||e>1237575)return null;var t,r=0,i=0,n=qc.gb18030;for(t=0;t0;){var a=k(r,Math.pow(64,i-1));s=e.emit(128+a%64),i-=1}return s}}function K(e,t){var r=t.fatal;this.decode=function(t){var i=t.get();if(i===Nc)return Lc;if(t.offset(1),B(i,0,127))return i;var n=e[i-128];return null===n?O(r):n}}function G(e,t){t.fatal,this.encode=function(t,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127))return t.emit(i);var n=H(i,e);return null===n&&P(i),t.emit(n+128)}}function Y(e,t){var r=t.fatal,i=0,n=0,s=0;this.decode=function(t){var a=t.get();if(a===Nc&&0===i&&0===n&&0===s)return Lc;a!==Nc||0===i&&0===n&&0===s||(i=0,n=0,s=0,O(r)),t.offset(1);var o;if(0!==s)return o=null,B(a,48,57)&&(o=M(10*(126*(10*(i-129)+(n-48))+(s-129))+a-48)),i=0,n=0,s=0,null===o?(t.offset(-3),O(r)):o;if(0!==n)return B(a,129,254)?(s=a,null):(t.offset(-2),i=0,n=0,O(r));if(0!==i){if(B(a,48,57)&&e)return n=a,null;var c=i,l=null;i=0;var h=127>a?64:65;return(B(a,64,126)||B(a,128,254))&&(l=190*(c-129)+(a-h)),o=null===l?null:q(l,qc.gbk),null===l&&t.offset(-1),null===o?O(r):o}return B(a,0,127)?a:128===a?8364:B(a,129,254)?(i=a,null):O(r)}}function W(e,t){t.fatal,this.encode=function(t,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127))return t.emit(i);var n=H(i,qc.gbk);if(null!==n){var s=k(n,190)+129,a=n%190,o=63>a?64:65;return t.emit(s,a+o)}if(null===n&&!e)return P(i);n=j(i);var c=k(k(k(n,10),126),10);n-=10*126*10*c;var l=k(k(n,10),126);n-=126*10*l;var h=k(n,10),u=n-10*h;return t.emit(c+129,l+48,h+129,u+48)}}function Q(e){var t=e.fatal,r=!1,i=0;this.decode=function(e){var n=e.get();if(n===Nc&&0===i)return Lc;if(n===Nc&&0!==i)return i=0,O(t);if(e.offset(1),126===i)return i=0,123===n?(r=!0,null):125===n?(r=!1,null):126===n?126:10===n?null:(e.offset(-1),O(t));if(0!==i){var s=i;i=0;var a=null;return B(n,33,126)&&(a=q(190*(s-1)+(n+63),qc.gbk)),10===n&&(r=!1),null===a?O(t):a}return 126===n?(i=126,null):r?B(n,32,127)?(i=n,null):(10===n&&(r=!1),O(t)):B(n,0,127)?n:O(t)}}function X(e){e.fatal;var t=!1;this.encode=function(e,r){var i=r.get();if(i===Lc)return Nc;if(r.offset(1),B(i,0,127)&&t)return r.offset(-1),t=!1,e.emit(126,125);if(126===i)return e.emit(126,126);if(B(i,0,127))return e.emit(i);if(!t)return r.offset(-1),t=!0,e.emit(126,123);var n=H(i,qc.gbk);if(null===n)return P(i);var s=k(n,190)+1,a=n%190-63;return B(s,33,126)&&B(a,33,126)?e.emit(s,a):P(i)}}function J(e){var t=e.fatal,r=0,i=null;this.decode=function(e){if(null!==i){var n=i;return i=null,n}var s=e.get();if(s===Nc&&0===r)return Lc;if(s===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var a=r,o=null;r=0;var c=127>s?64:98;if((B(s,64,126)||B(s,161,254))&&(o=157*(a-129)+(s-c)),1133===o)return i=772,202;if(1135===o)return i=780,202;if(1164===o)return i=772,234;if(1166===o)return i=780,234;var l=null===o?null:q(o,qc.big5);return null===o&&e.offset(-1),null===l?O(t):l}return B(s,0,127)?s:B(s,129,254)?(r=s,null):O(t)}}function Z(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);var i=H(r,qc.big5);if(null===i)return P(r);var n=k(i,157)+129,s=i%157,a=63>s?64:98;return e.emit(n,s+a)}}function $(e){var t=e.fatal,r=0,i=0;this.decode=function(e){var n=e.get();if(n===Nc)return 0===r&&0===i?Lc:(r=0,i=0,O(t));e.offset(1);var s,a;return 0!==i?(s=i,i=0,a=null,B(s,161,254)&&B(n,161,254)&&(a=q(94*(s-161)+n-161,qc.jis0212)),B(n,161,254)||e.offset(-1),null===a?O(t):a):142===r&&B(n,161,223)?(r=0,65377+n-161):143===r&&B(n,161,254)?(r=0,i=n,null):0!==r?(s=r,r=0,a=null,B(s,161,254)&&B(n,161,254)&&(a=q(94*(s-161)+n-161,qc.jis0208)),B(n,161,254)||e.offset(-1),null===a?O(t):a):B(n,0,127)?n:142===n||143===n||B(n,161,254)?(r=n,null):O(t)}}function et(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);if(165===r)return e.emit(92);if(8254===r)return e.emit(126);if(B(r,65377,65439))return e.emit(142,r-65377+161);var i=H(r,qc.jis0208);if(null===i)return P(r);var n=k(i,94)+161,s=i%94+161;return e.emit(n,s)}}function tt(e){var t=e.fatal,r={ASCII:0,escape_start:1,escape_middle:2,escape_final:3,lead:4,trail:5,Katakana:6},i=r.ASCII,n=!1,s=0;this.decode=function(e){var a=e.get();switch(a!==Nc&&e.offset(1),i){default:case r.ASCII:return 27===a?(i=r.escape_start,null):B(a,0,127)?a:a===Nc?Lc:O(t);case r.escape_start:return 36===a||40===a?(s=a,i=r.escape_middle,null):(a!==Nc&&e.offset(-1),i=r.ASCII,O(t));case r.escape_middle:var o=s;return s=0,36!==o||64!==a&&66!==a?36===o&&40===a?(i=r.escape_final,null):40!==o||66!==a&&74!==a?40===o&&73===a?(i=r.Katakana,null):(a===Nc?e.offset(-1):e.offset(-2),i=r.ASCII,O(t)):(i=r.ASCII,null):(n=!1,i=r.lead,null);case r.escape_final:return 68===a?(n=!0,i=r.lead,null):(a===Nc?e.offset(-2):e.offset(-3),i=r.ASCII,O(t));case r.lead:return 10===a?(i=r.ASCII,O(t,10)):27===a?(i=r.escape_start,null):a===Nc?Lc:(s=a,i=r.trail,null);case r.trail:if(i=r.lead,a===Nc)return O(t);var c=null,l=94*(s-33)+a-33;return B(s,33,126)&&B(a,33,126)&&(c=n===!1?q(l,qc.jis0208):q(l,qc.jis0212)),null===c?O(t):c;case r.Katakana:return 27===a?(i=r.escape_start,null):B(a,33,95)?65377+a-33:a===Nc?Lc:O(t)}}}function rt(e){e.fatal;var t={ASCII:0,lead:1,Katakana:2},r=t.ASCII;this.encode=function(e,i){var n=i.get();if(n===Lc)return Nc;if(i.offset(1),(B(n,0,127)||165===n||8254===n)&&r!==t.ASCII)return i.offset(-1),r=t.ASCII,e.emit(27,40,66);if(B(n,0,127))return e.emit(n);if(165===n)return e.emit(92);if(8254===n)return e.emit(126);if(B(n,65377,65439)&&r!==t.Katakana)return i.offset(-1),r=t.Katakana,e.emit(27,40,73);if(B(n,65377,65439))return e.emit(n-65377-33);if(r!==t.lead)return i.offset(-1),r=t.lead,e.emit(27,36,66);var s=H(n,qc.jis0208);if(null===s)return P(n);var a=k(s,94)+33,o=s%94+33;return e.emit(a,o)}}function it(e){var t=e.fatal,r=0;this.decode=function(e){var i=e.get();if(i===Nc&&0===r)return Lc;if(i===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var n=r;if(r=0,B(i,64,126)||B(i,128,252)){var s=127>i?64:65,a=160>n?129:193,o=q(188*(n-a)+i-s,qc.jis0208);return null===o?O(t):o}return e.offset(-1),O(t)}return B(i,0,128)?i:B(i,161,223)?65377+i-161:B(i,129,159)||B(i,224,252)?(r=i,null):O(t)}}function nt(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,128))return e.emit(r);if(165===r)return e.emit(92);if(8254===r)return e.emit(126);if(B(r,65377,65439))return e.emit(r-65377+161);var i=H(r,qc.jis0208);if(null===i)return P(r);var n=k(i,188),s=31>n?129:193,a=i%188,o=63>a?64:65;return e.emit(n+s,a+o)}}function st(e){var t=e.fatal,r=0;this.decode=function(e){var i=e.get();if(i===Nc&&0===r)return Lc;if(i===Nc&&0!==r)return r=0,O(t);if(e.offset(1),0!==r){var n=r,s=null;if(r=0,B(n,129,198)){var a=178*(n-129);B(i,65,90)?s=a+i-65:B(i,97,122)?s=a+26+i-97:B(i,129,254)&&(s=a+26+26+i-129)}B(n,199,253)&&B(i,161,254)&&(s=12460+94*(n-199)+(i-161));var o=null===s?null:q(s,qc["euc-kr"]);return null===s&&e.offset(-1),null===o?O(t):o}return B(i,0,127)?i:B(i,129,253)?(r=i,null):O(t)}}function at(e){e.fatal,this.encode=function(e,t){var r=t.get();if(r===Lc)return Nc;if(t.offset(1),B(r,0,127))return e.emit(r);var i=H(r,qc["euc-kr"]);if(null===i)return P(r);var n,s;if(12460>i){n=k(i,178)+129,s=i%178;var a=26>s?65:52>s?71:77;return e.emit(n,s+a)}return i-=12460,n=k(i,94)+199,s=i%94+161,e.emit(n,s)}}function ot(e){var t=e.fatal,r={ASCII:0,escape_start:1,escape_middle:2,escape_end:3,lead:4,trail:5},i=r.ASCII,n=0;this.decode=function(e){var s=e.get();switch(s!==Nc&&e.offset(1),i){default:case r.ASCII:return 14===s?(i=r.lead,null):15===s?null:27===s?(i=r.escape_start,null):B(s,0,127)?s:s===Nc?Lc:O(t);case r.escape_start:return 36===s?(i=r.escape_middle,null):(s!==Nc&&e.offset(-1),i=r.ASCII,O(t));case r.escape_middle:return 41===s?(i=r.escape_end,null):(s===Nc?e.offset(-1):e.offset(-2),i=r.ASCII,O(t));case r.escape_end:return 67===s?(i=r.ASCII,null):(s===Nc?e.offset(-2):e.offset(-3),i=r.ASCII,O(t));case r.lead:return 10===s?(i=r.ASCII,O(t,10)):14===s?null:15===s?(i=r.ASCII,null):s===Nc?Lc:(n=s,i=r.trail,null);case r.trail:if(i=r.lead,s===Nc)return O(t);var a=null;return B(n,33,70)&&B(s,33,126)?a=q(178*(n-1)+26+26+s-1,qc["euc-kr"]):B(n,71,126)&&B(s,33,126)&&(a=q(12460+94*(n-71)+(s-33),qc["euc-kr"])),null!==a?a:O(t)}}}function ct(e){e.fatal;var t={ASCII:0,lead:1},r=!1,i=t.ASCII;this.encode=function(e,n){var s=n.get();if(s===Lc)return Nc;if(r||(r=!0,e.emit(27,36,41,67)),n.offset(1),B(s,0,127)&&i!==t.ASCII)return n.offset(-1),i=t.ASCII,e.emit(15);if(B(s,0,127))return e.emit(s);if(i!==t.lead)return n.offset(-1),i=t.lead,e.emit(14);var a=H(s,qc["euc-kr"]);if(null===a)return P(s);var o,c;return 12460>a?(o=k(a,178)+1,c=a%178-26-26+1,B(o,33,70)&&B(c,33,126)?e.emit(o,c):P(s)):(a-=12460,o=k(a,94)+71,c=a%94+33,B(o,71,126)&&B(c,33,126)?e.emit(o,c):P(s))}}function lt(e,t){var r=t.fatal,i=null,n=null;this.decode=function(t){var s=t.get();if(s===Nc&&null===i&&null===n)return Lc;if(s===Nc&&(null!==i||null!==n))return O(r);if(t.offset(1),null===i)return i=s,null;var a;if(a=e?(i<<8)+s:(s<<8)+i,i=null,null!==n){var o=n;return n=null,B(a,56320,57343)?65536+1024*(o-55296)+(a-56320):(t.offset(-2),O(r))}return B(a,55296,56319)?(n=a,null):B(a,56320,57343)?O(r):a}}function ht(e,t){t.fatal,this.encode=function(t,r){function i(r){var i=r>>8,n=255&r;return e?t.emit(i,n):t.emit(n,i)}var n=r.get();if(n===Lc)return Nc;if(r.offset(1),B(n,55296,57343)&&P(n),65535>=n)return i(n);var s=k(n-65536,1024)+55296,a=(n-65536)%1024+56320;return i(s),i(a)}}function ut(e,t){return t.match([255,254])&&"utf-16"===e?(t.offset(2),void 0):t.match([254,255])&&"utf-16be"==e?(t.offset(2),void 0):t.match([239,187,191])&&"utf-8"==e?(t.offset(3),void 0):void 0}function dt(e,t){if(e=e?String(e):Hc,t=Object(t),this._encoding=F(e),null===this._encoding||"utf-8"!==this._encoding.name&&"utf-16"!==this._encoding.name&&"utf-16be"!==this._encoding.name)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function ft(e,t){if(e=e?String(e):Hc,t=Object(t),this._encoding=F(e),null===this._encoding)throw new TypeError("Unknown encoding: "+e);return this._streaming=!1,this._decoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty?Object.defineProperty(this,"encoding",{get:function(){return this._encoding.name}}):this.encoding=this._encoding.name,this}function pt(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function _t(){return new pt(null)}function gt(e,t,r,i,n,s){for(;--s>=0;){var a=t*this[e++]+r[i]+n;n=Math.floor(a/67108864),r[i++]=67108863&a}return n}function mt(e,t,r,i,n,s){for(var a=32767&t,o=t>>15;--s>=0;){var c=32767&this[e],l=this[e++]>>15,h=o*c+l*a;c=a*c+((32767&h)<<15)+r[i]+(1073741823&n),n=(c>>>30)+(h>>>15)+o*l+(n>>>30),r[i++]=1073741823&c}return n}function yt(e,t,r,i,n,s){for(var a=16383&t,o=t>>14;--s>=0;){var c=16383&this[e],l=this[e++]>>14,h=o*c+l*a;c=a*c+((16383&h)<<14)+r[i]+n,n=(c>>28)+(h>>14)+o*l,r[i++]=268435455&c}return n}function vt(e){return Wc.charAt(e)}function bt(e,t){var r=Qc[e.charCodeAt(t)];return null==r?-1:r}function wt(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function Et(e){this.t=1,this.s=0>e?-1:0,e>0?this[0]=e:-1>e?this[0]=e+DV:this.t=0}function Ct(e){var t=_t();return t.fromInt(e),t}function St(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.fromRadix(e,t),void 0;r=2}this.t=0,this.s=0;for(var i=e.length,n=!1,s=0;--i>=0;){var a=8==r?255&e[i]:bt(e,i);0>a?"-"==e.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function It(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,i=(1<0)for(o>o)>0&&(n=!0,s=vt(r));a>=0;)t>o?(r=(this[a]&(1<>(o+=this.DB-t)):(r=this[a]>>(o-=t)&i,0>=o&&(o+=this.DB,--a)),r>0&&(n=!0),n&&(s+=vt(r));return n?s:"0"}function Tt(){var e=_t();return pt.ZERO.subTo(this,e),e}function xt(){return this.s<0?this.negate():this}function Bt(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(t=r-e.t,0!=t)return t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}function kt(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function Rt(){return this.t<=0?0:this.DB*(this.t-1)+kt(this[this.t-1]^this.s&this.DM)}function Ut(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}function Dt(e,t){for(var r=e;r=0;--r)t[r+a+1]=this[r]>>n|o,o=(this[r]&s)<=0;--r)t[r]=0;t[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()}function Lt(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)return t.t=0,void 0;var i=e%this.DB,n=this.DB-i,s=(1<>i;for(var a=r+1;a>i;i>0&&(t[this.t-r-1]|=(this.s&s)<r;)i+=this[r]-e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=e.s}t.s=0>i?-1:0,-1>i?t[r++]=this.DV+i:i>0&&(t[r++]=i),t.t=r,t.clamp()}function Pt(e,t){var r=this.abs(),i=e.abs(),n=r.t;for(t.t=n+i.t;--n>=0;)t[n]=0;for(n=0;n=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}function qt(e,t,r){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t0?(i.lShiftTo(c,s),n.lShiftTo(c,r)):(i.copyTo(s),n.copyTo(r));var l=s.t,h=s[l-1];if(0!=h){var u=h*(1<1?s[l-2]>>this.F2:0),d=this.FV/u,f=(1<=0&&(r[r.t++]=1,r.subTo(m,r)),pt.ONE.dlShiftTo(l,m),m.subTo(s,s);s.t=0;){var y=r[--_]==h?this.DM:Math.floor(r[_]*d+(r[_-1]+p)*f);if((r[_]+=s.am(0,y,r,g,0,l))0&&r.rShiftTo(c,r),0>a&&pt.ZERO.subTo(r,r)}}}function Ht(e){var t=_t();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(pt.ZERO)>0&&e.subTo(t,t),t}function Mt(e){this.m=e}function jt(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function zt(e){return e}function Vt(e){e.divRemTo(this.m,null,e)}function Kt(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function Gt(e,t){e.squareTo(t),this.reduce(t)}function Yt(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return t=15&t*(2-(15&e)*t),t=255&t*(2-(255&e)*t),t=65535&t*(2-(65535&(65535&e)*t)),t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Wt(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function Xt(e){var t=_t();return e.copyTo(t),this.reduce(t),t}function Jt(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e[r]+=this.m.am(0,i,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Zt(e,t){e.squareTo(t),this.reduce(t)}function $t(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function er(){return 0==(this.t>0?1&this[0]:this.s)}function tr(e,t){if(e>4294967295||1>e)return pt.ONE;var r=_t(),i=_t(),n=t.convert(this),s=kt(e)-1;for(n.copyTo(r);--s>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,n,r);else{var a=r;r=i,i=a}return t.revert(r)}function rr(e,t){var r;return r=256>e||t.isEven()?new Mt(t):new Wt(t),this.exp(e,r)}function ir(){this.i=0,this.j=0,this.S=new Array}function nr(e){var t,r,i;for(t=0;256>t;++t)this.S[t]=t;for(r=0,t=0;256>t;++t)r=255&r+this.S[t]+e[t%e.length],i=this.S[t],this.S[t]=this.S[r],this.S[r]=i;this.i=0,this.j=0}function sr(){var e;return this.i=255&this.i+1,this.j=255&this.j+this.S[this.i],e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[255&e+this.S[this.i]]}function ar(){return new ir}function or(e){Jc[Zc++]^=255&e,Jc[Zc++]^=255&e>>8,Jc[Zc++]^=255&e>>16,Jc[Zc++]^=255&e>>24,Zc>=$c&&(Zc-=$c)}function cr(){or((new Date).getTime())}function lr(){if(null==Xc){for(cr(),Xc=ar(),Xc.init(Jc),Zc=0;Zc=1&&t>0;){var n=e[i--],s=e[i--];r[--t]=(bt(s,0)<<4)+bt(n,0)}r[--t]=0;for(var a=new ur,o=new Array;t>2;){for(o[0]=0;0==o[0];)a.nextBytes(o);r[--t]=o[0]}return r[--t]=2,r[--t]=0,new pt(r)}function pr(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function _r(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=dr(e,16),this.e=parseInt(t,16)):alert("Invalid RSA public key")}function gr(e){return e.modPowInt(this.e,this.n)}function mr(e){var t=fr(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var i=r.toString(16);return 0==(1&i.length)?i:"0"+i}function yr(){var e=_t();return this.copyTo(e),e}function vr(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function wr(){return 0==this.t?this.s:this[0]<<16>>16}function Er(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Cr(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Sr(e){if(null==e&&(e=10),0==this.signum()||2>e||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=Ct(r),n=_t(),s=_t(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(e)+a}function Ar(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),n=!1,s=0,a=0,o=0;oc?"-"==e.charAt(o)&&0==this.signum()&&(n=!0):(a=t*a+c,++s>=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),n&&pt.ZERO.subTo(this,this)}function Ir(e,t,r){if("number"==typeof t)if(2>e)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(pt.ONE.shiftLeft(e-1),Nr,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(pt.ONE.shiftLeft(e-1),this);else{var i=new Array,n=7&e;i.length=(e>>3)+1,t.nextBytes(i),n>0?i[0]&=(1<0)for(i>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<=0;)8>i?(r=(this[e]&(1<>(i+=this.DB-8)):(r=255&this[e]>>(i-=8),0>=i&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function xr(e){return 0==this.compareTo(e)}function Br(e){return this.compareTo(e)<0?this:e}function kr(e){return this.compareTo(e)>0?this:e}function Rr(e,t,r){var i,n,s=Math.min(e.t,this.t);for(i=0;s>i;++i)r[i]=t(this[i],e[i]);if(e.te?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function jr(e){var t=_t();return 0>e?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function zr(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function Vr(){for(var e=0;e=this.t?0!=this.s:0!=(this[t]&1<r;)i+=this[r]+e[r],t[r++]=i&this.DM,i>>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=e.s}t.s=0>i?-1:0,i>0?t[r++]=i:-1>i&&(t[r++]=this.DV+i),t.t=r,t.clamp()}function $r(e){var t=_t();return this.addTo(e,t),t}function ei(e){var t=_t();return this.subTo(e,t),t}function ti(e){var t=_t();return this.multiplyTo(e,t),t}function ri(){var e=_t();return this.squareTo(e),e}function ii(e){var t=_t();return this.divRemTo(e,t,null),t}function ni(e){var t=_t();return this.divRemTo(e,null,t),t}function si(e){var t=_t(),r=_t();return this.divRemTo(e,t,r),new Array(t,r)}function ai(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function oi(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}function ci(){}function li(e){return e}function hi(e,t,r){e.multiplyTo(t,r)}function ui(e,t){e.squareTo(t)}function di(e){return this.exp(e,new ci)}function fi(e,t,r){var i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;var n;for(n=r.t-this.t;n>i;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(n=Math.min(e.t,t);n>i;++i)this.am(0,e[i],r,i,0,t-i);r.clamp()}function pi(e,t,r){--t;var i=r.t=this.t+e.t-t;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(t-this.t,0);i2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=_t();return e.copyTo(t),this.reduce(t),t}function mi(e){return e}function yi(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function vi(e,t){e.squareTo(t),this.reduce(t)}function bi(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function wi(e,t){var r,i,n=e.bitLength(),s=Ct(1);if(0>=n)return s;r=18>n?1:48>n?3:144>n?4:768>n?5:6,i=8>n?new Mt(t):t.isEven()?new _i(t):new Wt(t);var a=new Array,o=3,c=r-1,l=(1<1){var h=_t();for(i.sqrTo(a[1],h);l>=o;)a[o]=_t(),i.mulTo(h,a[o-2],a[o]),o+=2}var u,d,f=e.t-1,p=!0,_=_t();for(n=kt(e[f])-1;f>=0;){for(n>=c?u=e[f]>>n-c&l:(u=(e[f]&(1<0&&(u|=e[f-1]>>this.DB+n-c)),o=r;0==(1&u);)u>>=1,--o;if((n-=o)<0&&(n+=this.DB,--f),p)a[u].copyTo(s),p=!1;else{for(;o>1;)i.sqrTo(s,_),i.sqrTo(_,s),o-=2;o>0?i.sqrTo(s,_):(d=s,s=_,_=d),i.mulTo(_,a[u],s)}for(;f>=0&&0==(e[f]&1<s)return t;for(s>n&&(s=n),s>0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function Ci(e){if(0>=e)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this[i])%e;return r}function Si(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return pt.ZERO;for(var r=e.clone(),i=this.clone(),n=Ct(1),s=Ct(0),a=Ct(0),o=Ct(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(e,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(i)>=0?(r.subTo(i,r),t&&n.subTo(a,n),s.subTo(o,s)):(i.subTo(r,i),t&&a.subTo(n,a),o.subTo(s,o))}return 0!=i.compareTo(pt.ONE)?pt.ZERO:o.compareTo(e)>=0?o.subtract(e):o.signum()<0?(o.addTo(e,o),o.signum()<0?o.add(e):o):o}function Ai(e){var t,r=this.abs();if(1==r.t&&r[0]<=rl[rl.length-1]){for(t=0;ti;)i*=rl[n++];for(i=r.modInt(i);n>t;)if(0==i%rl[t++])return!1}return r.millerRabin(e)}function Ii(e){var t=this.subtract(pt.ONE),r=t.getLowestSetBit();if(0>=r)return!1;var i=t.shiftRight(r);e=e+1>>1,e>rl.length&&(e=rl.length);for(var n=_t(),s=0;e>s;++s){n.fromInt(rl[Math.floor(Math.random()*rl.length)]);var a=n.modPow(i,this);if(0!=a.compareTo(pt.ONE)&&0!=a.compareTo(t)){for(var o=1;o++>3:null},a.DecoderConfigDescriptor=function(e){a.Descriptor.call(this,t,e)},a.DecoderConfigDescriptor.prototype=new a.Descriptor,a.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},a.DecoderSpecificInfo=function(e){a.Descriptor.call(this,r,e)},a.DecoderSpecificInfo.prototype=new a.Descriptor,a.SLConfigDescriptor=function(e){a.Descriptor.call(this,i,e)},a.SLConfigDescriptor.prototype=new a.Descriptor,this}function Bi(){this.boxes=new Array,this.mdats=new Array,this.moofs=new Array,this.isProgressive=!1,this.lastMoofIndex=0,this.lastPosition=0}function ki(){this.log_level=this.LOG_LEVEL_INFO,this.sampleListBuilt=!1,this.inputStream=null,this.inputIsoFile=null,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.fragmentedTracks=new Array,this.extractedTracks=new Array,this.isFragmentationStarted=!1,this.nextMoofNumber=0}var Ri=require("fs"),Ui=require("child_process"),Di=function(e,t){t+=" "+(new Date).toDateString()+" "+(new Date).toTimeString();var r=function(e,r){try{if(e||(Ri.write(r,t+"\n",function(){}),Ri.close(r)),A&&"undefined"!=typeof Wa){var i=Wa("console");i.innerHTML.length>1e6&&(i.innerHTML="");var n=document.createElement("p");n.className="log",n.innerHTML=t,i.appendChild(n)}}catch(s){}};try{Ri.open(o+Dn+"-"+e,"a",r)}catch(i){}};process.on("uncaughtException",function(e){var t=Ri.openSync("/debug.txt","a");Ri.writeSync(t,(new Date).toDateString()+" "+(new Date).toTimeString()),Ri.writeSync(t,e.stack),Ri.closeSync(t)}),process.on("exit",function(){setTimeout(function(){console.log("Process ended")},0),console.log("About to exit "+(new Date).toDateString()+" "+(new Date).toTimeString())});var Ni=console.log.bind(console),Li=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)},Oi=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)};console.log=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),(!a&&!S&&!c||-1!==process.platform.indexOf("win")&&T)&&Ni(e+" "+(new Date).toDateString()+" "+(new Date).toTimeString())};var Pi,Fi,qi,Hi,Mi,ji,zi;if(!A){if(process.argv&&process.argv.length>1){var Vi=process.argv.splice(2);if(5===Vi.length)Pi=Vi[0],Fi=Vi[1],qi=Vi[2],Hi=Vi[3],Mi=Vi[4];else{if(o=Vi[0]||"",o.length){if(-1===process.platform.indexOf("win")){var Ki=o[o.length-1];"/"!==Ki&&(o+="/")}}else Ni("Invalid directory parameter");if(T=!0,Vi.length>1)if("-P"!==Vi[1])ji=Vi[1],Vi.length>2&&(zi=!0);else{if(T=!1,x=!0,!(Vi.length>2))return;if(isNaN(parseInt(Vi[2])))return;Hi=parseInt(Vi[2])}}}var Gi=function(){console.log("update routers "+(new Date).toDateString()+" "+(new Date).toTimeString());var e=function(){console.log("child_process "+(new Date).toDateString()+" "+(new Date).toTimeString())};Ui.exec("/usr/local/bin/node "+o+"build-relays_and_dirs7.js",{timeout:12e5},e),Pi&&Ui.exec("/usr/local/bin/node "+o+"publish2.js "+Pi+" "+Fi+":"+qi+" "+Mi,{timeout:12e5},e)};T||x||setInterval(Gi,36e5)}if(T)var Yi,Wi,Qi,Xi=function(e){var t={host:"peersm.com",port:80,path:"/peersmclient/proxy.pac",method:"GET"};Yi="";var r=nn.request(t,function(t){t.on("data",function(e){Yi+=e.toString("utf8")}),t.on("end",function(){e()}),t.on("error",function(){console.log("Error proxy.pac")})});r.end()};else var Xi=function(e){var t=new XMLHttpRequest;return t?(t.open("GET",e,!1),t.send(null),t.responseText):void 0};var Ji,Zi,$i,en,tn=require("tls"),rn=require("net"),nn=require("http"),sn=(require("url"),require("crypto")),an=T?require(o+"node_modules/torrent-stream"):{},Guards=T||x?{}:require(o+"guards.js").Guards,on=T||x?{}:require(o+"relays.js").Relays,cn=T||x?{}:require(o+"dirs.js").Dirs,Exit=T||x?{}:require(o+"exit.js").Exit,ln=!1,hn=!0,un=hn?null:require(o+"crypto.js").Rsa,dn=hn?null:require(o+"crypto.js").PEM,fn=hn?null:require(o+"crypto.js").Hash,pn=498,_n=65535,gn={},mn=[],yn={},vn={},bn={},wn={},En={},Cn={},Sn={},An=[],In={},Tn={},xn={},Bn={},kn=0,Rn=Fi||"",Un="2679B51C906158F3DF4C59AFD73E2B1FDA6535E1",Dn=a?C?1:0:S?0:0,Nn="010001",Ln=new t("00000000000000000000000000000000","hex"),On=32767,Pn=Hi||(a?2:0),Fn=5,qn=5,Hn=3,Mn=zi?2:3,jn="-----BEGIN RSA PUBLIC KEY-----",zn="-----END RSA PUBLIC KEY-----",Vn=5e3,Kn=1e3,Gn=7e3,Yn=3,Wn=0,Qn=0,Xn=30,Jn=12,Zn=10,$n=s?20:5,es=!1,ts=5,rs=5e3,is=72e5,ns=36e5,ss=36e5,as=[],os=[],cs=1e3,ls=100,hs=500,us=50,ds=.8,fs=15e3,ps=16184,_s=t,gs="0d0a",ms=".com",ys=5e3,vs=2e3,bs={},ws="http:",Es="www.f4116a30c08bbdfd01813b96c909.com",Cs=null,Ss=null,As=36e6,Is=1e4,Ts=3e5,xs=9e5,Bs=5,ks=a?!1:!0,Rs=a?!1:!0,Us=a?!1:!0,Ds="",Ns=!1,Ls=1024,Os=!0,Ps=!1,Fs={},qs="undefined"!=typeof document?document.location.href:"",Hs=!1,Ms=!0,js=!1,zs=a?!1:!0,Vs=0,Ks=1e5,Gs="Retrieving... ",Ys=!0,Ws=!0,Qs="enc",Xs=T||x?null:Ri.readFileSync(o+"priv-key.pem"),Js=!1,Zs=65536,$s=2097152,ea=0,ta=0,ra=0,ia=100,na=0,sa=0,aa=0,oa=100,ca=0,la=0,ha=0,ua=100,da=0,fa=0,pa=0,_a=100,ga=0,ma=0,ya=0,va=100,ba=1e6,wa=2e6,Ea=1e3,Ca=125,Sa=3e4,Aa="0000000000000000000000000000000000000000",Ia=3e5,Ta="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF",xa={323:"text/h323","3gp":"video/3gpp",a:"application/octet-stream",acx:"application/internet-property-stream",ai:"application/postscript",aif:"audio/x-aiff",aifc:"audio/x-aiff",aiff:"audio/x-aiff",asc:"application/pgp-signature",asf:"video/x-ms-asf",asr:"video/x-ms-asf",asm:"text/x-asm",asx:"video/x-ms-asf",atom:"application/atom+xml",au:"audio/basic",avi:"video/x-msvideo",axs:"application/olescript",bas:"text/plain",bat:"application/x-msdownload",bcpio:"application/x-bcpio",bin:"application/octet-stream",bmp:"image/bmp",bz2:"application/x-bzip2",c:"text/x-c",cab:"application/vnd.ms-cab-compressed",cat:"application/vnd.ms-pkiseccat",cc:"text/x-c",cdf:"application/x-netcdf",cer:"application/x-x509-ca-cert",cgm:"image/cgm",chm:"application/vnd.ms-htmlhelp","class":"application/octet-stream",clp:"application/x-msclip",cmx:"image/x-cmx",cod:"image/cis-cod",com:"application/x-msdownload",conf:"text/plain",cpio:"application/x-cpio",cpp:"text/x-c",cpt:"application/mac-compactpro",crd:"application/x-mscardfile",crl:"application/pkix-crl",crt:"application/x-x509-ca-cert",csh:"application/x-csh",css:"text/css",csv:"text/csv",cxx:"text/x-c",dcr:"application/x-director",deb:"application/x-debian-package",der:"application/x-x509-ca-cert",diff:"text/x-diff",dir:"application/x-director",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dll:"application/x-msdownload",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dtd:"application/xml-dtd",dv:"video/x-dv",dvi:"application/x-dvi",dxr:"application/x-director",ear:"application/java-archive",eml:"message/rfc822",eps:"application/postscript",etx:"text/x-setext",evy:"application/envoy",exe:"application/x-msdownload",ez:"application/andrew-inset",f:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",fif:"application/fractals",flr:"x-world/x-vrml",flv:"video/x-flv","for":"text/x-fortran",gem:"application/octet-stream",gemspec:"text/x-script.ruby",gif:"image/gif",gram:"application/srgs",grxml:"application/srgs+xml",gtar:"application/x-gtar",gz:"application/x-gzip",h:"text/x-c",hdf:"application/x-hdf",hh:"text/x-c",hlp:"application/winhlp",hqx:"application/mac-binhex40",hta:"application/hta",htc:"text/x-component",htm:"text/html",html:"text/html",htt:"text/webviewhtml",ice:"x-conference/x-cooltalk",ico:"image/vnd.microsoft.icon",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",iii:"application/x-iphone",ins:"application/x-internet-signup",isp:"application/x-internet-signup",iso:"application/octet-stream",jar:"application/java-archive",java:"text/x-java-source",jfif:"image/pipeg",jnlp:"application/x-java-jnlp-file",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",kar:"audio/midi",latex:"application/x-latex",lha:"application/octet-stream",lsf:"video/x-la-asf",lsx:"video/x-la-asf",lzh:"application/octet-stream",log:"text/plain",m13:"application/x-msmediaview",m14:"application/x-msmediaview",m3u:"audio/x-mpegurl",m4a:"audio/mp4a-latm",m4b:"audio/mp4a-latm",m4p:"audio/mp4a-latm",m4u:"video/vnd.mpegurl",m4v:"video/mp4",mac:"image/x-macpaint",man:"text/troff",mathml:"application/mathml+xml",mbox:"application/mbox",mdb:"application/x-msaccess",mdoc:"text/troff",me:"text/troff",mesh:"model/mesh",mht:"message/rfc822",mhtml:"message/rfc822",mid:"audio/midi",midi:"audio/midi",mif:"application/vnd.mif",mime:"message/rfc822",mml:"application/mathml+xml",mng:"video/x-mng",mny:"application/x-msmoney",mov:"video/quicktime",movie:"video/x-sgi-movie",mp2:"video/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4v:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpg:"video/mpeg",mpga:"audio/mpeg",mpp:"application/vnd.ms-project",mpv2:"video/mpeg",ms:"text/troff",msh:"model/mesh",msi:"application/x-msdownload",mvb:"application/x-msmediaview",mxu:"video/vnd.mpegurl",nc:"application/x-netcdf",nws:"message/rfc822",oda:"application/oda",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",ogg:"application/ogg",p:"text/x-pascal",p10:"application/pkcs10",p12:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",p7c:"application/x-pkcs7-mime",p7m:"application/x-pkcs7-mime",p7r:"application/x-pkcs7-certreqresp",p7s:"application/x-pkcs7-signature",pac:"text/plain",pas:"text/x-pascal",pbm:"image/x-portable-bitmap",pct:"image/pict",pdb:"chemical/x-pdb",pdf:"application/pdf",pem:"application/x-x509-ca-cert",pfx:"application/x-pkcs12",pgm:"image/x-portable-graymap",pgn:"application/x-chess-pgn",pgp:"application/pgp-encrypted",pic:"image/pict",pict:"image/pict",pkg:"application/octet-stream",pko:"application/ynd.ms-pkipko",pl:"text/x-script.perl",pm:"text/x-script.perl-module",pma:"application/x-perfmon",pmc:"application/x-perfmon",pml:"application/x-perfmon",pmr:"application/x-perfmon",pmw:"application/x-perfmon",png:"image/png",pnm:"image/x-portable-anymap",pnt:"image/x-macpaint",pntg:"image/x-macpaint",pot:"application/vnd.ms-powerpoint",ppm:"image/x-portable-pixmap",pps:"application/vnd.ms-powerpoint",ppt:"application/vnd.ms-powerpoint",prf:"application/pics-rules",ps:"application/postscript",psd:"image/vnd.adobe.photoshop",pub:"application/x-mspublisher",py:"text/x-script.python",qt:"video/quicktime",qti:"image/x-quicktime",qtif:"image/x-quicktime",ra:"audio/x-pn-realaudio",rake:"text/x-script.ruby",ram:"audio/x-pn-realaudio",rar:"application/x-rar-compressed",ras:"image/x-cmu-raster",rb:"text/x-script.ruby",rdf:"application/rdf+xml",rgb:"image/x-rgb",rm:"application/vnd.rn-realmedia",rmi:"audio/mid",roff:"text/troff",rpm:"application/x-redhat-package-manager",rss:"application/rss+xml",rtf:"application/rtf",rtx:"text/richtext",ru:"text/x-script.ruby",s:"text/x-asm",scd:"application/x-msschedule",sct:"text/scriptlet",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgm:"text/sgml",sgml:"text/sgml",sh:"application/x-sh",shar:"application/x-shar",sig:"application/pgp-signature",silo:"model/mesh",sit:"application/x-stuffit",skd:"application/x-koan",skm:"application/x-koan",skp:"application/x-koan",skt:"application/x-koan",smi:"application/smil",smil:"application/smil",snd:"audio/basic",so:"application/octet-stream",spc:"application/x-pkcs7-certificates",spl:"application/x-futuresplash",src:"application/x-wais-source",sst:"application/vnd.ms-pkicertstore",stl:"application/vnd.ms-pkistl",stm:"text/html",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",svg:"image/svg+xml",svgz:"image/svg+xml",swf:"application/x-shockwave-flash",t:"text/troff",tar:"application/x-tar",tbz:"application/x-bzip-compressed-tar",tcl:"application/x-tcl",tex:"application/x-tex",texi:"application/x-texinfo",texinfo:"application/x-texinfo",text:"text/plain",tgz:"application/x-compressed",tif:"image/tiff",tiff:"image/tiff",torrent:"application/x-bittorrent",tr:"text/troff",trm:"application/x-msterminal",tsv:"text/tab-seperated-values",txt:"text/plain",uls:"text/iuls",ustar:"application/x-ustar",vcd:"application/x-cdlink",vcf:"text/x-vcard",vcs:"text/x-vcalendar",vrml:"model/vrml",vxml:"application/voicexml+xml",war:"application/java-archive",wav:"audio/x-wav",wbmp:"image/vnd.wap.wbmp",wbxml:"application/vnd.wap.wbxml",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",webm:"video/webm",wks:"application/vnd.ms-works",wma:"audio/x-ms-wma",wmf:"application/x-msmetafile",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",wmlsc:"application/vnd.wap.wmlscriptc",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wps:"application/vnd.ms-works",wri:"application/x-mswrite",wrl:"model/vrml",wrz:"x-world/x-vrml",wsdl:"application/wsdl+xml",xaf:"x-world/x-vrml",xbm:"image/x-xbitmap",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xml:"application/xml",xof:"x-world/x-vrml",xpm:"image/x-xpixmap",xsl:"application/xml",xslt:"application/xslt+xml",xul:"application/vnd.mozilla.xul+xml",xwd:"image/x-xwindowdump",xyz:"chemical/x-xyz",yaml:"text/yaml",yml:"text/yaml",z:"application/x-compress",zip:"application/zip"};if(Ms&&!A)var Ba={};if(A&&!I){var Yi=Xi("proxy.pac");Us||(Yi="var FindProxyForUrl="+Yi,eval(Yi),Zi=FindProxyForUrl("http://"+Es,Es,!0))}else Zi={ip:Rn,port:kn,wsport:Pn,fing:Un,o_modulus:"8bd0a81286858b11f2856ac2f3efd8a5e538b2f851a4c02cc717c94ea52418c587cc69515e46b5381d17cd2299cb4c59fae38250898eab31c9b8acfcf02110a96f0f03442ecd34f1befb0604e1ffbb981848534da9f3f23795ed7df047730cb9dab711722ad6504b893cebda2de4b41123d667474a166eba3ead7df8267dda15"};if(Us){ks=!1,Rs=!1;var ka=Zi;if(js=!0,zs=!1,T){var Ra=ji?1e6*ji:1e5,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,qa=0,Ha={};E=!1,Ha.list=function(e,r){Ri.readdir(o,function(i,n){i||n.forEach(function(i){if(-1===i.indexOf("debug.txt")&&-1===i.indexOf("debug-prod.txt")){var n,s,a=i.split("#");if(a.length>1){var c=a[1].split(".");n=a[0]+(c.length>1?"."+c[1]:""),s=a[1].split(".")[0]}if(n)r||Ri.stat(o+i,function(t,r){if(!t){var a={file_name:i,name:n,name_hash:s,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(a)}});else{var l=sn.createhash("sha1");l.update(new t(Date.now().toString()+El.localAddress.toString()+El.localPort.toString(),"utf8")),l=l.digest("hex");var c=i.split(".");if(c.length){var h=c.pop();if(c.length){var n=c.join("."),u=n+"#"+l+"."+h;Ri.rename(o+i,o+u,function(){Ri.stat(o+u,function(t,r){if(!t){var i={file_name:u,name:n,name_hash:l,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(i)}})})}}}}})})};var Ma=function(){Ss&&Ss.send_db_info(!0)},ja=function(e){e=e.split("ws://")[1].split(":");var t=e[1],r=e[0];console.log("peersm client "+r+" "+t);var i=new rn.Socket;return i.on("connect",function(){i.key_=sn.randomBytes(16).toString("base64");var e="GET / HTTP/1.1\r\n";e+="Host: "+i.remoteAddress+":"+i.remotePort+"\r\n",e+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",e+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",e+="Accept-Language: en-us,en;q=0.5\r\n",e+="Accept-Encoding: gzip, deflate\r\n",e+="Connection: keep-alive, Upgrade\r\n",e+="Sec-WebSocket-Version: 13\r\n",e+="Origin: http://peersm.com\r\n",e+="Sec-WebSocket-Key: "+i.key_+"\r\n",e+="Pragma: no-cache\r\n",e+="Cache-Control: no-cache\r\n",e+="Upgrade: websocket\r\n",e+="\r\n",console.log(e),i.write(e)}),i.on("data",function(e){if(i.connected__){var t=Sc(i.stream_ws__?[i.stream_ws__,e].concatBuffers():e);i.stream_ws__=t[1].length?t[1]:null,i.onmessage({data:t[0]})}else{i.on("end",function(){console.log("websocket_node end"),i.onclose()}),i.on("error",function(){console.log("websocket_node error"),i.onclose()});var r=ic(e.toString("utf8")),n=r["Sec-WebSocket-Accept"]||r["Sec-Websocket-Accept"];if(n){var s=sn.createHash("sha1");s.update(i.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var a=s.digest("base64");n===a?(console.log("Client says : Handshake successfull for "+El.remoteAddress+" "+El.remotePort),i.write=function(e){i._write(Ac(e,2,!0),null,function(){})},i.send=i.write,i.connected__=!0,i.onopen()):i.end()}else i.end()}}),i.close=i.end,i.connect(t,r),i},za=function(){};za.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Va=function(){};Va.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Ka=function(e){this.data=[],this.cursor=0,this.size=e};Ka.prototype.push=function(e){this.data.push(e),this.cursor+=e.length},Ka.prototype.unshift=function(e){this.data.unshift(e),this.cursor-=e.length},Ka.prototype.slice=function(e,r){var i,n,s=r-e,a=0,o=[];if(s>0&&this.data.length){for(s=Math.min(s,this.cursor);s>a;){var c=this.data.shift(),l=c.length;o.push(c),a+=l,this.cursor-=l}return i=o.concatBuffers(),n=i.slice(s),i=i.slice(0,s),this.cursor+=n.length,n.length&&this.data.unshift(n),i}return new t(0)};var Ga=function(e){this.fd=e.fd,this.size=e.size,this.type=e.type,this.cursor=0};Ga.prototype.slice=function(e,r){if(r){if(r>e){var i=new t(r-e);return Ri.readSync(this.fd,i,0,r-e,e+this.cursor),i}return new t(0)}return this.size=this.size-e,this.cursor=e,this};var Ya=function(){var e={};return e.get=function(e){var t={};return Ri.readdir(o,function(r,i){if(r)t.onsuccess({target:{result:null}});else{for(var n,s=!1,a=i.length,c=0;a>c;c++){var l=i[c];if(-1===l.indexOf("debug.txt")){var h,u,d=l.split("#");if(d.length>1){var f=d[1].split(".");f.length>1&&(n=f[1],h=d[0]+(f.length>1?"."+f[1]:"")),u=d[1].split(".")[0]}if(u===e){s=!0,Ri.stat(o+l,function(e,r){!e&&n?Ri.open(o+l,"r",function(e,i){if(e)t.onsuccess({target:{result:null}});else{var s;n&&(s=xa[n]),s||(s="application/octet-binary"),console.log(h+" "+u+" "+s);var a={fd:i,size:r.size,type:s};t.onsuccess({target:{result:{file_length:r.size,current_length:r.size,type:s,data:a}}})}}):t.onsuccess({target:{result:null}})});break}}}s||t.onsuccess({target:{result:null}})}}),t},e};Wi=function(){Yi="var FindProxyForUrl="+Yi,eval(Yi);var t=FindProxyForUrl("http://"+Es,Es,!0);Zi=t[1][_o(t[1].length)],ka=e?{ip:"213.246.53.127",port:0,wsport:0,fing:"E0671CF9CB593F27CD389CD4DD819BF9448EA834",o_modulus:"ca2a670479816ca562f7afc2667db1811f0efa7d595aa27cf532092a052c697b102c03d8b8dddc276050fe9cad15efe72758d9d9b0f581f5cbfd0be92ecd721711797354006625e74e0f733efee3ee779116efe87da3b5f8c1729e2d0a5f2c4de4d5906b6e383c0a0d8dddbc076cf426423f6f2b6fd46fab9f54fb8e42601a2d",name:"Tor Bridge"}:t[2],Js=!0,on=Guards,Ba.userAgent="node-Tor",Il()},Qi=function(){var e=function(){console.log("update prox --------"),Yi="var FindProxyForUrl="+Yi,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0)};Xi(e)},Xi(Wi),setInterval(Ma,1e4),setInterval(Qi,ss)}if(A){var Ha,Ra=0,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,Wa=document.getElementById.bind(document),qa=0,Qa=document.location.href.split("/"),Xa=Qa[Qa.length-1].split("#")[0],Ja=function(e){return e.pageY?e.pageY:e.clientY},Za=function(e){return e.pageX?e.pageX:e.clientX},$a=function(e,t,r,i){e.__event=e.__event||{},e.__event[t]&&eo(e,t,e.__event[t][0],e.__event[t][1]),e.__event[t]=[r,i],e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r)},eo=function(e,t,r,i){e.addEventListener?e.removeEventListener(t,r,i):e.attachEvent&&e.detachEvent("on"+t,r)},to=[Qs,"exe","com","bin","php","php3","php4","php5","phtml","inc","sql","pl","cgi","py","sh","c","cc","cpp","cxx","h","hpp","java","class","jar","html","html","shtml","dhtml","xhtml","xml","js","css","zip","tar","tgz","gz","bz2","tbz","rar","mp3","wav","3ga","midi","mid","rm","ra","ram","pls","m3u","mkw","webm","avi","mp4","m4v","mpg","mpeg","mov","swf","fla","doc","docx","xls","xlsx","rtf","pdf","txt","ppt","pptx","vcard","vcf","obj","max","3ds","3dm","kml","torrent","gpx","dxf","dwg","wsg","vb","pif","gadget","apk","msi","sxc","123","ots","nb","gsheet","xlr","ods","svgz","cdr","svg","ps","eps","orf","pef","rwl","mrw","mef","fff","erf","dcr","bay","3fr","srf","rw2","nef","cr2","arw","dng","dwt","irs","ait","art","aip","aia","ai","indd","prtpset","ppj","plb","prproj","aetx","aet","aes","aepx","aep","aec","ncorx","ncor","em","abr","csh","psb","psd","as","asc","ascs","aif","aiff","flac","iff","m4a","wma","srt","flv","3g2","3gp","asf","wmv","pcast","xlt","xltm","xltx","ans","ascii","log","odt","wpd","accdb","db","dbf","mdb","pdb","asp","aspx","asx","fnt","otf","ttf","dotx","wps2","dll","fon","cmd","srt"],ro=["tga","gif","jpg","tiff","jpeg","bmp","png"];to.forEach(function(e){La[e]="http://www.peersm.com/img/extensions/"+e+".png"});var io=function(){var e=new XMLHttpRequest;if(e){e.open("POST","bandwidth.html",!0);var t=Date.now(),r=1e5;e.send(new Uint8Array(r)),e.onreadystatechange=function(){if(4==e.readyState){var r=1e5/((Date.now()-t)/1e3);Ra=parseInt((Ra?(Ra+r)/2:r)/Ua),console.log("bandwidth : "+8*Ra/1e3+" Kbps")}}}};setInterval(io,18e6),io()}}on=Guards;var no=function(){Ri.rename(o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt"),o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt")+".old",function(){})};no(),A||T||x||console.log(Pi+" "+Fi+" "+qi+" "+Hi+" "+Mi);var so=function(e){var t=e.split("magnet:?xt=urn:btih:");return t.length>1?t[1]:void 0},ao=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Accept-Ranges:bytes",e+="Content-Encoding:gzip\r\n",e+="Content-Length:0\r\n",e+="Content-Type:*\r\n",e+="\r\n"},oo=function(){var e="HTTP/1.1 410 Gone\r\n";return e+="\r\n"},co=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Vary: Accept-Encoding\r\n",e+="Keep-Alive: timeout=2, max=100\r\n",e+="Connection: Keep-Alive\r\n",e+="Transfer-Encoding: chunked\r\n",e+="Content-Type: text/html\r\n",e+="\r\n1f\r\n//Outside of authorized domains\r\n0\r\n\r\n"},lo=function(e){var t="HTTP/1.1 301 Moved Permanently\r\n";return t+="Location: "+e+"\r\n",t+="\r\n"},ho=function(e){var t={url:e},r=e.split("/"),i=function(e){if(e.length){var r=e[0];t.host=r,e.shift()}t.rest=e.join("/")};return r.length>1?""===r[1]?(t.protocol=r[0]?r[0]:ws,r.shift(),r.shift()):t.protocol=ws:t.protocol=ws,i(r),t},uo=function(e){var t=[];return t.push(e.protocol?e.protocol:protocol),t.push(""),e.host&&t.push(e.host),e.rest&&t.push(e.rest),t.join("/")},fo=function(e,r){var i=new t(Eo(r?new t(e,"utf8"):new t(e,"hex"),Bl),"hex");return r?i.toString("hex"):i.toString("utf8")},po=function(e){var t=e.slice(0,1),r=e.slice(1,2),i=e.slice(2,2+r.readUInt());return e=e.slice(r.readUInt()+2),{data:e,addr:{type:t,length:r,value:i}}},_o=function(e){return parseInt(Math.random()*e)},go=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()+(e.getMilliseconds()>500?1:0),0)},mo=function(e){var t,r,i=[],n=[],s=[],a=e.nb_hop||Fn;if(a>Fn&&(a=Fn),e.nb_try=e.nb_try||1,e.nb_try>qn)return console.log("PATH : createPath : Too many attempts"),void 0;for(r=Guards.length,t=_o(r),t=Guards[t].split("-"),s.push(t[1]),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),a--,r=on.length,a--;a;)t=_o(r),-1==i.indexOf(t)&&on[t].split("-")[1]!=n[0].ip&&(i.push(t),a--);var o=function(e){var t=on[e].split("-"),r={ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]};s.push(t[1]),n.push(r)};for(i.forEach(o),r=Exit.length,t=_o(r);-1!=s.indexOf(Exit[t].split("-")[1]);)t=_o(r);return t=Exit[t].split("-"),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),n},yo=function(e,r){var i="GET /"+r+" HTTP/1.1\r\n";return i+="Host: "+e+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",new t(i,"utf8")},vo=function(e,r,i){var n="GET /"+r+" HTTP/1.1\r\n";return n+="Host: "+e+"\r\n",n+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",n+="Range: bytes="+i+"-\r\n",n+="Accept: */*\r\n",n+="Accept-Language: en\r\n",n+="Accept-Encoding: gzip, deflate\r\n",n+="Connection: keep-alive\r\n",n+="\r\n",new t(n,"utf8")},bo=function(e,t,r){var i=0;if(e.nbc_=e.nbc_?e.nbc_:0,t){if(e.nbc_===On)return!1}else if(65534===e.nbc_)return!1;for(;e[i]||0===i;)i=t?r?e.cid?++e.cid%On:On:e.cid?++e.cid%On:1:e.cid?++e.cid%65535:1;return e.cid=i,e.nbc_++,i},wo=function(e){for(var r="",i=0;5>i;i++){var n=sn.createhash("sha1");n.update(new t(e+"0"+i,"hex")),r+=n.digest("hex")}return new t(r,"hex")},Eo=function(e,t){var r=sn.createcipheriv("aes-128-ctr",t,Ln),i=r.update(e,"hex","hex");return i+=r.final("hex")},Co=function(e,r){var i=r.slice(0,70),n=r.slice(70),s=No(16),a=[s,i].concatBuffers(),o=new un;a=o.encrypt(new t(e.toString("hex"),"binary"),new t(Nn,"binary"),new t(a.toString("binary"),"binary"),"RSA_PKCS1_OAEP_PADDING","hex");var c=Eo(n,s);return[new t(a,"hex"),new t(c,"hex")].concatBuffers()},So=function(e,r,i){var n=new un,s=new t(n.decrypt(e,r,"RSA_PKCS1_OAEP_PADDING","hex"),"hex"),a=s.slice(0,16);return[s.slice(16),new t(Eo(i,a),"hex")].concatBuffers()},Ao=function(e){if(T){if(this.fc_t.length){var t=this.fc_t.shift();t()}}else if(e.source==window&&e.data==this.messageName&&(e.stopPropagation(),this.fc_t.length)){var t=this.fc_t.shift();t()}},Io=function(e,t,r,i){if(r)if(r.stop_)r._torrent_&&r._torrent_stream.destroy(),r=null,console.log("delete sid 2"),delete this[t];else{if(r._torrent_&&T&&"undefined"==typeof i){var n=Date.now()-r.start_t0;i=Math.ceil(1e6*n*ji/1e3/Da/ds),console.log("first blocks nb "+i)}else i="undefined"==typeof i?Fa:i;var s=[];if(r.reader.onload=function(n){if(n.target.result){var a=n.target.result instanceof ArrayBuffer?new Uint8Array(n.target.result):n.target.result;if(a.length)for(var o=0;i>o;o++){if(0===r.stream_window_s){r.cursor-=a.length,r._torrent_&&r._torrent_.unshift(a);break}if(r.stream_window_s--,s.push(a.slice(0,Math.min(a.length,pn))),!(a.length>pn))break;a=a.slice(pn)}}var c=Date.now();r.fc_t.push(function(){To.call(this,e,s,r,t,c)}.bind(this)),T?setTimeout(Ao.bind(r),0):window.postMessage("flush","*")}.bind(this),0!==i){var a=e.slice(r.cursor,Math.min(e.size,r.cursor+i*pn));r.cursor+=a.length,r.reader.readAsArrayBuffer(a)}else r.reader.onload({target:{result:null}})}},To=function(e,t,r,i,n){t.forEach(function(e){r.sent_+=e.length;var t=new qo(qo.prototype.RELAY_DB_DATA,i,e,this.last_.Df_hash),n=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(n)},this);var s,a=Date.now()-n,o=T?this.socket_.bufferSize:this.socket_.bufferedAmount,c=parseInt((r.cursor-o)/((Date.now()-r.start_t0)/1e3)),l=8*c,h=ba;if(r.cursorh)s=0;else if(T)s=Math.ceil(a*c/1e3/Da/ds);else{var u=Pa>o?Math.ceil((Pa-o)/Da):0;a&&(s=Math.ceil(a*c/1e3/Da/ds)),s=s?Math.min(u,s):u}s=l>h?0:o>Pa?0:s>Fa?s:Fa,m&&0!==a&&0!==s&&console.log("real bandwidth "+parseInt(8*c/1e3)+" kbps "+"- advertised bandwidth "+parseInt(8*Ra/1e3)+" kbps time "+a+" nbblocs "+s+" buffered amount "+o+" cursor "+r.cursor+" torrent buffered "+(r._torrent_?r._torrent_.cursor:"")),0!==r.stream_window_s||r.pause_[i]?e.size===r.cursor?(console.log("delete sid"),delete this[i],console.log(parseInt(8*r.cd_length/((Date.now()-r.start_t0)/1e3))+" bps")):this.send_db_data(e,i,s,!0):(console.log(parseInt(8*r.cursor/((Date.now()-r.start_t0)/1e3))+" kbps"),console.log("Pausing download CIC "+this.circId+" for stream "+i+" sent "+r.sent_+" remaining length "+(e.size-r.cursor)+" time "+Date.now()+" buffered amount "+o+" fc_t "+r.fc_t.length),r.pause_[i]=e)},xo=function(e){var t=bo(e),r={};return r.sid_=t,r.received_=0,r.sent_=0,r.stream_window=Oa,r.stream_window_s=Oa,r.send_data=!0,e[t]=r,r.pause_={},t},Bo=function(e){if(e){var t=e.split(".");return t=t.length?t[t.length-1]:""}return"exe"},ko=function(e){var t=e.cid_,r=e.sid_;r&&delete t[r],delete e.cid_,delete e.sid_},Ro=function(e){lh(e.bar_),lh(Th),lh(nh)},Uo=function(e,r,i){console.log("search in bittorrent");for(var n=An;n.length;)if(n[0].socket_)if(n[0].socket_.remoteAddress){if(!n[0].destroyed_)break;console.log("ORDB remove destroyed CIC fac "+n[0].circId),n.shift()}else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();if(n.length){var s=n[0];n.shift(),n.push(s);var a=No(16),o={d_length:r,hash_:new t(i,"hex")};In[a.toString("hex")]=[this,e,n,o,1],s.send_db_query(o,a)}else this.send_db_end(0,e)},Do=function(e){if("open"===e._stream_.readyState&&!e._source_.updating)if(e.append_buffer.length){e.append_cursor++;var t=e.append_buffer.shift();try{e._source_.appendBuffer(t)}catch(r){console.log("error updateend ")}}else e.append_cursor=0};t.prototype.readUInt=function(){switch(this.length){case 1:return this[0];case 2:return this.readUInt16BE(0);case 4:return this.readUInt32BE(0);default:return 0}},t.prototype.writeUInt=function(e){switch(this.length){case 1:this.writeUInt8(e,0);break;case 2:this.writeUInt16BE(e,0);break;case 4:this.writeUInt32BE(e,0)}return this},t.prototype.map=function(e){var t=e.length;Hs||A?(this.set(e),this.fill(0,t)):(e.copy(this),this.fill(0,t))},Array.prototype.concatBuffers2=function(){var e=[];return this.forEach(function(t){e.push(t.toString("hex"))}),new t(e.join(""),"hex")},Array.prototype.concatBuffers1=function(){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){for(var t=e.length,n=0;t>n;n++)r[i]=e[n],i++}),r},Array.prototype.concatBuffers=function(){if(Hs||A){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){var t=e.length;r.set(e,i),i+=t}),r}return t.concat(this)},t.prototype.parse=function(e){e.WS_OP_&&e.ws_;for(var t=e.stream_tor_;t.length;){var r,i=t.slice(0,2),n=t.slice(2,3),s=i.readUInt();if(e[s]&&e[s].clear_timers(),7==n.readUInt()||n.readUInt()>=128){var a=t.length;if(!(a>=5))break;var o=t.readUInt16BE(3);if(!(a>=o+5))break;r=t.slice(5,o+5),t=t.slice(o+5)}else{if(!(t.length>=512))break;r=t.slice(3,512),t=t.slice(512)}var c=new Po(i.readUInt(),n.readUInt(),r,!0);Vo.bind(e)([c])}e.stream_tor_=t;var l=e.queue_;e.WS_OP_&&e.ws_,l.shift(),l.length&&l[0]()},t.prototype.parseTLS=function(e){for(var r,i=e.stream_tor_;i.length;){var n=i.length;if(!(n>=5))break;var s=i.readUInt16BE(3);if(!(n>=s+5))break;if(r=i.slice(0,s+5),i=i.slice(s+5),22!==r[0]||e.ccs_)20===r[0]&&(e.ccs_=!0),e.process(r);else for(var a=r.readUInt(1,2),o=r.readUInt(3,3),c=r.slice(5,o);c.length;){var n=c.length;if(!(n>=4))break;var l=c.readUInt(1,3);if(!(n>=l+4))break;var h=[new t(1).writeUInt(22),new t(2).writeUInt(a),new t(2).writeUInt(l+4),c.slice(0,l+4)].concatBuffers();e.process(h),c=c.slice(l+4)}}e.stream_tor_=i;var u=e.queue_;u.shift(),u.length&&u[0]()},(A||Hs)&&(t=function(e,t){if(t||"string"!=typeof e||(t="utf8"),e instanceof Array||!isNaN(e)&&!t)return new Uint8Array(e);if("utf8"===t)return new dt("utf-8").encode(e);if("hex"===t)try{for(var r=new Uint8Array(e.length/2),i=e.length,n=0;i>n;n+=2)r[n/2]=parseInt(e[n]+e[n+1],16) -}catch(s){return new Uint8Array}if("binary"===t)for(var r=new Uint8Array(e.length),i=r.length,n=0;i>n;n++)r[n]=e.charCodeAt(n);return r},_s.isBuffer=function(e){return e instanceof this||e instanceof Uint8Array},Uint8Array.prototype.isBuffer=_s.prototype.isBuffer,Uint8Array.prototype.parse=_s.prototype.parse,Uint8Array.prototype.parseTLS=_s.prototype.parseTLS,t.isBuffer=function(e){return e instanceof Uint8Array},Uint8Array.prototype.slice=function(e,t){return t?this.subarray(e,t):this.subarray(e)},Uint8Array.prototype.map=function(e){var t=e.length;this.set(e),this.fill(0,t)},Uint8Array.prototype.readUInt=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16BE(e);case 3:return this.readUInt24BE(e);case 4:return this.readUInt32BE(e);default:return 0}},Uint8Array.prototype.readUIntLE=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16LE(e);case 4:return this.readUInt32LE(e);default:return 0}},Uint8Array.prototype.writeUInt=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16BE(e,t);break;case 3:this.writeUInt24BE(e,t);break;case 4:this.writeUInt32BE(e,t)}return this},Uint8Array.prototype.writeUIntLE=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16LE(e,t);break;case 4:this.writeUInt32LE(e,t)}return this},Uint8Array.prototype.fill=function(e,t){for(var r=this.length,i=t;r>i;i++)this[i]=e},Uint8Array.prototype.readUInt16BE=function(e){return this[e]<<8^this[e+1]},Uint8Array.prototype.readUInt24BE=function(e){return this[e]<<16^this[e+1]<<8^this[e+2]},Uint8Array.prototype.readUInt32BE=function(e){return this[e]<<24^this[e+1]<<16^this[e+2]<<8^this[e+3]},Uint8Array.prototype.readUInt16LE=function(e){return this[e]^this[e+1]<<8},Uint8Array.prototype.readUInt32LE=function(e){return this[e]^this[e+1]<<8^this[e+2]<<16^this[e+3]<<24},Uint8Array.prototype.writeUInt8=function(e,t){this[t]=e},Uint8Array.prototype.writeUInt16BE=function(e,t){this[t]=255&e>>8,this[t+1]=255&e},Uint8Array.prototype.writeUInt24BE=function(e,t){this[t]=255&e>>16,this[t+1]=255&e>>8,this[t+2]=255&e},Uint8Array.prototype.writeUInt32BE=function(e,t){this[t]=255&e>>24,this[t+1]=255&e>>16,this[t+2]=255&e>>8,this[t+3]=255&e},Uint8Array.prototype.writeUInt16LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8},Uint8Array.prototype.writeUInt32LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8,this[t+2]=255&e>>16,this[t+3]=255&e>>24},Uint8Array.prototype.toString=function(e){var t=this.length,r=[];if("utf8"===e)return new ft("utf-8").decode(this);if("hex"===e)for(var i=0;t>i;i++){var n=this[i].toString(16);r.push(1===n.length?"0"+n:n)}return"binary"===e?String.fromCharCode.apply(null,this):r.join("")},Ln=new t("00000000000000000000000000000000","hex"));var No=function(e){return sn.randomBytes(e)},Lo=function(e){for(var t=e.length,r=[],i=0;t>i;i++)r.push(e[i]);return r.join(".")},Oo=function(e){return new t(e.split("."))},Po=function(e,r,i,n){this.CircID=new t(2).writeUInt(e),this.Command=new t(1).writeUInt(r),this.Length=new t(2).writeUInt(i.length),this.Payload=n?zo.bind(this)(i):i};Po.prototype={PADDING:0,CREATE:1,CREATED:2,RELAY:3,DESTROY:4,CREATE_FAST:5,CREATED_FAST:6,NETINFO:8,RELAY_EARLY:9,VERSIONS:7,CREATE_FAST_WS:120,CREATED_FAST_WS:121,VPADDING:128,CERTS:129,AUTH_CHALLENGE:130,AUTHENTICATE:131,AUTHORIZE:132,RELAY_WS:190,versions_cell_decode:function(e){for(var t=[];e.length;)t.push(e.slice(0,2)),e=e.slice(2);return t},certs_cell_decode:function(e){var t=e.slice(0,1);e=e.slice(1);var r=[];for(r.push(t);e.length;){var i={};i.CertType=e.slice(0,1),i.CLEN=e.slice(1,3);var n=i.CLEN.readUInt();i.Certificate=e.slice(3,3+n),e=e.slice(3+n),r.push(i)}return r},auth_challenge_cell_decode:function(e){var t=[],r={};return r.Challenge=e.slice(0,32),r.N_Methods=e.slice(32,34),r.Methods=e.slice(34,34+r.N_Methods.readUInt()),t.push(r),t},netinfo_cell_decode:function(e){var t=[],r={};r.Timestamp=e.slice(0,4);var i=po(e.slice(4));e=i.data,r.other_OR=i.addr,r.nb_addresses=e.slice(0,1),r.this_ORs=[],e=e.slice(1);for(var n=r.nb_addresses.readUInt(),s=0;n>s;s++){var a=po(e);r.this_ORs.push(a.addr),e=a.data}return t.push(r),t},create_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),t.push(r),t},create_fast_ws_cell_decode:function(e){var r=[],i={},n=new un;try{i.key_material=new t(n.decrypt(Xs,e.slice(0,128).toString("hex"),"","hex"),"hex"),r.push(i)}catch(s){console.log("create fast pb decrypting")}return r},created_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),r.derivative_key_data=e.slice(20,40),t.push(r),t},created_fast_ws_cell_decode:function(e){var t=[],r={};return r.key=e.slice(0,40),t.push(r),t},create_cell_decode:function(e){var t=[],r={};return r.M_=e.slice(0,128),r.M2_=e.slice(128,186),t.push(r),t},created_cell_decode:function(e){var t=[],r={};return r.dh_data=e.slice(0,128),r.derivative_key_data=e.slice(128,148),t.push(r),t}};var Fo=function(e){e&&(this.OP_=!0,this.server_=e[0],this.path_=e,this.nb_=0,this.conn_=0,this.sent_=0,this.received_=0,this.circuit_window=cs,this.circuit_window_s=cs,this.stream_=[],this.pause_={},this.time_=(new Date).valueOf(),this.resolved_failed=0),this.perf_=0,this.time_average=0};Fo.prototype={padding_cell_handle:function(){this.next_&&this.next_.keep_alive()},versions_cell_handle:function(e){var r=this.socket_;if(!this.OR_||this.onion_)e.Payload.forEach(function(e){3==e.readUInt()&&(r.handshake_=3)},this),r.handshake_||this.end("v3 handshake not supported","handshake");else{var e=new Po(this.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));if(this.send(e),!r.ws_){var i={};i.CertType=new t(1).writeUInt(1),i.Certificate=new t(al(o+"pub-key.pem",o+"priv-id-key.pem","der",r.certid_,r.cert_date,r.cert_subject,r.cert_issuer),"hex"),i.CLEN=new t(2).writeUInt(i.Certificate.length),i=[i.CertType,i.CLEN,i.Certificate].concatBuffers();var n={};n.CertType=new t(1).writeUInt(2),n.Certificate=new t(al(o+"pub-id-key.pem",o+"priv-id-key.pem","der",parseInt(No(8).toString("hex"),16),r.cert_date,r.cert_issuer,r.cert_issuer),"hex"),n.CLEN=new t(2).writeUInt(n.Certificate.length),n=[n.CertType,n.CLEN,n.Certificate].concatBuffers(),e=new Po(this.circId,Po.prototype.CERTS,[new t(1).writeUInt(2),i,n].concatBuffers()),this.send(e);var s={};s.Challenge=No(32),s.N_Methods=new t(2).writeUInt(1),s.Methods=new t(2).writeUInt(0),e=new Po(this.circId,Po.prototype.AUTH_CHALLENGE,[s.Challenge,s.N_Methods,s.Methods].concatBuffers()),this.send(e)}var a=[],c={};c.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),c.other_OR={type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.remoteAddress)},c.nb_addresses=new t("01","hex"),c.this_ORs=[{type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.address().address)}],a.push(c),e=new Po(this.circId,Po.prototype.NETINFO,a),this.send(e)}},certs_cell_handle:function(){},auth_challenge_cell_handle:function(){},netinfo_cell_handle:function(e){var r={};if(!this.OR_f){var i=this.socket_.remoteAddress;if(e.Length=0,r.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),e.Length+=4,e.Payload[0].this_ORs.forEach(function(t){(Lo(t.value)==i||this)&&(r.other_OR=t,e.Length+=t.length,this._OR_ip_verified=!0)},this),this._OR_ip_verified)if(r.nb_addresses=new t(1).writeUInt(1),e.Length++,r.this_ORs=[e.Payload[0].other_OR],e.Length+=r.this_ORs[0].length,e.Payload=[r],this.send(e),this.socket_.handshake=!0,this.OP_)if(this.setCircId(),!zs&&!js||!ks&&!Us||Cs&&!Js)this.create();else if(A&&Zi&&(!Cs&&$i||!Js)){this.X_=No(20);var n=new t(vl.encrypt(this.X_.toString("hex")),"hex"),s=new Po(this.circId,Po.prototype.CREATE_FAST_WS,n);this.send(s)}else{this.X_=No(20);var s=new Po(this.circId,Po.prototype.CREATE_FAST,this.X_);this.send(s)}else this.setCircId(),this.create();else this.end("remote IP does not match","handshake")}},create_fast_cell_handle:function(e){console.log("OR receive create fast from "+this.socket_.remoteAddress+" CIC "+this.circId+" sending created_fast"),this.X_=e.Payload[0].key_material,this.Y_=No(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new Po(this.circId,Po.prototype.CREATED_FAST,[this.Y_,r].concatBuffers());this.send(i)},create_fast_ws_cell_handle:function(e){if(e.Payload.length){this.X_=e.Payload[0].key_material,this.Y_=No(20);var r=[this.X_,this.Y_].concatBuffers(),i=this.circuit_keys(r),n=new Po(this.circId,Po.prototype.CREATED_FAST_WS,new t(Eo([this.Y_,i].concatBuffers(),this.X_.slice(0,16)),"hex"));this.send(n)}else this.destroy(1)},created_handle:function(){if(this.conn_++,(zs||js)&&(ks||Us)&&!Cs&&$i&&this.request_.params_.ws===Cl&&delete this.next_,this.next_)this.extended_=this.next_,this.extend();else if((zs||js)&&(ks||Us)){if(console.log("CIRC : CIRCUIT ESTABLISHED FAST - CID "+this.circId+" "+(this.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(this.prev_?this.prev_.server_.ip:"NONE")+" LAST OR : "+this.server_.ip),Cs=this,ks)for(var e in bs)bs[e].associated||El.associate(this.first_,e);!es&&Zi&&(ks?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):El.db_cid_launched||rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})),this.first_.last_=this}else console.log("CIRC : CAN NOT HAVE ONLY ONE NODE IN THE PATH"),this.end("CAN NOT HAVE ONLY ONE NODE IN THE PATH")},created_fast_cell_handle:function(e){console.log("created fast received CIC "+this.circId),this.Y_=e.Payload[0].key_material;var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t);r.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},created_fast_ws_cell_handle:function(e){var r=new t(Eo(e.Payload[0].key,this.X_.slice(0,16)),"hex");this.Y_=r.slice(0,20);var i=[this.X_,this.Y_].concatBuffers(),n=this.circuit_keys(i);n.toString("hex")!=r.slice(20,40).toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},create_cell_handle:function(e){var r=e.Payload[0].M_,i=e.Payload[0].M2_;this.X_=So(this.socket_.privkey_.toString("utf-8"),r.toString("hex"),i);var n=sn.getDiffieHellman("modp2");n.generateKeys(),this.Y_=new t(n.getPublicKey("hex"),"hex");var s=new t(n.computeSecret(this.X_,"hex","hex"),"hex"),a=this.circuit_keys(s),o=new Po(this.circId,Po.prototype.CREATED,[this.Y_,a].concatBuffers());this.send(o)},created_cell_handle:function(e){if(this.OP_){console.log("OP created "+this.circId);var r=this.extended_?this.extended_:this;if(r.Y_=e.Payload[0].dh_data,A&&!r.DH_.computeSecret){var i=new t(1).writeUInt(2);vn[r.cid_hex]=function(t){var r=this.extended_?this.extended_:this,i=t.toString("hex");r.DH_.computeSecret=function(){return i},delete vn[r.cid_hex],this.created_cell_handle(e)}.bind(this);var n=new qo(qo.prototype.RELAY_INFO,0,[i,new t(r.cid_hex,"hex"),r.Y_].concatBuffers(),Cs.Df_hash),s=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(n));return Cs.send(s),void 0}var a=new t(r.DH_.computeSecret(r.Y_,"hex","hex"),"hex"),o=r.circuit_keys(a);if(o.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex"))r.end("KH key does not match","created_extended_key");else if(this.conn_++,r.ok_=!0,r.next_)r.extended_=r.next_,r.extend();else{if(zs&&ks)for(var c in bs)bs[c].associated||El.associate(this.first_,c);Us&&this.first_.request_.params_.db&&!Ss?(Ss=this.first_,Ss.send_db_info(),Ss.process=Ss.send_db_query,setInterval(this.send_db_info.bind(Ss),As),r?console.log("CIRC : CIRCUIT ESTABLISHED -CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined")):this.first_.request_.params_.db?(console.log("created handle circuit destroy"),this.first_.circuit_destroy()):(r?console.log("CIRC : CIRCUIT ESTABLISHED - CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined"),Qn++),$n>Qn&&Zi&&(js||zs?ks||Ss?(console.log("create new dl circuit"),rc({params_:{OP:!0,nb_hop:Hn,ws:El}})):rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}):rc({params_:{OP:!0,nb_hop:Hn}})),this.first_.last_=r,this.first_.process();var l=mn;if(l)for(;l.length;)this.first_.process(l[0]),l.shift()}}else if(this.prev_){console.log("OR process extend - created received from "+this.server_.ip+" sending relay_extended to CIC "+(this.prev_?this.prev_.circId:"undefined"));var h=e.Payload[0],n=new qo(qo.prototype.RELAY_EXTENDED,0,[h.dh_data,h.derivative_key_data].concatBuffers(),this.prev_.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY_EARLY,!0)}else this.next_.destroy()},extend_cell_handle:function(e){if(ka&&this.socket_.address().port===kn&&this.OR_f)console.log("ORDB - Do not extend send destroy"),this.circuit_destroy();else{var r=Lo(e.slice(0,4)),i=e.slice(4,6).readUInt(),n=e.slice(6,192),s=e.slice(192,212).toString("hex"),a=new Fo;if(a.server_={ip:r,port:i,fing:s},console.log("OR process extend toward "+a.server_.ip+" "+a.server_.port+" "+a.server_.fing),this.next_=a,a.prev_=this,a.onion_=n,a.OR_=!0,a.way_="socket out",a.circId=0,bn[r])a.socket_=bn[r],a.socket_.stream_tor_=new t(0),a.setCircId(),a.create(),console.log("OUTGOING OR SOCKET EXTEND : ---------Socket already exists send create ------------ CIC "+a.circId+" for "+a.server_.ip);else{var c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",l="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",h={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,c,l),servername:c,rejectUnauthorized:!1};console.log("OUTGOING OR SOCKET EXTEND : ---------OR starts client socket with------------"+h.servername+" "+a.server_.ip+" "+a.server_.port);var u=tn.connect(a.server_.port,a.server_.ip,h,function(){bn[a.server_.ip]=this,console.log("OR process extend sending versions"),a.socket_=this,this.OR_=!0,this.way_="socket out",this[a.circId]=a,this.stream_tor_=new t(0);var e=new Po(a.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));a.send(e)});u.on("data",Qo),u.circuits_destroy=function(){for(var e in wn)Object.keys(wn[e]).forEach(function(t){if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=wn[e][t];r&&r.socket_&&r.socket_.remoteAddress&&r.next_&&r.next_.socket_===u&&(console.log("destroy circ in CIC "+r.circId+" "+r.socket_.remoteAddress),r.circuit_destroy())}})},u.on("end",function(){console.log("or_tls_socket end"),delete bn[r],u.circuits_destroy()}),u.on("close",function(){console.log("or_tls_socket close"),delete bn[r],u.circuits_destroy()}),u.on("error",function(){console.log("or_tls_socket error"),delete bn[r],u.circuits_destroy()})}}},handle_destroy:function(e){if(this.OP_){var t=this.first_||this;console.log("OP receive destroy CIC "+t.circId+(t===Ss?" ------- DB_CID destroyed --------------- ":"")),t.destroyed_=!0,this.clear_timers(),t.circuit_destroy(!0)}else{console.log("OR "+(this.OR_f?"in":"out")+" received destroy from "+this.socket_.remoteAddress+" on CID "+this.circId);var t=this.prev_||this.next_;t?(console.log("OR "+(this.OR_f?"in":"out")+" send destroy to "+(t.socket_?t.socket_.remoteAddress:"")+" on CID "+t.circId),e=e.toString(),e=1===e.length?"0"+e:e,t.circuit_destroy(),this.circuit_destroy(!0)):this.circuit_destroy()}},relay_cell_handle:function(e,t){var r=e.Payload[0],i=e.Command.readUInt();this.OP_?this.stream_decrypt_backward(r,t):this.prev_?this.stream_encrypt_or_b(r,i):this.stream_decrypt_or_f(r,i)},relay_send_truncate:function(e){var r=new qo(qo.prototype.RELAY_TRUNCATE,0,new t(1).writeUInt(e),this.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(r));this.send(i)},relay_end_handle:function(e,r){var i=this.first_,n=i[e],s=function(){n.download_&&(Lh('

    An unexpected event occured(error '+r+"), please retry

    "),lh(n.bar_)),n._write_(new t(oo(),"utf8")),n.end()};if(n&&(n.abstract_client_tls&&n.abstract_client_tls.close(),delete n.abstract_client_tls,!n.destroyed))if(-1===[6,12].indexOf(r))Us||(console.log(n.nb_try),n.nb_tryZn||0===i.sent_)&&(i.bad_=!0),i.destroy_cid(n),i.request_retry(n,r)):s());else if(n._data_)if(12===parseInt(r))if(console.log("END : CONNRESET RETRY "+r+" CID "+this.first_.circId+" on port "+n.remotePort+" for request "+n.i_id),n.download_)if(n.url_){var a=function(){n.queue_.shift(),Lh('

    Remote server closed the connection (error '+r+"), download could not be completed, resuming...

    "),setTimeout(function(){Wa("alert_box").style.display="none"},1e4);var s=function(r){var n=ho(r.url_);r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.params_.stream=vo(n.host,n.rest,length),r.queue_=[],r.queue_s=[],delete r.eof_,delete i[e],delete r.cid_,delete r.check_hash,delete r.file_id,delete r.start_t0,r.received_=0,rc(r)};ah(n,!0,s)};n.queue_.push(a),1===n.queue_.length&&n.queue_[0]()}else $a(document.body,"mousedown",function(){},!1),Lh('

    Remote server closed the connection (error '+r+"), download could not be completed, please use Resume to resume the download.

    "),n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]());else i.perf_--,i.destroy_cid(n),n.destroy();else n.bufferSize||(ks&&n.abstract_client_tls?n.done_=!0:n.download_?n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]()):(i.destroy_cid(n),n.end()));else n.nb_try++,i.perf_--,i.destroy_cid(n),i.request_retry(n,r)},request_retry:function(e,t){console.log("Retry for request "+e.i_id),ks?e.relay_ws_handle(e.ini_data,!0):rc(e,this,"end "+t)},relay_truncated_handle:function(e){console.log("STREAM : Truncated received from "+this.server_.ip+" CIRC "+this.circId+" "+e);var t=this.first_;switch(e){case 8:this.handle_destroy(0);break;case 11:this.handle_destroy(0);break;default:var r=t.last_?t.last_.ok_:null;r||this.next_.change_or("- relay truncated",this.extend)}},relay_truncate_handle:function(e){console.log("truncate "+this.circId);var r=this.next_,i=new Po(r.circId,Po.prototype.DESTROY,new t("05","hex"));r.send(i);var n=new qo(qo.prototype.RELAY_TRUNCATED,0,new t(1).writeUInt(e),this.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY,!0)},stream_handle:function(e){switch(e.command.readUInt()){case e.RELAY_EXTEND:this.extend_cell_handle(e.data);break;case e.RELAY_TRUNCATE:this.end("Error OR receive truncate :"+e.data.slice(0,1).readUInt(),"truncate");break;case e.RELAY_EXTENDED:this.created_cell_handle(new Po(this.circId,Po.prototype.CREATED,e.data,!0));break;case e.RELAY_TRUNCATED:this.end("Error OP receive truncated :"+e.data.slice(0,1).readUInt(),"truncated");break;case e.RELAY_END:this.end("End :"+e.data.slice(0,1).readUInt(),"relay_end",e.streamId.readUInt());break;case e.RELAY_CONNECTED:this.stream_decode_connected(e),this.stream_handle_connected(e.streamId.readUInt());break;case e.RELAY_DATA:this.stream_handle_data(e);break;case e.RELAY_SENDME:Oi("RECEIVING SENDME CIC "+this.circId+" for stream "+e.streamId.readUInt()),this.stream_handle_sendme(e.streamId.readUInt());break;case e.RELAY_ASSOCIATE:this.associate(e.data.slice(0,e.length.readUInt()).toString("utf8"));break;case e.RELAY_INFO:this.info(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_WS:this.relay_ws_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_INFO:this.relay_db_info_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_QUERY:this.relay_db_query_handle(e);break;case e.RELAY_DB_CONNECTED:this.relay_db_connected_handle(e);break;case e.RELAY_DB_END:this.relay_db_end_handle(e);break;case e.RELAY_DB_DATA:this.relay_db_data_handle(e);break;case e.RELAY_DB_SENDME:this.relay_db_sendme_handle(e)}},stream_decode_connected:function(){},stream_handle_sendme:function(e){var t=this.first_,r=t.stream_;Oi("FLUSH BUFFER CIC "+t.circId+" sid "+(e||" whole circuit ")+" buffer length "+r.length);var i=Math.min(e?us:ls,r.length),n=0;for(e?t[e].stream_window_s+=us:t.circuit_window_s+=ls;i>n;){var s=e?r[n]:r[0];e?e===s[1]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),s[0]=null,n++):(s[0]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),n++),r.shift())}},stream_handle_connected:function(e,r){var i=this.first_,n=i[e];if(n)if(Us&&clearTimeout(n.socket_retry),this.clear_timers(),console.log("STREAM RELAY :--------------RELAY_CONNECTED TO---------------------- "+this.server_.ip+" VIA "+this.first_.server_.ip+" CID "+this.circId+" Stream "+e+" for request "+n.i_id),n.params_.stream){for(var s=n.params_.stream;s.length;){if(n.tls_client_connected||!n.abstract_client_tls,r)var a=new qo(qo.prototype.RELAY_DB_DATA,e,[new t(r,"hex"),s.slice(0,Math.min(s.length,pn-16))].concatBuffers(),this.Df_hash);else var a=new qo(qo.prototype.RELAY_DATA,e,s.slice(0,Math.min(s.length,pn)),this.Df_hash);var o=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(a));if(n.sent_++,i.resolved_failed=0,i.sent_++,i.time_=Date.now(),n.start_t0=i.time_,n.stream_window_s--,i.circuit_window_s--,0===n.stream_window_s||0===i.circuit_window_s?(console.log("Bufferizing CIC "+i.circId+" for request "+n.i_id),i.stream_.push[e]):this.send(o),!(s.length>pn))break;s=s.slice(pn)}n.squeue_&&(n.squeue_.shift(),n.squeue_.length&&n.squeue_[0]())}else sc(n)},stream_handle_data:function(e,r,i){var n=this.first_;if(n){var s=e.streamId.readUInt(),a=i||n[s];if(a){r||a.time_resp||(a.time_resp=Date.now(),n.time_average=(n.time_average+(a.time_resp-a.time_ini))/(n.time_average?2:1)),r?(console.log("STREAM RELAY : --------------RECEIVE DECODED TLS DATA FROM---------------------- "+this.server_.ip+" CID "+this.circId+" Stream "+s+" for request "+a.i_id+" length "+e.length.readUInt()),e.data.slice(0,e.length.readUInt())):a.tls_client_connected||!a.abstract_client_tls;var o=e.data.slice(0,e.length.readUInt());if(r)a.received_++;else{if(!a._data_||a.wait_header){var c;if(a._data_=!0,a.download_){if(o=a.wait_header?[a.wait_header,o].concatBuffers():o,c=ic(o.toString("utf8")),"undefined"==typeof c["1a"]||""!==c["1a"])return a.wait_header=o,void 0;delete a.wait_header;var l=c["0a"].split(" ");if(l=l[1]?l[1]:null){if(Oi("STREAM : status code "+l+" for request "+a.i_id),l=l.toString(),-1===["2","3"].indexOf(l[0]))return Lh('

    Wrong URL, please check and try again

    '),lh(a.bar_),n.send_relay_end(a.sid_),void 0;if("3"===l[0]){if(c.Location){var h=ho(c.Location);a.params_.stream=yo(h.host,h.rest),n.send_relay_end(a.sid_),delete n[a.sid_],delete a.cid_,rc(a)}return}if(a.d_length=a.d_length||0,a.content_=c["Content-Type"]?c["Content-Type"]:"application/octet-binary",c["Content-Length"]&&!a.clength_&&(a.clength_=parseInt(c["Content-Length"])),!a.clength_)for(var u in c)if(-1!==u.toLowerCase().indexOf("content-length")){a.clength_=parseInt(c[u]);break}a.pieces=Math.ceil(a.clength_/Da),c["Transfer-Encoding"]&&(a.encoding_=c["Transfer-Encoding"]),console.log("Start relay_data"),console.log(a.content_),console.log(a.clength_),console.log(a.encoding_?a.encoding_:"No encoding"),a._stream_&&fh(a),o=o.toString("hex").split(gs+gs),o.shift(),o=new t(o.join(gs+gs),"hex")}}}a._data_=!0,a.received_++,n.received_++,n.circuit_window--,a.stream_window--,a.resp__=a.resp__?a.resp__+o.length:o.length,0===n.received_%ls&&n.circuit_window1))return a.header_=o,void 0;a.header_=[a.header_?a.header_:new t(0),new t(f[0]+gs+gs,"hex")].concatBuffers(),a.header_l=a.header_.length}if(a.header_l){if(f.shift(),"chunked"!==a.encoding_){var c=ic(a.header_.toString("utf8"));c["Content-Length"]&&(a.clength_=parseInt(c["Content-Length"]),a.content_l=!0)}else f=f.join(gs+gs).split(gs),a.header_l=a.header_.length,a.clength_=f.length>1?parseInt(new t(f[0],"hex").toString("utf8"),16):0,f.shift(),a.pass_="",a.buff_="";o=new t(f.join(gs),"hex")}}if("chunked"===a.encoding_){if(a.html_.length+o.length>=a.clength_||a.wait_)var p=cc(o.toString("hex"),a);t.isBuffer(a.html_)?a.html_={length:parseInt((p?p:o).length)}:a.html_.length+=p?0:parseInt(o.length)}else a.html_=[a.html_,o].concatBuffers()}}try{}catch(_){}r||n.perf_++,a.nb_try=0;var f=a.html_?a.content_l&&a.clength_===a.html_.length||"chunked"===a.encoding_?!1:!0:!1;if(!f){if("chunked"!==a.encoding_&&(a.socks_s=!1),a.html_){var g=a.content_l?a.html_.toString("utf8"):a.decoder_.decode(p?p:o,{stream:!0});if(!a.content_l){if(a.buff_+=g,a.buff_.length=128)&&i.push(e.Length);var s=function(e){if(e.push)e.forEach(function(e){t.isBuffer(e)?i.push(e):s(e)});else for(var r in e)t.isBuffer(e[r])?i.push(e[r]):s(e[r])};if(e.Payload.push?e.Payload.forEach(function(e){s(e)}):i.push(e.Payload),i=i.concatBuffers(),7!==e.Command.readUInt()&&e.Command.readUInt()<128){var a=new t(512);a.map(i),i=a}if(this.OP_&&!r.last_){var o;this.clear_timers();var c;this===r?this.socket_?this.socket_.handshake_?(o=function(){console.log("CIRC : Create or first extend too long "+this.circId),this.circuit_retry()},c=Vn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){console.log("CIRC : Extend delay expired - change or "+this.server_.ip),this.change_or("- extend too long",this.extend)},c=Gn)}if(yh&&_h&&(chart1_int||chart2_int)&&parseInt(n)!==Po.prototype.PADDING){var l=go(new Date).getTime(),h=i.length;r===Ss?chart2_int&&(yh.dynRow2[l]=yh.dynRow2[l]?yh.dynRow2[l]+h:h):chart1_int&&(_h.dynRow2[l]=_h.dynRow2[l]?_h.dynRow2[l]+h:h)}if(this.OP_||this.OR_)try{if(this.OR_&&6===e.Command.readUInt()&&console.log("sending FAST to "+(this.server_?this.server_.ip:"OP")+" CIC "+e.CircID.readUInt()),this.socket_.ws_)if(this.OP_){if(A&&!I||T)var a=i;else var a=Ac(i,2,!0);this.socket_.write(a)}else this.socket_.write(Ac(i,2,!1));else this.socket_.write(i)}catch(u){if(console.log("OUTGOING SOCKET "+(this.OP_?"OP ":"OR ")+(this.socket_?this.socket_.ws_?"WS":"TLS":"")+" IP "+(this.server_?this.server_.ip:"")+" socket does not exist any longer"),this.OP_)this.socket_?T||this.socket_.destroy():(console.log("send1 circuit destroy"),this.circuit_destroy(!0));else if(!this.OR_f){var d=this.socket_;console.log("send2 circuit destroy"),this.circuit_destroy(!0),d&&d.circuits_destroy()}}else d.write(e)},navigate:function(e){var t=ho(e._host_);t.host="www."+fo(t.host,!0)+ms,Es=t.host,protocol=t.protocol,El.associate(Cs,t.host),console.log("send 301 and associate fake_d "+t.host+" location "+uo(t)),this.redirect(e,uo(t))},redirect:function(e,r){console.log("redirect send 301 for url "+r),Ds?(alert(lo(r)),e.__write__(new t(lo(r),"utf8"))):e._write_(new t(lo(r),"utf8")),e.destroy(),this.destroy_cid(e,!0),delete e._host_},send_db_info:function(e){e=e||null;var r=function(e){if(e.file_length===e.current_length&&Ss){console.log("send_db_info"),console.log(e.name_hash);var r=new t(e.name_hash,"hex"),i=new t(1).writeUInt(r.length),n=new t(1).writeUInt(0),s=T?new t(1).writeUInt(1):new t(0),a=[i,r,n,s].concatBuffers(),o=new qo(qo.prototype.RELAY_DB_INFO,0,a,Ss.last_.Df_hash),c=new Po(Ss.circId,Po.prototype.RELAY,Ss.last_.stream_encrypt_forward(o));Ss.send(c)}};Ha.list(r,e)},send_db_query:function(e,r){if(e){console.log("send_db_query");var i,n=e.params_?e.params_.hash_:e.hash_,s=e.d_length.toString(16);s=s.length%2?"0"+s:s,s=new t(s,"hex"),size_l=new t(1).writeUInt(s.length),console.log("send_db_query hash "+n.toString("hex")+" "+size_l[0]+" "+s.toString("hex")+" tid "+(r?r.toString("hex"):""));var a=[new t(1).writeUInt(n.length),n,size_l,s].concatBuffers();if(r)a=[a,r].concatBuffers(),i=0;else{if(i=bo(this),e.cid_=this,!i)return;this[i]=e,e.sid_=i,e.received_=0,e.sent_=0}if(this.OP_){console.log("OP send db_query CID "+this.circId+" sid "+i);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));e.query_time=Date.now(),this.send(c);var l=function(){this.socket_&&(e._torrentc_||(console.log("serving party not responding"),e.db_try++,this.send_db_end(1,i),delete e.sid_,this.send_db_query(e)))}.bind(this);e.db_tryNo answer from the network, changing peer to peer circuits, please wait and retry

    '),lh(e.bar_),console.log("db_query no answer circuit destroy"),Ss.circuit_destroy(),Ss=null)}else{this.prev_=this,this.nb_query=this.nb_query||0,this.nb_query++,console.log("ORDB send db_query CID "+this.prev_.circId+" sid "+i+" "+this.prev_.socket_.remoteAddress);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.prev_.Db_hash);this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}}},send_db_end:function(e,r,i){r=r||0,console.log("send db_end CID "+this.circId+" sid "+r+" reason "+e+" "+("undefined"!=typeof i?i.toString("hex"):""));var n=new t(1).writeUInt(e);if(n=i?[n,i].concatBuffers():n,this.OP_){var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.last_.Df_hash),a=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(s));this.send(a)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_connected:function(e,r,i,n){e=e.toString(16),e=e.length%2?"0"+e:e,e=new t(e,"hex"),size_l=new t(1).writeUInt(e.length),i=new t(i,"utf8");var s=new t(2).writeUInt(i.length);console.log("send db_connected "+e.toString("hex")+" CID "+this.circId+" sid "+r+" type "+i.toString("utf8"));var a=[size_l,e,s,i].concatBuffers();if(n&&(a=[n,a].concatBuffers()),this.OP_){var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));this.send(c)}else{this.prev_=this;var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.prev_.Db_hash); -this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_data:function(e,t,r,i){if(this.OP_){var n=this[t];i||(n.fc_t=[],console.log("sending db data "+(this.OP_?"OP ":"ORDB sid ")+t+" BANDWIDTH "+8*Ra+" bps "+(this.OP_?" 512 bytes every "+(1+1e3/(Ra/Da))+" ms then nbblocks "+Math.ceil(Na*Ra/1e3/Da)+" every "+Na+"ms window size "+n.stream_window_s+" "+this.circuit_window_s:"")+" cd "+e.size),n.start_t0=Date.now(),n.cd_length=e.size,n.messageName="flush",T||$a(window,"message",Ao.bind(n),!0),n.reader=T?new Va:new FileReader,n.cursor=0),Io.call(this,e,t,n,r)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_DATA,t,e.slice(0,Math.min(e.length,pn)),this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_sendme:function(e){if(e=e||0,this.OP_){var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)}else{this.prev_=this;var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.prev_.Db_hash);this.stream_encrypt_or_b(r.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},circuit_keys:function(e){var t=wo(e.toString("hex")),r=t.slice(0,20);return this.Df_=t.slice(20,40),this.Db_=t.slice(40,60),this.Kf_=t.slice(60,76),this.Kb_=t.slice(76,92),this.Kf_cipher=sn.createcipheriv("aes-128-ctr",this.Kf_,Ln),this.Kb_cipher=sn.createcipheriv("aes-128-ctr",this.Kb_,Ln),this.Df_hash=new fn("sha1"),this.Db_hash=new fn("sha1"),this.Df_hash.update(this.Df_),this.Db_hash.update(this.Db_),r},stream_encrypt_forward:function(e){for(var r=this,i=e.toBuffer();r;)i=new t(r.Kf_cipher.update(i,"hex","hex"),"hex"),r=r.prev_;return i},stream_decrypt_backward:function(e,r){var i,n=this;if(w)var s=Date.now();for(var a=e.length;n&&!(n.Kb_&&(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),i=n.recognized(e)));)n=n.extended_;if(s&&(ga++,ma+=a,ya+=Date.now()-s,0===ga%va&&ya&&(console.log("CRYPTO perf decrypt backward: "+parseInt(8*ma/(ya/1e3))+" bps"),ga=0,ma=0,ya=0)),i&&41===i.command.readUInt(),i)if(r){var o=new qo(qo.prototype.RELAY_END,i.streamId,new t("0A","hex"),n.Df_hash),c=new Po(n.circId,Po.prototype.RELAY,n.stream_encrypt_forward(o));n.send(c)}else n.stream_handle(i);else this.end("Unrecognized stream","unrecognized"),console.log(e.toString("hex"))},stream_decrypt_or_f:function(e,r,i){if(this.Kf_cipher){if(e=new t(this.Kf_cipher.update(e,"hex","hex"),"hex"),!i)var n=this.recognized(e);if(n)this.stream_handle(n);else if(Rs&&this.socket_.fake_cid===this);else if(this.next_){var s=new Po(this.next_.circId,r,e);this.next_.send(s)}}},stream_encrypt_or_b:function(e,r,i){var n=this.prev_;if(n&&n.Kb_cipher){if(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),!i)var s=n.recognized(e);if(s)this.stream_handle(s);else if(n){var a=new Po(n.circId,r,e);n.send(a)}}},recognized:function(e){if(0==e.slice(1,3).readUInt()){var r=e.slice(9,11),i=Math.min(11+r.readUInt(),e.length),n=new qo(e.slice(0,1).readUInt(),e.slice(3,5).readUInt(),e.slice(11,i));n.length=r;var s=e.slice(5,9);if(this.OR_f){this.Df_hash.update(n.toBuffer());var a=new t(this.Df_hash.digest("hex"),"hex").slice(0,4)}else{this.Db_hash.update(n.toBuffer());var a=new t(this.Db_hash.digest("hex"),"hex").slice(0,4)}if(a.toString("hex")==s.toString("hex"))return n}},extend:function(){var e=this.extended_,r=Oo(e.server_.ip),i=new t(2).writeUInt(parseInt(e.server_.port)),n=new t(e.server_.fing,"hex");if(!A||sn.getDiffieHellman){var s=sn.getDiffieHellman("modp2");s.generateKeys(),e.DH_=s,e.X_=new t(s.getPublicKey("hex"),"hex");var a=function(){var s=Co(new t(e.server_.o_modulus,"hex"),e.X_),a=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,s,n].concatBuffers(),this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(a));this.send(o)};e.server_.o_modulus?a.call(this):e.get_certs(a)}else{var a=function(t){var s=t.slice(0,2).readUInt();e.X_=t.slice(2,2+s),e.DH_={};var a=t.slice(2+s),o=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,a,n].concatBuffers(),this.Df_hash),c=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(o));delete vn[e.cid_hex],this.send(c)}.bind(this);e.create_extend_info(a)}},create:function(){if(this.onion_){var e=new Po(this.circId,Po.prototype.CREATE,this.onion_);this.send(e)}else if(A){var r=function(e){var t=e.slice(0,2).readUInt();this.X_=e.slice(2,2+t);var r=e.slice(2+t),i=new Po(this.circId,Po.prototype.CREATE,r);delete vn[this.cid_hex],this.send(i)}.bind(this);this.DH_={},this.create_extend_info(r)}else{var i=sn.getDiffieHellman("modp2");i.generateKeys(),this.DH_=i,this.X_=new t(i.getPublicKey("hex"),"hex");var r=function(){var e=Co(new t(this.server_.o_modulus,"hex"),this.X_),r=new Po(this.circId,Po.prototype.CREATE,e);this.send(r)};this.server_.o_modulus?r.call(this):this.get_certs(r)}},create_extend_info:function(e){var r=new t(1).writeUInt(1),i=No(16),n=i.toString("hex");this.cid_hex=n;var s=new t(this.server_.o_modulus,"hex");vn[n]=e;var a=new qo(qo.prototype.RELAY_INFO,0,[r,i,s].concatBuffers(),Cs.Df_hash),o=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(a));Cs.send(o)},destroy:function(){console.log("CIRC : -------------------------- SEND DESTROY ------------------- "+(this.server_?this.server_.ip:this.socket_.remoteAddress)+(this.OP_?" OP":" OR")+" CID "+this.circId);var e=new Po(this.circId,Po.prototype.DESTROY,new t("09","hex"));this.send(e)},send_relay_end:function(e){var r=this.first_||this,i=new qo(qo.prototype.RELAY_END,e,new t(0),r.last_.Df_hash),n=new Po(r.circId,Po.prototype.RELAY,r.last_.stream_encrypt_forward(i));r.send(n)},associate:function(e){console.log("ASSOCIATE OR RECEIVE "+e),this.socket_.fake_cid=this,En[e]={circ_:this}},info:function(e){if(this.OP_){var r=e.slice(0,16).toString("hex");vn[r]&&vn[r](e.slice(16))}else{var i=e.slice(0,1).readUInt(),r=e.slice(1,17);switch(i){case 1:var n=e.slice(17),s=sn.getDiffieHellman("modp2");s.generateKeys(),Bn[r.toString("hex")]=s;var a=new t(s.getPublicKey("hex"),"hex"),o=Co(n,a);e=new qo(qo.prototype.RELAY_INFO,0,[r,new t(2).writeUInt(a.length),a,o].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);this.send(c);break;case 2:var l=r.toString("hex");if(Bn[l]){var h=new t(Bn[l].computeSecret(e.slice(17),"hex","hex"),"hex");e=new qo(qo.prototype.RELAY_INFO,0,[r,h].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);delete Bn[l],this.send(c)}}}},relay_ws_handle:function(e,r){if(this.OP_){var i=null,s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8").split(":");if(e=e.slice(2+s),console.log("OP ws receive request "+a[3]+" adresse "+a[0]+" port "+a[1]+" data "+e.length),e.length){var o={},c=yn[a[3]];c?c.params_&&(i=c.params_.host):(c={nb_try:0,no_exit:[],i_id:a[3]},yn[a[3]]=c);var l=function(e){for(var r=e,i=new t(new t(a[0]+":"+a[1],"utf8").toString("hex"),"hex"),n=i.length.toString(16);4!==n.length;)n="0"+n;if(i=[new t(n,"hex"),i].concatBuffers(),n=i.length,0===r.length){var s=new qo(qo.prototype.RELAY_WS,0,i,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));this.send(o)}else for(;r.length;){var c;c=r.length+n>_n?r.slice(0,_n-n):r,c=[i,c].concatBuffers();var s=new qo(qo.prototype.RELAY_WS,0,c,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));if(this.send(o),!(r.length+n>_n))break;r=r.slice(_n-n)}}.bind(Cs);if(!Ds||!c.tls_server_connected){var h=function(){if(c.wait_header=c.wait_header?[c.wait_header,e].concatBuffers():e,c.wsqueue_&&c.wsqueue_.length){var t=c.wsqueue_[0];c.wsqueue_.shift(),t()}};if(e.length>=4){var u=e.toString("hex");u.substr(u.length-8)!==gs+gs?h():(e=c.wait_header?c.wait_header:e,delete c.wait_header)}else h();c._write_=l,c.destroy=function(){Ds?(delete c.abstract_server_tls,c.abstract_client_tls?(delete c.abstract_client_tls,l(new t(0))):c._write_(new t(0))):c._write_(new t(0))}}var d=function(e){var s=a[2],l=ic(e),h=l.Accept?l.Accept:"";-1!==h.indexOf("text/html")&&delete l["Accept-Encoding"],c.referer_=l.Referer,delete l.Referer,l.Connection="keep-alive";var u=l["0a"].split(" "),d="";if(u.length>1){var f="/"===u[1].substr(0,1)?u[1].substr(1):u[1];d=fo(f)}var p=function(){if("http"===d.substr(0,4)){var h=ho(d);u[1]="/"+(h.rest?h.rest:""),l["0a"]=u.join(" "),l.Host&&(l.Host=h.host?h.host:""),delete l.Cookie,l["X-Requested-With"]||(c._host_=h.protocol+"//"+l.Host)}else l.Host&&(c.fake_domain=l.Host,l.Host=bs[l.Host].real_domain);l.Accept&&-1!==l.Accept.indexOf("text/html")&&(l["Accept-Encoding"]="identity"),e=nc(l),o.OP=!0,o.nb_hop=Hn,o.one_c=!0,Ds&&(s=protocol===ws&&"443"===s?"80":s),o.host=l.Host+":"+s,i&&o.host!==i&&(delete c.tls_client_connected,delete c.abstract_client_tls,c.cid_&&c.cid_.destroy_cid(c,!0)),o.stream=new t(e,"utf8"),c.params_=o,c._data_=!1,c._init_=Xo,c._init_(),r&&(c.nb_try=n),c.remoteAddress=a[0],c.remotePort=a[1],c.end=c.destroy};if("https"===d.substr(0,5)||"https:"===protocol){if(!Ns)return console.log("https not supported now "+d),c._write_(new t(ao(),"utf8")),void 0;if(p(),c.abstract_client_tls){console.log("Reuse TLS Client for request "+c.i_id);var _=function(){c.abstract_client_tls.prepare(sl(c.params_.stream.toString("hex")))};c.request_decoded.socks_s?(console.log("Queue "+c.i_id),c.abstract_client_tls.queue_socks.push(_)):_()}else{console.log("Create TLS Client for request "+c.i_id);var g=ho(d),e=c.params_.stream;c.abstract_client_tls=cl(c,g.host),c.abstract_client_tls.stream_tor_=new t(0),c.abstract_client_tls.queue_socks=[];var m={};m._init_=Xo,m._init_(),m._host_=c._host_,m.cid_=c.cid_,m.i_id=c.i_id,m.fake_domain=c.fake_domain,m.socks_s=!0,m.__write__=c.__write__,m.destroy=c.destroy,m.referer_=c.referer_,c.request_decoded=m,m.request_=c,m.received_=0;var y=c.abstract_client_tls,v=function(e){var t=function(e){return function(){this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.stream_tor_.parseTLS(this)}};y.queue_=y.queue_||[],y.queue_.push(t(e).bind(y)),1===y.queue_.length&&y.queue_[0](),y.queue_socks.length&&!m.socks_s&&(m.socks_s=!0,console.log("Unqueue request "+c.i_id),y.queue_socks[0](),y.queue_socks.shift())};c._write_=v,c.write_c=function(e){c.params_.stream=e,rc(c)},c.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.error=function(e,t){console.log(" Error TLS client disconnected "+t.message),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.connected=function(t){console.log("TLS client connected to site for request "+c.i_id),c.tls_client_connected=!0,c._data_=!1,console.log("Sending https request for request "+c.i_id+" to site "+e.toString("utf8")),t.prepare(sl(e.toString("hex")))},c.abstract_client_tls.dataReady=function(e){var r=e.data.data.slice(e.data.read,e.data.length_);e.data.read=e.data.length_;var i={streamId:new t(2).writeUInt(c.sid_),data:r,length:new t(2).writeUInt(r.length)};c.cid_&&c.cid_.last_.stream_handle_data(i,c.__write__,m)},c.abstract_client_tls.handshake()}}else p(),rc(c)};if(c.relay_ws_handle=d,Ds)c.abstract_server_tls||(c.abstract_server_tls=cl(c,Es,!0),c.write_s=l,c.abstract_server_tls.closed=function(){console.log(" TLS server disconnected for request "+c.i_id),c.destroy()},c.abstract_server_tls.error=function(e,t){-1===t.message.indexOf("Unknown")&&(console.log("Error TLS server disconnected for request "+c.i_id+" "+t.message),c.destroy())},c.abstract_server_tls.connected=function(){console.log("TLS server connected to socks client for request "+c.i_id),c.tls_server_connected=!0,c._write_=function(e){c.abstract_server_tls?(console.log("tls server send to SOCKS"),c.abstract_server_tls.prepare(sl(e.toString("hex"))),c.done_&&c.destroy()):console.log("can't send to SOCKS server connection closed for request "+c.i_id)},c.__write__=c._write_,c.abstract_server_tls.dataReady=function(e){console.log(e.data.read);var t=e.data.data.slice(e.data.read,e.data.length_).toString("utf8");-1!==t.indexOf("Host")&&(e.data.read=e.data.length_,console.log("TLS server receive "+t),c.ini_data=t,d(t))}}),c.abstract_server_tls.process(e);else{var f=e.toString("utf8");c.ini_data=f,d(f)}}}if(this.OR_){var s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8");e=e.slice(2+s);var c=Cn[a];if(e.length)return c.write(e),void 0;c.bufferSize||(console.log("OR ws destroy request "+c.i_id),c.end())}},relay_db_info_handle:function(e){console.log("receive relay_db_info CID "+this.circId);var t,r,i,n,s,a;t=e[0],e=e.slice(1),n=e.slice(0,t).toString("hex"),e=e.slice(t),r=e[0],e=e.slice(1),e.length&&(i=e[0]),console.log("db_info "+n+" part "+r+" fac "+(i?"yes":"no")),s=Sn[n],s?(s.forEach(function(e){e[0]===this&&(a=!0)},this),a||s.push([this,null,null,0])):Sn[n]=[[this,null,null,0]],i&&(console.log(An.indexOf(this)),-1===An.indexOf(this)&&(console.log("pushing facilitator CID "+this.circId),An.push(this)))},relay_db_query_handle:function(e){var r=e.streamId.readUInt();console.log("receive relay_db_query CIC "+this.circId+" sid "+r),e=e.data.slice(0,e.length.readUInt());var i=e[0];e=e.slice(1);var n=e.slice(0,i).toString("hex");e=e.slice(i),i=e[0],e=e.slice(1);var s=parseInt(e.slice(0,i).toString("hex"),16);if(e=e.slice(i),console.log("Receive db_query for "+n+" on CID "+this.circId+" sid "+r+" requesting "+s+" bytes "+e.toString("hex")),this.OP_){var a=e.slice(0,16),c=this.first_;if(n!==Aa){var l=Ya(),h=l.get(n);h.onsuccess=function(e){var t=e.target.result;if(t)if(t.file_length===t.current_length&&se.length&&(e=t)}),sr?-1:1}).sort(function(e,t){return e[0].socket_?t[0].socket_?0:1:-1});var i=u.length;if(u.forEach(function(e){console.log("f has "+e[0].circId+" valid "+(e[0].socket_?"yes":"no"))}),i){for(;u.length;)if(u[0][0].socket_)if(u[0][0].socket_.remoteAddress){if(!u[0][0].destroyed_)break;console.log("ORDB remove destroyed CIC "+u[0][0].circId),u.shift()}else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();if(u.length){var d=u[0][0];u[0][3]++;var a=No(16),f={d_length:s,hash_:new t(n,"hex")};In[a.toString("hex")]=[this,r,u,f,1],d.send_db_query(f,a)}else Uo.call(this,r,s,n)}else Uo.call(this,r,s,n)}else An.length?Uo.call(this,r,s,n):(console.log("ORDB does not know the file"),this.send_db_end(0,r))}},relay_db_connected_handle:function(e){var t=e.streamId.readUInt();if(console.log("receive relay_db_connected CID "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt()),this.OP_){var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),s=this.first_[t];if(s){if("torrent"===n){if(s.url_)return console.log("direct download"),this.first_.send_db_end(1,t),ko(s),Fh(s.query_t0),rc(s),void 0;$a(document.body,"mousedown",function(){},!1),console.log("put torrent timer"),s._streaming_||Lh('

    The file is not available in Peersm network, looking for it in Bittorrent network.

    '),s._torrentc_=setTimeout(function(){this.first_.send_db_end(1,t),ko(s),Ro(s),Lh('

    Could not find the file in bittorrent, stopping download

    ')}.bind(this),Ia)}else Wa("alert_box").style.display="none",s._torrentc_&&(console.log("remove torrent timer"),clearTimeout(s._torrentc_));s.flowc=s.flowc?s.flowc:Date.now()-s.query_time,console.log("db_query/db_connected "+(Date.now()-s.query_time)+" ms "+s.flowc),Fh(s.query_t0),s.clength_=i,s.pieces=Math.ceil(s.clength_/Da),s.content_=n,s.sid_=t,s.received_=0,s.sent_=0,s.nb_try=0,s.stream_window=Oa,s.stream_window_s=Oa,s._stream_&&"torrent"!==n&&fh(s)}}else{var a=e.slice(0,16).toString("hex");e=e.slice(16);var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),o=In[a];"torrent"!==n&&delete In[a],console.log("db_connected "+a+" type "+n+" size "+i+" "+typeof o),this.nb_query=0,o&&(this.socket_?o[0].socket_&&(o[0].send_db_connected(i,o[1],n),Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t]=o,xn[o[0].socket_.remotePort+"-"+o[0].socket_.remoteAddress+"-"+o[0].circId+"-"+o[1]]=[this,t],this[t]={},o[0][o[1]]={},console.log("i_or associated with remote port "+this.socket_.remotePort+" remote address "+this.socket_.remoteAddress+" CIC "+this.circId+" Stream "+t),console.log("f_or associated with remote port "+o[0].socket_.remotePort+" remote address "+o[0].socket_.remoteAddress+" CIC "+o[0].circId+" Stream "+o[1])):o[0].send_db_end(0,o[1]))}},relay_db_end_handle:function(e){var r=e.streamId.readUInt();e=e.data.slice(0,e.length.readUInt());var i=e.slice(0,1).readUInt();if(console.log("receive db_end sid "+r+" reason "+i+" CIC "+this.circId),this.OP_){var n=this.first_,s=n[r];if(s)if(s.send_data)s.fc_t?s.fc_t.length?(console.log("queue not empty - stop sending"),s.stop_=!0):(console.log("queue empty - delete request"),s._torrent_&&s._torrent_stream.destroy(),delete n[r]):s.__torrent__&&(console.log("destroying engine"),s.__torrent__.destroy());else if(Fh(s.query_t0),Fh(s.sendme_tout),Fh(s.waiting_),2===i||s.reason_||3===i){Fh(s.sendme_tout),Fh(s.waiting_),s.reason_=2;var a=function(){if(s.nb_tryThe remote peers closed the connections, attempts to resume streaming failed.

    ')):($a(document.body,"mousedown",function(){},!1),Lh('

    The remote peers closed the connections during the download, attempts to resume failed, storing downloaded part, please wait that the file appears in Local Storage.

    Use resume later to get the complete file.

    '),rh(s)),delete s.reason_)};s.queue_=s.queue_||[],s.queue_.push(a),1===s.queue_.length&&s.queue_[0]()}else if(s.url_)if(s.reload2_||s.reload_){console.log("resuming direct download");var o=function(e){var i=e.d_length;e.blob_=Ji?new t(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_});var s=ho(e.url_);e.params_.stream=vo(s.host,s.rest,i),delete e.params_.db_,delete e.cid_,delete n[r],delete e.file_id,delete e.start_t0,e.received_=0,rc(e)};ah(s,!0,o)}else this.destroy_cid(s),delete s.params_.db_,delete s.content_,delete s.d_length,delete s.clength_,delete s.blob_,_h&&(gh.vAxis.maxValue=Ks,_h.draw(mh,gh)),rc(s);else $a(document.body,"mousedown",function(){},!1),Lh('

    The file is currently not available from peers in Peersm and Bittorrent networks and can not be downloaded directly, please check the URL or the Hash Name you are using

    '),ko(s),Ro(s)}else if(this.nb_query=0,e.length>1){console.log("db_end with tid CIC "+this.circId+" db_test length "+(this.db_test?this.db_test.length:"")),this.db_test&&this.db_test.forEach(function(e){clearTimeout(e)});var c=e.slice(1,17).toString("hex"),l=In[c];if(l){var h=l[2],u=l[4];if(h[u]){l[4]++;var d=h[u][0];d.send_db_query(l[3],new t(c,"hex")),console.log("try another peer "+d.circId+" tid "+c+" stream length "+e.length)}else An.length?Uo.call(this,r,l[3].d_length,l[3].hash):(l[0].send_db_end(i,l[1]),delete In[c])}}else{console.log("forwarding db_end");var f=xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(f)try{3!==i&&(delete Tn[f[0].socket_.remotePort+"-"+f[0].socket_.remoteAddress+"-"+f[0].circId+"-"+f[1]],delete xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete f[0][f[2]]),f[0].send_db_end(i,f[1])}catch(p){}else{var _=Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(_)try{_[0].send_db_end(i,_[1]),delete xn[_[0].socket_.remotePort+"-"+_[0].socket_.remoteAddress+"-"+_[0].circId+"-"+_[1]],delete Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete _[0][_[2]]}catch(p){}}delete this[r]}},relay_db_data_handle:function(e){if(b)var r=Date.now();var i=e.streamId.readUInt();if(e=e.data.slice(0,e.length.readUInt()),this.OP_){var n=this.first_,s=n[i];if(s){0===s.received_&&(console.log("start_t0 received "+Date.now()),s.start_t0=Date.now(),n.send_db_sendme(i)),s.received_++,n.received_++,s.stream_window--,s._write_(e);var a=s.received_,o=parseInt(e.length*s.received_/((Date.now()-s.start_t0)/1e3)),c=Math.ceil(o*(s.flowc/2/1e3)/e.length);c=Math.ceil(Oa-c>0?Math.min(c,Oa*(1-ds)):Oa*(1-ds));var l,h=function(r){var a=function(e){console.log("sendme timeout received_ "+s.received_+" rec "+e+" stream-blocs "+(Oa-c)),s.received_!==e||s._stream_?h(s.received_):(Fh(s.sendme_tout),Fh(s.waiting_),console.log("resuming peer to peer download received "+s.received_),n.send_db_end(1,i),n.relay_db_end_handle({streamId:new t(2).writeUInt(i),length:new t(2).writeUInt(1),data:new t(1).writeUInt(2)}))};Fh(s.sendme_tout),Fh(s.waiting_),console.log(8*o+" bps nbBlocs "+c+" stream window "+s.stream_window+" - sending sendme stream received "+n.received_*e.length+" - Buffer Amount: "+El.bufferedAmount+" "+Date.now()),n.send_db_sendme(i),s.stream_window+=Oa,console.log("sendme timeout "+l+" stream length "+e.length),s.sendme_tout.push(setTimeout(function(){a(r)},l))};s.stream_window===c&&(0===El.bufferedAmount||n.received_*e.lengthr;r++){var i=new Fo;i.OP_=!0,i.t0_=[],i.server_=e.path_[r+1],e.next_=i,i.prev_=e,i.path_=e.path_,i.nb_=e.nb_+1,i.socket_=this.socket_,i.circId=this.circId,i.first_=this,e=i}return!0}var n=parseInt(this.server_.fing,16)Resuming direct download from '+this.last_.server_.ip+"

    ")):Lh('

    File not available from Peers, starting direct download from '+this.last_.server_.ip+"

    "),setTimeout(function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},12e3)),e.cid_=this,e.params_.host&&!e.destroyed){var r=new t(e.params_.host);r=new t(r.toString("hex")+"00","hex");var i=bo(this);if(i){console.log("STREAM : --------------SEND RELAY_BEGIN---------------------- CID "+this.circId+" on OR "+this.first_.server_.ip+" Stream "+i+" for request "+e.i_id+" on port "+e.remotePort+" host "+r.toString("utf8")),console.log(e.params_.stream.toString("utf8").substr(0,300)),this[i]=e,e.sid_=i,e.received_=0,e.sent_=0,e.stream_window=hs,e.stream_window_s=hs;var n=function(){var t=this;console.log("Timeout Bad circuit "+t.circId),!t.perf_>0&&(t.bad_=!0),t.send_relay_end(i),e.nb_try++,delete e.cid_,delete t[i],rc(e)},s=function(){var t=new qo(qo.prototype.RELAY_BEGIN,i,r,this.last_.Df_hash),s=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));Us&&(e.socket_retry=setTimeout(n.bind(this),rs)),this.send(s)};s.call(this)}}},sendme:function(e){e=e||{sid_:0,i_id:-1};var r=new qo(qo.prototype.RELAY_SENDME,e.sid_,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)},set_certs:function(e){try{e=e.split(jn),this.server_.onion_k=jn+e[1].split(zn)[0]+zn,this.server_.sign_k=jn+e[2].split(zn)[0]+zn;var t=new dn;return this.server_.o_modulus=t.modulus(this.server_.onion_k),this.server_.s_modulus=t.modulus(this.server_.sign_k),!0}catch(r){return this.nb_error=this.nb_error?++this.nb_error:1,!1}},get_certs:function(e){if(this.server_&&!this.ok_){var t=cn.length,r=this.server_.fing,i=_o(t),n=cn[i].split(":"),s=n[0],a=n[1],o={host:s,path:"/tor/server/fp/"+r,port:a,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip deflate","Accept-Language":"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3","Cache-Control":"max-age=0",Connection:"keep-alive",Host:s,"User-Agent":"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0"}},c=nn.request(o,function(t){if(c.data_="",200!=t.statusCode){this.clear_t0_();try{this.get_certs(e)}catch(i){}}t.on("data",function(e){this.clear_t0_(),c.data_+=e.toString("utf8")}.bind(this)),t.on("end",function(){this.server_&&!c.destroy_&&(this.certs_||(this.set_certs(c.data_)?(this.certs_=!0,this.prev_?e.call(this.prev_):e.call(this)):this.nb_error>4?this.change_or("CERTS : get_certs wrong cert for "+r,this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e)))}.bind(this))}.bind(this)),l=function(){this.clear_t0_(),this.server_&&(this.nb_error=this.nb_error?++this.nb_error:1,this.nb_error>4?this.change_or("error get_certs",this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e))}.bind(this);c.on("error",l),c.end();var h=function(){this.clear_t0_(),c.removeListener("error",l),l=function(){console.log("CERTS : error fired after abort for "+s)},c.on("error",l),c.destroy_=!0,c.socket.destroy(),this.server_&&this.get_certs(e)}.bind(this);this.t0_.push(setTimeout(h,1e3))}},change_or:function(e,t){if(this.server_){console.log("change_or ----------- CIC "+this.circId);var r,i,n=[];if(this.first_)var s=this.first_.request_;var a="undefined"==typeof s?null:s.params_?s.params_.db:null;if(this.prev_||!Zi||("undefined"==typeof this.server_?1:this.server_!==Zi)){if(this.first_===Ss||a)return this.first_&&(console.log("change_or circuit destroy"),this.first_.circuit_destroy(),s&&Ko(s)),void 0;var i=this.prev_?this.next_?on:Exit:Guards,o=i.length;for(this.clear_timers(),this.clear_t0_(),this.path_?n=this.path_.map(function(e){return e.ip}):n.push(this.server_.ip),r=_o(o);-1!=n.indexOf(i[r].split("-")[1]);)r=_o(o);var c=i[r].split("-");i={ip:c[1],fing:c[0],port:c[2],band:c[3],o_modulus:c[5]?c[5]:c[4]}}else console.log("change_or one OR "+this.circId),i=Zi;for(var l=this;l;)delete l.destroy_,delete l.nb_error,delete l.ok_,l=l.next_;delete this.first_.last_;var h=new Fo;Object.keys(this).forEach(function(e){h[e]=this[e]},this),h.server_=i;try{var u=this.server_.ip;this.server_o=this.server_}catch(d){console.log("_server error"),this.clear_timers();for(var f in this)"function"!=typeof this[f]&&console.log(f+" "+this[f]);this.first_.destroy()}delete this.server_,delete h.certs_,this.next_&&(h.next_.prev_=h),this.prev_?(h.prev_.extended_&&(h.prev_.extended_=h),h.prev_.next_=h,-1==e.indexOf("get_certs")&&(h=h.prev_,delete h.certs_)):h.first_=h,h.first_.reconstruct_path(),t&&(this.prev_||this.first_===this)?t.call(h):this.socket_.first_===this?(delete gn[u],h.socket_&&(this.destroy_=!0,h.socket_.destroy(),delete h.socket_),delete h.extended_,h.circId=0,h.first_=h,h.path_.shift(),h.path_.unshift(h.server_),tc(h)):this.next_.change_or("PATH : first socket exists, change path",this.create)}},circuit_retry:function(){if(!es)if(this.ok_||this.socket_.first_!==this){this.destroy(),delete this.ok_,delete this.first_.last_;var e=this.circId;this.circId=bo(this.socket_),delete this.socket_[e],this.socket_[this.circId]=this,this.socket_.nbc_--;for(var t=this;t.extended_;)t.extended_.circId=this.circId,t=t.extended_,delete t.extended_;this===t&&this.socket_.first_!==this?t.create():t.change_or("circuit_retry from first OR circId="+this.circId,this.create.bind(this)) -}else this.change_or("initial socket closed unexpectedly or unexpected circuit creation error or new circuit creation error")},reconstruct_path:function(){for(var e=this,t=[];e.next_;)t.push(e.server_),e=e.next_;for(;e.prev_;)e.path_=t,e.first_=this,e=e.prev_},circuit_destroy:function(e){if(this.socket_){this.socket_.remoteAddress?console.log("CIRC : circuit destroy "+(this.OP_?"OP ":"OR "+(this.OR_f?"in ":"out "))+(this.socket_.address()?this.socket_.address().address:"")+" CID "+this.circId+" remote "+this.socket_.remoteAddress):console.log("circuit destroy : socket no remote address CIC "+(this.OP_?"OP ":"OR ")+" "+this.circId);var t;if(this.socket_){var r=this.socket_;this.next_?e||this.destroyed_||(this.destroyed_=!0,r.remoteAddress&&(console.log("circuit_destroy remote address "+r.remoteAddress+" CIC "+this.circId),this.destroy())):this.socket_.address()&&ka&&parseInt(this.socket_.address().port)===parseInt(kn)&&r.OR_f&&(console.log("ORDB - call db_destroy"),this.circuit_db_destroy()),delete r[this.circId],delete this.socket_,Object.keys(r).forEach(function(e){isNaN(e)||null==e||(t=!0)},this),t||this===Ss||r.ws_||(console.log("circuit_destroy: destroy socket"),r.destroy())}}console.log("circuit_destroy "+(this.OP_?"OP":"OR")),this.OP_&&(console.log("requests_destroy"),this.requests_destroy()),delete this.next_,delete this.prev_},circuit_db_destroy:function(){this.socket_&&Object.keys(this).forEach(function(e){if(!isNaN(e)&&null!=e){var t=this.socket_?this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+e:this.server_?this.server_.port+"-"+this.server_.ip+"-"+this.circId+"-"+e:"",r=Tn[t]||xn[t];r&&(console.log("------- "+r[1]),r[0].send_db_end(2,r[1]),delete xn[t],delete Tn[t],delete this[e],delete r[0][r[1]])}},this)},requests_destroy:function(){for(var e in this)if(!isNaN(e)&&null!=e){var t=this[e];t.abstract_client_tls&&t.abstract_client_tls.close(),delete t.abstract_client_tls,this.destroy_cid(t),Ss?this!==Ss?t._data_?t.destroy():this.request_retry(t,"requests_destroy"):Sl(t):Us&&Sl(t)}if(ks){if(this===Cs){console.log("destroy CIC resend associate ");for(var e in bs)delete bs[e].associated;Cs=null,rc({params_:{OP:!0,nb_hop:Hn,ws:El}})}}else Ss?this===Ss&&(Ss=null,rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})):Us&&rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})},clear_timers:function(){this.OP_&&(this.first_.tc_.forEach(function(e){clearTimeout(e)}),this.first_.tc_=[])},clear_t0_:function(){this.t0_&&(this.t0_.forEach(function(e){clearTimeout(e)}),this.t0_=[])},end:function(e,t,r){if(r)var i=this.first_||this,n=i[r]?i[r]:i.request_;this.OP_,e=e.split(":"),console.log2=function(){};var s=function(){if(e.length>1)switch(parseInt(e[1])){case 0:return console.log2("-- CIC NONE (No reason given.)"),0;case 1:return console.log2("-- CIC PROTOCOL (Tor protocol violation.)"),1;case 2:return console.log2("-- CIC INTERNAL (Internal error.)"),2;case 3:return console.log2("-- CIC REQUESTED (A client sent a TRUNCATE command.)"),3;case 4:return console.log2("-- CIC HIBERNATING (Not currently operating; trying to save bandwidth.)"),4;case 5:return console.log2("-- CIC RESOURCELIMIT (Out of memory, sockets, or circuit IDs.) "+this.circId+" "+(this.OP_?" OP ":" OR ")),5;case 6:return console.log2(" -- CIC CONNECTFAILED (Unable to reach relay.)"),6;case 7:return console.log2("-- CIC OR_IDENTITY (Connected to relay, but its OR identity was not as expected.)"),7;case 8:return console.log2("-- CIC OR_CONN_CLOSED (The OR connection that was carrying this circuit died CID "+this.circId+" "+(this.OP_?" OP ":" OR ")),8;case 9:return console.log2("-- CIC FINISHED (The circuit has expired for being dirty or old.)"),9;case 10:return console.log2("-- CIC TIMEOUT (Circuit construction took too long)"),10;case 11:return console.log2("-- CIC DESTROYED (The circuit was destroyed w/o client TRUNCATE)"),11;case 12:return console.log2("-- CIC NOSUCHSERVICE (Request for unknown hidden service)"),12}}.bind(this),a=function(){if(e.length>1)switch(parseInt(e[1])){case 1:return console.log2("-- RELAY REASON_MISC (catch-all for unlisted reasons) request "+(n?n.i_id:"")),1;case 2:return console.log2("-- RELAY REASON_RESOLVEFAILED (couldn t look up hostname) request "+(n?n.i_id:"")),2;case 3:return console.log2("-- RELAY REASON_CONNECTREFUSED (remote host refused connection) [*] request "+(n?n.i_id:"")),3;case 4:return console.log2("-- RELAY REASON_EXITPOLICY (OR refuses to connect to host or port) request "+(n?n.i_id:"")),4;case 5:return console.log2("-- RELAY REASON_DESTROY (Circuit is being destroyed) request "+(n?n.i_id:"")),5;case 6:return console.log2("-- RELAY REASON_DONE (Anonymized TCP connection was closed) request "+(n?n.i_id:"")),6;case 7:return console.log2("-- RELAY REASON_TIMEOUT (Connection timed out, or OR timed out while connecting) request "+(n?n.i_id:"")),7;case 8:return console.log2("-- RELAY REASON_NOROUTE (Routing error while attempting to contact destination) request "+(n?n.i_id:"")),8;case 9:return console.log2("-- RELAY REASON_HIBERNATING (OR is temporarily hibernating) request "+(n?n.i_id:"")),9;case 10:return console.log2("-- RELAY REASON_INTERNAL (Internal error at the OR) request "+(n?n.i_id:"")),10;case 11:return console.log2("-- RELAY REASON_RESOURCELIMIT (OR has no resources to fulfill request) request "+(n?n.i_id:"")),11;case 12:return console.log2("-- RELAY REASON_CONNRESET (Connection was unexpectedly reset) request "+(n?n.i_id:"")),12;case 13:return console.log2("-- RELAY REASON_TORPROTOCOL (Sent when closing connection because of Tor protocol violations.) request "+(n?n.i_id:"")),13;case 14:return console.log2("-- RELAY REASON_NOTDIRECTORY (Client sent RELAY_BEGIN_DIR to a non-directory relay.) request "+(n?n.i_id:"")),14}}.bind(this);if(t)switch(t){case"handshake":this.change_or("handshake failed");break;case"fast_key":this.change_or("wrong fast key");break;case"created_extended_key":this.change_or("wrong create or extend key",this.prev_?this.prev_.extend:null);break;case"truncated":this.relay_truncated_handle(s());break;case"truncate":this.relay_truncate_handle(s());break;case"destroy":this.handle_destroy(s());break;case"unrecognized":console.log("end unrecognized circuit destroy"),this.circuit_destroy();break;case"relay_end":n&&"undefined"!=typeof n.i_id&&this.relay_end_handle(r,a())}else delete this.socket_[this.circId]}};var qo=function(e,r,i,n){this.command=new t(1).writeUInt(e),this.recognize=new t("0000","hex"),this.streamId=new t(2).writeUInt(r),this.digest=new t("00000000","hex"),this.length=new t(2).writeUInt(i.length),this.data=e===this.RELAY_WS?new t(i.length):new t(pn),this.data.map(i),n&&(n.update(this.toBuffer()),this.digest=new t(n.digest("hex"),"hex").slice(0,4))};qo.prototype={RELAY_BEGIN:1,RELAY_DATA:2,RELAY_END:3,RELAY_CONNECTED:4,RELAY_SENDME:5,RELAY_EXTEND:6,RELAY_EXTENDED:7,RELAY_TRUNCATE:8,RELAY_TRUNCATED:9,RELAY_DROP:10,RELAY_RESOLVE:11,RELAY_RESOLVED:12,RELAY_BEGIN_DIR:13,RELAY_ASSOCIATE:40,RELAY_WS:41,RELAY_INFO:42,RELAY_DB_INFO:80,RELAY_DB_QUERY:81,RELAY_DB_CONNECTED:82,RELAY_DB_DATA:83,RELAY_DB_END:84,RELAY_DB_SENDME:85,toBuffer:function(){return[this.command,this.recognize,this.streamId,this.digest,this.length,this.data].concatBuffers()}};var Ho,Mo,jo,zo=function(e){switch(this.Command.readUInt()){case this.VERSIONS:return this.versions_cell_decode(e);case this.CERTS:return this.certs_cell_decode(e);case this.AUTH_CHALLENGE:return this.auth_challenge_cell_decode(e);case this.NETINFO:return this.netinfo_cell_decode(e);case this.CREATED_FAST:return this.created_fast_cell_decode(e);case this.CREATED_FAST_WS:return this.created_fast_ws_cell_decode(e);case this.CREATE_FAST:return this.create_fast_cell_decode(e);case this.CREATE_FAST_WS:return this.create_fast_ws_cell_decode(e);case this.CREATED:return this.created_cell_decode(e);case this.CREATE:return this.create_cell_decode(e);default:return[e]}},Vo=function(e,t){if(e)for(var r=e.length,i=0;r>i;i++){var n=e[i],s=n.CircID.readUInt();if(this[s])var a=this[s];else{if(!this.OR_||!this.OR_f)return;if(this[0]){var a=this[0];a.circId=s,this[s]=a,delete this[0]}else{var a=new Fo;a.OR_=!0,a.OR_f=!0,a.circId=s,a.socket_=this,a.way_="socket in",this[s]=a}}try{a.clear_timers()}catch(o){}if(6===n.Command.readUInt()&&console.log("handle cell "+n.Command.readUInt()),yh&&_h&&(chart1_int||chart2_int)&&n.Command.readUInt()!==n.PADDING){var c=go(new Date).getTime(),l=0;n.Payload.forEach(function(e){l+=e.length}),a.first_===Ss?chart2_int&&(yh.dynRow[c]=yh.dynRow[c]?yh.dynRow[c]+l:l):chart1_int&&(_h.dynRow[c]=_h.dynRow[c]?_h.dynRow[c]+l:l)}if(a.destroyed_)console.log("received cell for destroyed CIC "+a.circId);else switch(n.Command.readUInt()){case n.PADDING:a.padding_cell_handle(n);break;case n.VERSIONS:a.versions_cell_handle(n);break;case n.CERTS:a.certs_cell_handle(n);break;case n.AUTH_CHALLENGE:a.auth_challenge_cell_handle(n);break;case n.NETINFO:a.netinfo_cell_handle(n);break;case n.CREATE_FAST:a.create_fast_cell_handle(n);break;case n.CREATE_FAST_WS:a.create_fast_ws_cell_handle(n);break;case n.CREATED_FAST:a.created_fast_cell_handle(n);break;case n.CREATED_FAST_WS:a.created_fast_ws_cell_handle(n);break;case n.CREATE:a.create_cell_handle(n);break;case n.CREATED:a.created_cell_handle(n);break;case n.RELAY:a.relay_cell_handle(n,t);break;case n.RELAY_WS:a.relay_cell_handle(n,t);break;case n.RELAY_EARLY:a.relay_cell_handle(n,t);break;case n.DESTROY:a.end("Destroy reason:"+n.Payload[0].slice(0,1).readUInt(),"destroy")}}else console.log("end or banish circuit_destroy"),this.circuit_destroy()},Ko=function(e){console.log("circuit_start"),Us&&Qn>Xn&&(document.location.href=document.location.href);var t=e.params_,r=[];if(t.nb_hop?t.nb_hop>2&&(r=mo(t)):r=mo(t),Zi&&(r[0]=Zi),(ks||Us)&&$i&&!Cs){if(t.ws!==Cl)return;r[0]=$i}t.db&&(r[Mn-1]=ka);var i=gn[r[0].ip],n=new Fo(r);if(n.request_=e,n.first_=n,n.tc_=[],i)if(i.abstract_client_tls&&!i.tls_connected&&i.wsconnected_)console.log("start TLS handshake - circuit start "),i.abstract_client_tls.handshake();else if(console.log("TLS connected - start create_fast"),n.server_=i.server_,n.socket_=i,n.tc_=[],n.setCircId())if(Js){console.log("Sending fast CIC "+n.circId+" "+i.server_.ip+" "+n.destroyed_),t.db&&(El.db_cid_launched=!0),n.X_=No(20);var s=new Po(n.circId,Po.prototype.CREATE_FAST,n.X_);n.send(s)}else n.create();else console.log("PATH : no more circuits available");else console.log("circuit_start init socket"),n.circId=0,t.ws?t.ws.wsconnected_&&($o(t.ws,n),Zo.call(t.ws,n)):tc(n)},Go=function(e){e&&(console.log("CIRCUITS destroy "+(e.remoteAddress?e.remoteAddress:"")),e.OP_&&delete gn[e.remoteAddress],Object.keys(e).forEach(function(t){if(!isNaN(t)&&null!=t){var r=e[t];console.log("delete cic "+r.circId+" socket "+(r.server_?r.server_.ip:"")),e.OP_?(r.requests_destroy(),delete gn[r.server_.ip]):r.next_?r.next_.destroy():r.prev_?r.prev_.destroy():r.circuit_db_destroy(),delete r.socket_,delete e[t]}}))},Yo=function(e,t){var r=[];for(var i in gn){var n=[];Object.keys(gn[i]).forEach(function(t){var r=gn[i][t];isNaN(t)||null==t||!r.last_||-1!==e.no_exit.indexOf(r)||r.bad_||(!Us||r!==Ss&&r!==Cs)&&n.push(r)}),n.length&&r.push(n)}if(r.length){if(!t){var s,a,o=r[_o(r.length)];if(e.nb_try){o=o.map(function(e){return[e,e.time_average]}),o.sort(function(e,t){return e=e[1],t=t[1],e==t?0:t>e?-1:1});var i=0,c=o.length;if(Us)i=parseInt(o.length/2);else for(var l=0;c>l;l++)if(0!==o[l][1]){i=l;break}i&&(o=o.slice(i,Math.min(o.length,Yn+i))),Oi("best circuits "+(o[0]?o[0][0].circId:"")+" "+(o[1]?o[1][0].circId:"")+" "+(o[2]?o[2][0].circId:"")),a=_o(o.length),s=o[a][0]}else a=_o(o.length),s=o[a],s.time_=(new Date).valueOf();return s}if(1===r.length&&1===r[0].length)return!0}else Us&&console.log("choose circuit no circuit found for request "+e.i_id)},Wo=function(e){return function(){if(this.OR_&&this.address().port===kn,this.ws_&&(!A||I||this.OR_)&&!T){this.WS_OP_;var r=Sc(this.stream_ws_?[this.stream_ws_,e].concatBuffers():e);try{e=r[0]}catch(i){return console.log("wsdecode error or FIN (first bit at 1):"+(e.length?e[0]:"")+" closing WS."),this.end(),void 0}this.ws_&&this.WS_OP_&&r[1].length,this.stream_ws_=r[1].length?r[1]:null}if(this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.WS_OP_&&this.ws_,h)var n=Date.now();if(this.ws_&&Us&&!A&&!T){this.pair.encrypted.t0&&(ca++,la+=this.stream_tor_.length,ha+=Date.now()-this.pair.encrypted.t0,0===ca%ua&&ha&&(console.log("wsdecode perf (pass to encrypted): "+parseInt(8*la/(ha/1e3))+" bps"),ca=0,la=0,ha=0)),this.pair.encrypted.write(this.stream_tor_),this.stream_tor_=new t(0);var s=this.queue_;s.shift(),s.length&&s[0]()}else this.stream_tor_.parse(this);n&&(ea++,ta+=e.length,ra+=Date.now()-n,0===ea%ia&&ra&&(this.OR_?this.address()&&ka&&this.address().port===kn&&this.OR_f&&console.log("Parser perf (ORDB):"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length):console.log("Parser perf:"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length),ea=0,ta=0,ra=0))}},Qo=function(e){this.queue_=this.queue_||[],this.queue_.push(Wo(e).bind(this)),1===this.queue_.length&&this.queue_[0]()},Xo=function(){delete this.end_,delete this.html_,delete this.header_,delete this.header_l,delete this.content_,delete this.content_l,delete this.clength_,delete this.encoding_,delete this.pass_,delete this.t0_,delete this.script_,delete this.header_sent,delete this.decoder_,delete this.f_,delete this.wait_,delete this.buff_,this.nb_try=0,delete this.time_resp},Jo=function(e){var r={};Xo.call(r),r.params_={},r.params_.OP=!0,r.params_.nb_hop=Hn,r.params_.one_c=!0,r.nb_try=0,r.no_exit=[],r.squeue_=[],r.wsqueue_=[],r._date_=Date.now(),r.i_id=qa,qa++,e=ho(e),r.params_.host=e.host;var i="GET /"+e.rest+" HTTP/1.1\r\n";return i+="Host: "+e.host+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",r.params_.stream=new t(i,"utf8"),r.remotePort="60000",r.remoteAddress="1.2.3.4",r.write=function(){},r.end=function(){},r.destroy=function(){},r.close=function(){},r._init_=Xo,r._write_=r.write,r},Zo=function(e){gn[e.server_.ip]=this,this[e.circId]=e,this.stream_tor_=new t(0);var r=new Po(e.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));e.send(r)},$o=function(e,r){r.socket_=e,e.first_=r,e.server_=r.server_,e.nbc_=0,Js&&e===El&&(e.buff_w=Os?new Mc.util.ByteBuffer:new t(0),e.abstract_client_tls=cl(e,"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net"),e.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),clearInterval(en),Al(e),e.destroy(),Dc()},e.abstract_client_tls.error=function(t,r){-1===r.message.indexOf("MAC")?(console.log(" Error TLS client disconnected "+r.message),clearInterval(en),Al(e),e.destroy(),Dc()):console.log("bad MAC")},e.write=function(t){Os?e.buff_w.putBytes(t.toString("binary")):e.buff_w=e.buff_w.length?[e.buff_w,t].concatBuffers():t},e.abstract_client_tls.connected=function(){console.log("TLS client connected"),en=setInterval(xc,1e4),e.tls_connected=!0,e.write=function(t){Os?e.abstract_client_tls.prepare(t.data?t.getBytes():t.toString("binary")):e.abstract_client_tls.prepare(sl(t.toString("hex")))},e.write(e.buff_w)},e.write_c=function(r){r.length&&(Os?e.send(new t(r,"binary")):e.send(r))},e.abstract_client_tls.dataReady=function(r){if(Os){if(r.data.length()){var i=new t(r.data.getBytes(),"binary");e.t0&&(xh++,Bh+=i.length,kh+=Date.now()-e.t0,0===xh%Rh&&kh&&(console.log("TLS perf (dataReady): "+parseInt(8*Bh/(kh/1e3))+" bps"),xh=0,Bh=0,kh=0)),Qo.call(e,i)}}else{var i=r.data.data.slice(r.data.read,r.data.length_);r.data.read=r.data.length_,console.log(i.length),i.length&&Qo.call(e,i)}},e.wsconnected_&&(console.log("start TLS handshake "),delete e.abstract_client_tls.handshaking,e.abstract_client_tls.handshake()))},ec=function(e){e.OR_=!0,e.OR_f=!0,e.way_="socket in",e.privkey_=Xs,e.stream_tor_=new t(0);var r=new Fo;r.remote_=e.remoteAddress,r.OR_=!0,r.OR_f=!0,r.circId=0,r.socket_=e,r.way_="socket in",e[0]=r},tc=function(e){var t="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",r="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",i={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,t,r),servername:t,rejectUnauthorized:!1};console.log("OUTGOING SOCKET : ---------start initial socket------------"+i.servername+" "+e.server_.ip+" "+e.server_.port);var n=tn.connect(e.server_.port,e.server_.ip,i,function(){clearTimeout(c),Zo.call(this,e)});n.on("data",Qo);var s=function(){n.nbc_>1?Go(tc):(clearTimeout(c),e.destroy_?Go(tc):e.last_?Go(tc):(e.clear_t0_(),delete e.ok_,delete gn[e.server_.ip],e.circuit_retry()))};n.on("end",s),n.on("close",s),n.on("error",function(){clearTimeout(c),e.destroy_=!0,n.destroy(),e.last_||e.change_or("initial socket error")});var a=function(){e.destroy_=!0,n.destroy(),e.change_or("initial socket failed")};$o(n,e);var c=setTimeout(a,2e3)},rc=function(e,t){var r=e.params_;if(e.time_ini=Date.now(),r)if(r.OP)if(r.one_c)if(t)if(Yo(e,!0)===!0)Ko(e);else{var i;if(!ks||e.params_.ws){if(i=Yo(e),t)for(var n=5;t===i&&0!==n;)i=Yo(e),n--}else for(i=Cs;i===Cs;)i=Yo(e);i?i.process(e):Ko(e)}else{var i;if(e.cid_&&e.cid_.bad_&&(delete e.tls_client_connected,delete e.abstract_client_tls,e.cid_.destroy_cid(e)),!ks&&!Us||e.params_.ws||e.params_.db_)i=e.cid_?e.cid_:r.one_c?Yo(e):null;else for(i=e.cid_?e.cid_:Cs;i===Cs||i===Ss;)i=Yo(e);i?(console.log("choose circuit "+i.circId+" for request "+e.i_id),i[e.sid_]?i.last_?i.last_.stream_handle_connected(e.sid_):(i.destroy_cid(e),rc(e)):i.process(e)):(console.log("no circuits"),0===mn.length?Ko(e):mn.push(e))}else Ko(e);else{var s="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",c=new Date,l=parseInt(No(8).toString("hex"),16),h=al(o+"pub-key.pem",o+"priv-key.pem","pem",l,c,s,a),u={key:Ri.readFileSync(o+"priv-key.pem"),cert:h,servername:s,requestCert:!0},d=tn.createServer(u,function(e){var t=e.remoteAddress,r=e.remotePort;ec(e),e.on("data",Qo),e.on("error",function(e){console.log("OR socket error"),console.log(e),delete wn[t+":"+r]}),e.on("end",function(){delete wn[t+":"+r]}),e.on("close",function(){delete wn[t+":"+r]}),e.cert_issuer=a,e.cert_subject=s,e.cert_date=c,e.certid_=l,wn[t+":"+r]=e});d.listen(r.port,function(){console.log("OR : server launched port "+r.port),Us&&setInterval(Uc,xs)}),d.on("OR : clientError",function(e){console.log(e)}),d.on("error",function(e){console.log(e)}),d.on("end",function(e){console.log(e)})}},ic=function(e){try{var t={},r=0;return e=e.split("\r\n"),e.forEach(function(e,i){if(e=e.split(":"),e.length>1&&0!=i){var n=e[0];e=e.map(function(e){return e.trim()}),e.shift(),e=e.join(":"),t[n]=e}else t[r+"a"]=e.join(":"),r++}),t}catch(i){console.log("caller"),console.log(ic.caller.toString().substr(0,50))}},nc=function(e){var t=[],r=0;for(var i in e)isNaN(i.substr(0,1))?t.push(i+": "+e[i]):e[i]?t.push(e[i]):r++;for(var n=0;r>n;n++)t.push("");return t.join("\r\n")},sc=function(e){e.start_&&(e.write(e.start_),delete e.start_)},ac=function(e,t,r){var i=/(((\b(https?|ftp|file):\/\/)|\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,n=!1,s=function(i){var s=e.split(i);if(""===s[s.length-1]&&!r)return n=!0,void 0;var a=e;i=ho(i);var o=t.fake_domain,c=bs[o],l=c.real_domain_s;if(i.host)if(-1!==i.host.indexOf(l)){var h=i.host.split("."),u=c.real_domain_a;a=i.host===c.real_domain?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):2===h.length&&"www"===u[0]||2===u.length&&"www"===h[0]?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):"http"+Ds+"://"+o+"/"+fo(uo(i),!0)}else-1===i.host.indexOf(o)&&(a="http"+Ds+"://"+o+"/"+fo(uo(i),!0));return a},a=e.replace(i,s);return n&&(t.pass_+=e),{html:n?e:a,pass:n}},oc=function(e){var t="";return t="",[t,e].join("")},cc=function(e,r){var i=e.toString("hex").split(gs),n=n||[],s=[];return i.forEach(function(e,a){if(r.wait_){var o=parseInt(new t(e,"hex").toString("utf8"),16);return 0===o&&(r.end_=!0,n.push("0d0a300d0a0d0a")),r.clength_+=o?o:0,e.length?a!==i.length-1&&(r.wait_=!1):0===a&&(r.wait_=!1),void 0}var c=r.clength_,l=r.html_.length,h=new t(e,"hex").length+2;(c>=l+h||l+h-2===c)&&s.push(e),l+h-2===c||a===i.length-1?(s=s.join(gs),n.push(s),r.html_.length+=h-2,a!==i.length-1&&(r.wait_=!0),s=[]):r.html_.length+=h}),new t(n.join(""),"hex")},lc=function(e){if(!(e instanceof Uint8Array)){var r=new t(e.length);r.map(e),e=r}return e},hc=function(e){console.log("destroy ws cid"),e.remoteAddress&&e.remotePort?delete wn[e.remoteAddress+":"+e.remotePort]:Rc()},uc=function(e,r){var i=e["Sec-WebSocket-Key"],n=sn.createhash("sha1");n.update(i+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64");var a="HTTP/1.1 101 WebSocket Protocol Handshake\r\n";a+="Upgrade: websocket\r\n",a+="Connection: Upgrade\r\n",a+="Sec-WebSocket-Accept:"+s+"\r\n",a+="Access-Control-Allow-Origin:"+e.Origin+"\r\n",a+="\r\n",console.log("INCOMING SOCKET :"+a),r.ws_=!0,ec(r),r.connected_=!0,r.wsconnected_=!0,r.write(a)},dc=function(e){this.key_=sn.randomBytes(16).toString("base64");var t="GET / HTTP/1.1\r\n";return t+="Host: "+e.ip+(js?":"+e.wsport:"")+"\r\n",t+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",t+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",t+="Accept-Language: en-us,en;q=0.5\r\n",t+="Accept-Encoding: gzip, deflate\r\n",t+="Connection: keep-alive, Upgrade\r\n",t+="Sec-WebSocket-Version: 13\r\n",t+="Origin: http://ianonym.com\r\n",t+="Sec-WebSocket-Key: "+this.key_+"\r\n",t+="Pragma: no-cache\r\n",t+="Cache-Control: no-cache\r\n",t+="Upgrade: websocket\r\n",t+="\r\n"},fc=0,pc=0,_c=0,gc=100,mc=0,yc=0,vc=0,bc=100,wc=function(e){d&&(Ho=Date.now()),f&&(Mo=Date.now()),console.log("start websocket");var t=T?new ja("ws://"+e.ip+":"+e.wsport):new WebSocket("ws://"+e.ip+":"+e.wsport);return T||(t.write=t.send),t.binaryType="arraybuffer",t.setNoDelay=function(){},t.connect=function(){},t.WS_OP_=!0,t.onopen=Cc,t.onmessage=function(e){var r=e.data instanceof ArrayBuffer?new Uint8Array(e.data):e.data;Ho&&(fc++,pc+=r.length,_c+=Date.now()-Ho,0===fc%gc&&_c&&(console.log("WS perf (received from WS before processing): "+parseInt(8*pc/(_c/1e3))+" bps - Buffered : "+t.bufferedAmount),fc=0,pc=0,_c=0)),(d||p)&&(Ho=Date.now()),Js&&t===El?(g&&(t.t0=Date.now()),jo&&0!==Ho-jo&&console.log("WS delay between processed and next received: "+(Ho-jo)+" data length "+r.length),Os?t.abstract_client_tls.process(r.toString("binary")):t.abstract_client_tls.process(r),p&&(jo=Date.now()),Mo&&(mc++,yc+=r.length,vc+=Date.now()-Mo,0===mc%bc&&vc&&(console.log("WS perf (received from WS after processed): "+parseInt(8*yc/(vc/1e3))+" bps - Buffered : "+t.bufferedAmount),mc=0,yc=0,vc=0)),f&&(Mo=Date.now())):Qo.call(this,r)},t.onclose=function(){console.log("Websocket closed ws://"+e.ip+":"+e.wsport)},T||(t.destroy=t.close,t.bufferSize=t.bufferedAmount),t.remoteAddress=e.ip,t.remotePort=Dn,t.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},t.setKeepAlive=function(){},t},Ec=function(e){var r=ic(e.toString("utf8")),i=r["Sec-WebSocket-Accept"];if(i){var n=sn.createhash("sha1");n.update(this.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64"),i===s&&(console.log("WS Client says : Handshake successfull"),Cc.call(this))}},Cc=function(){console.log("websocket connected");try{Kl.innerHTML="

    Websocket connected

    "}catch(e){}this.connected_=!0,this.wsconnected_=!0,this.ws_=!0,Us&&(this===Cl&&$i&&rc({params_:{OP:!0,nb_hop:Hn,ws:this}}),!Js||this!==El||!Cs&&$i||(console.log("launch db_cid"),this.db_cid_launched=!0,rc({params_:{OP:!0,nb_hop:Mn,ws:this,db:!0}})),Js||setInterval(xc,1e4))},Sc=function(e,r){r=r||[];var i,n=e.length,s=0,a=0,n=e.length,o=new t(0),c=new t(0);if(0===e.length)return[o,c];var l=e[0];if(e.length>1){var h=128&e[1],u=127&e[1];if(126===u?(s=e.slice(2,4).readUInt(),h=h&&e.slice(4,8),a=h?8:4):127===u?(s=parseInt(e.slice(2,10).toString("hex"),16),h=h&&e.slice(10,14),a=h?14:10):(s=u,h=h&&e.slice(2,6),a=h?6:2),o=e.slice(a,a+s),i=o.length,h&&o.length===s&&0!=s)for(var d=0;i>d;d++)o[d]=o[d]^h[d%4]}return o.length!==s||0===s?(i=o.length,a=n,c=e):r.push(o),n-a>i?Sc(e.slice(i+a),r):1&l?[r.concatBuffers().toString("utf8"),c.toString("utf8")]:2&l?[r.concatBuffers(),c]:void 0},Ac=function(e,r,i){var n,s,a,o=e.length;i=i?sn.randomBytes(4):i;var c=1===r?"81":"82";if(126>o?(s=(i?128|o:o).toString(16),s=1===s.length?"0"+s:s):o>=126&&65535>=o?(c+=i?"FE":"7E",a=2):(c+=i?"FF":"7F",a=8),!s)for(s=o.toString(16),s=s.length%2?"0"+s:s;s.length!==2*a;)s="00"+s;if(c+=s,n=new t(c,"hex"),i)for(var l=e.length,h=new t(l),u=0;l>u;u++)h[u]=e[u]^i[u%4];else h=e;return i?[n,i,h].concatBuffers():[n,h].concatBuffers()},Ic=function(e,r){for(var i=e.remoteAddress+":"+e.remotePort+":"+e.port_+":"+e.i_id,n=e.fake_,s=new t(new t(i,"utf8").toString("hex"),"hex"),a=s.length.toString(16);4!==a.length;)a="0"+a;for(s=[new t(a,"hex"),s].concatBuffers(),a=s.toString("hex");r.length;){var o;o=r.length+a>_n?r.slice(0,_n-a):r,o=[s,o].concatBuffers();var c=new qo(qo.prototype.RELAY_WS,0,o,n.Db_hash).toBuffer();c=new t(n.Kb_cipher.update(c,"hex","hex"),"hex");var l=new Po(n.circId,Po.prototype.RELAY_WS,c); +this.URL=e.readString(t),this.size-=t+1}else this.URL=null;32&this.flags?(this.OCR_ES_ID=e.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(e)},a.ES_Descriptor.prototype.getOTI=function(){var e=this.findDescriptor(t);return e?e.oti:0},a.ES_Descriptor.prototype.getAudioConfig=function(){var e=this.findDescriptor(t);if(!e)return null;var i=e.findDescriptor(r);return i&&i.data?(248&i.data[0])>>3:null},a.DecoderConfigDescriptor=function(e){a.Descriptor.call(this,t,e)},a.DecoderConfigDescriptor.prototype=new a.Descriptor,a.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8(),this.streamType=e.readUint8(),this.bufferSize=e.readUint24(),this.maxBitrate=e.readUint32(),this.avgBitrate=e.readUint32(),this.size-=13,this.parseRemainingDescriptors(e)},a.DecoderSpecificInfo=function(e){a.Descriptor.call(this,r,e)},a.DecoderSpecificInfo.prototype=new a.Descriptor,a.SLConfigDescriptor=function(e){a.Descriptor.call(this,i,e)},a.SLConfigDescriptor.prototype=new a.Descriptor,this}function Bi(){this.boxes=new Array,this.mdats=new Array,this.moofs=new Array,this.isProgressive=!1,this.lastMoofIndex=0,this.lastPosition=0}function ki(){this.log_level=this.LOG_LEVEL_INFO,this.sampleListBuilt=!1,this.inputStream=null,this.inputIsoFile=null,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.fragmentedTracks=new Array,this.extractedTracks=new Array,this.isFragmentationStarted=!1,this.nextMoofNumber=0}var Ri=require("fs"),Ui=require("child_process"),Di=function(e,t){t+=" "+(new Date).toDateString()+" "+(new Date).toTimeString();var r=function(e,r){try{if(e||(Ri.write(r,t+"\n",function(){}),Ri.close(r)),A&&"undefined"!=typeof Wa){var i=Wa("console");i.innerHTML.length>1e6&&(i.innerHTML="");var n=document.createElement("p");n.className="log",n.innerHTML=t,i.appendChild(n)}}catch(s){}};try{Ri.open(o+Dn+"-"+e,"a",r)}catch(i){}};process.on("uncaughtException",function(e){var t=Ri.openSync("/debug.txt","a");Ri.writeSync(t,(new Date).toDateString()+" "+(new Date).toTimeString()),Ri.writeSync(t,e.stack),Ri.closeSync(t)}),process.on("exit",function(){setTimeout(function(){console.log("Process ended")},0),console.log("About to exit "+(new Date).toDateString()+" "+(new Date).toTimeString())});var Ni=console.log.bind(console),Li=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)},Oi=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),a||S||c||Ni(e)};console.log=function(e){Di(a||c?"debug-prod.txt":S?"debug-prod2.txt":"debug.txt",e),(!a&&!S&&!c||-1!==process.platform.indexOf("win")&&T)&&Ni(e+" "+(new Date).toDateString()+" "+(new Date).toTimeString())};var Pi,Fi,qi,Hi,Mi,ji,zi;if(!A){if(process.argv&&process.argv.length>1){var Vi=process.argv.splice(2);if(5===Vi.length)Pi=Vi[0],Fi=Vi[1],qi=Vi[2],Hi=Vi[3],Mi=Vi[4];else{if(o=Vi[0]||"",o.length){if(-1===process.platform.indexOf("win")){var Ki=o[o.length-1];"/"!==Ki&&(o+="/")}}else Ni("Invalid directory parameter");if(T=!0,Vi.length>1)if("-P"!==Vi[1])ji=Vi[1],Vi.length>2&&(zi=!0);else{if(T=!1,x=!0,!(Vi.length>2))return;if(isNaN(parseInt(Vi[2])))return;Hi=parseInt(Vi[2])}}}var Gi=function(){console.log("update routers "+(new Date).toDateString()+" "+(new Date).toTimeString());var e=function(){console.log("child_process "+(new Date).toDateString()+" "+(new Date).toTimeString())};Ui.exec("/usr/local/bin/node "+o+"build-relays_and_dirs7.js",{timeout:12e5},e),Pi&&Ui.exec("/usr/local/bin/node "+o+"publish2.js "+Pi+" "+Fi+":"+qi+" "+Mi,{timeout:12e5},e)};T||x||setInterval(Gi,36e5)}if(T)var Yi,Wi,Qi,Xi=function(e){var t={host:"peersm.com",port:80,path:"/peersmclient/proxy.pac",method:"GET"};Yi="";var r=nn.request(t,function(t){t.on("data",function(e){Yi+=e.toString("utf8")}),t.on("end",function(){e()}),t.on("error",function(){console.log("Error proxy.pac")})});r.end()};else var Xi=function(e){var t=new XMLHttpRequest;return t?(t.open("GET",e,!1),t.send(null),t.responseText):void 0};var Ji,Zi,$i,en,tn=require("tls"),rn=require("net"),nn=require("http"),sn=(require("url"),require("crypto")),an=T?require(o+"node_modules/torrent-stream"):{},Guards=T||x?{}:require(o+"guards.js").Guards,on=T||x?{}:require(o+"relays.js").Relays,cn=T||x?{}:require(o+"dirs.js").Dirs,Exit=T||x?{}:require(o+"exit.js").Exit,ln=!1,hn=!0,un=hn?null:require(o+"crypto.js").Rsa,dn=hn?null:require(o+"crypto.js").PEM,fn=hn?null:require(o+"crypto.js").Hash,pn=498,_n=65535,gn={},mn=[],yn={},vn={},bn={},wn={},En={},Cn={},Sn={},An=[],In={},Tn={},xn={},Bn={},kn=0,Rn=Fi||"",Un="2679B51C906158F3DF4C59AFD73E2B1FDA6535E1",Dn=a?C?1:0:S?0:0,Nn="010001",Ln=new t("00000000000000000000000000000000","hex"),On=32767,Pn=Hi||(a?2:0),Fn=5,qn=5,Hn=3,Mn=zi?2:3,jn="-----BEGIN RSA PUBLIC KEY-----",zn="-----END RSA PUBLIC KEY-----",Vn=5e3,Kn=1e3,Gn=7e3,Yn=3,Wn=0,Qn=0,Xn=30,Jn=12,Zn=10,$n=s?20:5,es=!1,ts=5,rs=5e3,is=72e5,ns=36e5,ss=36e5,as=[],os=[],cs=1e3,ls=100,hs=500,us=50,ds=.8,fs=15e3,ps=16184,_s=t,gs="0d0a",ms=".com",ys=5e3,vs=2e3,bs={},ws="http:",Es="www.f4116a30c08bbdfd01813b96c909.com",Cs=null,Ss=null,As=36e6,Is=1e4,Ts=3e5,xs=9e5,Bs=5,ks=a?!1:!0,Rs=a?!1:!0,Us=a?!1:!0,Ds="",Ns=!1,Ls=1024,Os=!0,Ps=!1,Fs={},qs="undefined"!=typeof document?document.location.href:"",Hs=!1,Ms=!0,js=!1,zs=a?!1:!0,Vs=0,Ks=1e5,Gs="Retrieving... ",Ys=!0,Ws=!0,Qs="enc",Xs=T||x?null:Ri.readFileSync(o+"priv-key.pem"),Js=!1,Zs=65536,$s=2097152,ea=0,ta=0,ra=0,ia=100,na=0,sa=0,aa=0,oa=100,ca=0,la=0,ha=0,ua=100,da=0,fa=0,pa=0,_a=100,ga=0,ma=0,ya=0,va=100,ba=1e6,wa=2e6,Ea=1e3,Ca=125,Sa=3e4,Aa="0000000000000000000000000000000000000000",Ia=3e5,Ta="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF",xa={323:"text/h323","3gp":"video/3gpp",a:"application/octet-stream",acx:"application/internet-property-stream",ai:"application/postscript",aif:"audio/x-aiff",aifc:"audio/x-aiff",aiff:"audio/x-aiff",asc:"application/pgp-signature",asf:"video/x-ms-asf",asr:"video/x-ms-asf",asm:"text/x-asm",asx:"video/x-ms-asf",atom:"application/atom+xml",au:"audio/basic",avi:"video/x-msvideo",axs:"application/olescript",bas:"text/plain",bat:"application/x-msdownload",bcpio:"application/x-bcpio",bin:"application/octet-stream",bmp:"image/bmp",bz2:"application/x-bzip2",c:"text/x-c",cab:"application/vnd.ms-cab-compressed",cat:"application/vnd.ms-pkiseccat",cc:"text/x-c",cdf:"application/x-netcdf",cer:"application/x-x509-ca-cert",cgm:"image/cgm",chm:"application/vnd.ms-htmlhelp","class":"application/octet-stream",clp:"application/x-msclip",cmx:"image/x-cmx",cod:"image/cis-cod",com:"application/x-msdownload",conf:"text/plain",cpio:"application/x-cpio",cpp:"text/x-c",cpt:"application/mac-compactpro",crd:"application/x-mscardfile",crl:"application/pkix-crl",crt:"application/x-x509-ca-cert",csh:"application/x-csh",css:"text/css",csv:"text/csv",cxx:"text/x-c",dcr:"application/x-director",deb:"application/x-debian-package",der:"application/x-x509-ca-cert",diff:"text/x-diff",dir:"application/x-director",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dll:"application/x-msdownload",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dtd:"application/xml-dtd",dv:"video/x-dv",dvi:"application/x-dvi",dxr:"application/x-director",ear:"application/java-archive",eml:"message/rfc822",eps:"application/postscript",etx:"text/x-setext",evy:"application/envoy",exe:"application/x-msdownload",ez:"application/andrew-inset",f:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",fif:"application/fractals",flr:"x-world/x-vrml",flv:"video/x-flv","for":"text/x-fortran",gem:"application/octet-stream",gemspec:"text/x-script.ruby",gif:"image/gif",gram:"application/srgs",grxml:"application/srgs+xml",gtar:"application/x-gtar",gz:"application/x-gzip",h:"text/x-c",hdf:"application/x-hdf",hh:"text/x-c",hlp:"application/winhlp",hqx:"application/mac-binhex40",hta:"application/hta",htc:"text/x-component",htm:"text/html",html:"text/html",htt:"text/webviewhtml",ice:"x-conference/x-cooltalk",ico:"image/vnd.microsoft.icon",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",iii:"application/x-iphone",ins:"application/x-internet-signup",isp:"application/x-internet-signup",iso:"application/octet-stream",jar:"application/java-archive",java:"text/x-java-source",jfif:"image/pipeg",jnlp:"application/x-java-jnlp-file",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",kar:"audio/midi",latex:"application/x-latex",lha:"application/octet-stream",lsf:"video/x-la-asf",lsx:"video/x-la-asf",lzh:"application/octet-stream",log:"text/plain",m13:"application/x-msmediaview",m14:"application/x-msmediaview",m3u:"audio/x-mpegurl",m4a:"audio/mp4a-latm",m4b:"audio/mp4a-latm",m4p:"audio/mp4a-latm",m4u:"video/vnd.mpegurl",m4v:"video/mp4",mac:"image/x-macpaint",man:"text/troff",mathml:"application/mathml+xml",mbox:"application/mbox",mdb:"application/x-msaccess",mdoc:"text/troff",me:"text/troff",mesh:"model/mesh",mht:"message/rfc822",mhtml:"message/rfc822",mid:"audio/midi",midi:"audio/midi",mif:"application/vnd.mif",mime:"message/rfc822",mml:"application/mathml+xml",mng:"video/x-mng",mny:"application/x-msmoney",mov:"video/quicktime",movie:"video/x-sgi-movie",mp2:"video/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4v:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpg:"video/mpeg",mpga:"audio/mpeg",mpp:"application/vnd.ms-project",mpv2:"video/mpeg",ms:"text/troff",msh:"model/mesh",msi:"application/x-msdownload",mvb:"application/x-msmediaview",mxu:"video/vnd.mpegurl",nc:"application/x-netcdf",nws:"message/rfc822",oda:"application/oda",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",ogg:"application/ogg",p:"text/x-pascal",p10:"application/pkcs10",p12:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",p7c:"application/x-pkcs7-mime",p7m:"application/x-pkcs7-mime",p7r:"application/x-pkcs7-certreqresp",p7s:"application/x-pkcs7-signature",pac:"text/plain",pas:"text/x-pascal",pbm:"image/x-portable-bitmap",pct:"image/pict",pdb:"chemical/x-pdb",pdf:"application/pdf",pem:"application/x-x509-ca-cert",pfx:"application/x-pkcs12",pgm:"image/x-portable-graymap",pgn:"application/x-chess-pgn",pgp:"application/pgp-encrypted",pic:"image/pict",pict:"image/pict",pkg:"application/octet-stream",pko:"application/ynd.ms-pkipko",pl:"text/x-script.perl",pm:"text/x-script.perl-module",pma:"application/x-perfmon",pmc:"application/x-perfmon",pml:"application/x-perfmon",pmr:"application/x-perfmon",pmw:"application/x-perfmon",png:"image/png",pnm:"image/x-portable-anymap",pnt:"image/x-macpaint",pntg:"image/x-macpaint",pot:"application/vnd.ms-powerpoint",ppm:"image/x-portable-pixmap",pps:"application/vnd.ms-powerpoint",ppt:"application/vnd.ms-powerpoint",prf:"application/pics-rules",ps:"application/postscript",psd:"image/vnd.adobe.photoshop",pub:"application/x-mspublisher",py:"text/x-script.python",qt:"video/quicktime",qti:"image/x-quicktime",qtif:"image/x-quicktime",ra:"audio/x-pn-realaudio",rake:"text/x-script.ruby",ram:"audio/x-pn-realaudio",rar:"application/x-rar-compressed",ras:"image/x-cmu-raster",rb:"text/x-script.ruby",rdf:"application/rdf+xml",rgb:"image/x-rgb",rm:"application/vnd.rn-realmedia",rmi:"audio/mid",roff:"text/troff",rpm:"application/x-redhat-package-manager",rss:"application/rss+xml",rtf:"application/rtf",rtx:"text/richtext",ru:"text/x-script.ruby",s:"text/x-asm",scd:"application/x-msschedule",sct:"text/scriptlet",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgm:"text/sgml",sgml:"text/sgml",sh:"application/x-sh",shar:"application/x-shar",sig:"application/pgp-signature",silo:"model/mesh",sit:"application/x-stuffit",skd:"application/x-koan",skm:"application/x-koan",skp:"application/x-koan",skt:"application/x-koan",smi:"application/smil",smil:"application/smil",snd:"audio/basic",so:"application/octet-stream",spc:"application/x-pkcs7-certificates",spl:"application/x-futuresplash",src:"application/x-wais-source",sst:"application/vnd.ms-pkicertstore",stl:"application/vnd.ms-pkistl",stm:"text/html",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",svg:"image/svg+xml",svgz:"image/svg+xml",swf:"application/x-shockwave-flash",t:"text/troff",tar:"application/x-tar",tbz:"application/x-bzip-compressed-tar",tcl:"application/x-tcl",tex:"application/x-tex",texi:"application/x-texinfo",texinfo:"application/x-texinfo",text:"text/plain",tgz:"application/x-compressed",tif:"image/tiff",tiff:"image/tiff",torrent:"application/x-bittorrent",tr:"text/troff",trm:"application/x-msterminal",tsv:"text/tab-seperated-values",txt:"text/plain",uls:"text/iuls",ustar:"application/x-ustar",vcd:"application/x-cdlink",vcf:"text/x-vcard",vcs:"text/x-vcalendar",vrml:"model/vrml",vxml:"application/voicexml+xml",war:"application/java-archive",wav:"audio/x-wav",wbmp:"image/vnd.wap.wbmp",wbxml:"application/vnd.wap.wbxml",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",webm:"video/webm",wks:"application/vnd.ms-works",wma:"audio/x-ms-wma",wmf:"application/x-msmetafile",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",wmlsc:"application/vnd.wap.wmlscriptc",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wps:"application/vnd.ms-works",wri:"application/x-mswrite",wrl:"model/vrml",wrz:"x-world/x-vrml",wsdl:"application/wsdl+xml",xaf:"x-world/x-vrml",xbm:"image/x-xbitmap",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xml:"application/xml",xof:"x-world/x-vrml",xpm:"image/x-xpixmap",xsl:"application/xml",xslt:"application/xslt+xml",xul:"application/vnd.mozilla.xul+xml",xwd:"image/x-xwindowdump",xyz:"chemical/x-xyz",yaml:"text/yaml",yml:"text/yaml",z:"application/x-compress",zip:"application/zip"};if(Ms&&!A)var Ba={};if(A&&!I){var Yi=Xi("proxy.pac");Us||(Yi="var FindProxyForUrl="+Yi,eval(Yi),Zi=FindProxyForUrl("http://"+Es,Es,!0))}else Zi={ip:Rn,port:kn,wsport:Pn,fing:Un,o_modulus:"8bd0a81286858b11f2856ac2f3efd8a5e538b2f851a4c02cc717c94ea52418c587cc69515e46b5381d17cd2299cb4c59fae38250898eab31c9b8acfcf02110a96f0f03442ecd34f1befb0604e1ffbb981848534da9f3f23795ed7df047730cb9dab711722ad6504b893cebda2de4b41123d667474a166eba3ead7df8267dda15"};if(Us){ks=!1,Rs=!1;var ka=Zi;if(js=!0,zs=!1,T){var Ra=ji?1e6*ji:1e5,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,qa=0,Ha={};E=!1,Ha.list=function(e,r){Ri.readdir(o,function(i,n){i||n.forEach(function(i){if(-1===i.indexOf("debug.txt")&&-1===i.indexOf("debug-prod.txt")){var n,s,a=i.split("#");if(a.length>1){var c=a[1].split(".");n=a[0]+(c.length>1?"."+c[1]:""),s=a[1].split(".")[0]}if(n)r||Ri.stat(o+i,function(t,r){if(!t){var a={file_name:i,name:n,name_hash:s,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(a)}});else{var l=sn.createhash("sha1");l.update(new t(Date.now().toString()+El.localAddress.toString()+El.localPort.toString(),"utf8")),l=l.digest("hex");var c=i.split(".");if(c.length){var h=c.pop();if(c.length){var n=c.join("."),u=n+"#"+l+"."+h;Ri.rename(o+i,o+u,function(){Ri.stat(o+u,function(t,r){if(!t){var i={file_name:u,name:n,name_hash:l,hash:"0000000000000000000000000000000000000000",file_length:r.size,current_length:r.size,type:"application/octet-binary"};e(i)}})})}}}}})})};var Ma=function(){Ss&&Ss.send_db_info(!0)},ja=function(e){e=e.split("ws://")[1].split(":");var t=e[1],r=e[0];console.log("peersm client "+r+" "+t);var i=new rn.Socket;return i.on("connect",function(){i.key_=sn.randomBytes(16).toString("base64");var e="GET / HTTP/1.1\r\n";e+="Host: "+i.remoteAddress+":"+i.remotePort+"\r\n",e+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",e+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",e+="Accept-Language: en-us,en;q=0.5\r\n",e+="Accept-Encoding: gzip, deflate\r\n",e+="Connection: keep-alive, Upgrade\r\n",e+="Sec-WebSocket-Version: 13\r\n",e+="Origin: http://peersm.com\r\n",e+="Sec-WebSocket-Key: "+i.key_+"\r\n",e+="Pragma: no-cache\r\n",e+="Cache-Control: no-cache\r\n",e+="Upgrade: websocket\r\n",e+="\r\n",console.log(e),i.write(e)}),i.on("data",function(e){if(i.connected__){var t=Sc(i.stream_ws__?[i.stream_ws__,e].concatBuffers():e);i.stream_ws__=t[1].length?t[1]:null,i.onmessage({data:t[0]})}else{i.on("end",function(){console.log("websocket_node end"),i.onclose()}),i.on("error",function(){console.log("websocket_node error"),i.onclose()});var r=ic(e.toString("utf8")),n=r["Sec-WebSocket-Accept"]||r["Sec-Websocket-Accept"];if(n){var s=sn.createHash("sha1");s.update(i.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var a=s.digest("base64");n===a?(console.log("Client says : Handshake successfull for "+El.remoteAddress+" "+El.remotePort),i.write=function(e){i._write(Ac(e,2,!0),null,function(){})},i.send=i.write,i.connected__=!0,i.onopen()):i.end()}else i.end()}}),i.close=i.end,i.connect(t,r),i},za=function(){};za.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Va=function(){};Va.prototype.readAsArrayBuffer=function(e){this.onload({target:{result:e}})};var Ka=function(e){this.data=[],this.cursor=0,this.size=e};Ka.prototype.push=function(e){this.data.push(e),this.cursor+=e.length},Ka.prototype.unshift=function(e){this.data.unshift(e),this.cursor-=e.length},Ka.prototype.slice=function(e,r){var i,n,s=r-e,a=0,o=[];if(s>0&&this.data.length){for(s=Math.min(s,this.cursor);s>a;){var c=this.data.shift(),l=c.length;o.push(c),a+=l,this.cursor-=l}return i=o.concatBuffers(),n=i.slice(s),i=i.slice(0,s),this.cursor+=n.length,n.length&&this.data.unshift(n),i}return new t(0)};var Ga=function(e){this.fd=e.fd,this.size=e.size,this.type=e.type,this.cursor=0};Ga.prototype.slice=function(e,r){if(r){if(r>e){var i=new t(r-e);return Ri.readSync(this.fd,i,0,r-e,e+this.cursor),i}return new t(0)}return this.size=this.size-e,this.cursor=e,this};var Ya=function(){var e={};return e.get=function(e){var t={};return Ri.readdir(o,function(r,i){if(r)t.onsuccess({target:{result:null}});else{for(var n,s=!1,a=i.length,c=0;a>c;c++){var l=i[c];if(-1===l.indexOf("debug.txt")){var h,u,d=l.split("#");if(d.length>1){var f=d[1].split(".");f.length>1&&(n=f[1],h=d[0]+(f.length>1?"."+f[1]:"")),u=d[1].split(".")[0]}if(u===e){s=!0,Ri.stat(o+l,function(e,r){!e&&n?Ri.open(o+l,"r",function(e,i){if(e)t.onsuccess({target:{result:null}});else{var s;n&&(s=xa[n]),s||(s="application/octet-binary"),console.log(h+" "+u+" "+s);var a={fd:i,size:r.size,type:s};t.onsuccess({target:{result:{file_length:r.size,current_length:r.size,type:s,data:a}}})}}):t.onsuccess({target:{result:null}})});break}}}s||t.onsuccess({target:{result:null}})}}),t},e};Wi=function(){Yi="var FindProxyForUrl="+Yi,eval(Yi);var t=FindProxyForUrl("http://"+Es,Es,!0);Zi=t[1][_o(t[1].length)],ka=e?{ip:"213.246.53.127",port:0,wsport:0,fing:"E0671CF9CB593F27CD389CD4DD819BF9448EA834",o_modulus:"ca2a670479816ca562f7afc2667db1811f0efa7d595aa27cf532092a052c697b102c03d8b8dddc276050fe9cad15efe72758d9d9b0f581f5cbfd0be92ecd721711797354006625e74e0f733efee3ee779116efe87da3b5f8c1729e2d0a5f2c4de4d5906b6e383c0a0d8dddbc076cf426423f6f2b6fd46fab9f54fb8e42601a2d",name:"Tor Bridge"}:t[2],Js=!0,on=Guards,Ba.userAgent="node-Tor",Il()},Qi=function(){var e=function(){console.log("update prox --------"),Yi="var FindProxyForUrl="+Yi,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0)};Xi(e)},Xi(Wi),setInterval(Ma,1e4),setInterval(Qi,ss)}if(A){var Ha,Ra=0,Ua=1,Da=498,Na=50,La={},Oa=1e3,Pa=2e6,Fa=5,Wa=document.getElementById.bind(document),qa=0,Qa=document.location.href.split("/"),Xa=Qa[Qa.length-1].split("#")[0],Ja=function(e){return e.pageY?e.pageY:e.clientY},Za=function(e){return e.pageX?e.pageX:e.clientX},$a=function(e,t,r,i){e.__event=e.__event||{},e.__event[t]&&eo(e,t,e.__event[t][0],e.__event[t][1]),e.__event[t]=[r,i],e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r)},eo=function(e,t,r,i){e.addEventListener?e.removeEventListener(t,r,i):e.attachEvent&&e.detachEvent("on"+t,r)},to=[Qs,"exe","com","bin","php","php3","php4","php5","phtml","inc","sql","pl","cgi","py","sh","c","cc","cpp","cxx","h","hpp","java","class","jar","html","html","shtml","dhtml","xhtml","xml","js","css","zip","tar","tgz","gz","bz2","tbz","rar","mp3","wav","3ga","midi","mid","rm","ra","ram","pls","m3u","mkw","webm","avi","mp4","m4v","mpg","mpeg","mov","swf","fla","doc","docx","xls","xlsx","rtf","pdf","txt","ppt","pptx","vcard","vcf","obj","max","3ds","3dm","kml","torrent","gpx","dxf","dwg","wsg","vb","pif","gadget","apk","msi","sxc","123","ots","nb","gsheet","xlr","ods","svgz","cdr","svg","ps","eps","orf","pef","rwl","mrw","mef","fff","erf","dcr","bay","3fr","srf","rw2","nef","cr2","arw","dng","dwt","irs","ait","art","aip","aia","ai","indd","prtpset","ppj","plb","prproj","aetx","aet","aes","aepx","aep","aec","ncorx","ncor","em","abr","csh","psb","psd","as","asc","ascs","aif","aiff","flac","iff","m4a","wma","srt","flv","3g2","3gp","asf","wmv","pcast","xlt","xltm","xltx","ans","ascii","log","odt","wpd","accdb","db","dbf","mdb","pdb","asp","aspx","asx","fnt","otf","ttf","dotx","wps2","dll","fon","cmd","srt"],ro=["tga","gif","jpg","tiff","jpeg","bmp","png"];to.forEach(function(e){La[e]="http://www.peersm.com/img/extensions/"+e+".png"});var io=function(){var e=new XMLHttpRequest;if(e){e.open("POST","bandwidth.html",!0);var t=Date.now(),r=1e5;e.send(new Uint8Array(r)),e.onreadystatechange=function(){if(4==e.readyState){var r=1e5/((Date.now()-t)/1e3);Ra=parseInt((Ra?(Ra+r)/2:r)/Ua),console.log("bandwidth : "+8*Ra/1e3+" Kbps")}}}};setInterval(io,18e6),io()}}on=Guards;var no=function(){Ri.rename(o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt"),o+(a||c?Dn+"-debug-prod.txt":S?Dn+"-debug-prod2.txt":Dn+"-debug.txt")+".old",function(){})};no(),A||T||x||console.log(Pi+" "+Fi+" "+qi+" "+Hi+" "+Mi);var so=function(e){var t=e.split("magnet:?xt=urn:btih:");return t.length>1?t[1]:void 0},ao=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Accept-Ranges:bytes",e+="Content-Encoding:gzip\r\n",e+="Content-Length:0\r\n",e+="Content-Type:*\r\n",e+="\r\n"},oo=function(){var e="HTTP/1.1 410 Gone\r\n";return e+="\r\n"},co=function(){var e="HTTP/1.1 200 OK\r\n";return e+="Vary: Accept-Encoding\r\n",e+="Keep-Alive: timeout=2, max=100\r\n",e+="Connection: Keep-Alive\r\n",e+="Transfer-Encoding: chunked\r\n",e+="Content-Type: text/html\r\n",e+="\r\n1f\r\n//Outside of authorized domains\r\n0\r\n\r\n"},lo=function(e){var t="HTTP/1.1 301 Moved Permanently\r\n";return t+="Location: "+e+"\r\n",t+="\r\n"},ho=function(e){var t={url:e},r=e.split("/"),i=function(e){if(e.length){var r=e[0];t.host=r,e.shift()}t.rest=e.join("/")};return r.length>1?""===r[1]?(t.protocol=r[0]?r[0]:ws,r.shift(),r.shift()):t.protocol=ws:t.protocol=ws,i(r),t},uo=function(e){var t=[];return t.push(e.protocol?e.protocol:protocol),t.push(""),e.host&&t.push(e.host),e.rest&&t.push(e.rest),t.join("/")},fo=function(e,r){var i=new t(Eo(r?new t(e,"utf8"):new t(e,"hex"),Bl),"hex");return r?i.toString("hex"):i.toString("utf8")},po=function(e){var t=e.slice(0,1),r=e.slice(1,2),i=e.slice(2,2+r.readUInt());return e=e.slice(r.readUInt()+2),{data:e,addr:{type:t,length:r,value:i}}},_o=function(e){return parseInt(Math.random()*e)},go=function(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds()+(e.getMilliseconds()>500?1:0),0)},mo=function(e){var t,r,i=[],n=[],s=[],a=e.nb_hop||Fn;if(a>Fn&&(a=Fn),e.nb_try=e.nb_try||1,e.nb_try>qn)return console.log("PATH : createPath : Too many attempts"),void 0;for(r=Guards.length,t=_o(r),t=Guards[t].split("-"),s.push(t[1]),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),a--,r=on.length,a--;a;)t=_o(r),-1==i.indexOf(t)&&on[t].split("-")[1]!=n[0].ip&&(i.push(t),a--);var o=function(e){var t=on[e].split("-"),r={ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]};s.push(t[1]),n.push(r)};for(i.forEach(o),r=Exit.length,t=_o(r);-1!=s.indexOf(Exit[t].split("-")[1]);)t=_o(r);return t=Exit[t].split("-"),n.push({ip:t[1],fing:t[0],port:t[2],band:t[3],o_modulus:t[5]?t[5]:t[4]}),n},yo=function(e,r){var i="GET /"+r+" HTTP/1.1\r\n";return i+="Host: "+e+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",new t(i,"utf8")},vo=function(e,r,i){var n="GET /"+r+" HTTP/1.1\r\n";return n+="Host: "+e+"\r\n",n+="User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0\r\n",n+="Range: bytes="+i+"-\r\n",n+="Accept: */*\r\n",n+="Accept-Language: en\r\n",n+="Accept-Encoding: gzip, deflate\r\n",n+="Connection: keep-alive\r\n",n+="\r\n",new t(n,"utf8")},bo=function(e,t,r){var i=0;if(e.nbc_=e.nbc_?e.nbc_:0,t){if(e.nbc_===On)return!1}else if(65534===e.nbc_)return!1;for(;e[i]||0===i;)i=t?r?e.cid?++e.cid%On:On:e.cid?++e.cid%On:1:e.cid?++e.cid%65535:1;return e.cid=i,e.nbc_++,i},wo=function(e){for(var r="",i=0;5>i;i++){var n=sn.createhash("sha1");n.update(new t(e+"0"+i,"hex")),r+=n.digest("hex")}return new t(r,"hex")},Eo=function(e,t){var r=sn.createcipheriv("aes-128-ctr",t,Ln),i=r.update(e,"hex","hex");return i+=r.final("hex")},Co=function(e,r){var i=r.slice(0,70),n=r.slice(70),s=No(16),a=[s,i].concatBuffers(),o=new un;a=o.encrypt(new t(e.toString("hex"),"binary"),new t(Nn,"binary"),new t(a.toString("binary"),"binary"),"RSA_PKCS1_OAEP_PADDING","hex");var c=Eo(n,s);return[new t(a,"hex"),new t(c,"hex")].concatBuffers()},So=function(e,r,i){var n=new un,s=new t(n.decrypt(e,r,"RSA_PKCS1_OAEP_PADDING","hex"),"hex"),a=s.slice(0,16);return[s.slice(16),new t(Eo(i,a),"hex")].concatBuffers()},Ao=function(e){if(T){if(this.fc_t.length){var t=this.fc_t.shift();t()}}else if(e.source==window&&e.data==this.messageName&&(e.stopPropagation(),this.fc_t.length)){var t=this.fc_t.shift();t()}},Io=function(e,t,r,i){if(r)if(r.stop_)r._torrent_&&r._torrent_stream.destroy(),r=null,console.log("delete sid 2"),delete this[t];else{if(r._torrent_&&T&&"undefined"==typeof i){var n=Date.now()-r.start_t0;i=Math.ceil(1e6*n*ji/1e3/Da/ds),console.log("first blocks nb "+i)}else i="undefined"==typeof i?Fa:i;var s=[];if(r.reader.onload=function(n){if(n.target.result){var a=n.target.result instanceof ArrayBuffer?new Uint8Array(n.target.result):n.target.result;if(a.length)for(var o=0;i>o;o++){if(0===r.stream_window_s){r.cursor-=a.length,r._torrent_&&r._torrent_.unshift(a);break}if(r.stream_window_s--,s.push(a.slice(0,Math.min(a.length,pn))),!(a.length>pn))break;a=a.slice(pn)}}var c=Date.now();r.fc_t.push(function(){To.call(this,e,s,r,t,c)}.bind(this)),T?setTimeout(Ao.bind(r),0):window.postMessage("flush","*")}.bind(this),0!==i){var a=e.slice(r.cursor,Math.min(e.size,r.cursor+i*pn));r.cursor+=a.length,r.reader.readAsArrayBuffer(a)}else r.reader.onload({target:{result:null}})}},To=function(e,t,r,i,n){t.forEach(function(e){r.sent_+=e.length;var t=new qo(qo.prototype.RELAY_DB_DATA,i,e,this.last_.Df_hash),n=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));this.send(n)},this);var s,a=Date.now()-n,o=T?this.socket_.bufferSize:this.socket_.bufferedAmount,c=parseInt((r.cursor-o)/((Date.now()-r.start_t0)/1e3)),l=8*c,h=ba;if(r.cursorh)s=0;else if(T)s=Math.ceil(a*c/1e3/Da/ds);else{var u=Pa>o?Math.ceil((Pa-o)/Da):0;a&&(s=Math.ceil(a*c/1e3/Da/ds)),s=s?Math.min(u,s):u}s=l>h?0:o>Pa?0:s>Fa?s:Fa,m&&0!==a&&0!==s&&console.log("real bandwidth "+parseInt(8*c/1e3)+" kbps "+"- advertised bandwidth "+parseInt(8*Ra/1e3)+" kbps time "+a+" nbblocs "+s+" buffered amount "+o+" cursor "+r.cursor+" torrent buffered "+(r._torrent_?r._torrent_.cursor:"")),0!==r.stream_window_s||r.pause_[i]?e.size===r.cursor?(console.log("delete sid"),delete this[i],console.log(parseInt(8*r.cd_length/((Date.now()-r.start_t0)/1e3))+" bps")):this.send_db_data(e,i,s,!0):(console.log(parseInt(8*r.cursor/((Date.now()-r.start_t0)/1e3))+" kbps"),console.log("Pausing download CIC "+this.circId+" for stream "+i+" sent "+r.sent_+" remaining length "+(e.size-r.cursor)+" time "+Date.now()+" buffered amount "+o+" fc_t "+r.fc_t.length),r.pause_[i]=e)},xo=function(e){var t=bo(e),r={};return r.sid_=t,r.received_=0,r.sent_=0,r.stream_window=Oa,r.stream_window_s=Oa,r.send_data=!0,e[t]=r,r.pause_={},t},Bo=function(e){if(e){var t=e.split(".");return t=t.length?t[t.length-1]:""}return"exe"},ko=function(e){var t=e.cid_,r=e.sid_;r&&delete t[r],delete e.cid_,delete e.sid_},Ro=function(e){lh(e.bar_),lh(xh),lh(nh)},Uo=function(e,r,i){console.log("search in bittorrent");for(var n=An;n.length;)if(n[0].socket_)if(n[0].socket_.remoteAddress){if(!n[0].destroyed_)break;console.log("ORDB remove destroyed CIC fac "+n[0].circId),n.shift()}else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();else console.log("ORDB remove fac "+n[0].circId),n[0].circuit_destroy(),n.shift();if(n.length){var s=n[0];n.shift(),n.push(s);var a=No(16),o={d_length:r,hash_:new t(i,"hex")};In[a.toString("hex")]=[this,e,n,o,1],s.send_db_query(o,a)}else this.send_db_end(0,e)},Do=function(e){if("open"===e._stream_.readyState&&!e._source_.updating)if(e.append_buffer.length){e.append_cursor++;var t=e.append_buffer.shift();try{e._source_.appendBuffer(t)}catch(r){console.log("error updateend ")}}else e.append_cursor=0};t.prototype.readUInt=function(){switch(this.length){case 1:return this[0];case 2:return this.readUInt16BE(0);case 4:return this.readUInt32BE(0);default:return 0}},t.prototype.writeUInt=function(e){switch(this.length){case 1:this.writeUInt8(e,0);break;case 2:this.writeUInt16BE(e,0);break;case 4:this.writeUInt32BE(e,0)}return this},t.prototype.map=function(e){var t=e.length;Hs||A?(this.set(e),this.fill(0,t)):(e.copy(this),this.fill(0,t))},Array.prototype.concatBuffers2=function(){var e=[];return this.forEach(function(t){e.push(t.toString("hex"))}),new t(e.join(""),"hex")},Array.prototype.concatBuffers1=function(){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){for(var t=e.length,n=0;t>n;n++)r[i]=e[n],i++}),r},Array.prototype.concatBuffers=function(){if(Hs||A){var e=0;this.forEach(function(t){e+=t.length});var r=new t(e),i=0;return this.forEach(function(e){var t=e.length;r.set(e,i),i+=t}),r}return t.concat(this)},t.prototype.parse=function(e){e.WS_OP_&&e.ws_;for(var t=e.stream_tor_;t.length;){var r,i=t.slice(0,2),n=t.slice(2,3),s=i.readUInt();if(e[s]&&e[s].clear_timers(),7==n.readUInt()||n.readUInt()>=128){var a=t.length;if(!(a>=5))break;var o=t.readUInt16BE(3);if(!(a>=o+5))break;r=t.slice(5,o+5),t=t.slice(o+5)}else{if(!(t.length>=512))break;r=t.slice(3,512),t=t.slice(512)}var c=new Po(i.readUInt(),n.readUInt(),r,!0);Vo.bind(e)([c])}e.stream_tor_=t;var l=e.queue_;e.WS_OP_&&e.ws_,l.shift(),l.length&&l[0]()},t.prototype.parseTLS=function(e){for(var r,i=e.stream_tor_;i.length;){var n=i.length;if(!(n>=5))break;var s=i.readUInt16BE(3);if(!(n>=s+5))break;if(r=i.slice(0,s+5),i=i.slice(s+5),22!==r[0]||e.ccs_)20===r[0]&&(e.ccs_=!0),e.process(r);else for(var a=r.readUInt(1,2),o=r.readUInt(3,3),c=r.slice(5,o);c.length;){var n=c.length;if(!(n>=4))break;var l=c.readUInt(1,3);if(!(n>=l+4))break;var h=[new t(1).writeUInt(22),new t(2).writeUInt(a),new t(2).writeUInt(l+4),c.slice(0,l+4)].concatBuffers();e.process(h),c=c.slice(l+4)}}e.stream_tor_=i;var u=e.queue_;u.shift(),u.length&&u[0]()},(A||Hs)&&(t=function(e,t){if(t||"string"!=typeof e||(t="utf8"),e instanceof Array||!isNaN(e)&&!t)return new Uint8Array(e);if("utf8"===t)return new dt("utf-8").encode(e);if("hex"===t)try{for(var r=new Uint8Array(e.length/2),i=e.length,n=0;i>n;n+=2)r[n/2]=parseInt(e[n]+e[n+1],16) +}catch(s){return new Uint8Array}if("binary"===t)for(var r=new Uint8Array(e.length),i=r.length,n=0;i>n;n++)r[n]=e.charCodeAt(n);return r},_s.isBuffer=function(e){return e instanceof this||e instanceof Uint8Array},Uint8Array.prototype.isBuffer=_s.prototype.isBuffer,Uint8Array.prototype.parse=_s.prototype.parse,Uint8Array.prototype.parseTLS=_s.prototype.parseTLS,t.isBuffer=function(e){return e instanceof Uint8Array},Uint8Array.prototype.slice=function(e,t){return t?this.subarray(e,t):this.subarray(e)},Uint8Array.prototype.map=function(e){var t=e.length;this.set(e),this.fill(0,t)},Uint8Array.prototype.readUInt=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16BE(e);case 3:return this.readUInt24BE(e);case 4:return this.readUInt32BE(e);default:return 0}},Uint8Array.prototype.readUIntLE=function(e,t){switch(e=e||0,t=t||this.length){case 1:return this[e];case 2:return this.readUInt16LE(e);case 4:return this.readUInt32LE(e);default:return 0}},Uint8Array.prototype.writeUInt=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16BE(e,t);break;case 3:this.writeUInt24BE(e,t);break;case 4:this.writeUInt32BE(e,t)}return this},Uint8Array.prototype.writeUIntLE=function(e,t,r){switch(t=t||0,r=r||this.length){case 1:this.writeUInt8(e,t);break;case 2:this.writeUInt16LE(e,t);break;case 4:this.writeUInt32LE(e,t)}return this},Uint8Array.prototype.fill=function(e,t){for(var r=this.length,i=t;r>i;i++)this[i]=e},Uint8Array.prototype.readUInt16BE=function(e){return this[e]<<8^this[e+1]},Uint8Array.prototype.readUInt24BE=function(e){return this[e]<<16^this[e+1]<<8^this[e+2]},Uint8Array.prototype.readUInt32BE=function(e){return this[e]<<24^this[e+1]<<16^this[e+2]<<8^this[e+3]},Uint8Array.prototype.readUInt16LE=function(e){return this[e]^this[e+1]<<8},Uint8Array.prototype.readUInt32LE=function(e){return this[e]^this[e+1]<<8^this[e+2]<<16^this[e+3]<<24},Uint8Array.prototype.writeUInt8=function(e,t){this[t]=e},Uint8Array.prototype.writeUInt16BE=function(e,t){this[t]=255&e>>8,this[t+1]=255&e},Uint8Array.prototype.writeUInt24BE=function(e,t){this[t]=255&e>>16,this[t+1]=255&e>>8,this[t+2]=255&e},Uint8Array.prototype.writeUInt32BE=function(e,t){this[t]=255&e>>24,this[t+1]=255&e>>16,this[t+2]=255&e>>8,this[t+3]=255&e},Uint8Array.prototype.writeUInt16LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8},Uint8Array.prototype.writeUInt32LE=function(e,t){this[t]=255&e,this[t+1]=255&e>>8,this[t+2]=255&e>>16,this[t+3]=255&e>>24},Uint8Array.prototype.toString=function(e){var t=this.length,r=[];if("utf8"===e)return new ft("utf-8").decode(this);if("hex"===e)for(var i=0;t>i;i++){var n=this[i].toString(16);r.push(1===n.length?"0"+n:n)}return"binary"===e?String.fromCharCode.apply(null,this):r.join("")},Ln=new t("00000000000000000000000000000000","hex"));var No=function(e){return sn.randomBytes(e)},Lo=function(e){for(var t=e.length,r=[],i=0;t>i;i++)r.push(e[i]);return r.join(".")},Oo=function(e){return new t(e.split("."))},Po=function(e,r,i,n){this.CircID=new t(2).writeUInt(e),this.Command=new t(1).writeUInt(r),this.Length=new t(2).writeUInt(i.length),this.Payload=n?zo.bind(this)(i):i};Po.prototype={PADDING:0,CREATE:1,CREATED:2,RELAY:3,DESTROY:4,CREATE_FAST:5,CREATED_FAST:6,NETINFO:8,RELAY_EARLY:9,VERSIONS:7,CREATE_FAST_WS:120,CREATED_FAST_WS:121,VPADDING:128,CERTS:129,AUTH_CHALLENGE:130,AUTHENTICATE:131,AUTHORIZE:132,RELAY_WS:190,versions_cell_decode:function(e){for(var t=[];e.length;)t.push(e.slice(0,2)),e=e.slice(2);return t},certs_cell_decode:function(e){var t=e.slice(0,1);e=e.slice(1);var r=[];for(r.push(t);e.length;){var i={};i.CertType=e.slice(0,1),i.CLEN=e.slice(1,3);var n=i.CLEN.readUInt();i.Certificate=e.slice(3,3+n),e=e.slice(3+n),r.push(i)}return r},auth_challenge_cell_decode:function(e){var t=[],r={};return r.Challenge=e.slice(0,32),r.N_Methods=e.slice(32,34),r.Methods=e.slice(34,34+r.N_Methods.readUInt()),t.push(r),t},netinfo_cell_decode:function(e){var t=[],r={};r.Timestamp=e.slice(0,4);var i=po(e.slice(4));e=i.data,r.other_OR=i.addr,r.nb_addresses=e.slice(0,1),r.this_ORs=[],e=e.slice(1);for(var n=r.nb_addresses.readUInt(),s=0;n>s;s++){var a=po(e);r.this_ORs.push(a.addr),e=a.data}return t.push(r),t},create_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),t.push(r),t},create_fast_ws_cell_decode:function(e){var r=[],i={},n=new un;try{i.key_material=new t(n.decrypt(Xs,e.slice(0,128).toString("hex"),"","hex"),"hex"),r.push(i)}catch(s){console.log("create fast pb decrypting")}return r},created_fast_cell_decode:function(e){var t=[],r={};return r.key_material=e.slice(0,20),r.derivative_key_data=e.slice(20,40),t.push(r),t},created_fast_ws_cell_decode:function(e){var t=[],r={};return r.key=e.slice(0,40),t.push(r),t},create_cell_decode:function(e){var t=[],r={};return r.M_=e.slice(0,128),r.M2_=e.slice(128,186),t.push(r),t},created_cell_decode:function(e){var t=[],r={};return r.dh_data=e.slice(0,128),r.derivative_key_data=e.slice(128,148),t.push(r),t}};var Fo=function(e){e&&(this.OP_=!0,this.server_=e[0],this.path_=e,this.nb_=0,this.conn_=0,this.sent_=0,this.received_=0,this.circuit_window=cs,this.circuit_window_s=cs,this.stream_=[],this.pause_={},this.time_=(new Date).valueOf(),this.resolved_failed=0),this.perf_=0,this.time_average=0};Fo.prototype={padding_cell_handle:function(){this.next_&&this.next_.keep_alive()},versions_cell_handle:function(e){var r=this.socket_;if(!this.OR_||this.onion_)e.Payload.forEach(function(e){3==e.readUInt()&&(r.handshake_=3)},this),r.handshake_||this.end("v3 handshake not supported","handshake");else{var e=new Po(this.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));if(this.send(e),!r.ws_){var i={};i.CertType=new t(1).writeUInt(1),i.Certificate=new t(al(o+"pub-key.pem",o+"priv-id-key.pem","der",r.certid_,r.cert_date,r.cert_subject,r.cert_issuer),"hex"),i.CLEN=new t(2).writeUInt(i.Certificate.length),i=[i.CertType,i.CLEN,i.Certificate].concatBuffers();var n={};n.CertType=new t(1).writeUInt(2),n.Certificate=new t(al(o+"pub-id-key.pem",o+"priv-id-key.pem","der",parseInt(No(8).toString("hex"),16),r.cert_date,r.cert_issuer,r.cert_issuer),"hex"),n.CLEN=new t(2).writeUInt(n.Certificate.length),n=[n.CertType,n.CLEN,n.Certificate].concatBuffers(),e=new Po(this.circId,Po.prototype.CERTS,[new t(1).writeUInt(2),i,n].concatBuffers()),this.send(e);var s={};s.Challenge=No(32),s.N_Methods=new t(2).writeUInt(1),s.Methods=new t(2).writeUInt(0),e=new Po(this.circId,Po.prototype.AUTH_CHALLENGE,[s.Challenge,s.N_Methods,s.Methods].concatBuffers()),this.send(e)}var a=[],c={};c.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),c.other_OR={type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.remoteAddress)},c.nb_addresses=new t("01","hex"),c.this_ORs=[{type:new t("04","hex"),length:new t("04","hex"),value:Oo(r.address().address)}],a.push(c),e=new Po(this.circId,Po.prototype.NETINFO,a),this.send(e)}},certs_cell_handle:function(){},auth_challenge_cell_handle:function(){},netinfo_cell_handle:function(e){var r={};if(!this.OR_f){var i=this.socket_.remoteAddress;if(e.Length=0,r.Timestamp=new t(4).writeUInt(parseInt((new Date).valueOf()/1e3)),e.Length+=4,e.Payload[0].this_ORs.forEach(function(t){(Lo(t.value)==i||this)&&(r.other_OR=t,e.Length+=t.length,this._OR_ip_verified=!0)},this),this._OR_ip_verified)if(r.nb_addresses=new t(1).writeUInt(1),e.Length++,r.this_ORs=[e.Payload[0].other_OR],e.Length+=r.this_ORs[0].length,e.Payload=[r],this.send(e),this.socket_.handshake=!0,this.OP_)if(this.setCircId(),!zs&&!js||!ks&&!Us||Cs&&!Js)this.create();else if(A&&Zi&&(!Cs&&$i||!Js)){this.X_=No(20);var n=new t(vl.encrypt(this.X_.toString("hex")),"hex"),s=new Po(this.circId,Po.prototype.CREATE_FAST_WS,n);this.send(s)}else{this.X_=No(20);var s=new Po(this.circId,Po.prototype.CREATE_FAST,this.X_);this.send(s)}else this.setCircId(),this.create();else this.end("remote IP does not match","handshake")}},create_fast_cell_handle:function(e){console.log("OR receive create fast from "+this.socket_.remoteAddress+" CIC "+this.circId+" sending created_fast"),this.X_=e.Payload[0].key_material,this.Y_=No(20);var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t),i=new Po(this.circId,Po.prototype.CREATED_FAST,[this.Y_,r].concatBuffers());this.send(i)},create_fast_ws_cell_handle:function(e){if(e.Payload.length){this.X_=e.Payload[0].key_material,this.Y_=No(20);var r=[this.X_,this.Y_].concatBuffers(),i=this.circuit_keys(r),n=new Po(this.circId,Po.prototype.CREATED_FAST_WS,new t(Eo([this.Y_,i].concatBuffers(),this.X_.slice(0,16)),"hex"));this.send(n)}else this.destroy(1)},created_handle:function(){if(this.conn_++,(zs||js)&&(ks||Us)&&!Cs&&$i&&this.request_.params_.ws===Cl&&delete this.next_,this.next_)this.extended_=this.next_,this.extend();else if((zs||js)&&(ks||Us)){if(console.log("CIRC : CIRCUIT ESTABLISHED FAST - CID "+this.circId+" "+(this.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(this.prev_?this.prev_.server_.ip:"NONE")+" LAST OR : "+this.server_.ip),Cs=this,ks)for(var e in bs)bs[e].associated||El.associate(this.first_,e);!es&&Zi&&(ks?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):El.db_cid_launched||rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})),this.first_.last_=this}else console.log("CIRC : CAN NOT HAVE ONLY ONE NODE IN THE PATH"),this.end("CAN NOT HAVE ONLY ONE NODE IN THE PATH")},created_fast_cell_handle:function(e){console.log("created fast received CIC "+this.circId),this.Y_=e.Payload[0].key_material;var t=[this.X_,this.Y_].concatBuffers(),r=this.circuit_keys(t);r.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},created_fast_ws_cell_handle:function(e){var r=new t(Eo(e.Payload[0].key,this.X_.slice(0,16)),"hex");this.Y_=r.slice(0,20);var i=[this.X_,this.Y_].concatBuffers(),n=this.circuit_keys(i);n.toString("hex")!=r.slice(20,40).toString("hex")?this.end("KH key does not match","fast_key"):this.created_handle()},create_cell_handle:function(e){var r=e.Payload[0].M_,i=e.Payload[0].M2_;this.X_=So(this.socket_.privkey_.toString("utf-8"),r.toString("hex"),i);var n=sn.getDiffieHellman("modp2");n.generateKeys(),this.Y_=new t(n.getPublicKey("hex"),"hex");var s=new t(n.computeSecret(this.X_,"hex","hex"),"hex"),a=this.circuit_keys(s),o=new Po(this.circId,Po.prototype.CREATED,[this.Y_,a].concatBuffers());this.send(o)},created_cell_handle:function(e){if(this.OP_){console.log("OP created "+this.circId);var r=this.extended_?this.extended_:this;if(r.Y_=e.Payload[0].dh_data,A&&!r.DH_.computeSecret){var i=new t(1).writeUInt(2);vn[r.cid_hex]=function(t){var r=this.extended_?this.extended_:this,i=t.toString("hex");r.DH_.computeSecret=function(){return i},delete vn[r.cid_hex],this.created_cell_handle(e)}.bind(this);var n=new qo(qo.prototype.RELAY_INFO,0,[i,new t(r.cid_hex,"hex"),r.Y_].concatBuffers(),Cs.Df_hash),s=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(n));return Cs.send(s),void 0}var a=new t(r.DH_.computeSecret(r.Y_,"hex","hex"),"hex"),o=r.circuit_keys(a);if(o.toString("hex")!=e.Payload[0].derivative_key_data.toString("hex"))r.end("KH key does not match","created_extended_key");else if(this.conn_++,r.ok_=!0,r.next_)r.extended_=r.next_,r.extend();else{if(zs&&ks)for(var c in bs)bs[c].associated||El.associate(this.first_,c);Us&&this.first_.request_.params_.db&&!Ss?(Ss=this.first_,Ss.send_db_info(),Ss.process=Ss.send_db_query,setInterval(this.send_db_info.bind(Ss),As),r?console.log("CIRC : CIRCUIT ESTABLISHED -CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined")):this.first_.request_.params_.db?(console.log("created handle circuit destroy"),this.first_.circuit_destroy()):(r?console.log("CIRC : CIRCUIT ESTABLISHED - CID "+r.circId+" "+(r.socket_.ws_?"WS":"")+" FIRST OR :"+this.first_.server_.ip+" MIDDLE OR :"+(r.prev_?r.prev_.server_.ip:"NONE")+" LAST OR : UNDISCLOSED"):console.log("OP created lcirc is undefined"),Qn++),$n>Qn&&Zi&&(js||zs?ks||Ss?(console.log("create new dl circuit"),rc({params_:{OP:!0,nb_hop:Hn,ws:El}})):rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}):rc({params_:{OP:!0,nb_hop:Hn}})),this.first_.last_=r,this.first_.process();var l=mn;if(l)for(;l.length;)this.first_.process(l[0]),l.shift()}}else if(this.prev_){console.log("OR process extend - created received from "+this.server_.ip+" sending relay_extended to CIC "+(this.prev_?this.prev_.circId:"undefined"));var h=e.Payload[0],n=new qo(qo.prototype.RELAY_EXTENDED,0,[h.dh_data,h.derivative_key_data].concatBuffers(),this.prev_.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY_EARLY,!0)}else this.next_.destroy()},extend_cell_handle:function(e){if(ka&&this.socket_.address().port===kn&&this.OR_f)console.log("ORDB - Do not extend send destroy"),this.circuit_destroy();else{var r=Lo(e.slice(0,4)),i=e.slice(4,6).readUInt(),n=e.slice(6,192),s=e.slice(192,212).toString("hex"),a=new Fo;if(a.server_={ip:r,port:i,fing:s},console.log("OR process extend toward "+a.server_.ip+" "+a.server_.port+" "+a.server_.fing),this.next_=a,a.prev_=this,a.onion_=n,a.OR_=!0,a.way_="socket out",a.circId=0,bn[r])a.socket_=bn[r],a.socket_.stream_tor_=new t(0),a.setCircId(),a.create(),console.log("OUTGOING OR SOCKET EXTEND : ---------Socket already exists send create ------------ CIC "+a.circId+" for "+a.server_.ip);else{var c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",l="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",h={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,c,l),servername:c,rejectUnauthorized:!1};console.log("OUTGOING OR SOCKET EXTEND : ---------OR starts client socket with------------"+h.servername+" "+a.server_.ip+" "+a.server_.port);var u=tn.connect(a.server_.port,a.server_.ip,h,function(){bn[a.server_.ip]=this,console.log("OR process extend sending versions"),a.socket_=this,this.OR_=!0,this.way_="socket out",this[a.circId]=a,this.stream_tor_=new t(0);var e=new Po(a.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));a.send(e)});u.on("data",Qo),u.circuits_destroy=function(){for(var e in wn)Object.keys(wn[e]).forEach(function(t){if(!isNaN(t)&&null!=t&&"function"!=typeof t){var r=wn[e][t];r&&r.socket_&&r.socket_.remoteAddress&&r.next_&&r.next_.socket_===u&&(console.log("destroy circ in CIC "+r.circId+" "+r.socket_.remoteAddress),r.circuit_destroy())}})},u.on("end",function(){console.log("or_tls_socket end"),delete bn[r],u.circuits_destroy()}),u.on("close",function(){console.log("or_tls_socket close"),delete bn[r],u.circuits_destroy()}),u.on("error",function(){console.log("or_tls_socket error"),delete bn[r],u.circuits_destroy()})}}},handle_destroy:function(e){if(this.OP_){var t=this.first_||this;console.log("OP receive destroy CIC "+t.circId+(t===Ss?" ------- DB_CID destroyed --------------- ":"")),t.destroyed_=!0,this.clear_timers(),t.circuit_destroy(!0)}else{console.log("OR "+(this.OR_f?"in":"out")+" received destroy from "+this.socket_.remoteAddress+" on CID "+this.circId);var t=this.prev_||this.next_;t?(console.log("OR "+(this.OR_f?"in":"out")+" send destroy to "+(t.socket_?t.socket_.remoteAddress:"")+" on CID "+t.circId),e=e.toString(),e=1===e.length?"0"+e:e,t.circuit_destroy(),this.circuit_destroy(!0)):this.circuit_destroy()}},relay_cell_handle:function(e,t){var r=e.Payload[0],i=e.Command.readUInt();this.OP_?this.stream_decrypt_backward(r,t):this.prev_?this.stream_encrypt_or_b(r,i):this.stream_decrypt_or_f(r,i)},relay_send_truncate:function(e){var r=new qo(qo.prototype.RELAY_TRUNCATE,0,new t(1).writeUInt(e),this.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(r));this.send(i)},relay_end_handle:function(e,r){var i=this.first_,n=i[e],s=function(){n.download_&&(Oh('

    An unexpected event occured(error '+r+"), please retry

    "),lh(n.bar_)),n._write_(new t(oo(),"utf8")),n.end()};if(n&&(n.abstract_client_tls&&n.abstract_client_tls.close(),delete n.abstract_client_tls,!n.destroyed))if(-1===[6,12].indexOf(r))Us||(console.log(n.nb_try),n.nb_tryZn||0===i.sent_)&&(i.bad_=!0),i.destroy_cid(n),i.request_retry(n,r)):s());else if(n._data_)if(12===parseInt(r))if(console.log("END : CONNRESET RETRY "+r+" CID "+this.first_.circId+" on port "+n.remotePort+" for request "+n.i_id),n.download_)if(n.url_){var a=function(){n.queue_.shift(),Oh('

    Remote server closed the connection (error '+r+"), download could not be completed, resuming...

    "),setTimeout(function(){Wa("alert_box").style.display="none"},1e4);var s=function(r){var n=ho(r.url_);r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.params_.stream=vo(n.host,n.rest,length),r.queue_=[],r.queue_s=[],delete r.eof_,delete i[e],delete r.cid_,delete r.check_hash,delete r.file_id,delete r.start_t0,r.received_=0,rc(r)};ah(n,!0,s)};n.queue_.push(a),1===n.queue_.length&&n.queue_[0]()}else $a(document.body,"mousedown",function(){},!1),Oh('

    Remote server closed the connection (error '+r+"), download could not be completed, please use Resume to resume the download.

    "),n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]());else i.perf_--,i.destroy_cid(n),n.destroy();else n.bufferSize||(ks&&n.abstract_client_tls?n.done_=!0:n.download_?n.eof_||(n.eof_=!0,n.queue_.push(fin_.bind(n)),1===n.queue_.length&&n.queue_[0]()):(i.destroy_cid(n),n.end()));else n.nb_try++,i.perf_--,i.destroy_cid(n),i.request_retry(n,r)},request_retry:function(e,t){console.log("Retry for request "+e.i_id),ks?e.relay_ws_handle(e.ini_data,!0):rc(e,this,"end "+t)},relay_truncated_handle:function(e){console.log("STREAM : Truncated received from "+this.server_.ip+" CIRC "+this.circId+" "+e);var t=this.first_;switch(e){case 8:this.handle_destroy(0);break;case 11:this.handle_destroy(0);break;default:var r=t.last_?t.last_.ok_:null;r||this.next_.change_or("- relay truncated",this.extend)}},relay_truncate_handle:function(e){console.log("truncate "+this.circId);var r=this.next_,i=new Po(r.circId,Po.prototype.DESTROY,new t("05","hex"));r.send(i);var n=new qo(qo.prototype.RELAY_TRUNCATED,0,new t(1).writeUInt(e),this.Db_hash);this.stream_encrypt_or_b(n.toBuffer(),Po.prototype.RELAY,!0)},stream_handle:function(e){switch(e.command.readUInt()){case e.RELAY_EXTEND:this.extend_cell_handle(e.data);break;case e.RELAY_TRUNCATE:this.end("Error OR receive truncate :"+e.data.slice(0,1).readUInt(),"truncate");break;case e.RELAY_EXTENDED:this.created_cell_handle(new Po(this.circId,Po.prototype.CREATED,e.data,!0));break;case e.RELAY_TRUNCATED:this.end("Error OP receive truncated :"+e.data.slice(0,1).readUInt(),"truncated");break;case e.RELAY_END:this.end("End :"+e.data.slice(0,1).readUInt(),"relay_end",e.streamId.readUInt());break;case e.RELAY_CONNECTED:this.stream_decode_connected(e),this.stream_handle_connected(e.streamId.readUInt());break;case e.RELAY_DATA:this.stream_handle_data(e);break;case e.RELAY_SENDME:Oi("RECEIVING SENDME CIC "+this.circId+" for stream "+e.streamId.readUInt()),this.stream_handle_sendme(e.streamId.readUInt());break;case e.RELAY_ASSOCIATE:this.associate(e.data.slice(0,e.length.readUInt()).toString("utf8"));break;case e.RELAY_INFO:this.info(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_WS:this.relay_ws_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_INFO:this.relay_db_info_handle(e.data.slice(0,e.length.readUInt()));break;case e.RELAY_DB_QUERY:this.relay_db_query_handle(e);break;case e.RELAY_DB_CONNECTED:this.relay_db_connected_handle(e);break;case e.RELAY_DB_END:this.relay_db_end_handle(e);break;case e.RELAY_DB_DATA:this.relay_db_data_handle(e);break;case e.RELAY_DB_SENDME:this.relay_db_sendme_handle(e)}},stream_decode_connected:function(){},stream_handle_sendme:function(e){var t=this.first_,r=t.stream_;Oi("FLUSH BUFFER CIC "+t.circId+" sid "+(e||" whole circuit ")+" buffer length "+r.length);var i=Math.min(e?us:ls,r.length),n=0;for(e?t[e].stream_window_s+=us:t.circuit_window_s+=ls;i>n;){var s=e?r[n]:r[0];e?e===s[1]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),s[0]=null,n++):(s[0]&&(setTimeout(function(){t.send(s[0])},parseInt(1+1e3/(Ra/Da))),n++),r.shift())}},stream_handle_connected:function(e,r){var i=this.first_,n=i[e];if(n)if(Us&&clearTimeout(n.socket_retry),this.clear_timers(),console.log("STREAM RELAY :--------------RELAY_CONNECTED TO---------------------- "+this.server_.ip+" VIA "+this.first_.server_.ip+" CID "+this.circId+" Stream "+e+" for request "+n.i_id),n.params_.stream){for(var s=n.params_.stream;s.length;){if(n.tls_client_connected||!n.abstract_client_tls,r)var a=new qo(qo.prototype.RELAY_DB_DATA,e,[new t(r,"hex"),s.slice(0,Math.min(s.length,pn-16))].concatBuffers(),this.Df_hash);else var a=new qo(qo.prototype.RELAY_DATA,e,s.slice(0,Math.min(s.length,pn)),this.Df_hash);var o=new Po(this.circId,Po.prototype.RELAY,this.stream_encrypt_forward(a));if(n.sent_++,i.resolved_failed=0,i.sent_++,i.time_=Date.now(),n.start_t0=i.time_,n.stream_window_s--,i.circuit_window_s--,0===n.stream_window_s||0===i.circuit_window_s?(console.log("Bufferizing CIC "+i.circId+" for request "+n.i_id),i.stream_.push[e]):this.send(o),!(s.length>pn))break;s=s.slice(pn)}n.squeue_&&(n.squeue_.shift(),n.squeue_.length&&n.squeue_[0]())}else sc(n)},stream_handle_data:function(e,r,i){var n=this.first_;if(n){var s=e.streamId.readUInt(),a=i||n[s];if(a){r||a.time_resp||(a.time_resp=Date.now(),n.time_average=(n.time_average+(a.time_resp-a.time_ini))/(n.time_average?2:1)),r?(console.log("STREAM RELAY : --------------RECEIVE DECODED TLS DATA FROM---------------------- "+this.server_.ip+" CID "+this.circId+" Stream "+s+" for request "+a.i_id+" length "+e.length.readUInt()),e.data.slice(0,e.length.readUInt())):a.tls_client_connected||!a.abstract_client_tls;var o=e.data.slice(0,e.length.readUInt());if(r)a.received_++;else{if(!a._data_||a.wait_header){var c;if(a._data_=!0,a.download_){if(o=a.wait_header?[a.wait_header,o].concatBuffers():o,c=ic(o.toString("utf8")),"undefined"==typeof c["1a"]||""!==c["1a"])return a.wait_header=o,void 0;delete a.wait_header;var l=c["0a"].split(" ");if(l=l[1]?l[1]:null){if(Oi("STREAM : status code "+l+" for request "+a.i_id),l=l.toString(),-1===["2","3"].indexOf(l[0]))return Oh('

    Wrong URL, please check and try again

    '),lh(a.bar_),n.send_relay_end(a.sid_),void 0;if("3"===l[0]){if(c.Location){var h=ho(c.Location);a.params_.stream=yo(h.host,h.rest),n.send_relay_end(a.sid_),delete n[a.sid_],delete a.cid_,rc(a)}return}if(a.d_length=a.d_length||0,a.content_=c["Content-Type"]?c["Content-Type"]:"application/octet-binary",c["Content-Length"]&&!a.clength_&&(a.clength_=parseInt(c["Content-Length"])),!a.clength_)for(var u in c)if(-1!==u.toLowerCase().indexOf("content-length")){a.clength_=parseInt(c[u]);break}a.pieces=Math.ceil(a.clength_/Da),c["Transfer-Encoding"]&&(a.encoding_=c["Transfer-Encoding"]),console.log("Start relay_data"),console.log(a.content_),console.log(a.clength_),console.log(a.encoding_?a.encoding_:"No encoding"),a._stream_&&fh(a),o=o.toString("hex").split(gs+gs),o.shift(),o=new t(o.join(gs+gs),"hex")}}}a._data_=!0,a.received_++,n.received_++,n.circuit_window--,a.stream_window--,a.resp__=a.resp__?a.resp__+o.length:o.length,0===n.received_%ls&&n.circuit_window1))return a.header_=o,void 0;a.header_=[a.header_?a.header_:new t(0),new t(f[0]+gs+gs,"hex")].concatBuffers(),a.header_l=a.header_.length}if(a.header_l){if(f.shift(),"chunked"!==a.encoding_){var c=ic(a.header_.toString("utf8"));c["Content-Length"]&&(a.clength_=parseInt(c["Content-Length"]),a.content_l=!0)}else f=f.join(gs+gs).split(gs),a.header_l=a.header_.length,a.clength_=f.length>1?parseInt(new t(f[0],"hex").toString("utf8"),16):0,f.shift(),a.pass_="",a.buff_="";o=new t(f.join(gs),"hex")}}if("chunked"===a.encoding_){if(a.html_.length+o.length>=a.clength_||a.wait_)var p=cc(o.toString("hex"),a);t.isBuffer(a.html_)?a.html_={length:parseInt((p?p:o).length)}:a.html_.length+=p?0:parseInt(o.length)}else a.html_=[a.html_,o].concatBuffers()}}try{}catch(_){}r||n.perf_++,a.nb_try=0;var f=a.html_?a.content_l&&a.clength_===a.html_.length||"chunked"===a.encoding_?!1:!0:!1;if(!f){if("chunked"!==a.encoding_&&(a.socks_s=!1),a.html_){var g=a.content_l?a.html_.toString("utf8"):a.decoder_.decode(p?p:o,{stream:!0});if(!a.content_l){if(a.buff_+=g,a.buff_.length=128)&&i.push(e.Length);var s=function(e){if(e.push)e.forEach(function(e){t.isBuffer(e)?i.push(e):s(e)});else for(var r in e)t.isBuffer(e[r])?i.push(e[r]):s(e[r])};if(e.Payload.push?e.Payload.forEach(function(e){s(e)}):i.push(e.Payload),i=i.concatBuffers(),7!==e.Command.readUInt()&&e.Command.readUInt()<128){var a=new t(512);a.map(i),i=a}if(this.OP_&&!r.last_){var o;this.clear_timers();var c;this===r?this.socket_?this.socket_.handshake_?(o=function(){console.log("CIRC : Create or first extend too long "+this.circId),this.circuit_retry()},c=Vn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){this.change_or("Handshake version no answer or bad answer - change OR")},c=Kn):(o=function(){console.log("CIRC : Extend delay expired - change or "+this.server_.ip),this.change_or("- extend too long",this.extend)},c=Gn)}if(yh&&_h&&(chart1_int||chart2_int)&&parseInt(n)!==Po.prototype.PADDING){var l=go(new Date).getTime(),h=i.length;r===Ss?chart2_int&&(yh.dynRow2[l]=yh.dynRow2[l]?yh.dynRow2[l]+h:h):chart1_int&&(_h.dynRow2[l]=_h.dynRow2[l]?_h.dynRow2[l]+h:h)}if(this.OP_||this.OR_)try{if(this.OR_&&6===e.Command.readUInt()&&console.log("sending FAST to "+(this.server_?this.server_.ip:"OP")+" CIC "+e.CircID.readUInt()),this.socket_.ws_)if(this.OP_){if(A&&!I||T)var a=i;else var a=Ac(i,2,!0);this.socket_.write(a)}else this.socket_.write(Ac(i,2,!1));else this.socket_.write(i)}catch(u){if(console.log("OUTGOING SOCKET "+(this.OP_?"OP ":"OR ")+(this.socket_?this.socket_.ws_?"WS":"TLS":"")+" IP "+(this.server_?this.server_.ip:"")+" socket does not exist any longer"),this.OP_)this.socket_?T||this.socket_.destroy():(console.log("send1 circuit destroy"),this.circuit_destroy(!0));else if(!this.OR_f){var d=this.socket_;console.log("send2 circuit destroy"),this.circuit_destroy(!0),d&&d.circuits_destroy()}}else d.write(e)},navigate:function(e){var t=ho(e._host_);t.host="www."+fo(t.host,!0)+ms,Es=t.host,protocol=t.protocol,El.associate(Cs,t.host),console.log("send 301 and associate fake_d "+t.host+" location "+uo(t)),this.redirect(e,uo(t))},redirect:function(e,r){console.log("redirect send 301 for url "+r),Ds?(alert(lo(r)),e.__write__(new t(lo(r),"utf8"))):e._write_(new t(lo(r),"utf8")),e.destroy(),this.destroy_cid(e,!0),delete e._host_},send_db_info:function(e){e=e||null;var r=function(e){if(e.file_length===e.current_length&&Ss){console.log("send_db_info"),console.log(e.name_hash);var r=new t(e.name_hash,"hex"),i=new t(1).writeUInt(r.length),n=new t(1).writeUInt(0),s=T?new t(1).writeUInt(1):new t(0),a=[i,r,n,s].concatBuffers(),o=new qo(qo.prototype.RELAY_DB_INFO,0,a,Ss.last_.Df_hash),c=new Po(Ss.circId,Po.prototype.RELAY,Ss.last_.stream_encrypt_forward(o));Ss.send(c)}};Ha.list(r,e)},send_db_query:function(e,r){if(e){console.log("send_db_query");var i,n=e.params_?e.params_.hash_:e.hash_,s=e.d_length.toString(16);s=s.length%2?"0"+s:s,s=new t(s,"hex"),size_l=new t(1).writeUInt(s.length),console.log("send_db_query hash "+n.toString("hex")+" "+size_l[0]+" "+s.toString("hex")+" tid "+(r?r.toString("hex"):""));var a=[new t(1).writeUInt(n.length),n,size_l,s].concatBuffers();if(r)a=[a,r].concatBuffers(),i=0;else{if(i=bo(this),e.cid_=this,!i)return;this[i]=e,e.sid_=i,e.received_=0,e.sent_=0}if(this.OP_){console.log("OP send db_query CID "+this.circId+" sid "+i);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));e.query_time=Date.now(),this.send(c);var l=function(){this.socket_&&(e._torrentc_||(console.log("serving party not responding"),e.db_try++,this.send_db_end(1,i),delete e.sid_,this.send_db_query(e)))}.bind(this);e.db_tryNo answer from the network, changing peer to peer circuits, please wait and retry

    '),lh(e.bar_),console.log("db_query no answer circuit destroy"),Ss.circuit_destroy(),Ss=null)}else{this.prev_=this,this.nb_query=this.nb_query||0,this.nb_query++,console.log("ORDB send db_query CID "+this.prev_.circId+" sid "+i+" "+this.prev_.socket_.remoteAddress);var o=new qo(qo.prototype.RELAY_DB_QUERY,i,a,this.prev_.Db_hash);this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}}},send_db_end:function(e,r,i){r=r||0,console.log("send db_end CID "+this.circId+" sid "+r+" reason "+e+" "+("undefined"!=typeof i?i.toString("hex"):""));var n=new t(1).writeUInt(e);if(n=i?[n,i].concatBuffers():n,this.OP_){var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.last_.Df_hash),a=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(s));this.send(a)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_END,r,n,this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_connected:function(e,r,i,n){e=e.toString(16),e=e.length%2?"0"+e:e,e=new t(e,"hex"),size_l=new t(1).writeUInt(e.length),i=new t(i,"utf8");var s=new t(2).writeUInt(i.length);console.log("send db_connected "+e.toString("hex")+" CID "+this.circId+" sid "+r+" type "+i.toString("utf8"));var a=[size_l,e,s,i].concatBuffers();if(n&&(a=[n,a].concatBuffers()),this.OP_){var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.last_.Df_hash),c=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(o));this.send(c)}else{this.prev_=this;var o=new qo(qo.prototype.RELAY_DB_CONNECTED,r,a,this.prev_.Db_hash); +this.stream_encrypt_or_b(o.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_data:function(e,t,r,i){if(this.OP_){var n=this[t];i||(n.fc_t=[],console.log("sending db data "+(this.OP_?"OP ":"ORDB sid ")+t+" BANDWIDTH "+8*Ra+" bps "+(this.OP_?" 512 bytes every "+(1+1e3/(Ra/Da))+" ms then nbblocks "+Math.ceil(Na*Ra/1e3/Da)+" every "+Na+"ms window size "+n.stream_window_s+" "+this.circuit_window_s:"")+" cd "+e.size),n.start_t0=Date.now(),n.cd_length=e.size,n.messageName="flush",T||$a(window,"message",Ao.bind(n),!0),n.reader=T?new Va:new FileReader,n.cursor=0),Io.call(this,e,t,n,r)}else{this.prev_=this;var s=new qo(qo.prototype.RELAY_DB_DATA,t,e.slice(0,Math.min(e.length,pn)),this.prev_.Db_hash);this.stream_encrypt_or_b(s.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},send_db_sendme:function(e){if(e=e||0,this.OP_){var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)}else{this.prev_=this;var r=new qo(qo.prototype.RELAY_DB_SENDME,e,new t(0),this.prev_.Db_hash);this.stream_encrypt_or_b(r.toBuffer(),Po.prototype.RELAY,!0),delete this.prev_}},circuit_keys:function(e){var t=wo(e.toString("hex")),r=t.slice(0,20);return this.Df_=t.slice(20,40),this.Db_=t.slice(40,60),this.Kf_=t.slice(60,76),this.Kb_=t.slice(76,92),this.Kf_cipher=sn.createcipheriv("aes-128-ctr",this.Kf_,Ln),this.Kb_cipher=sn.createcipheriv("aes-128-ctr",this.Kb_,Ln),this.Df_hash=new fn("sha1"),this.Db_hash=new fn("sha1"),this.Df_hash.update(this.Df_),this.Db_hash.update(this.Db_),r},stream_encrypt_forward:function(e){for(var r=this,i=e.toBuffer();r;)i=new t(r.Kf_cipher.update(i,"hex","hex"),"hex"),r=r.prev_;return i},stream_decrypt_backward:function(e,r){var i,n=this;if(w)var s=Date.now();for(var a=e.length;n&&!(n.Kb_&&(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),i=n.recognized(e)));)n=n.extended_;if(s&&(ga++,ma+=a,ya+=Date.now()-s,0===ga%va&&ya&&(console.log("CRYPTO perf decrypt backward: "+parseInt(8*ma/(ya/1e3))+" bps"),ga=0,ma=0,ya=0)),i&&41===i.command.readUInt(),i)if(r){var o=new qo(qo.prototype.RELAY_END,i.streamId,new t("0A","hex"),n.Df_hash),c=new Po(n.circId,Po.prototype.RELAY,n.stream_encrypt_forward(o));n.send(c)}else n.stream_handle(i);else this.end("Unrecognized stream","unrecognized"),console.log(e.toString("hex"))},stream_decrypt_or_f:function(e,r,i){if(this.Kf_cipher){if(e=new t(this.Kf_cipher.update(e,"hex","hex"),"hex"),!i)var n=this.recognized(e);if(n)this.stream_handle(n);else if(Rs&&this.socket_.fake_cid===this);else if(this.next_){var s=new Po(this.next_.circId,r,e);this.next_.send(s)}}},stream_encrypt_or_b:function(e,r,i){var n=this.prev_;if(n&&n.Kb_cipher){if(e=new t(n.Kb_cipher.update(e,"hex","hex"),"hex"),!i)var s=n.recognized(e);if(s)this.stream_handle(s);else if(n){var a=new Po(n.circId,r,e);n.send(a)}}},recognized:function(e){if(0==e.slice(1,3).readUInt()){var r=e.slice(9,11),i=Math.min(11+r.readUInt(),e.length),n=new qo(e.slice(0,1).readUInt(),e.slice(3,5).readUInt(),e.slice(11,i));n.length=r;var s=e.slice(5,9);if(this.OR_f){this.Df_hash.update(n.toBuffer());var a=new t(this.Df_hash.digest("hex"),"hex").slice(0,4)}else{this.Db_hash.update(n.toBuffer());var a=new t(this.Db_hash.digest("hex"),"hex").slice(0,4)}if(a.toString("hex")==s.toString("hex"))return n}},extend:function(){var e=this.extended_,r=Oo(e.server_.ip),i=new t(2).writeUInt(parseInt(e.server_.port)),n=new t(e.server_.fing,"hex");if(!A||sn.getDiffieHellman){var s=sn.getDiffieHellman("modp2");s.generateKeys(),e.DH_=s,e.X_=new t(s.getPublicKey("hex"),"hex");var a=function(){var s=Co(new t(e.server_.o_modulus,"hex"),e.X_),a=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,s,n].concatBuffers(),this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(a));this.send(o)};e.server_.o_modulus?a.call(this):e.get_certs(a)}else{var a=function(t){var s=t.slice(0,2).readUInt();e.X_=t.slice(2,2+s),e.DH_={};var a=t.slice(2+s),o=new qo(qo.prototype.RELAY_EXTEND,0,[r,i,a,n].concatBuffers(),this.Df_hash),c=new Po(this.circId,Po.prototype.RELAY_EARLY,this.stream_encrypt_forward(o));delete vn[e.cid_hex],this.send(c)}.bind(this);e.create_extend_info(a)}},create:function(){if(this.onion_){var e=new Po(this.circId,Po.prototype.CREATE,this.onion_);this.send(e)}else if(A){var r=function(e){var t=e.slice(0,2).readUInt();this.X_=e.slice(2,2+t);var r=e.slice(2+t),i=new Po(this.circId,Po.prototype.CREATE,r);delete vn[this.cid_hex],this.send(i)}.bind(this);this.DH_={},this.create_extend_info(r)}else{var i=sn.getDiffieHellman("modp2");i.generateKeys(),this.DH_=i,this.X_=new t(i.getPublicKey("hex"),"hex");var r=function(){var e=Co(new t(this.server_.o_modulus,"hex"),this.X_),r=new Po(this.circId,Po.prototype.CREATE,e);this.send(r)};this.server_.o_modulus?r.call(this):this.get_certs(r)}},create_extend_info:function(e){var r=new t(1).writeUInt(1),i=No(16),n=i.toString("hex");this.cid_hex=n;var s=new t(this.server_.o_modulus,"hex");vn[n]=e;var a=new qo(qo.prototype.RELAY_INFO,0,[r,i,s].concatBuffers(),Cs.Df_hash),o=new Po(Cs.circId,Po.prototype.RELAY_WS,Cs.stream_encrypt_forward(a));Cs.send(o)},destroy:function(){console.log("CIRC : -------------------------- SEND DESTROY ------------------- "+(this.server_?this.server_.ip:this.socket_.remoteAddress)+(this.OP_?" OP":" OR")+" CID "+this.circId);var e=new Po(this.circId,Po.prototype.DESTROY,new t("09","hex"));this.send(e)},send_relay_end:function(e){var r=this.first_||this,i=new qo(qo.prototype.RELAY_END,e,new t(0),r.last_.Df_hash),n=new Po(r.circId,Po.prototype.RELAY,r.last_.stream_encrypt_forward(i));r.send(n)},associate:function(e){console.log("ASSOCIATE OR RECEIVE "+e),this.socket_.fake_cid=this,En[e]={circ_:this}},info:function(e){if(this.OP_){var r=e.slice(0,16).toString("hex");vn[r]&&vn[r](e.slice(16))}else{var i=e.slice(0,1).readUInt(),r=e.slice(1,17);switch(i){case 1:var n=e.slice(17),s=sn.getDiffieHellman("modp2");s.generateKeys(),Bn[r.toString("hex")]=s;var a=new t(s.getPublicKey("hex"),"hex"),o=Co(n,a);e=new qo(qo.prototype.RELAY_INFO,0,[r,new t(2).writeUInt(a.length),a,o].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);this.send(c);break;case 2:var l=r.toString("hex");if(Bn[l]){var h=new t(Bn[l].computeSecret(e.slice(17),"hex","hex"),"hex");e=new qo(qo.prototype.RELAY_INFO,0,[r,h].concatBuffers(),this.Db_hash).toBuffer(),e=new t(this.Kb_cipher.update(e,"hex","hex"),"hex");var c=new Po(this.circId,Po.prototype.RELAY_WS,e);delete Bn[l],this.send(c)}}}},relay_ws_handle:function(e,r){if(this.OP_){var i=null,s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8").split(":");if(e=e.slice(2+s),console.log("OP ws receive request "+a[3]+" adresse "+a[0]+" port "+a[1]+" data "+e.length),e.length){var o={},c=yn[a[3]];c?c.params_&&(i=c.params_.host):(c={nb_try:0,no_exit:[],i_id:a[3]},yn[a[3]]=c);var l=function(e){for(var r=e,i=new t(new t(a[0]+":"+a[1],"utf8").toString("hex"),"hex"),n=i.length.toString(16);4!==n.length;)n="0"+n;if(i=[new t(n,"hex"),i].concatBuffers(),n=i.length,0===r.length){var s=new qo(qo.prototype.RELAY_WS,0,i,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));this.send(o)}else for(;r.length;){var c;c=r.length+n>_n?r.slice(0,_n-n):r,c=[i,c].concatBuffers();var s=new qo(qo.prototype.RELAY_WS,0,c,this.Df_hash),o=new Po(this.circId,Po.prototype.RELAY_WS,this.stream_encrypt_forward(s));if(this.send(o),!(r.length+n>_n))break;r=r.slice(_n-n)}}.bind(Cs);if(!Ds||!c.tls_server_connected){var h=function(){if(c.wait_header=c.wait_header?[c.wait_header,e].concatBuffers():e,c.wsqueue_&&c.wsqueue_.length){var t=c.wsqueue_[0];c.wsqueue_.shift(),t()}};if(e.length>=4){var u=e.toString("hex");u.substr(u.length-8)!==gs+gs?h():(e=c.wait_header?c.wait_header:e,delete c.wait_header)}else h();c._write_=l,c.destroy=function(){Ds?(delete c.abstract_server_tls,c.abstract_client_tls?(delete c.abstract_client_tls,l(new t(0))):c._write_(new t(0))):c._write_(new t(0))}}var d=function(e){var s=a[2],l=ic(e),h=l.Accept?l.Accept:"";-1!==h.indexOf("text/html")&&delete l["Accept-Encoding"],c.referer_=l.Referer,delete l.Referer,l.Connection="keep-alive";var u=l["0a"].split(" "),d="";if(u.length>1){var f="/"===u[1].substr(0,1)?u[1].substr(1):u[1];d=fo(f)}var p=function(){if("http"===d.substr(0,4)){var h=ho(d);u[1]="/"+(h.rest?h.rest:""),l["0a"]=u.join(" "),l.Host&&(l.Host=h.host?h.host:""),delete l.Cookie,l["X-Requested-With"]||(c._host_=h.protocol+"//"+l.Host)}else l.Host&&(c.fake_domain=l.Host,l.Host=bs[l.Host].real_domain);l.Accept&&-1!==l.Accept.indexOf("text/html")&&(l["Accept-Encoding"]="identity"),e=nc(l),o.OP=!0,o.nb_hop=Hn,o.one_c=!0,Ds&&(s=protocol===ws&&"443"===s?"80":s),o.host=l.Host+":"+s,i&&o.host!==i&&(delete c.tls_client_connected,delete c.abstract_client_tls,c.cid_&&c.cid_.destroy_cid(c,!0)),o.stream=new t(e,"utf8"),c.params_=o,c._data_=!1,c._init_=Xo,c._init_(),r&&(c.nb_try=n),c.remoteAddress=a[0],c.remotePort=a[1],c.end=c.destroy};if("https"===d.substr(0,5)||"https:"===protocol){if(!Ns)return console.log("https not supported now "+d),c._write_(new t(ao(),"utf8")),void 0;if(p(),c.abstract_client_tls){console.log("Reuse TLS Client for request "+c.i_id);var _=function(){c.abstract_client_tls.prepare(sl(c.params_.stream.toString("hex")))};c.request_decoded.socks_s?(console.log("Queue "+c.i_id),c.abstract_client_tls.queue_socks.push(_)):_()}else{console.log("Create TLS Client for request "+c.i_id);var g=ho(d),e=c.params_.stream;c.abstract_client_tls=cl(c,g.host),c.abstract_client_tls.stream_tor_=new t(0),c.abstract_client_tls.queue_socks=[];var m={};m._init_=Xo,m._init_(),m._host_=c._host_,m.cid_=c.cid_,m.i_id=c.i_id,m.fake_domain=c.fake_domain,m.socks_s=!0,m.__write__=c.__write__,m.destroy=c.destroy,m.referer_=c.referer_,c.request_decoded=m,m.request_=c,m.received_=0;var y=c.abstract_client_tls,v=function(e){var t=function(e){return function(){this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.stream_tor_.parseTLS(this)}};y.queue_=y.queue_||[],y.queue_.push(t(e).bind(y)),1===y.queue_.length&&y.queue_[0](),y.queue_socks.length&&!m.socks_s&&(m.socks_s=!0,console.log("Unqueue request "+c.i_id),y.queue_socks[0](),y.queue_socks.shift())};c._write_=v,c.write_c=function(e){c.params_.stream=e,rc(c)},c.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.error=function(e,t){console.log(" Error TLS client disconnected "+t.message),delete c.abstract_client_tls,delete c.tls_client_connected,c.cid_&&c.cid_.destroy_cid(c)},c.abstract_client_tls.connected=function(t){console.log("TLS client connected to site for request "+c.i_id),c.tls_client_connected=!0,c._data_=!1,console.log("Sending https request for request "+c.i_id+" to site "+e.toString("utf8")),t.prepare(sl(e.toString("hex")))},c.abstract_client_tls.dataReady=function(e){var r=e.data.data.slice(e.data.read,e.data.length_);e.data.read=e.data.length_;var i={streamId:new t(2).writeUInt(c.sid_),data:r,length:new t(2).writeUInt(r.length)};c.cid_&&c.cid_.last_.stream_handle_data(i,c.__write__,m)},c.abstract_client_tls.handshake()}}else p(),rc(c)};if(c.relay_ws_handle=d,Ds)c.abstract_server_tls||(c.abstract_server_tls=cl(c,Es,!0),c.write_s=l,c.abstract_server_tls.closed=function(){console.log(" TLS server disconnected for request "+c.i_id),c.destroy()},c.abstract_server_tls.error=function(e,t){-1===t.message.indexOf("Unknown")&&(console.log("Error TLS server disconnected for request "+c.i_id+" "+t.message),c.destroy())},c.abstract_server_tls.connected=function(){console.log("TLS server connected to socks client for request "+c.i_id),c.tls_server_connected=!0,c._write_=function(e){c.abstract_server_tls?(console.log("tls server send to SOCKS"),c.abstract_server_tls.prepare(sl(e.toString("hex"))),c.done_&&c.destroy()):console.log("can't send to SOCKS server connection closed for request "+c.i_id)},c.__write__=c._write_,c.abstract_server_tls.dataReady=function(e){console.log(e.data.read);var t=e.data.data.slice(e.data.read,e.data.length_).toString("utf8");-1!==t.indexOf("Host")&&(e.data.read=e.data.length_,console.log("TLS server receive "+t),c.ini_data=t,d(t))}}),c.abstract_server_tls.process(e);else{var f=e.toString("utf8");c.ini_data=f,d(f)}}}if(this.OR_){var s=e.slice(0,2).readUInt(),a=e.slice(2,2+s).toString("utf8");e=e.slice(2+s);var c=Cn[a];if(e.length)return c.write(e),void 0;c.bufferSize||(console.log("OR ws destroy request "+c.i_id),c.end())}},relay_db_info_handle:function(e){console.log("receive relay_db_info CID "+this.circId);var t,r,i,n,s,a;t=e[0],e=e.slice(1),n=e.slice(0,t).toString("hex"),e=e.slice(t),r=e[0],e=e.slice(1),e.length&&(i=e[0]),console.log("db_info "+n+" part "+r+" fac "+(i?"yes":"no")),s=Sn[n],s?(s.forEach(function(e){e[0]===this&&(a=!0)},this),a||s.push([this,null,null,0])):Sn[n]=[[this,null,null,0]],i&&(console.log(An.indexOf(this)),-1===An.indexOf(this)&&(console.log("pushing facilitator CID "+this.circId),An.push(this)))},relay_db_query_handle:function(e){var r=e.streamId.readUInt();console.log("receive relay_db_query CIC "+this.circId+" sid "+r),e=e.data.slice(0,e.length.readUInt());var i=e[0];e=e.slice(1);var n=e.slice(0,i).toString("hex");e=e.slice(i),i=e[0],e=e.slice(1);var s=parseInt(e.slice(0,i).toString("hex"),16);if(e=e.slice(i),console.log("Receive db_query for "+n+" on CID "+this.circId+" sid "+r+" requesting "+s+" bytes "+e.toString("hex")),this.OP_){var a=e.slice(0,16),c=this.first_;if(n!==Aa){var l=Ya(),h=l.get(n);h.onsuccess=function(e){var t=e.target.result;if(t)if(t.file_length===t.current_length&&se.length&&(e=t)}),sr?-1:1}).sort(function(e,t){return e[0].socket_?t[0].socket_?0:1:-1});var i=u.length;if(u.forEach(function(e){console.log("f has "+e[0].circId+" valid "+(e[0].socket_?"yes":"no"))}),i){for(;u.length;)if(u[0][0].socket_)if(u[0][0].socket_.remoteAddress){if(!u[0][0].destroyed_)break;console.log("ORDB remove destroyed CIC "+u[0][0].circId),u.shift()}else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();else console.log("ORDB remove "+u[0][0].circId),u[0][0].circuit_destroy(),u.shift();if(u.length){var d=u[0][0];u[0][3]++;var a=No(16),f={d_length:s,hash_:new t(n,"hex")};In[a.toString("hex")]=[this,r,u,f,1],d.send_db_query(f,a)}else Uo.call(this,r,s,n)}else Uo.call(this,r,s,n)}else An.length?Uo.call(this,r,s,n):(console.log("ORDB does not know the file"),this.send_db_end(0,r))}},relay_db_connected_handle:function(e){var t=e.streamId.readUInt();if(console.log("receive relay_db_connected CID "+this.circId+" sid "+t),e=e.data.slice(0,e.length.readUInt()),this.OP_){var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),s=this.first_[t];if(s){if("torrent"===n){if(s.url_)return console.log("direct download"),this.first_.send_db_end(1,t),ko(s),qh(s.query_t0),rc(s),void 0;$a(document.body,"mousedown",function(){},!1),console.log("put torrent timer"),s._streaming_||Oh('

    The file is not available in Peersm network, looking for it in Bittorrent network.

    '),s._torrentc_=setTimeout(function(){this.first_.send_db_end(1,t),ko(s),Ro(s),Oh('

    Could not find the file in bittorrent, stopping download

    ')}.bind(this),Ia)}else Wa("alert_box").style.display="none",s._torrentc_&&(console.log("remove torrent timer"),clearTimeout(s._torrentc_));s.flowc=s.flowc?s.flowc:Date.now()-s.query_time,console.log("db_query/db_connected "+(Date.now()-s.query_time)+" ms "+s.flowc),qh(s.query_t0),s.clength_=i,s.pieces=Math.ceil(s.clength_/Da),s.content_=n,s.sid_=t,s.received_=0,s.sent_=0,s.nb_try=0,s.stream_window=Oa,s.stream_window_s=Oa,s._stream_&&"torrent"!==n&&fh(s)}}else{var a=e.slice(0,16).toString("hex");e=e.slice(16);var r=e[0];e=e.slice(1);var i=parseInt(e.slice(0,r).toString("hex"),16);e=e.slice(r),r=e.slice(0,2).readUInt(),e=e.slice(2);var n=e.slice(0,r).toString("utf8"),o=In[a];"torrent"!==n&&delete In[a],console.log("db_connected "+a+" type "+n+" size "+i+" "+typeof o),this.nb_query=0,o&&(this.socket_?o[0].socket_&&(o[0].send_db_connected(i,o[1],n),Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+t]=o,xn[o[0].socket_.remotePort+"-"+o[0].socket_.remoteAddress+"-"+o[0].circId+"-"+o[1]]=[this,t],this[t]={},o[0][o[1]]={},console.log("i_or associated with remote port "+this.socket_.remotePort+" remote address "+this.socket_.remoteAddress+" CIC "+this.circId+" Stream "+t),console.log("f_or associated with remote port "+o[0].socket_.remotePort+" remote address "+o[0].socket_.remoteAddress+" CIC "+o[0].circId+" Stream "+o[1])):o[0].send_db_end(0,o[1]))}},relay_db_end_handle:function(e){var r=e.streamId.readUInt();e=e.data.slice(0,e.length.readUInt());var i=e.slice(0,1).readUInt();if(console.log("receive db_end sid "+r+" reason "+i+" CIC "+this.circId),this.OP_){var n=this.first_,s=n[r];if(s)if(s.send_data)s.fc_t?s.fc_t.length?(console.log("queue not empty - stop sending"),s.stop_=!0):(console.log("queue empty - delete request"),s._torrent_&&s._torrent_stream.destroy(),delete n[r]):s.__torrent__&&(console.log("destroying engine"),s.__torrent__.destroy());else if(qh(s.query_t0),qh(s.sendme_tout),qh(s.waiting_),2===i||s.reason_||3===i){qh(s.sendme_tout),qh(s.waiting_),s.reason_=2;var a=function(){if(s.nb_tryThe remote peers closed the connections, attempts to resume streaming failed.

    ')):($a(document.body,"mousedown",function(){},!1),Oh('

    The remote peers closed the connections during the download, attempts to resume failed, storing downloaded part, please wait that the file appears in Local Storage.

    Use resume later to get the complete file.

    '),rh(s)),delete s.reason_)};s.queue_=s.queue_||[],s.queue_.push(a),1===s.queue_.length&&s.queue_[0]()}else if(s.url_)if(s.reload2_||s.reload_){console.log("resuming direct download");var o=function(e){var i=e.d_length;e.blob_=Ji?new t(0):new Blob([],{type:e.content_chrome?e.content_chrome:e.content_});var s=ho(e.url_);e.params_.stream=vo(s.host,s.rest,i),delete e.params_.db_,delete e.cid_,delete n[r],delete e.file_id,delete e.start_t0,e.received_=0,rc(e)};ah(s,!0,o)}else this.destroy_cid(s),delete s.params_.db_,delete s.content_,delete s.d_length,delete s.clength_,delete s.blob_,_h&&(gh.vAxis.maxValue=Ks,_h.draw(mh,gh)),rc(s);else $a(document.body,"mousedown",function(){},!1),Oh('

    The file is currently not available from peers in Peersm and Bittorrent networks and can not be downloaded directly, please check the URL or the Hash Name you are using

    '),ko(s),Ro(s)}else if(this.nb_query=0,e.length>1){console.log("db_end with tid CIC "+this.circId+" db_test length "+(this.db_test?this.db_test.length:"")),this.db_test&&this.db_test.forEach(function(e){clearTimeout(e)});var c=e.slice(1,17).toString("hex"),l=In[c];if(l){var h=l[2],u=l[4];if(h[u]){l[4]++;var d=h[u][0];d.send_db_query(l[3],new t(c,"hex")),console.log("try another peer "+d.circId+" tid "+c+" stream length "+e.length)}else An.length?Uo.call(this,r,l[3].d_length,l[3].hash):(l[0].send_db_end(i,l[1]),delete In[c])}}else{console.log("forwarding db_end");var f=xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(f)try{3!==i&&(delete Tn[f[0].socket_.remotePort+"-"+f[0].socket_.remoteAddress+"-"+f[0].circId+"-"+f[1]],delete xn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete f[0][f[2]]),f[0].send_db_end(i,f[1])}catch(p){}else{var _=Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r];if(_)try{_[0].send_db_end(i,_[1]),delete xn[_[0].socket_.remotePort+"-"+_[0].socket_.remoteAddress+"-"+_[0].circId+"-"+_[1]],delete Tn[this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+r],delete _[0][_[2]]}catch(p){}}delete this[r]}},relay_db_data_handle:function(e){if(b)var r=Date.now();var i=e.streamId.readUInt();if(e=e.data.slice(0,e.length.readUInt()),this.OP_){var n=this.first_,s=n[i];if(s){0===s.received_&&(console.log("start_t0 received "+Date.now()),s.start_t0=Date.now(),n.send_db_sendme(i)),s.received_++,n.received_++,s.stream_window--,s._write_(e);var a=s.received_,o=parseInt(e.length*s.received_/((Date.now()-s.start_t0)/1e3)),c=Math.ceil(o*(s.flowc/2/1e3)/e.length);c=Math.ceil(Oa-c>0?Math.min(c,Oa*(1-ds)):Oa*(1-ds));var l,h=function(r){var a=function(e){console.log("sendme timeout received_ "+s.received_+" rec "+e+" stream-blocs "+(Oa-c)),s.received_!==e||s._stream_?h(s.received_):(qh(s.sendme_tout),qh(s.waiting_),console.log("resuming peer to peer download received "+s.received_),n.send_db_end(1,i),n.relay_db_end_handle({streamId:new t(2).writeUInt(i),length:new t(2).writeUInt(1),data:new t(1).writeUInt(2)}))};qh(s.sendme_tout),qh(s.waiting_),console.log(8*o+" bps nbBlocs "+c+" stream window "+s.stream_window+" - sending sendme stream received "+n.received_*e.length+" - Buffer Amount: "+El.bufferedAmount+" "+Date.now()),n.send_db_sendme(i),s.stream_window+=Oa,console.log("sendme timeout "+l+" stream length "+e.length),s.sendme_tout.push(setTimeout(function(){a(r)},l))};s.stream_window===c&&(0===El.bufferedAmount||n.received_*e.lengthr;r++){var i=new Fo;i.OP_=!0,i.t0_=[],i.server_=e.path_[r+1],e.next_=i,i.prev_=e,i.path_=e.path_,i.nb_=e.nb_+1,i.socket_=this.socket_,i.circId=this.circId,i.first_=this,e=i}return!0}var n=parseInt(this.server_.fing,16)Resuming direct download from '+this.last_.server_.ip+"

    ")):Oh('

    File not available from Peers, starting direct download from '+this.last_.server_.ip+"

    "),setTimeout(function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},12e3)),e.cid_=this,e.params_.host&&!e.destroyed){var r=new t(e.params_.host);r=new t(r.toString("hex")+"00","hex");var i=bo(this);if(i){console.log("STREAM : --------------SEND RELAY_BEGIN---------------------- CID "+this.circId+" on OR "+this.first_.server_.ip+" Stream "+i+" for request "+e.i_id+" on port "+e.remotePort+" host "+r.toString("utf8")),console.log(e.params_.stream.toString("utf8").substr(0,300)),this[i]=e,e.sid_=i,e.received_=0,e.sent_=0,e.stream_window=hs,e.stream_window_s=hs;var n=function(){var t=this;console.log("Timeout Bad circuit "+t.circId),!t.perf_>0&&(t.bad_=!0),t.send_relay_end(i),e.nb_try++,delete e.cid_,delete t[i],rc(e)},s=function(){var t=new qo(qo.prototype.RELAY_BEGIN,i,r,this.last_.Df_hash),s=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(t));Us&&(e.socket_retry=setTimeout(n.bind(this),rs)),this.send(s)};s.call(this)}}},sendme:function(e){e=e||{sid_:0,i_id:-1};var r=new qo(qo.prototype.RELAY_SENDME,e.sid_,new t(0),this.last_.Df_hash),i=new Po(this.circId,Po.prototype.RELAY,this.last_.stream_encrypt_forward(r));this.send(i)},set_certs:function(e){try{e=e.split(jn),this.server_.onion_k=jn+e[1].split(zn)[0]+zn,this.server_.sign_k=jn+e[2].split(zn)[0]+zn;var t=new dn;return this.server_.o_modulus=t.modulus(this.server_.onion_k),this.server_.s_modulus=t.modulus(this.server_.sign_k),!0}catch(r){return this.nb_error=this.nb_error?++this.nb_error:1,!1}},get_certs:function(e){if(this.server_&&!this.ok_){var t=cn.length,r=this.server_.fing,i=_o(t),n=cn[i].split(":"),s=n[0],a=n[1],o={host:s,path:"/tor/server/fp/"+r,port:a,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding":"gzip deflate","Accept-Language":"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3","Cache-Control":"max-age=0",Connection:"keep-alive",Host:s,"User-Agent":"Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0"}},c=nn.request(o,function(t){if(c.data_="",200!=t.statusCode){this.clear_t0_();try{this.get_certs(e)}catch(i){}}t.on("data",function(e){this.clear_t0_(),c.data_+=e.toString("utf8")}.bind(this)),t.on("end",function(){this.server_&&!c.destroy_&&(this.certs_||(this.set_certs(c.data_)?(this.certs_=!0,this.prev_?e.call(this.prev_):e.call(this)):this.nb_error>4?this.change_or("CERTS : get_certs wrong cert for "+r,this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e)))}.bind(this))}.bind(this)),l=function(){this.clear_t0_(),this.server_&&(this.nb_error=this.nb_error?++this.nb_error:1,this.nb_error>4?this.change_or("error get_certs",this.first_!==this?function(){this.get_certs(e)}:null):this.get_certs(e))}.bind(this);c.on("error",l),c.end();var h=function(){this.clear_t0_(),c.removeListener("error",l),l=function(){console.log("CERTS : error fired after abort for "+s)},c.on("error",l),c.destroy_=!0,c.socket.destroy(),this.server_&&this.get_certs(e)}.bind(this);this.t0_.push(setTimeout(h,1e3))}},change_or:function(e,t){if(this.server_){console.log("change_or ----------- CIC "+this.circId);var r,i,n=[];if(this.first_)var s=this.first_.request_;var a="undefined"==typeof s?null:s.params_?s.params_.db:null;if(this.prev_||!Zi||("undefined"==typeof this.server_?1:this.server_!==Zi)){if(this.first_===Ss||a)return this.first_&&(console.log("change_or circuit destroy"),this.first_.circuit_destroy(),s&&Ko(s)),void 0;var i=this.prev_?this.next_?on:Exit:Guards,o=i.length;for(this.clear_timers(),this.clear_t0_(),this.path_?n=this.path_.map(function(e){return e.ip}):n.push(this.server_.ip),r=_o(o);-1!=n.indexOf(i[r].split("-")[1]);)r=_o(o);var c=i[r].split("-");i={ip:c[1],fing:c[0],port:c[2],band:c[3],o_modulus:c[5]?c[5]:c[4]}}else console.log("change_or one OR "+this.circId),i=Zi;for(var l=this;l;)delete l.destroy_,delete l.nb_error,delete l.ok_,l=l.next_;delete this.first_.last_;var h=new Fo;Object.keys(this).forEach(function(e){h[e]=this[e]},this),h.server_=i;try{var u=this.server_.ip;this.server_o=this.server_}catch(d){console.log("_server error"),this.clear_timers();for(var f in this)"function"!=typeof this[f]&&console.log(f+" "+this[f]);this.first_.destroy()}delete this.server_,delete h.certs_,this.next_&&(h.next_.prev_=h),this.prev_?(h.prev_.extended_&&(h.prev_.extended_=h),h.prev_.next_=h,-1==e.indexOf("get_certs")&&(h=h.prev_,delete h.certs_)):h.first_=h,h.first_.reconstruct_path(),t&&(this.prev_||this.first_===this)?t.call(h):this.socket_.first_===this?(delete gn[u],h.socket_&&(this.destroy_=!0,h.socket_.destroy(),delete h.socket_),delete h.extended_,h.circId=0,h.first_=h,h.path_.shift(),h.path_.unshift(h.server_),tc(h)):this.next_.change_or("PATH : first socket exists, change path",this.create)}},circuit_retry:function(){if(!es)if(this.ok_||this.socket_.first_!==this){this.destroy(),delete this.ok_,delete this.first_.last_;var e=this.circId;this.circId=bo(this.socket_),delete this.socket_[e],this.socket_[this.circId]=this,this.socket_.nbc_--;for(var t=this;t.extended_;)t.extended_.circId=this.circId,t=t.extended_,delete t.extended_;this===t&&this.socket_.first_!==this?t.create():t.change_or("circuit_retry from first OR circId="+this.circId,this.create.bind(this)) +}else this.change_or("initial socket closed unexpectedly or unexpected circuit creation error or new circuit creation error")},reconstruct_path:function(){for(var e=this,t=[];e.next_;)t.push(e.server_),e=e.next_;for(;e.prev_;)e.path_=t,e.first_=this,e=e.prev_},circuit_destroy:function(e){if(this.socket_){this.socket_.remoteAddress?console.log("CIRC : circuit destroy "+(this.OP_?"OP ":"OR "+(this.OR_f?"in ":"out "))+(this.socket_.address()?this.socket_.address().address:"")+" CID "+this.circId+" remote "+this.socket_.remoteAddress):console.log("circuit destroy : socket no remote address CIC "+(this.OP_?"OP ":"OR ")+" "+this.circId);var t;if(this.socket_){var r=this.socket_;this.next_?e||this.destroyed_||(this.destroyed_=!0,r.remoteAddress&&(console.log("circuit_destroy remote address "+r.remoteAddress+" CIC "+this.circId),this.destroy())):this.socket_.address()&&ka&&parseInt(this.socket_.address().port)===parseInt(kn)&&r.OR_f&&(console.log("ORDB - call db_destroy"),this.circuit_db_destroy()),delete r[this.circId],delete this.socket_,Object.keys(r).forEach(function(e){isNaN(e)||null==e||(t=!0)},this),t||this===Ss||r.ws_||(console.log("circuit_destroy: destroy socket"),r.destroy())}}console.log("circuit_destroy "+(this.OP_?"OP":"OR")),this.OP_&&(console.log("requests_destroy"),this.requests_destroy()),delete this.next_,delete this.prev_},circuit_db_destroy:function(){this.socket_&&Object.keys(this).forEach(function(e){if(!isNaN(e)&&null!=e){var t=this.socket_?this.socket_.remotePort+"-"+this.socket_.remoteAddress+"-"+this.circId+"-"+e:this.server_?this.server_.port+"-"+this.server_.ip+"-"+this.circId+"-"+e:"",r=Tn[t]||xn[t];r&&(console.log("------- "+r[1]),r[0].send_db_end(2,r[1]),delete xn[t],delete Tn[t],delete this[e],delete r[0][r[1]])}},this)},requests_destroy:function(){for(var e in this)if(!isNaN(e)&&null!=e){var t=this[e];t.abstract_client_tls&&t.abstract_client_tls.close(),delete t.abstract_client_tls,this.destroy_cid(t),Ss?this!==Ss?t._data_?t.destroy():this.request_retry(t,"requests_destroy"):Sl(t):Us&&Sl(t)}if(ks){if(this===Cs){console.log("destroy CIC resend associate ");for(var e in bs)delete bs[e].associated;Cs=null,rc({params_:{OP:!0,nb_hop:Hn,ws:El}})}}else Ss?this===Ss&&(Ss=null,rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})):Us&&rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}})},clear_timers:function(){this.OP_&&(this.first_.tc_.forEach(function(e){clearTimeout(e)}),this.first_.tc_=[])},clear_t0_:function(){this.t0_&&(this.t0_.forEach(function(e){clearTimeout(e)}),this.t0_=[])},end:function(e,t,r){if(r)var i=this.first_||this,n=i[r]?i[r]:i.request_;this.OP_,e=e.split(":"),console.log2=function(){};var s=function(){if(e.length>1)switch(parseInt(e[1])){case 0:return console.log2("-- CIC NONE (No reason given.)"),0;case 1:return console.log2("-- CIC PROTOCOL (Tor protocol violation.)"),1;case 2:return console.log2("-- CIC INTERNAL (Internal error.)"),2;case 3:return console.log2("-- CIC REQUESTED (A client sent a TRUNCATE command.)"),3;case 4:return console.log2("-- CIC HIBERNATING (Not currently operating; trying to save bandwidth.)"),4;case 5:return console.log2("-- CIC RESOURCELIMIT (Out of memory, sockets, or circuit IDs.) "+this.circId+" "+(this.OP_?" OP ":" OR ")),5;case 6:return console.log2(" -- CIC CONNECTFAILED (Unable to reach relay.)"),6;case 7:return console.log2("-- CIC OR_IDENTITY (Connected to relay, but its OR identity was not as expected.)"),7;case 8:return console.log2("-- CIC OR_CONN_CLOSED (The OR connection that was carrying this circuit died CID "+this.circId+" "+(this.OP_?" OP ":" OR ")),8;case 9:return console.log2("-- CIC FINISHED (The circuit has expired for being dirty or old.)"),9;case 10:return console.log2("-- CIC TIMEOUT (Circuit construction took too long)"),10;case 11:return console.log2("-- CIC DESTROYED (The circuit was destroyed w/o client TRUNCATE)"),11;case 12:return console.log2("-- CIC NOSUCHSERVICE (Request for unknown hidden service)"),12}}.bind(this),a=function(){if(e.length>1)switch(parseInt(e[1])){case 1:return console.log2("-- RELAY REASON_MISC (catch-all for unlisted reasons) request "+(n?n.i_id:"")),1;case 2:return console.log2("-- RELAY REASON_RESOLVEFAILED (couldn t look up hostname) request "+(n?n.i_id:"")),2;case 3:return console.log2("-- RELAY REASON_CONNECTREFUSED (remote host refused connection) [*] request "+(n?n.i_id:"")),3;case 4:return console.log2("-- RELAY REASON_EXITPOLICY (OR refuses to connect to host or port) request "+(n?n.i_id:"")),4;case 5:return console.log2("-- RELAY REASON_DESTROY (Circuit is being destroyed) request "+(n?n.i_id:"")),5;case 6:return console.log2("-- RELAY REASON_DONE (Anonymized TCP connection was closed) request "+(n?n.i_id:"")),6;case 7:return console.log2("-- RELAY REASON_TIMEOUT (Connection timed out, or OR timed out while connecting) request "+(n?n.i_id:"")),7;case 8:return console.log2("-- RELAY REASON_NOROUTE (Routing error while attempting to contact destination) request "+(n?n.i_id:"")),8;case 9:return console.log2("-- RELAY REASON_HIBERNATING (OR is temporarily hibernating) request "+(n?n.i_id:"")),9;case 10:return console.log2("-- RELAY REASON_INTERNAL (Internal error at the OR) request "+(n?n.i_id:"")),10;case 11:return console.log2("-- RELAY REASON_RESOURCELIMIT (OR has no resources to fulfill request) request "+(n?n.i_id:"")),11;case 12:return console.log2("-- RELAY REASON_CONNRESET (Connection was unexpectedly reset) request "+(n?n.i_id:"")),12;case 13:return console.log2("-- RELAY REASON_TORPROTOCOL (Sent when closing connection because of Tor protocol violations.) request "+(n?n.i_id:"")),13;case 14:return console.log2("-- RELAY REASON_NOTDIRECTORY (Client sent RELAY_BEGIN_DIR to a non-directory relay.) request "+(n?n.i_id:"")),14}}.bind(this);if(t)switch(t){case"handshake":this.change_or("handshake failed");break;case"fast_key":this.change_or("wrong fast key");break;case"created_extended_key":this.change_or("wrong create or extend key",this.prev_?this.prev_.extend:null);break;case"truncated":this.relay_truncated_handle(s());break;case"truncate":this.relay_truncate_handle(s());break;case"destroy":this.handle_destroy(s());break;case"unrecognized":console.log("end unrecognized circuit destroy"),this.circuit_destroy();break;case"relay_end":n&&"undefined"!=typeof n.i_id&&this.relay_end_handle(r,a())}else delete this.socket_[this.circId]}};var qo=function(e,r,i,n){this.command=new t(1).writeUInt(e),this.recognize=new t("0000","hex"),this.streamId=new t(2).writeUInt(r),this.digest=new t("00000000","hex"),this.length=new t(2).writeUInt(i.length),this.data=e===this.RELAY_WS?new t(i.length):new t(pn),this.data.map(i),n&&(n.update(this.toBuffer()),this.digest=new t(n.digest("hex"),"hex").slice(0,4))};qo.prototype={RELAY_BEGIN:1,RELAY_DATA:2,RELAY_END:3,RELAY_CONNECTED:4,RELAY_SENDME:5,RELAY_EXTEND:6,RELAY_EXTENDED:7,RELAY_TRUNCATE:8,RELAY_TRUNCATED:9,RELAY_DROP:10,RELAY_RESOLVE:11,RELAY_RESOLVED:12,RELAY_BEGIN_DIR:13,RELAY_ASSOCIATE:40,RELAY_WS:41,RELAY_INFO:42,RELAY_DB_INFO:80,RELAY_DB_QUERY:81,RELAY_DB_CONNECTED:82,RELAY_DB_DATA:83,RELAY_DB_END:84,RELAY_DB_SENDME:85,toBuffer:function(){return[this.command,this.recognize,this.streamId,this.digest,this.length,this.data].concatBuffers()}};var Ho,Mo,jo,zo=function(e){switch(this.Command.readUInt()){case this.VERSIONS:return this.versions_cell_decode(e);case this.CERTS:return this.certs_cell_decode(e);case this.AUTH_CHALLENGE:return this.auth_challenge_cell_decode(e);case this.NETINFO:return this.netinfo_cell_decode(e);case this.CREATED_FAST:return this.created_fast_cell_decode(e);case this.CREATED_FAST_WS:return this.created_fast_ws_cell_decode(e);case this.CREATE_FAST:return this.create_fast_cell_decode(e);case this.CREATE_FAST_WS:return this.create_fast_ws_cell_decode(e);case this.CREATED:return this.created_cell_decode(e);case this.CREATE:return this.create_cell_decode(e);default:return[e]}},Vo=function(e,t){if(e)for(var r=e.length,i=0;r>i;i++){var n=e[i],s=n.CircID.readUInt();if(this[s])var a=this[s];else{if(!this.OR_||!this.OR_f)return;if(this[0]){var a=this[0];a.circId=s,this[s]=a,delete this[0]}else{var a=new Fo;a.OR_=!0,a.OR_f=!0,a.circId=s,a.socket_=this,a.way_="socket in",this[s]=a}}try{a.clear_timers()}catch(o){}if(6===n.Command.readUInt()&&console.log("handle cell "+n.Command.readUInt()),yh&&_h&&(chart1_int||chart2_int)&&n.Command.readUInt()!==n.PADDING){var c=go(new Date).getTime(),l=0;n.Payload.forEach(function(e){l+=e.length}),a.first_===Ss?chart2_int&&(yh.dynRow[c]=yh.dynRow[c]?yh.dynRow[c]+l:l):chart1_int&&(_h.dynRow[c]=_h.dynRow[c]?_h.dynRow[c]+l:l)}if(a.destroyed_)console.log("received cell for destroyed CIC "+a.circId);else switch(n.Command.readUInt()){case n.PADDING:a.padding_cell_handle(n);break;case n.VERSIONS:a.versions_cell_handle(n);break;case n.CERTS:a.certs_cell_handle(n);break;case n.AUTH_CHALLENGE:a.auth_challenge_cell_handle(n);break;case n.NETINFO:a.netinfo_cell_handle(n);break;case n.CREATE_FAST:a.create_fast_cell_handle(n);break;case n.CREATE_FAST_WS:a.create_fast_ws_cell_handle(n);break;case n.CREATED_FAST:a.created_fast_cell_handle(n);break;case n.CREATED_FAST_WS:a.created_fast_ws_cell_handle(n);break;case n.CREATE:a.create_cell_handle(n);break;case n.CREATED:a.created_cell_handle(n);break;case n.RELAY:a.relay_cell_handle(n,t);break;case n.RELAY_WS:a.relay_cell_handle(n,t);break;case n.RELAY_EARLY:a.relay_cell_handle(n,t);break;case n.DESTROY:a.end("Destroy reason:"+n.Payload[0].slice(0,1).readUInt(),"destroy")}}else console.log("end or banish circuit_destroy"),this.circuit_destroy()},Ko=function(e){console.log("circuit_start"),Us&&Qn>Xn&&(document.location.href=document.location.href);var t=e.params_,r=[];if(t.nb_hop?t.nb_hop>2&&(r=mo(t)):r=mo(t),Zi&&(r[0]=Zi),(ks||Us)&&$i&&!Cs){if(t.ws!==Cl)return;r[0]=$i}t.db&&(r[Mn-1]=ka);var i=gn[r[0].ip],n=new Fo(r);if(n.request_=e,n.first_=n,n.tc_=[],i)if(i.abstract_client_tls&&!i.tls_connected&&i.wsconnected_)console.log("start TLS handshake - circuit start "),i.abstract_client_tls.handshake();else if(console.log("TLS connected - start create_fast"),n.server_=i.server_,n.socket_=i,n.tc_=[],n.setCircId())if(Js){console.log("Sending fast CIC "+n.circId+" "+i.server_.ip+" "+n.destroyed_),t.db&&(El.db_cid_launched=!0),n.X_=No(20);var s=new Po(n.circId,Po.prototype.CREATE_FAST,n.X_);n.send(s)}else n.create();else console.log("PATH : no more circuits available");else console.log("circuit_start init socket"),n.circId=0,t.ws?t.ws.wsconnected_&&($o(t.ws,n),Zo.call(t.ws,n)):tc(n)},Go=function(e){e&&(console.log("CIRCUITS destroy "+(e.remoteAddress?e.remoteAddress:"")),e.OP_&&delete gn[e.remoteAddress],Object.keys(e).forEach(function(t){if(!isNaN(t)&&null!=t){var r=e[t];console.log("delete cic "+r.circId+" socket "+(r.server_?r.server_.ip:"")),e.OP_?(r.requests_destroy(),delete gn[r.server_.ip]):r.next_?r.next_.destroy():r.prev_?r.prev_.destroy():r.circuit_db_destroy(),delete r.socket_,delete e[t]}}))},Yo=function(e,t){var r=[];for(var i in gn){var n=[];Object.keys(gn[i]).forEach(function(t){var r=gn[i][t];isNaN(t)||null==t||!r.last_||-1!==e.no_exit.indexOf(r)||r.bad_||(!Us||r!==Ss&&r!==Cs)&&n.push(r)}),n.length&&r.push(n)}if(r.length){if(!t){var s,a,o=r[_o(r.length)];if(e.nb_try){o=o.map(function(e){return[e,e.time_average]}),o.sort(function(e,t){return e=e[1],t=t[1],e==t?0:t>e?-1:1});var i=0,c=o.length;if(Us)i=parseInt(o.length/2);else for(var l=0;c>l;l++)if(0!==o[l][1]){i=l;break}i&&(o=o.slice(i,Math.min(o.length,Yn+i))),Oi("best circuits "+(o[0]?o[0][0].circId:"")+" "+(o[1]?o[1][0].circId:"")+" "+(o[2]?o[2][0].circId:"")),a=_o(o.length),s=o[a][0]}else a=_o(o.length),s=o[a],s.time_=(new Date).valueOf();return s}if(1===r.length&&1===r[0].length)return!0}else Us&&console.log("choose circuit no circuit found for request "+e.i_id)},Wo=function(e){return function(){if(this.OR_&&this.address().port===kn,this.ws_&&(!A||I||this.OR_)&&!T){this.WS_OP_;var r=Sc(this.stream_ws_?[this.stream_ws_,e].concatBuffers():e);try{e=r[0]}catch(i){return console.log("wsdecode error or FIN (first bit at 1):"+(e.length?e[0]:"")+" closing WS."),this.end(),void 0}this.ws_&&this.WS_OP_&&r[1].length,this.stream_ws_=r[1].length?r[1]:null}if(this.stream_tor_=this.stream_tor_.length?[this.stream_tor_,e].concatBuffers():e,this.WS_OP_&&this.ws_,h)var n=Date.now();if(this.ws_&&Us&&!A&&!T){this.pair.encrypted.t0&&(ca++,la+=this.stream_tor_.length,ha+=Date.now()-this.pair.encrypted.t0,0===ca%ua&&ha&&(console.log("wsdecode perf (pass to encrypted): "+parseInt(8*la/(ha/1e3))+" bps"),ca=0,la=0,ha=0)),this.pair.encrypted.write(this.stream_tor_),this.stream_tor_=new t(0);var s=this.queue_;s.shift(),s.length&&s[0]()}else this.stream_tor_.parse(this);n&&(ea++,ta+=e.length,ra+=Date.now()-n,0===ea%ia&&ra&&(this.OR_?this.address()&&ka&&this.address().port===kn&&this.OR_f&&console.log("Parser perf (ORDB):"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length):console.log("Parser perf:"+parseInt(8*ta/(ra/1e3))+" bps "+this.stream_tor_.length),ea=0,ta=0,ra=0))}},Qo=function(e){this.queue_=this.queue_||[],this.queue_.push(Wo(e).bind(this)),1===this.queue_.length&&this.queue_[0]()},Xo=function(){delete this.end_,delete this.html_,delete this.header_,delete this.header_l,delete this.content_,delete this.content_l,delete this.clength_,delete this.encoding_,delete this.pass_,delete this.t0_,delete this.script_,delete this.header_sent,delete this.decoder_,delete this.f_,delete this.wait_,delete this.buff_,this.nb_try=0,delete this.time_resp},Jo=function(e){var r={};Xo.call(r),r.params_={},r.params_.OP=!0,r.params_.nb_hop=Hn,r.params_.one_c=!0,r.nb_try=0,r.no_exit=[],r.squeue_=[],r.wsqueue_=[],r._date_=Date.now(),r.i_id=qa,qa++,e=ho(e),r.params_.host=e.host;var i="GET /"+e.rest+" HTTP/1.1\r\n";return i+="Host: "+e.host+"\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: */*\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="\r\n",r.params_.stream=new t(i,"utf8"),r.remotePort="60000",r.remoteAddress="1.2.3.4",r.write=function(){},r.end=function(){},r.destroy=function(){},r.close=function(){},r._init_=Xo,r._write_=r.write,r},Zo=function(e){gn[e.server_.ip]=this,this[e.circId]=e,this.stream_tor_=new t(0);var r=new Po(e.circId,Po.prototype.VERSIONS,new t(2).writeUInt(3));e.send(r)},$o=function(e,r){r.socket_=e,e.first_=r,e.server_=r.server_,e.nbc_=0,Js&&e===El&&(e.buff_w=Os?new Mc.util.ByteBuffer:new t(0),e.abstract_client_tls=cl(e,"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net"),e.abstract_client_tls.closed=function(){console.log(" TLS client disconnected."),clearInterval(en),Al(e),e.destroy(),Dc()},e.abstract_client_tls.error=function(t,r){-1===r.message.indexOf("MAC")?(console.log(" Error TLS client disconnected "+r.message),clearInterval(en),Al(e),e.destroy(),Dc()):console.log("bad MAC")},e.write=function(t){Os?e.buff_w.putBytes(t.toString("binary")):e.buff_w=e.buff_w.length?[e.buff_w,t].concatBuffers():t},e.abstract_client_tls.connected=function(){console.log("TLS client connected"),en=setInterval(xc,1e4),e.tls_connected=!0,e.write=function(t){Os?e.abstract_client_tls.prepare(t.data?t.getBytes():t.toString("binary")):e.abstract_client_tls.prepare(sl(t.toString("hex")))},e.write(e.buff_w)},e.write_c=function(r){r.length&&(Os?e.send(new t(r,"binary")):e.send(r))},e.abstract_client_tls.dataReady=function(r){if(Os){if(r.data.length()){var i=new t(r.data.getBytes(),"binary");e.t0&&(Bh++,kh+=i.length,Rh+=Date.now()-e.t0,0===Bh%Uh&&Rh&&(console.log("TLS perf (dataReady): "+parseInt(8*kh/(Rh/1e3))+" bps"),Bh=0,kh=0,Rh=0)),Qo.call(e,i)}}else{var i=r.data.data.slice(r.data.read,r.data.length_);r.data.read=r.data.length_,console.log(i.length),i.length&&Qo.call(e,i)}},e.wsconnected_&&(console.log("start TLS handshake "),delete e.abstract_client_tls.handshaking,e.abstract_client_tls.handshake()))},ec=function(e){e.OR_=!0,e.OR_f=!0,e.way_="socket in",e.privkey_=Xs,e.stream_tor_=new t(0);var r=new Fo;r.remote_=e.remoteAddress,r.OR_=!0,r.OR_f=!0,r.circId=0,r.socket_=e,r.way_="socket in",e[0]=r},tc=function(e){var t="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",r="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",i={key:Ri.readFileSync(o+"priv-key.pem"),cert:al(o+"pub-key.pem",o+"priv-key.pem","pem",parseInt(No(8).toString("hex"),16),new Date,t,r),servername:t,rejectUnauthorized:!1};console.log("OUTGOING SOCKET : ---------start initial socket------------"+i.servername+" "+e.server_.ip+" "+e.server_.port);var n=tn.connect(e.server_.port,e.server_.ip,i,function(){clearTimeout(c),Zo.call(this,e)});n.on("data",Qo);var s=function(){n.nbc_>1?Go(tc):(clearTimeout(c),e.destroy_?Go(tc):e.last_?Go(tc):(e.clear_t0_(),delete e.ok_,delete gn[e.server_.ip],e.circuit_retry()))};n.on("end",s),n.on("close",s),n.on("error",function(){clearTimeout(c),e.destroy_=!0,n.destroy(),e.last_||e.change_or("initial socket error")});var a=function(){e.destroy_=!0,n.destroy(),e.change_or("initial socket failed")};$o(n,e);var c=setTimeout(a,2e3)},rc=function(e,t){var r=e.params_;if(e.time_ini=Date.now(),r)if(r.OP)if(r.one_c)if(t)if(Yo(e,!0)===!0)Ko(e);else{var i;if(!ks||e.params_.ws){if(i=Yo(e),t)for(var n=5;t===i&&0!==n;)i=Yo(e),n--}else for(i=Cs;i===Cs;)i=Yo(e);i?i.process(e):Ko(e)}else{var i;if(e.cid_&&e.cid_.bad_&&(delete e.tls_client_connected,delete e.abstract_client_tls,e.cid_.destroy_cid(e)),!ks&&!Us||e.params_.ws||e.params_.db_)i=e.cid_?e.cid_:r.one_c?Yo(e):null;else for(i=e.cid_?e.cid_:Cs;i===Cs||i===Ss;)i=Yo(e);i?(console.log("choose circuit "+i.circId+" for request "+e.i_id),i[e.sid_]?i.last_?i.last_.stream_handle_connected(e.sid_):(i.destroy_cid(e),rc(e)):i.process(e)):(console.log("no circuits"),0===mn.length?Ko(e):mn.push(e))}else Ko(e);else{var s="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",c=new Date,l=parseInt(No(8).toString("hex"),16),h=al(o+"pub-key.pem",o+"priv-key.pem","pem",l,c,s,a),u={key:Ri.readFileSync(o+"priv-key.pem"),cert:h,servername:s,requestCert:!0},d=tn.createServer(u,function(e){var t=e.remoteAddress,r=e.remotePort;ec(e),e.on("data",Qo),e.on("error",function(e){console.log("OR socket error"),console.log(e),delete wn[t+":"+r]}),e.on("end",function(){delete wn[t+":"+r]}),e.on("close",function(){delete wn[t+":"+r]}),e.cert_issuer=a,e.cert_subject=s,e.cert_date=c,e.certid_=l,wn[t+":"+r]=e});d.listen(r.port,function(){console.log("OR : server launched port "+r.port),Us&&setInterval(Uc,xs)}),d.on("OR : clientError",function(e){console.log(e)}),d.on("error",function(e){console.log(e)}),d.on("end",function(e){console.log(e)})}},ic=function(e){try{var t={},r=0;return e=e.split("\r\n"),e.forEach(function(e,i){if(e=e.split(":"),e.length>1&&0!=i){var n=e[0];e=e.map(function(e){return e.trim()}),e.shift(),e=e.join(":"),t[n]=e}else t[r+"a"]=e.join(":"),r++}),t}catch(i){console.log("caller"),console.log(ic.caller.toString().substr(0,50))}},nc=function(e){var t=[],r=0;for(var i in e)isNaN(i.substr(0,1))?t.push(i+": "+e[i]):e[i]?t.push(e[i]):r++;for(var n=0;r>n;n++)t.push("");return t.join("\r\n")},sc=function(e){e.start_&&(e.write(e.start_),delete e.start_)},ac=function(e,t,r){var i=/(((\b(https?|ftp|file):\/\/)|\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,n=!1,s=function(i){var s=e.split(i);if(""===s[s.length-1]&&!r)return n=!0,void 0;var a=e;i=ho(i);var o=t.fake_domain,c=bs[o],l=c.real_domain_s;if(i.host)if(-1!==i.host.indexOf(l)){var h=i.host.split("."),u=c.real_domain_a;a=i.host===c.real_domain?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):2===h.length&&"www"===u[0]||2===u.length&&"www"===h[0]?"http"+Ds+"://"+o+"/"+(i.rest?i.rest:""):"http"+Ds+"://"+o+"/"+fo(uo(i),!0)}else-1===i.host.indexOf(o)&&(a="http"+Ds+"://"+o+"/"+fo(uo(i),!0));return a},a=e.replace(i,s);return n&&(t.pass_+=e),{html:n?e:a,pass:n}},oc=function(e){var t="";return t="",[t,e].join("")},cc=function(e,r){var i=e.toString("hex").split(gs),n=n||[],s=[];return i.forEach(function(e,a){if(r.wait_){var o=parseInt(new t(e,"hex").toString("utf8"),16);return 0===o&&(r.end_=!0,n.push("0d0a300d0a0d0a")),r.clength_+=o?o:0,e.length?a!==i.length-1&&(r.wait_=!1):0===a&&(r.wait_=!1),void 0}var c=r.clength_,l=r.html_.length,h=new t(e,"hex").length+2;(c>=l+h||l+h-2===c)&&s.push(e),l+h-2===c||a===i.length-1?(s=s.join(gs),n.push(s),r.html_.length+=h-2,a!==i.length-1&&(r.wait_=!0),s=[]):r.html_.length+=h}),new t(n.join(""),"hex")},lc=function(e){if(!(e instanceof Uint8Array)){var r=new t(e.length);r.map(e),e=r}return e},hc=function(e){console.log("destroy ws cid"),e.remoteAddress&&e.remotePort?delete wn[e.remoteAddress+":"+e.remotePort]:Rc()},uc=function(e,r){var i=e["Sec-WebSocket-Key"],n=sn.createhash("sha1");n.update(i+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64");var a="HTTP/1.1 101 WebSocket Protocol Handshake\r\n";a+="Upgrade: websocket\r\n",a+="Connection: Upgrade\r\n",a+="Sec-WebSocket-Accept:"+s+"\r\n",a+="Access-Control-Allow-Origin:"+e.Origin+"\r\n",a+="\r\n",console.log("INCOMING SOCKET :"+a),r.ws_=!0,ec(r),r.connected_=!0,r.wsconnected_=!0,r.write(a)},dc=function(e){this.key_=sn.randomBytes(16).toString("base64");var t="GET / HTTP/1.1\r\n";return t+="Host: "+e.ip+(js?":"+e.wsport:"")+"\r\n",t+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0\r\n",t+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",t+="Accept-Language: en-us,en;q=0.5\r\n",t+="Accept-Encoding: gzip, deflate\r\n",t+="Connection: keep-alive, Upgrade\r\n",t+="Sec-WebSocket-Version: 13\r\n",t+="Origin: http://ianonym.com\r\n",t+="Sec-WebSocket-Key: "+this.key_+"\r\n",t+="Pragma: no-cache\r\n",t+="Cache-Control: no-cache\r\n",t+="Upgrade: websocket\r\n",t+="\r\n"},fc=0,pc=0,_c=0,gc=100,mc=0,yc=0,vc=0,bc=100,wc=function(e){d&&(Ho=Date.now()),f&&(Mo=Date.now()),console.log("start websocket");var t=T?new ja("ws://"+e.ip+":"+e.wsport):new WebSocket("ws://"+e.ip+":"+e.wsport);return T||(t.write=t.send),t.binaryType="arraybuffer",t.setNoDelay=function(){},t.connect=function(){},t.WS_OP_=!0,t.onopen=Cc,t.onmessage=function(e){var r=e.data instanceof ArrayBuffer?new Uint8Array(e.data):e.data;Ho&&(fc++,pc+=r.length,_c+=Date.now()-Ho,0===fc%gc&&_c&&(console.log("WS perf (received from WS before processing): "+parseInt(8*pc/(_c/1e3))+" bps - Buffered : "+t.bufferedAmount),fc=0,pc=0,_c=0)),(d||p)&&(Ho=Date.now()),Js&&t===El?(g&&(t.t0=Date.now()),jo&&0!==Ho-jo&&console.log("WS delay between processed and next received: "+(Ho-jo)+" data length "+r.length),Os?t.abstract_client_tls.process(r.toString("binary")):t.abstract_client_tls.process(r),p&&(jo=Date.now()),Mo&&(mc++,yc+=r.length,vc+=Date.now()-Mo,0===mc%bc&&vc&&(console.log("WS perf (received from WS after processed): "+parseInt(8*yc/(vc/1e3))+" bps - Buffered : "+t.bufferedAmount),mc=0,yc=0,vc=0)),f&&(Mo=Date.now())):Qo.call(this,r)},t.onclose=function(){console.log("Websocket closed ws://"+e.ip+":"+e.wsport)},T||(t.destroy=t.close,t.bufferSize=t.bufferedAmount),t.remoteAddress=e.ip,t.remotePort=Dn,t.address=function(){return{port:0,family:"IPv4",address:"127.0.0.1"}},t.setKeepAlive=function(){},t},Ec=function(e){var r=ic(e.toString("utf8")),i=r["Sec-WebSocket-Accept"];if(i){var n=sn.createhash("sha1");n.update(this.key_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11");var s=n.digest("hex");s=new t(s,"hex").toString("base64"),i===s&&(console.log("WS Client says : Handshake successfull"),Cc.call(this))}},Cc=function(){console.log("websocket connected");try{Kl.innerHTML="

    Websocket connected

    "}catch(e){}this.connected_=!0,this.wsconnected_=!0,this.ws_=!0,Us&&(this===Cl&&$i&&rc({params_:{OP:!0,nb_hop:Hn,ws:this}}),!Js||this!==El||!Cs&&$i||(console.log("launch db_cid"),this.db_cid_launched=!0,rc({params_:{OP:!0,nb_hop:Mn,ws:this,db:!0}})),Js||setInterval(xc,1e4))},Sc=function(e,r){r=r||[];var i,n=e.length,s=0,a=0,n=e.length,o=new t(0),c=new t(0);if(0===e.length)return[o,c];var l=e[0];if(e.length>1){var h=128&e[1],u=127&e[1];if(126===u?(s=e.slice(2,4).readUInt(),h=h&&e.slice(4,8),a=h?8:4):127===u?(s=parseInt(e.slice(2,10).toString("hex"),16),h=h&&e.slice(10,14),a=h?14:10):(s=u,h=h&&e.slice(2,6),a=h?6:2),o=e.slice(a,a+s),i=o.length,h&&o.length===s&&0!=s)for(var d=0;i>d;d++)o[d]=o[d]^h[d%4]}return o.length!==s||0===s?(i=o.length,a=n,c=e):r.push(o),n-a>i?Sc(e.slice(i+a),r):1&l?[r.concatBuffers().toString("utf8"),c.toString("utf8")]:2&l?[r.concatBuffers(),c]:void 0},Ac=function(e,r,i){var n,s,a,o=e.length;i=i?sn.randomBytes(4):i;var c=1===r?"81":"82";if(126>o?(s=(i?128|o:o).toString(16),s=1===s.length?"0"+s:s):o>=126&&65535>=o?(c+=i?"FE":"7E",a=2):(c+=i?"FF":"7F",a=8),!s)for(s=o.toString(16),s=s.length%2?"0"+s:s;s.length!==2*a;)s="00"+s;if(c+=s,n=new t(c,"hex"),i)for(var l=e.length,h=new t(l),u=0;l>u;u++)h[u]=e[u]^i[u%4];else h=e;return i?[n,i,h].concatBuffers():[n,h].concatBuffers()},Ic=function(e,r){for(var i=e.remoteAddress+":"+e.remotePort+":"+e.port_+":"+e.i_id,n=e.fake_,s=new t(new t(i,"utf8").toString("hex"),"hex"),a=s.length.toString(16);4!==a.length;)a="0"+a;for(s=[new t(a,"hex"),s].concatBuffers(),a=s.toString("hex");r.length;){var o;o=r.length+a>_n?r.slice(0,_n-a):r,o=[s,o].concatBuffers();var c=new qo(qo.prototype.RELAY_WS,0,o,n.Db_hash).toBuffer();c=new t(n.Kb_cipher.update(c,"hex","hex"),"hex");var l=new Po(n.circId,Po.prototype.RELAY_WS,c); if(n.send(l),!(r.length+a>_n))break;r=r.slice(_n-a)}},Tc=function(e){e.i_id=Wn,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),Wn++,as.push(e.i_id),console.log("INCOMING SOCKET : ------------------------------------- new incoming socket ----------------------------------------------- request "+e.i_id+" on port "+e.remotePort);var r=function(r){var i=r.split(":::");if(3!==i.length){var n={},s=ic(r);if(n.OP=!0,n.nb_hop=Hn,n.one_c=!0,-1!=r.indexOf("WebSocket")){if(console.log("Answer websocket"),uc(s,e),Us){var a="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".net",c="www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com",l=new Date,h=parseInt(No(8).toString("hex"),16),u=al(o+"pub-key.pem",o+"priv-key.pem","pem",h,l,a,c),d=sn.createCredentials({key:Ri.readFileSync(o+"priv-key.pem"),cert:u,servername:a}),f=new tn.createSecurePair(d,!0);e.pair=f;var p=f.cleartext;p.tlspair_=!0,p.server=e.server,p.i_id=e.i_id,p.nb_try=e.nb_try,p.no_exit=e.no_exit,p.squeue_=e.squeue_,p.wsqueue_=e.wsqueue_,p._date_=e._date_,p._init_=e._init_,p.OR_=e.OR_,p.OR_f=e.OR_f,p.way_=e.way_,p.privkey_=e.privkey_,p.connected_=e.connected_,p.wsconnected_=e.wsconnected_,p.address=function(){return{port:e.address().port,family:"IPv4",address:e.address().address}},p.__defineGetter__("remoteAddress",function(){return e.remoteAddress}),p.__defineGetter__("remotePort",function(){return e.remotePort}),p.stream_tor_=new t(0),p.cert_issuer=c,p.cert_subject=a,p.cert_date=l,p.certid_=h,e.write=function(t){e._write(Ac(t,2,!1),null,function(){})},wn[e.remoteAddress+":"+e.remotePort]=p,f.encrypted.pipe(e),p.on("data",function(e){p.t0&&(na++,sa+=e.length,aa+=Date.now()-p.t0,0===na%oa&&aa&&(console.log("cleartext perf: "+parseInt(8*sa/(aa/1e3))+" bps"),na=0,sa=0,aa=0)),Qo.call(p,e)}),p.on("end",function(){e.end()}),p.on("error",function(){e.end()})}return!1}return-1!=r.indexOf("HTTP")&&s.Host&&(n.host=s.Host+":80",e.connected_=!0),n.stream=new t(new t(r,"utf8").toString("hex"),"hex"),5===n.stream.slice(0,1).readUInt()?(e.socks_=!0,e.connected_=!0,e.write(new t("0500","hex")),!1):n}e.params_={host:i[0],OP:!0,nb_hop:i[1],stream:new t(new t(i[2],"utf8").toString("hex"),"hex"),one_c:i[3]},rc(e)};e.on("data",function(i){e.ws_||console.log("INCOMING SOCKET :------------- RECEIVED FROM INCOMING SOCKET ------------ "+e.i_id+" on port "+e.remotePort+" "+e.remoteAddress+" "+e.address().port);var n;if(e.connected_){if(n={},n.OP=!0,n.nb_hop=Hn,n.one_c=!0,n.host=e.host_?e.host_:!1,e.params_?e.params_.host=n.host:e.params_=n,n.stream=n.host?i:!1,n.stream)if(e.fake_){var s=function(e){return function(){Ic(this,e)}};e.wsqueue_.push(s(i).bind(e))}else{var s=function(t){return function(){this.params_.stream=t,rc(e)}};e.squeue_.push(s(i).bind(e))}if(e.ws_)return e.wsconnected_?(e.pair&&(u&&(e.pair.cleartext.t0=Date.now()),_&&(e.pair.encrypted.t0=Date.now())),Qo.call(this,i),void 0):(console.log("server ws not connected"),uc(ic(i.toString("utf8")),e),void 0);if(e.socks_&&!n.stream){switch(i.slice(3,4).readUInt()){case 1:e.host_=Lo(i.slice(4,8))+":"+i.slice(8).readUInt();break;case 3:var o=i.slice(4,5).readUInt();if(!Rs){e.host_=i.slice(5,5+o).toString("utf8")+":"+i.slice(o+5).readUInt();break}if(!e.ws_){var c=En[i.slice(5,5+o).toString("utf8")];if(c){var l=e.remoteAddress+":"+e.remotePort;Cn[l]=e,e.fake_=c.circ_,e.port_=i.slice(o+5).readUInt(),e.host_=i.slice(5,5+o).toString("utf8");break}e.host_=i.slice(5,5+o).toString("utf8")+":"+i.slice(o+5).readUInt(),console.log("outside domain "+e.host_+" request "+e.i_id),e.__outside__=!0;break}default:return}if(e.host_===Rn+":"+Dn&&(e.ws_=!0,e.setNoDelay(!0)),n.host=e.host_,console.log("INCOMING SOCKET : socks request "+e.i_id+" host "+e.host_+" remote "+e.remoteAddress+":"+e.remotePort),a&&C){var h=["www.lepoint.fr:80","212.95.70.230:80","www.monip.org:80","217.70.182.162:80"];if(e.__connect__=h,443===parseInt(e.host_.split(":")[1]))return e.write([new t("050200","hex"),i.slice(3)].concatBuffers()),void 0}return e.start_=[new t("050000","hex"),i.slice(3)].concatBuffers(),sc(e),void 0}}else n=r(i.toString("utf8"));if(n&&n.stream)if(e.fake_){var d=e.wsqueue_[0];e.wsqueue_.shift(),d()}else{if(Rs&&e.__outside__)return e.write(new t(ao(),"utf8")),void 0;if(a&&C){var f=ic(n.stream.toString("utf8"));if(f.Host=f.Host||"",-1===["www.lepoint.fr","www.monip.org"].indexOf(f.Host)||-1===e.__connect__.indexOf(e.host_))return e.write(new t(co(),"utf8")),void 0}e._data_=!1,1===e.squeue_.length&&e.squeue_[0]()}}),e.on("end",function(){console.log("INCOMING SOCKET : End -------------------------end incoming socket------------------------------------- request "+e.i_id+" host "+e.host_),Bc(),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("close",function(){console.log("INCOMING SOCKET : Close -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e.on("error",function(){console.log("INCOMING SOCKET : Error -------------------------end incoming socket------------------------------------- request "+e.i_id),setTimeout(kc,0),os.push(e.i_id),e.ws_&&hc(e);try{e.cid_.destroy_cid(e,!0)}catch(t){}}),e._write_=function(t){if(!e.destroyed)try{e.write(t)}catch(r){}},e._init_=Xo},xc=function(){var e=[],t=[],i=0,n=0,s=!1,o=(new Date).valueOf();for(var c in gn)e.push([c,gn[c]]);var l=0;e.forEach(function(e){Object.keys(e[1]).forEach(function(r){if(!isNaN(r)&&null!=r){var s=e[1][r],a=s.last_?s.last_:null;if(a)if(Object.keys(s).forEach(function(e){isNaN(e)||null==e||t.push(s[e].i_id+" "+s[e].remotePort)}),Jn>i&&(o-s.time_Qn||s.time_average=0&&(!s.bad_||s.time_averagens&&!zi){var c;for(var r in s)if(!isNaN(r)&&null!=r&&"function"!=typeof r){c=!0;break}c?(console.log("download in progres, not changing DB CID ----------"),s.time_=Date.now()):(console.log("monitor UPDATE DB CID ---------"+s.circId),s.circuit_destroy())}if(Us&&s.last_){var h=s.last_;h.server_&&s!==Ss&&h.server_.ip===Fi&&h.server_.port===qi&&(console.log("destroying ordb last CIC "+s.circId),s.circuit_destroy())}}else if(s.bad_){var c;for(var r in s)if(!isNaN(r)&&null!=r){c=!0;break}c||(console.log("monitor DESTROY "+s.circId),s.circuit_destroy())}else s.bad_=!0}})});var h=[];as.forEach(function(e){-1===os.indexOf(e)&&h.push(e)}),Qn=i,ys=n?l/n:ys,(r||a)&&Li("MONITOR ---- "+i+" circuits on "+$n+" TIME_AVERAGE "+ys),es=i>=$n&&!s?!Us||Ss?!0:!1:!1,!es&&Zi&&(E||(js||zs?El&&(console.log("establish new circuit"),ks||Ss?rc({params_:{OP:!0,nb_hop:Hn,ws:El}}):(El.tls_connected||delete El.db_cid_launched,console.log("monitor create db circuit"),rc({params_:{OP:!0,nb_hop:Mn,ws:El,db:!0}}))):rc({params_:{OP:!0,nb_hop:Hn}}))),Us&&Dc()},Bc=function(){var e=[];for(var t in bn)e.push([t,bn[t]]);console.log("----------------- "+e.length+" sockets out----------------"),e.forEach(function(e){Object.keys(e[1]).forEach(function(t){isNaN(t)||null==t||e[1][t]})}),console.log("-----------------")},kc=function(){var e=[];for(var t in bn)e.push([t,bn[t]]);e.forEach(function(e){var t;Object.keys(e[1]).forEach(function(r){if(!isNaN(r)&&null!=r&&"function"!=typeof r){var i,n=e[1][r];n&&n.prev_&&n.prev_.socket_&&n.prev_.socket_.remoteAddress&&(i=!0,t=!0),i||n&&(console.log("clearing circuit out n "+r+" CIC "+n.circId),n.circuit_destroy(),delete e[1][r])}}),t||(console.log("delete OR_sock "+e[0]),delete bn[e[0]])})},Rc=function(){for(var e in wn){var t=wn[e];t?t.remoteAddress||(console.log("deleting or_sock_in remoteadd "+e),delete wn[e]):(console.log("deleting or_sock_in "+e),delete wn[e])}kc()},Uc=function(){for(var e in wn)parseInt(wn[e].address().port)===parseInt(qi)&&Object.keys(wn[e]).forEach(function(r){if(!isNaN(r)&&null!=r)try{var i=wn[e][r];i.db_test&&i.db_test.forEach(function(e){clearTimeout(e)}),i.db_test=[];var n=function(){i.destroyed_||(console.log("Destroying db_query_no_answer CID "+i.circId+" remote "+(i.socket_?i.socket_.remoteAddress:"null")),i.circuit_destroy(),i.destroyed_=!0)};if(0!==i.circId)if(i.socket_&&!i.destroyed_){var s;for(var a in i)if(!isNaN(a)&&null!=a&&(Tn[i.socket_.remotePort+"-"+i.socket_.remoteAddress+"-"+i.circId+"-"+a]||xn[i.socket_.remotePort+"-"+i.socket_.remoteAddress+"-"+i.circId+"-"+a])){s=!0;break}if(s)console.log("Download in progress - Not testing CID "+i.circId+" remote "+i.socket_.remoteAddress+" "+Date.now());else{console.log("Testing CID "+i.circId+" remote "+i.socket_.remoteAddress+" "+Date.now());var o=No(16),c={d_length:0,hash_:new t("0000000000000000000000000000000000000000","hex")};i.send_db_query(c,o),i.db_test.push(setTimeout(n,Ts))}}else n()}catch(l){}})},Dc=function(){if(Eh){var e=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="P2P (Peersm, BitTorrent) and web anonymized circuits : "+e+(e>1?" circuits":" circuit")}};if(A||Ms){var Nc=-1,Lc=-1;L.prototype=Error.prototype;var Oc=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"utf-8"}],heading:"The Encoding"},{encodings:[{labels:["cp864","ibm864"],name:"ibm864"},{labels:["cp866","ibm866"],name:"ibm866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso_8859-2","l2","latin2"],name:"iso-8859-2"},{labels:["csisolatin3","iso-8859-3","iso_8859-3","iso-ir-109","l3","latin3"],name:"iso-8859-3"},{labels:["csisolatin4","iso-8859-4","iso_8859-4","iso-ir-110","l4","latin4"],name:"iso-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso_8859-5","iso-ir-144"],name:"iso-8859-5"},{labels:["arabic","csisolatinarabic","ecma-114","iso-8859-6","iso_8859-6","iso-ir-127"],name:"iso-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso_8859-7","iso-ir-126"],name:"iso-8859-7"},{labels:["csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-i","iso-ir-138","iso_8859-8","visual"],name:"iso-8859-8"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","l6","latin6"],name:"iso-8859-10"},{labels:["iso-8859-13"],name:"iso-8859-13"},{labels:["iso-8859-14","iso8859-14"],name:"iso-8859-14"},{labels:["iso-8859-15","iso_8859-15"],name:"iso-8859-15"},{labels:["iso-8859-16"],name:"iso-8859-16"},{labels:["koi8-r","koi8_r"],name:"koi8-r"},{labels:["koi8-u"],name:"koi8-u"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["iso-8859-11","tis-620","windows-874"],name:"windows-874"},{labels:["windows-1250","x-cp1250"],name:"windows-1250"},{labels:["windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ascii","ansi_x3.4-1968","csisolatin1","iso-8859-1","iso8859-1","iso_8859-1","l1","latin1","us-ascii","windows-1252"],name:"windows-1252"},{labels:["cp1253","windows-1253"],name:"windows-1253"},{labels:["csisolatin5","iso-8859-9","iso-ir-148","l5","latin5","windows-1254"],name:"windows-1254"},{labels:["cp1255","windows-1255"],name:"windows-1255"},{labels:["cp1256","windows-1256"],name:"windows-1256"},{labels:["windows-1257"],name:"windows-1257"},{labels:["cp1258","windows-1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gbk","gb_2312","gb_2312-80","iso-ir-58","x-gbk"],name:"gbk"},{labels:["gb18030"],name:"gb18030"},{labels:["hz-gb-2312"],name:"hz-gb-2312"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"euc-jp"},{labels:["csiso2022jp","iso-2022-jp"],name:"iso-2022-jp"},{labels:["csshiftjis","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"shift_jis"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"euc-kr"},{labels:["csiso2022kr","iso-2022-kr"],name:"iso-2022-kr"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["utf-16","utf-16le"],name:"utf-16"},{labels:["utf-16be"],name:"utf-16be"}],heading:"Legacy utf-16 encodings"}],Pc={},Fc={};Oc.forEach(function(e){e.encodings.forEach(function(e){Pc[e.name]=e,e.labels.forEach(function(t){Fc[t]=e})})});var qc={};Pc["utf-8"].getEncoder=function(e){return new V(e)},Pc["utf-8"].getDecoder=function(e){return new z(e)},function(){["ibm864","ibm866","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-10","iso-8859-13","iso-8859-14","iso-8859-15","iso-8859-16","koi8-r","koi8-u","macintosh","windows-874","windows-1250","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","x-mac-cyrillic"].forEach(function(e){var t=Pc[e],r=qc[e];t.getDecoder=function(e){return new K(r,e)},t.getEncoder=function(e){return new G(r,e)}})}(),Pc.gbk.getEncoder=function(e){return new W(!1,e)},Pc.gbk.getDecoder=function(e){return new Y(!1,e)},Pc.gb18030.getEncoder=function(e){return new W(!0,e)},Pc.gb18030.getDecoder=function(e){return new Y(!0,e)},Pc["hz-gb-2312"].getEncoder=function(e){return new X(e)},Pc["hz-gb-2312"].getDecoder=function(e){return new Q(e)},Pc.big5.getEncoder=function(e){return new Z(e)},Pc.big5.getDecoder=function(e){return new J(e)},Pc["euc-jp"].getEncoder=function(e){return new et(e)},Pc["euc-jp"].getDecoder=function(e){return new $(e)},Pc["iso-2022-jp"].getEncoder=function(e){return new rt(e)},Pc["iso-2022-jp"].getDecoder=function(e){return new tt(e)},Pc.shift_jis.getEncoder=function(e){return new nt(e)},Pc.shift_jis.getDecoder=function(e){return new it(e)},Pc["euc-kr"].getEncoder=function(e){return new at(e)},Pc["euc-kr"].getDecoder=function(e){return new st(e)},Pc["iso-2022-kr"].getEncoder=function(e){return new ct(e)},Pc["iso-2022-kr"].getDecoder=function(e){return new ot(e)},Pc["utf-16"].getEncoder=function(e){return new ht(!1,e)},Pc["utf-16"].getDecoder=function(e){return new lt(!1,e)},Pc["utf-16be"].getEncoder=function(e){return new ht(!0,e)},Pc["utf-16be"].getDecoder=function(e){return new lt(!0,e)};var Hc="utf-8";dt.prototype={encode:function(e,t){e=e?String(e):"",t=Object(t),this._streaming||(this._encoder=this._encoding.getEncoder(this._options)),this._streaming=Boolean(t.stream);for(var r=[],i=new U(r),n=new D(e);n.get()!==Lc;)this._encoder.encode(i,n);if(!this._streaming){var s;do s=this._encoder.encode(i,n);while(s!==Nc);this._encoder=null}return new Uint8Array(r)}},ft.prototype={decode:function(e,t){if(e&&!("buffer"in e&&"byteOffset"in e&&"byteLength"in e))throw new TypeError("Expected ArrayBufferView");e||(e=new Uint8Array(0)),t=Object(t),this._streaming||(this._decoder=this._encoding.getDecoder(this._options)),this._streaming=Boolean(t.stream);var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=new R(r);this._BOMseen||(this._BOMseen=!0,ut(this._encoding.name,i));for(var n,s=new N;i.get()!==Nc;)n=this._decoder.decode(i),null!==n&&n!==Lc&&s.emit(n);if(!this._streaming){do n=this._decoder.decode(i),null!==n&&n!==Lc&&s.emit(n);while(n!==Lc&&i.get()!=Nc);this._decoder=null}return s.string()}};var Mc={};!function(){var e=Mc,t=e.util=e.util||{};"undefined"!=typeof process&&process.nextTick?(t.nextTick=process.nextTick,t.setImmediate="function"==typeof setImmediate?setImmediate:t.nextTick):"function"==typeof setImmediate?(t.setImmediate=setImmediate,t.nextTick=function(e){return setImmediate(e)}):(t.setImmediate=function(e){setTimeout(e,0)},t.nextTick=t.setImmediate),t.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.ByteBuffer=function(e){this.data=e||"",this.read=0},t.ByteBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteBuffer.prototype.putByte=function(e){return this.data+=String.fromCharCode(e),this},t.ByteBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this},t.ByteBuffer.prototype.putBytes=function(e){return this.data+=e,this},t.ByteBuffer.prototype.putString=function(e){return this.data+=t.encodeUtf8(e),this},t.ByteBuffer.prototype.putInt16=function(e){return this.data+=String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt24=function(e){return this.data+=String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt32=function(e){return this.data+=String.fromCharCode(255&e>>24)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e),this},t.ByteBuffer.prototype.putInt16Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8),this},t.ByteBuffer.prototype.putInt24Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e>>16),this},t.ByteBuffer.prototype.putInt32Le=function(e){return this.data+=String.fromCharCode(255&e)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>24),this},t.ByteBuffer.prototype.putInt=function(e,t){do t-=8,this.data+=String.fromCharCode(255&e>>t);while(t>0);return this},t.ByteBuffer.prototype.putSignedInt=function(e,t){return 0>e&&(e+=2<0);return t},t.ByteBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},t.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},t.ByteBuffer.prototype.bytes=function(e){return"undefined"==typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},t.ByteBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},t.ByteBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},t.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteBuffer.prototype.copy=function(){var e=t.createBuffer(this.data);return e.read=this.read,e},t.ByteBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},t.ByteBuffer.prototype.toHex=function(){for(var e="",t=this.read;tr&&(e+="0"),e+=r.toString(16)}return e},t.ByteBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())},t.createBuffer=function(e,r){return r=r||"raw",void 0!==e&&"utf8"===r&&(e=t.encodeUtf8(e)),new t.ByteBuffer(e)},t.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),t>>>=1,t>0&&(e+=e);return r},t.xorBytes=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},t.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24)+String.fromCharCode(255&e>>16)+String.fromCharCode(255&e>>8)+String.fromCharCode(255&e)};var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,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,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];t.encode64=function(e,t){for(var i,n,s,a="",o="",c=0;c>2),a+=r.charAt((3&i)<<4|n>>4),isNaN(n)?a+="==":(a+=r.charAt((15&n)<<2|s>>6),a+=isNaN(s)?"=":r.charAt(63&s)),t&&a.length>t&&(o+=a.substr(0,t)+"\r\n",a=a.substr(t));return o+=a},t.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,s,a="",o=0;o>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==s&&(a+=String.fromCharCode((3&n)<<6|s)));return a},t.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},t.decodeUtf8=function(e){return decodeURIComponent(escape(e))},t.deflate=function(e,r,i){if(r=t.decode64(e.deflate(t.encode64(r)).rval),i){var n=2,s=r.charCodeAt(1);32&s&&(n=6),r=r.substring(n,r.length-4)}return r},t.inflate=function(e,r){var i=e.inflate(t.encode64(r)).rval;return null===i?null:t.decode64(i)};var n=function(e,r,i){if(!e)throw{message:"WebStorage not available."};var n;if(null===i?n=e.removeItem(r):(i=t.encode64(JSON.stringify(i)),n=e.setItem(r,i)),"undefined"!=typeof n&&n.rval!==!0)throw n.error},s=function(e,r){if(!e)throw{message:"WebStorage not available."};var i=e.getItem(r);if(e.init)if(null===i.rval){if(i.error)throw i.error;i=null}else i=i.rval;return null!==i&&(i=JSON.parse(t.decode64(i))),i},a=function(e,t,r,i){var a=s(e,t);null===a&&(a={}),a[r]=i,n(e,t,a)},o=function(e,t,r){var i=s(e,t);return null!==i&&(i=r in i?i[r]:null),i},c=function(e,t,r){var i=s(e,t);if(null!==i&&r in i){delete i[r];var a=!0;for(var o in i){a=!1;break}a&&(i=null),n(e,t,i)}},l=function(e,t){n(e,t,null)},h=function(e,t,r){var i=null;"undefined"==typeof r&&(r=["web","flash"]);var n,s=!1,a=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw{message:"Flash local storage not available."};i=e.apply(this,t),s="flash"===n}("web"===n||"both"===n)&&(t[0]=localStorage,i=e.apply(this,t),s=!0)}catch(c){a=c}if(s)break}if(!s)throw a;return i};t.setItem=function(e,t,r,i,n){h(a,arguments,n)},t.getItem=function(e,t,r,i){return h(o,arguments,i)},t.removeItem=function(e,t,r,i){h(c,arguments,i)},t.clearItems=function(e,t,r){h(l,arguments,r)},t.parseUrl=function(e){var t=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;t.lastIndex=0;var r=t.exec(e),i=null===r?null:{full:e,scheme:r[1],host:r[2],port:r[3],path:r[4]};return i&&(i.fullHost=i.host,i.port?80!==i.port&&"http"===i.scheme?i.fullHost+=":"+i.port:443!==i.port&&"https"===i.scheme&&(i.fullHost+=":"+i.port):"http"===i.scheme?i.port=80:"https"===i.scheme&&(i.port=443),i.full=i.scheme+"://"+i.fullHost),i};var u=null;t.getQueryVariables=function(e){var t,r=function(e){for(var t={},r=e.split("&"),i=0;i0?(n=r[i].substring(0,a),s=r[i].substring(a+1)):(n=r[i],s=null),n in t||(t[n]=[]),n in Object.prototype||null===s||t[n].push(unescape(s))}return t};return"undefined"==typeof e?(null===u&&(u="undefined"==typeof window?{}:r(window.location.search.substring(1))),t=u):t=r(e),t},t.parseFragment=function(e){var r=e,i="",n=e.indexOf("?");n>0&&(r=e.substring(0,n),i=e.substring(n+1));var s=r.split("/");s.length>0&&""===s[0]&&s.shift();var a=""===i?{}:t.getQueryVariables(i);return{pathString:r,queryString:i,path:s,query:a}},t.makeRequest=function(e){var r=t.parseFragment(e),i={path:r.pathString,query:r.queryString,getPath:function(e){return"undefined"==typeof e?r.path:r.path[e]},getQuery:function(e,t){var i;return"undefined"==typeof e?i=r.query:(i=r.query[e],i&&"undefined"!=typeof t&&(i=i[t])),i},getQueryLast:function(e,t){var r,n=i.getQuery(e);return r=n?n[n.length-1]:t}};return i},t.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var i=jQuery.param(t||{});return r=r||"",e+(i.length>0?"?"+i:"")+(r.length>0?"#"+r:"")},t.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var i=0,n=t.length;n>i;){var s=t[i++];if(i==n)e[s]=r;else{var a=s in e;(!a||a&&"object"!=typeof e[s]||a&&null===e[s])&&(e[s]={}),e=e[s]}}},t.getPath=function(e,t,r){for(var i=0,n=t.length,s=!0;s&&n>i&&"object"==typeof e&&null!==e;){var a=t[i++];s=a in e,s&&(e=e[a])}return s?e:r},t.deletePath=function(e,t){if("object"==typeof e&&null!==e)for(var r=0,i=t.length;i>r;){var n=t[r++];if(r==i)delete e[n];else{if(!(n in e)||"object"!=typeof e[n]||null===e[n])break;e=e[n]}}},t.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.format=function(e){for(var t,r,i=/%./g,n=0,s=[],a=0;t=i.exec(e);){r=e.substring(a,i.lastIndex-2),r.length>0&&s.push(r),a=i.lastIndex;var o=t[0][1];switch(o){case"s":case"o":n");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(a)),s.join("")},t.formatNumber=function(e,t,r,i){var n=e,s=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,o=void 0===i?".":i,c=0>n?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",h=l.length>3?l.length%3:0;return c+(h?l.substr(0,h)+o:"")+l.substr(h).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?a+Math.abs(n-l).toFixed(s).slice(2):"")},t.formatSize=function(e){return e=e>=1073741824?t.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?t.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?t.formatNumber(e/1024,0)+" KiB":t.formatNumber(e,0)+" bytes"},t.bytesFromIP=function(e){return-1!==e.indexOf(".")?t.bytesFromIPv4(e):-1!==e.indexOf(":")?t.bytesFromIPv6(e):null},t.bytesFromIPv4=function(e){if(e=e.split("."),4!==e.length)return null;for(var r=t.createBuffer(),i=0;is;++s)if(e[s]&&0!==e[s].length){var a=t.hexToBytes(e[s]);a.length<2&&n.putByte(0),n.putBytes(a)}else n.fillWithByte(0,i),i=0;return n.getBytes()},t.bytesToIP=function(e){return 4===e.length?t.bytesToIPv4(e):16===e.length?t.bytesToIPv6(e):null},t.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;ri[n].end-i[n].start&&(n=i.length-1)):i.push({start:c,end:c})}r.push(a)}if(i.length>0){var l=i[n];l.end-l.start>0&&(r.splice(l.start,l.end-l.start+1,""),0===l.start&&r.unshift(""),7===l.end&&r.push(""))}return r.join(":")}}(),Os||(Mc.util.ByteBuffer=function(){},Mc.util.createBuffer=function(e,r){var i=new Mc.util.ByteBuffer;return e?(i.data=new t(e,r||"binary"),i.length_=i.data.length):(i.data=new t(Ls),i.length_=0),i.read=0,i},Mc.util.ByteBuffer.prototype.length=function(){return this.length_-this.read},Mc.util.ByteBuffer.prototype.isEmpty=function(){return 0===this.length_-this.read},Mc.util.ByteBuffer.prototype.putByte=function(e){this.data.length>=this.length_+1?this.data.writeUInt(e,this.length_,1):this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array([e])].concatBuffers():new Uint8Array([e]),this.length_+=1},Mc.util.ByteBuffer.prototype.getByte=function(){return this.data[this.read++]},Mc.util.ByteBuffer.prototype.at=function(e){return this.data[this.read+e]},Mc.util.ByteBuffer.prototype.last=function(){return this.data[this.length_-1]},Mc.util.ByteBuffer.prototype.fillWithByte=function(e,t){if(this.data.length>=this.length_+t)for(var r=this.length_,i=0;t>i;i++)this.data[r+i]=e;else{for(var n=[],i=0;t>i;i++)n.push(e);this.data=this.length_?[this.data.slice(0,this.length_),new Uint8Array(n)].concatBuffers():new Uint8Array(n)}this.length_+=t},Mc.util.ByteBuffer.prototype.putBytes=function(e){var r;r="string"==typeof e?new t(e,"binary"):e;var i=r.length;this.data.length>=this.length_+i?this.data.set(r,this.length_):this.data=this.length_?[this.data.slice(0,this.length_),r].concatBuffers():r,this.length_+=i},Mc.util.ByteBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e).toString("binary"),this.read+=e):0===e?t="":(t=this.data.slice(this.read,this.length_).toString("binary"),this.clear()),t},Mc.util.ByteBuffer.prototype.putBuffer=function(e){this.data.length>=this.length_+e.length_?e.length_&&this.data.set(e.data.slice(0,e.length_),this.length_):this.data=this.length_?[this.data.slice(0,this.length_),e.data.slice(0,e.length_)].concatBuffers():e.data.slice(0,e.length_),this.length_+=e.length_,e.clear()},Mc.util.ByteBuffer.prototype.bytes=function(e){return e?this.data.slice(this.read,this.read+e).toString("binary"):this.data.slice(this.read,this.length_).toString("binary")},Mc.util.ByteBuffer.prototype.putInt16=function(e){this.data.length>=this.length_+2?this.data.writeUInt(e,this.length_,2):this.data=this.length_?[this.data.slice(0,this.length_),new t(2).writeUInt(e)].concatBuffers():new t(2).writeUInt(e),this.length_+=2},Mc.util.ByteBuffer.prototype.putInt24=function(e){this.data.length>=this.length_+3?this.data.writeUInt(e,this.length_,3):this.data=this.length_?[this.data.slice(0,this.length_),new t(3).writeUInt(e)].concatBuffers():new t(3).writeUInt(e),this.length_+=3},Mc.util.ByteBuffer.prototype.putInt32=function(e){this.data.length>=this.length_+4?this.data.writeUInt(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new t(4).writeUInt(e)].concatBuffers():new t(4).writeUInt(e),this.length_+=4},Mc.util.ByteBuffer.prototype.putInt32Le=function(e){this.data.length>=this.length_+4?this.data.writeUIntLE(e,this.length_,4):this.data=this.length_?[this.data.slice(0,this.length_),new t(4).writeUIntLE(e)].concatBuffers():new t(4).writeUIntLE(e),this.length_+=4},Mc.util.ByteBuffer.prototype.putInt=function(e,r){r/=8,this.data.length>=this.length_+r?this.data.writeUInt(e,this.length_,r):this.data=this.length_?[this.data.slice(0,this.length_),new t(r).writeUInt(e)].concatBuffers():new t(r).writeUInt(e),this.length_+=r},Mc.util.ByteBuffer.prototype.getInt16=function(){var e=this.data.readUInt(this.read,2);return this.read+=2,e},Mc.util.ByteBuffer.prototype.getInt24=function(){var e=this.data.readUInt(this.read,3);return this.read+=3,e},Mc.util.ByteBuffer.prototype.getInt32=function(){var e=this.data.readUInt(this.read,4);return this.read+=4,e},Mc.util.ByteBuffer.prototype.getInt32Le=function(){var e=this.data.readUIntLE(this.read,4); return this.read+=4,e},Mc.util.ByteBuffer.prototype.getInt=function(e){e/=8;var t=this.data.readUInt(this.read,e);return this.read+=e,t},Mc.util.ByteBuffer.prototype.compact=function(){if(this.length()){var e=this.data.slice(this.read,this.length_);this.data=new t(Math.max(Ls,e.length)),this.data.set(e),this.length_=e.length,this.read=0}else this.clear()},Mc.util.ByteBuffer.prototype.clear=function(){this.data=new t(Ls),this.length_=0,this.read=0},Mc.util.ByteBuffer.prototype.truncate=function(e){var r=Math.max(0,this.length()-e),i=this.data.slice(this.read,r);this.data=new t(Ls),this.data.length>i.length?this.data.set(i):this.data=i,this.length_=i.length,this.read=0},Mc.util.ByteBuffer.prototype.toHex=function(){return this.data.slice(0,this.length_).toString("hex")},Mc.util.ByteBuffer.prototype.toString=function(){return new t(this.data.slice(0,this.length_).toString("binary"),"utf8").toString("utf8")}),function(){var e=Mc.sha1=Mc.sha1||{};Mc.md=Mc.md||{},Mc.md.algorithms=Mc.md.algorithms||{},Mc.md.sha1=Mc.md.algorithms.sha1=e;var t=null,r=!1,i=function(){t=String.fromCharCode(128),t+=Mc.util.fillString(String.fromCharCode(0),64),r=!0},n=function(e,t,r){for(var i,n,s,a,o,c,l,h,u=r.length();u>=64;){for(n=e.h0,s=e.h1,a=e.h2,o=e.h3,c=e.h4,h=0;16>h;++h)i=r.getInt32(),t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;20>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=o^s&(a^o),i=(n<<5|n>>>27)+l+c+1518500249+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;32>h;++h)i=t[h-3]^t[h-8]^t[h-14]^t[h-16],i=i<<1|i>>>31,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;40>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+1859775393+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;60>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s&a|o&(s^a),i=(n<<5|n>>>27)+l+c+2400959708+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;for(;80>h;++h)i=t[h-6]^t[h-16]^t[h-28]^t[h-32],i=i<<2|i>>>30,t[h]=i,l=s^a^o,i=(n<<5|n>>>27)+l+c+3395469782+i,c=o,o=a,a=s<<30|s>>>2,s=n,n=i;e.h0+=n,e.h1+=s,e.h2+=a,e.h3+=o,e.h4+=c,u-=64}};e.create=function(){r||i();var e=null,s=Mc.util.createBuffer(),a=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};return o.start=function(){return o.messageLength=0,s=Mc.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o},o.start(),o.update=function(t,r){return"utf8"===r&&(t=Mc.util.encodeUtf8(t)),o.messageLength+=t.length,s.putBytes(t),n(e,a,s),(s.read>2048||0===s.length())&&s.compact(),o},o.digest=function(){var r=o.messageLength,i=Mc.util.createBuffer();i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(255&r>>>29),i.putInt32(4294967295&r<<3);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(c,a,i);var l=Mc.util.createBuffer();return l.putInt32(c.h0),l.putInt32(c.h1),l.putInt32(c.h2),l.putInt32(c.h3),l.putInt32(c.h4),l},o.digest2=function(){var r=o.messageLength,i=Mc.util.createBuffer(),c=Mc.util.createBuffer(s.data.slice(s.read)),l=a.slice(0);i.putBytes(s.bytes()),i.putBytes(t.substr(0,64-(r+8)%64)),i.putInt32(255&r>>>29),i.putInt32(4294967295&r<<3);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};n(h,a,i);var u=Mc.util.createBuffer();return u.putInt32(h.h0),u.putInt32(h.h1),u.putInt32(h.h2),u.putInt32(h.h3),u.putInt32(h.h4),s=c,a=l,u},o},e.createhash=function(){var t=e.create(),r=t.update;return t.update=function(e){return r(e.toString("binary"))},t.digest=function(){return t.digest2().toHex()},t}}(),function(){var e=Mc;e.hmac={};var t=e.hmac;t.create=function(){var t=null,r=null,i=null,n=null,s={};return s.start=function(s,a){if(null!==s)if(s.constructor==String){if(s=s.toLowerCase(),!(s in e.md.algorithms))throw'Unknown hash algorithm "'+s+'"';r=e.md.algorithms[s].create()}else r=s;if(null===a)a=t;else{if(a.constructor==String)a=e.util.createBuffer(a);else if(a.constructor==Array){var o=a;a=e.util.createBuffer();for(var c=0;cr.blockLength&&(r.start(),r.update(a.bytes()),a=r.digest()),i=e.util.createBuffer(),n=e.util.createBuffer(),l=a.length();for(var c=0;l>c;++c){var o=a.at(c);i.putByte(54^o),n.putByte(92^o)}if(lc;++c)i.putByte(54),n.putByte(92);t=a,i=i.bytes(),n=n.bytes()}r.start(),r.update(i)},s.update=function(e){r.update(e)},s.getMac=function(){var e=r.digest().bytes();return r.start(),r.update(n),r.update(e),r.digest()},s.digest=s.getMac,s}}(),function(){var e,t,r,i,n,s=!1,a=4,o=function(){s=!0,r=[0,1,2,4,8,16,32,64,128,27,54];for(var a=new Array(256),o=0;128>o;++o)a[o]=o<<1,a[o+128]=283^o+128<<1;e=new Array(256),t=new Array(256),i=new Array(4),n=new Array(4);for(var o=0;4>o;++o)i[o]=new Array(256),n[o]=new Array(256);for(var c,l,h,u,d,f,p,_=0,g=0,o=0;256>o;++o){u=g^g<<1^g<<2^g<<3^g<<4,u=99^(u>>8^255&u),e[_]=u,t[u]=_,d=a[u],c=a[_],l=a[c],h=a[l],f=d<<24^u<<16^u<<8^(u^d),p=(c^l^h)<<24^(_^h)<<16^(_^l^h)<<8^(_^c^h);for(var m=0;4>m;++m)i[m][_]=f,n[m][u]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===_?_=g=1:(_=c^a[a[a[c^h]]],g^=a[a[g]])}},c=function(t,i){for(var s,o=t.slice(0),c=1,l=o.length,h=l+6+1,u=a*h,d=l;u>d;++d)s=o[d-1],0===d%l?(s=e[255&s>>>16]<<24^e[255&s>>>8]<<16^e[255&s]<<8^e[s>>>24]^r[c]<<24,c++):l>6&&4===d%l&&(s=e[s>>>24]<<24^e[255&s>>>16]<<16^e[255&s>>>8]<<8^e[255&s]),o[d]=o[d-l]^s;if(i){for(var f,p=n[0],_=n[1],g=n[2],m=n[3],y=o.slice(0),u=o.length,d=0,v=u-a;u>d;d+=a,v-=a)if(0===d||d===u-a)y[d]=o[v],y[d+1]=o[v+3],y[d+2]=o[v+2],y[d+3]=o[v+1];else for(var b=0;a>b;++b)f=o[v+b],y[d+(3&-b)]=p[e[f>>>24]]^_[e[255&f>>>16]]^g[e[255&f>>>8]]^m[e[255&f]];o=y}return o},l=function(r,s,a,o){var c,l,h,u,d,f=r.length/4-1;o?(c=n[0],l=n[1],h=n[2],u=n[3],d=t):(c=i[0],l=i[1],h=i[2],u=i[3],d=e);var p,_,g,m,y,v,b;p=s[0]^r[0],_=s[o?3:1]^r[1],g=s[2]^r[2],m=s[o?1:3]^r[3];for(var w=3,E=1;f>E;++E)y=c[p>>>24]^l[255&_>>>16]^h[255&g>>>8]^u[255&m]^r[++w],v=c[_>>>24]^l[255&g>>>16]^h[255&m>>>8]^u[255&p]^r[++w],b=c[g>>>24]^l[255&m>>>16]^h[255&p>>>8]^u[255&_]^r[++w],m=c[m>>>24]^l[255&p>>>16]^h[255&_>>>8]^u[255&g]^r[++w],p=y,_=v,g=b;a[0]=d[p>>>24]<<24^d[255&_>>>16]<<16^d[255&g>>>8]<<8^d[255&m]^r[++w],a[o?3:1]=d[_>>>24]<<24^d[255&g>>>16]<<16^d[255&m>>>8]<<8^d[255&p]^r[++w],a[2]=d[g>>>24]<<24^d[255&m>>>16]<<16^d[255&p>>>8]<<8^d[255&_]^r[++w],a[o?1:3]=d[m>>>24]<<24^d[255&p>>>16]<<16^d[255&_>>>8]<<8^d[255&g]^r[++w]},h=function(e,t,r,i,n){function h(){if(i)for(var e=0;a>e;++e)b[e]=y.getInt32();else for(var e=0;a>e;++e)b[e]=E[e]^y.getInt32();if(l(T,b,w,i),i){for(var e=0;a>e;++e)v.putInt32(E[e]^w[e]);E=b.slice(0)}else{for(var e=0;a>e;++e)v.putInt32(w[e]);E=w}}function u(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e){var t=b[e]^w[e];i||(b[e]=t),v.putInt32(t)}}function d(){l(T,b,w,!1);for(var e=0;a>e;++e)b[e]=y.getInt32();for(var e=0;a>e;++e)v.putInt32(b[e]^w[e]),b[e]=w[e]}function f(){l(T,b,w,!1);for(var e=a-1;e>=0;--e){if(4294967295!==b[e]){++b[e];break}b[e]=0}for(var e=0;a>e;++e)v.putInt32(y.getInt32()^w[e])}var p=null;if(s||o(),n=(n||"CBC").toUpperCase(),"string"!=typeof e||16!==e.length&&24!==e.length&&32!==e.length){if(Mc.util.isArray(e)&&(16===e.length||24===e.length||32===e.length))for(var _=e,e=Mc.util.createBuffer(),g=0;g<_.length;++g)e.putByte(_[g])}else e=Mc.util.createBuffer(e);if(!Mc.util.isArray(e)){var _=e;e=[];var m=_.length();if(16===m||24===m||32===m){m>>>=2;for(var g=0;m>g;++g)e.push(_.getInt32())}}if(!Mc.util.isArray(e)||4!==e.length&&6!==e.length&&8!==e.length)return p;var y,v,b,w,E,C,S,A=-1!==["CFB","OFB","CTR"].indexOf(n),I="CBC"===n,T=c(e,i&&!A),x=a<<2;if(p={output:null},"CBC"===n)S=h;else if("CFB"===n)S=u;else if("OFB"===n)S=d;else{if("CTR"!==n)throw{message:'Unsupported block cipher mode of operation: "'+n+'"'};S=f}return p.update=function(e){for(C||y.putBuffer(e);y.length()>=x||y.length()>0&&C;)S()},p.update2=function(e){for(e&&e.length()&&(y.data=y.data.substr(y.read),y.read=0,y.putBuffer(e));y.length()>=x;)S();p.overflow&&v.getBytes(p.overflow);var t=y.length()%x;if(t){for(var r=Mc.util.createBuffer(y.data.slice(y.read)),i=b.slice(0);y.length()>0;)S();y=r,b=i,v.truncate(x-t)}else y.data="",y.read=0;p.overflow=t},p.finish=function(e){var t=!0,r=y.length()%x;if(!i)if(e)t=e(x,y,i);else if(I){var n=y.length()===x?x:x-y.length();y.fillWithByte(n,n)}if(t&&(C=!0,p.update()),i&&(I&&(t=0===r),t))if(e)t=e(x,v,i);else if(I){var s=v.length(),o=v.at(s-1);o>a<<2?t=!1:v.truncate(o)}return!I&&!e&&r>0&&v.truncate(x-r),t},p.start=function(e,t){if(null===e&&(e=E.slice(0)),"string"==typeof e&&16===e.length)e=Mc.util.createBuffer(e);else if(Mc.util.isArray(e)&&16===e.length)for(var r=e,e=Mc.util.createBuffer(),i=0;16>i;++i)e.putByte(r[i]);if(!Mc.util.isArray(e)){var r=e;e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32()}if(y=Mc.util.createBuffer(),v=t||Mc.util.createBuffer(),E=e.slice(0),b=new Array(a),w=new Array(a),C=!1,p.output=v,-1!==["CFB","OFB","CTR"].indexOf(n)){for(var i=0;a>i;++i)b[i]=E[i];E=null}},null!==t&&p.start(t,r),p};Mc.aes=Mc.aes||{},Mc.aes.startEncrypting=function(e,t,r,i){return h(e,t,r,!1,i)},Mc.aes.createEncryptionCipher=function(e,t){return h(e,null,null,!1,t)},Mc.aes.startDecrypting=function(e,t,r,i){return h(e,t,r,!0,i)},Mc.aes.createDecryptionCipher=function(e,t){return h(e,null,null,!0,t)},Mc.aes._expandKey=function(e,t){return s||o(),c(e,t)},Mc.aes._updateBlock=l,Mc.aes.createcipheriv=function(e,t,r){var i=e.split("-")[2],n=Mc.util.createBuffer();t=Mc.util.createBuffer(t.toString("binary")),r=Mc.util.createBuffer(r.toString("binary"));var s=Mc.aes.startEncrypting(t,r,n,i),a=s.update2;return s.update=function(e){var t;return e=e?Mc.util.createBuffer(e.toString("binary")):Mc.util.createBuffer(),a(e),t=n.toHex(),n.data="",n.read=0,t},s}}(),function(){var e=Mc;e.asn1={};var t=e.asn1;t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(e,t,r,i){return{tagClass:e,type:t,constructed:r,composed:r||i.constructor==Array,value:i}};var r=function(e){var t=e.getByte();if(128==t)return void 0;var r,i=128&t;return r=i?e.getInt((127&t)<<3):t};t.fromDer=function(i){if(i.constructor==String&&(i=e.util.createBuffer(i)),i.length()<2)throw{message:"Too few bytes to parse DER.",bytes:i.length()};var n=i.getByte(),s=192&n,a=31&n,o=r(i);if(i.length()1){var u=i.read,d=i.getByte();if(0===d){n=i.getByte();var f=192&n;if(f===t.Class.UNIVERSAL||f===t.Class.CONTEXT_SPECIFIC)try{var p=r(i);h=p===o-(i.read-u),h&&(++u,--o)}catch(_){}}i.read=u}if(h)if(c=[],void 0===o)for(;;){if(i.bytes(2)===String.fromCharCode(0,0)){i.getBytes(2);break}c.push(t.fromDer(i))}else for(var g=i.length();o>0;)c.push(t.fromDer(i)),o-=g-i.length(),g=i.length();else{if(void 0===o)throw{message:"Non-constructed ASN.1 object of indefinite length."};if(a===t.Type.BMPSTRING){c="";for(var m=0;o>m;m+=2)c+=String.fromCharCode(i.getInt16())}else c=i.getBytes(o)}return t.create(s,a,l,c)},t.toDer=function(r){var i=e.util.createBuffer(),n=r.tagClass|r.type,s=e.util.createBuffer();if(r.composed){r.constructed?n|=32:s.putByte(0);for(var a=0;a>>=8;while(o>0);i.putByte(128|c.length);for(var a=c.length-1;a>=0;--a)i.putByte(c.charCodeAt(a))}return i.putBuffer(s),i},t.oidToDer=function(t){var r=t.split("."),i=e.util.createBuffer();i.putByte(40*parseInt(r[0],10)+parseInt(r[1],10));for(var n,s,a,o,c=2;c>>=7,n||(o|=128),s.push(o),n=!1;while(a>0);for(var l=s.length-1;l>=0;--l)i.putByte(s[l])}return i},t.derToOid=function(t){var r;t.constructor==String&&(t=e.util.createBuffer(t));var i=t.getByte();r=Math.floor(i/40)+"."+i%40;for(var n=0;t.length()>0;)i=t.getByte(),n<<=7,128&i?n+=127&i:(r+="."+(n+i),n=0);return r},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),l=10;"+"!==c&&"-"!==c&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,0),l&&(c=e.charAt(l),"+"===c||"-"===c)){var h=parseInt(e.substr(l+1,2),10),u=parseInt(e.substr(l+4,2),10),d=60*h+u;d*=6e4,"+"===c?t.setTime(+t-d):t.setTime(+t+d)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),i=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,l=0,h=!1;"Z"==e.charAt(e.length-1)&&(h=!0);var u=e.length-5,d=e.charAt(u);if("+"===d||"-"===d){var f=parseInt(e.substr(u+1,2),10),p=parseInt(e.substr(u+4,2),10);l=60*f+p,l*=6e4,"+"===d&&(l*=-1),h=!0}return"."==e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),h?(t.setUTCFullYear(r,i,n),t.setUTCHours(s,a,o,c),t.setTime(+t+l)):(t.setFullYear(r,i,n),t.setHours(s,a,o,c)),t},t.dateToUtcTime=function(e){var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var i=0;i0&&(a+="\n");for(var o="",c=0;n*s>c;++c)o+=" ";switch(a+=o+"Tag: ",r.tagClass){case t.Class.UNIVERSAL:a+="Universal:";break;case t.Class.APPLICATION:a+="Application:";break;case t.Class.CONTEXT_SPECIFIC:a+="Context-Specific:";break;case t.Class.PRIVATE:a+="Private:"}if(r.tagClass===t.Class.UNIVERSAL)switch(a+=r.type,r.type){case t.Type.NONE:a+=" (None)";break;case t.Type.BOOLEAN:a+=" (Boolean)";break;case t.Type.BITSTRING:a+=" (Bit string)";break;case t.Type.INTEGER:a+=" (Integer)";break;case t.Type.OCTETSTRING:a+=" (Octet string)";break;case t.Type.NULL:a+=" (Null)";break;case t.Type.OID:a+=" (Object Identifier)";break;case t.Type.ODESC:a+=" (Object Descriptor)";break;case t.Type.EXTERNAL:a+=" (External or Instance of)";break;case t.Type.REAL:a+=" (Real)";break;case t.Type.ENUMERATED:a+=" (Enumerated)";break;case t.Type.EMBEDDED:a+=" (Embedded PDV)";break;case t.Type.UTF8:a+=" (UTF8)";break;case t.Type.ROID:a+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:a+=" (Sequence)";break;case t.Type.SET:a+=" (Set)";break;case t.Type.PRINTABLESTRING:a+=" (Printable String)";break;case t.Type.IA5String:a+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:a+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:a+=" (Generalized time)";break;case t.Type.BMPSTRING:a+=" (BMP String)"}else a+=r.type;if(a+="\n",a+=o+"Constructed: "+r.constructed+"\n",r.composed){a+=o+"Sub values: "+r.value.length;for(var c=0;c=Yc;++Yc)Qc[Gc++]=Yc;for(Gc="a".charCodeAt(0),Yc=10;36>Yc;++Yc)Qc[Gc++]=Yc;for(Gc="A".charCodeAt(0),Yc=10;36>Yc;++Yc)Qc[Gc++]=Yc;Mt.prototype.convert=jt,Mt.prototype.revert=zt,Mt.prototype.reduce=Vt,Mt.prototype.mulTo=Kt,Mt.prototype.sqrTo=Gt,Wt.prototype.convert=Qt,Wt.prototype.revert=Xt,Wt.prototype.reduce=Jt,Wt.prototype.mulTo=$t,Wt.prototype.sqrTo=Zt,pt.prototype.copyTo=wt,pt.prototype.fromInt=Et,pt.prototype.fromString=St,pt.prototype.clamp=At,pt.prototype.dlShiftTo=Ut,pt.prototype.drShiftTo=Dt,pt.prototype.lShiftTo=Nt,pt.prototype.rShiftTo=Lt,pt.prototype.subTo=Ot,pt.prototype.multiplyTo=Pt,pt.prototype.squareTo=Ft,pt.prototype.divRemTo=qt,pt.prototype.invDigit=Yt,pt.prototype.isEven=er,pt.prototype.exp=tr,pt.prototype.toString=It,pt.prototype.negate=Tt,pt.prototype.abs=xt,pt.prototype.compareTo=Bt,pt.prototype.bitLength=Rt,pt.prototype.mod=Ht,pt.prototype.modPowInt=rr,pt.ZERO=Ct(0),pt.ONE=Ct(1),ir.prototype.init=nr,ir.prototype.next=sr;var Xc,Jc,Zc,$c=256,Ba=Ba||window.navigator;if(null==Jc){Jc=new Array,Zc=0;var el;if("Netscape"==Ba.appName&&Ba.appVersion<"5"&&window.crypto){var tl=window.crypto.random(32);for(el=0;elZc;)el=Math.floor(65536*Math.random()),Jc[Zc++]=el>>>8,Jc[Zc++]=255⪙Zc=0,cr()}ur.prototype.nextBytes=hr,pr.prototype.doPublic=gr,pr.prototype.setPublic=_r,pr.prototype.encrypt=mr,ci.prototype.convert=li,ci.prototype.revert=li,ci.prototype.mulTo=hi,ci.prototype.sqrTo=ui,_i.prototype.convert=gi,_i.prototype.revert=mi,_i.prototype.reduce=yi,_i.prototype.mulTo=bi,_i.prototype.sqrTo=vi;var rl=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],il=(1<<26)/rl[rl.length-1];pt.prototype.chunkSize=Er,pt.prototype.toRadix=Sr,pt.prototype.fromRadix=Ar,pt.prototype.fromNumber=Ir,pt.prototype.bitwiseTo=Rr,pt.prototype.changeBit=Wr,pt.prototype.addTo=Zr,pt.prototype.dMultiply=ai,pt.prototype.dAddOffset=oi,pt.prototype.multiplyLowerTo=fi,pt.prototype.multiplyUpperTo=pi,pt.prototype.modInt=Ci,pt.prototype.millerRabin=Ii,pt.prototype.clone=yr,pt.prototype.intValue=vr,pt.prototype.byteValue=br,pt.prototype.shortValue=wr,pt.prototype.signum=Cr,pt.prototype.toByteArray=Tr,pt.prototype.equals=xr,pt.prototype.min=Br,pt.prototype.max=kr,pt.prototype.and=Dr,pt.prototype.or=Lr,pt.prototype.xor=Pr,pt.prototype.andNot=qr,pt.prototype.not=Hr,pt.prototype.shiftLeft=Mr,pt.prototype.shiftRight=jr,pt.prototype.getLowestSetBit=Vr,pt.prototype.bitCount=Gr,pt.prototype.testBit=Yr,pt.prototype.setBit=Qr,pt.prototype.clearBit=Xr,pt.prototype.flipBit=Jr,pt.prototype.add=$r,pt.prototype.subtract=ei,pt.prototype.multiply=ti,pt.prototype.divide=ii,pt.prototype.remainder=ni,pt.prototype.divideAndRemainder=si,pt.prototype.modPow=wi,pt.prototype.modInverse=Si,pt.prototype.pow=di,pt.prototype.gcd=Ei,pt.prototype.isProbablePrime=Ai,pt.prototype.square=ri,function(){var e=Mc;e.prng={};var t=e.prng;t.create=function(t){function r(){if(i.pools[0].messageLength<32){for(var t,r,n,s=32-i.pools[0].messageLength<<5,a="",o=Math.floor(65535*Math.random());a.length>16),r+=(32767&t)<<16,r+=t>>15,r=(2147483647&r)+(r>>31),o=4294967295&r;for(var c=0;3>c;++c)n=o>>>(c<<3),n^=Math.floor(255*Math.random()),a+=String.fromCharCode(255&n)}i.collect(a)}else{var l=e.md.sha1.create();l.update(i.pools[0].digest().getBytes()),i.pools[0].start();for(var h=1,c=1;32>c;++c)h=31==h?2147483648:h<<2,0===h%i.reseeds&&(l.update(i.pools[c].digest().getBytes()),i.pools[c].start());var u=l.digest().getBytes();l.start(),l.update(u);var d=l.digest().getBytes();i.key=i.plugin.formatKey(u),i.seed=i.plugin.formatSeed(d),++i.reseeds,i.generated=0,i.time=+new Date}}for(var i={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0},n=t.md,s=new Array(32),a=0;32>a;++a)s[a]=n.create();return i.pools=s,i.pool=0,i.generate=function(t){null===i.key&&r();for(var n=i.plugin.cipher,s=i.plugin.increment,a=i.plugin.formatKey,o=i.plugin.formatSeed,c=e.util.createBuffer();c.length()=1048576){var h=+new Date;h-i.time<100&&r()}}return c.getBytes(t)},i.collect=function(e){for(var t=e.length,n=0;t>n;++n)i.pools[i.pool].update(e.substr(n,1)),i.pool=31===i.pool?0:i.pool+1;if(i.pools[0].messageLength>=32){var s=+new Date;(null===i.time||s-i.time<100)&&r()}},i.collectInt=function(e,t){var r="";do t-=8,r+=String.fromCharCode(255&e>>t);while(t>0);i.collect(r)},i}}(),function(e){var t=Mc;t.random={};var r={},i=new Array(4),n=t.util.createBuffer();r.formatKey=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),t.aes._expandKey(e,!1)},r.formatSeed=function(e){var r=t.util.createBuffer(e);return e=new Array(4),e[0]=r.getInt32(),e[1]=r.getInt32(),e[2]=r.getInt32(),e[3]=r.getInt32(),e},r.cipher=function(e,r){return t.aes._updateBlock(e,r,i,!1),n.putInt32(i[0]),n.putInt32(i[1]),n.putInt32(i[2]),n.putInt32(i[3]),n.getBytes()},r.increment=function(e){return++e[3],e},r.md=t.md.sha1;var s=t.prng.create(r);if(s.collectInt(+new Date,32),"undefined"!=typeof Ba){var a="";for(var o in Ba)try{"string"==typeof Ba[o]&&(a+=Ba[o])}catch(c){}s.collect(a),a=null}e&&(e().mousemove(function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)}),e().keypress(function(e){s.collectInt(e.charCode,8)})),t.random.getBytes=function(e){return s.generate(e)}}("undefined"!=typeof jQuery?jQuery:null),function(){var e={},t=Mc;t.pki=t.pki||{},t.pki.oids=e,e["1.2.840.113549.1.1.1"]="rsaEncryption",e.rsaEncryption="1.2.840.113549.1.1.1",e["1.2.840.113549.1.1.4"]="md5withRSAEncryption",e.md5withRSAEncryption="1.2.840.113549.1.1.4",e["1.2.840.113549.1.1.5"]="sha1withRSAEncryption",e.sha1withRSAEncryption="1.2.840.113549.1.1.5",e["1.2.840.113549.1.1.7"]="RSAES-OAEP",e["RSAES-OAEP"]="1.2.840.113549.1.1.7",e["1.2.840.113549.1.1.8"]="mgf1",e.mgf1="1.2.840.113549.1.1.8",e["1.2.840.113549.1.1.9"]="pSpecified",e.pSpecified="1.2.840.113549.1.1.9",e["1.2.840.113549.1.1.10"]="RSASSA-PSS",e["RSASSA-PSS"]="1.2.840.113549.1.1.10",e["1.2.840.113549.1.1.11"]="sha256WithRSAEncryption",e.sha256WithRSAEncryption="1.2.840.113549.1.1.11",e["1.2.840.113549.1.1.12"]="sha384WithRSAEncryption",e.sha384WithRSAEncryption="1.2.840.113549.1.1.12",e["1.2.840.113549.1.1.13"]="sha512WithRSAEncryption",e.sha512WithRSAEncryption="1.2.840.113549.1.1.13",e["1.3.14.3.2.26"]="sha1",e.sha1="1.3.14.3.2.26",e["2.16.840.1.101.3.4.2.1"]="sha256",e.sha256="2.16.840.1.101.3.4.2.1",e["2.16.840.1.101.3.4.2.2"]="sha384",e.sha384="2.16.840.1.101.3.4.2.2",e["2.16.840.1.101.3.4.2.3"]="sha512",e.sha512="2.16.840.1.101.3.4.2.3",e["1.2.840.113549.2.5"]="md5",e.md5="1.2.840.113549.2.5",e["1.2.840.113549.1.7.1"]="data",e.data="1.2.840.113549.1.7.1",e["1.2.840.113549.1.7.2"]="signedData",e.signedData="1.2.840.113549.1.7.2",e["1.2.840.113549.1.7.3"]="envelopedData",e.envelopedData="1.2.840.113549.1.7.3",e["1.2.840.113549.1.7.4"]="signedAndEnvelopedData",e.signedAndEnvelopedData="1.2.840.113549.1.7.4",e["1.2.840.113549.1.7.5"]="digestedData",e.digestedData="1.2.840.113549.1.7.5",e["1.2.840.113549.1.7.6"]="encryptedData",e.encryptedData="1.2.840.113549.1.7.6",e["1.2.840.113549.1.9.20"]="friendlyName",e.friendlyName="1.2.840.113549.1.9.20",e["1.2.840.113549.1.9.21"]="localKeyId",e.localKeyId="1.2.840.113549.1.9.21",e["1.2.840.113549.1.9.22.1"]="x509Certificate",e.x509Certificate="1.2.840.113549.1.9.22.1",e["1.2.840.113549.1.12.10.1.1"]="keyBag",e.keyBag="1.2.840.113549.1.12.10.1.1",e["1.2.840.113549.1.12.10.1.2"]="pkcs8ShroudedKeyBag",e.pkcs8ShroudedKeyBag="1.2.840.113549.1.12.10.1.2",e["1.2.840.113549.1.12.10.1.3"]="certBag",e.certBag="1.2.840.113549.1.12.10.1.3",e["1.2.840.113549.1.12.10.1.4"]="crlBag",e.crlBag="1.2.840.113549.1.12.10.1.4",e["1.2.840.113549.1.12.10.1.5"]="secretBag",e.secretBag="1.2.840.113549.1.12.10.1.5",e["1.2.840.113549.1.12.10.1.6"]="safeContentsBag",e.safeContentsBag="1.2.840.113549.1.12.10.1.6",e["1.2.840.113549.1.5.13"]="pkcs5PBES2",e.pkcs5PBES2="1.2.840.113549.1.5.13",e["1.2.840.113549.1.5.12"]="pkcs5PBKDF2",e.pkcs5PBKDF2="1.2.840.113549.1.5.12",e["1.2.840.113549.1.12.1.1"]="pbeWithSHAAnd128BitRC4",e.pbeWithSHAAnd128BitRC4="1.2.840.113549.1.12.1.1",e["1.2.840.113549.1.12.1.2"]="pbeWithSHAAnd40BitRC4",e.pbeWithSHAAnd40BitRC4="1.2.840.113549.1.12.1.2",e["1.2.840.113549.1.12.1.3"]="pbeWithSHAAnd3-KeyTripleDES-CBC",e["pbeWithSHAAnd3-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.3",e["1.2.840.113549.1.12.1.4"]="pbeWithSHAAnd2-KeyTripleDES-CBC",e["pbeWithSHAAnd2-KeyTripleDES-CBC"]="1.2.840.113549.1.12.1.4",e["1.2.840.113549.1.12.1.5"]="pbeWithSHAAnd128BitRC2-CBC",e["pbeWithSHAAnd128BitRC2-CBC"]="1.2.840.113549.1.12.1.5",e["1.2.840.113549.1.12.1.6"]="pbewithSHAAnd40BitRC2-CBC",e["pbewithSHAAnd40BitRC2-CBC"]="1.2.840.113549.1.12.1.6",e["1.2.840.113549.3.7"]="des-EDE3-CBC",e["des-EDE3-CBC"]="1.2.840.113549.3.7",e["2.16.840.1.101.3.4.1.2"]="aes128-CBC",e["aes128-CBC"]="2.16.840.1.101.3.4.1.2",e["2.16.840.1.101.3.4.1.22"]="aes192-CBC",e["aes192-CBC"]="2.16.840.1.101.3.4.1.22",e["2.16.840.1.101.3.4.1.42"]="aes256-CBC",e["aes256-CBC"]="2.16.840.1.101.3.4.1.42",e["2.5.4.3"]="commonName",e.commonName="2.5.4.3",e["2.5.4.5"]="serialName",e.serialName="2.5.4.5",e["2.5.4.6"]="countryName",e.countryName="2.5.4.6",e["2.5.4.7"]="localityName",e.localityName="2.5.4.7",e["2.5.4.8"]="stateOrProvinceName",e.stateOrProvinceName="2.5.4.8",e["2.5.4.10"]="organizationName",e.organizationName="2.5.4.10",e["2.5.4.11"]="organizationalUnitName",e.organizationalUnitName="2.5.4.11",e["1.2.840.113549.1.9.1"]="emailAddress",e.emailAddress="1.2.840.113549.1.9.1",e["2.5.29.1"]="authorityKeyIdentifier",e["2.5.29.2"]="keyAttributes",e["2.5.29.3"]="certificatePolicies",e["2.5.29.4"]="keyUsageRestriction",e["2.5.29.5"]="policyMapping",e["2.5.29.6"]="subtreesConstraint",e["2.5.29.7"]="subjectAltName",e["2.5.29.8"]="issuerAltName",e["2.5.29.9"]="subjectDirectoryAttributes",e["2.5.29.10"]="basicConstraints",e["2.5.29.11"]="nameConstraints",e["2.5.29.12"]="policyConstraints",e["2.5.29.13"]="basicConstraints",e["2.5.29.14"]="subjectKeyIdentifier",e.subjectKeyIdentifier="2.5.29.14",e["2.5.29.15"]="keyUsage",e.keyUsage="2.5.29.15",e["2.5.29.16"]="privateKeyUsagePeriod",e["2.5.29.17"]="subjectAltName",e.subjectAltName="2.5.29.17",e["2.5.29.18"]="issuerAltName",e.issuerAltName="2.5.29.18",e["2.5.29.19"]="basicConstraints",e.basicConstraints="2.5.29.19",e["2.5.29.20"]="cRLNumber",e["2.5.29.21"]="cRLReason",e["2.5.29.22"]="expirationDate",e["2.5.29.23"]="instructionCode",e["2.5.29.24"]="invalidityDate",e["2.5.29.25"]="cRLDistributionPoints",e["2.5.29.26"]="issuingDistributionPoint",e["2.5.29.27"]="deltaCRLIndicator",e["2.5.29.28"]="issuingDistributionPoint",e["2.5.29.29"]="certificateIssuer",e["2.5.29.30"]="nameConstraints",e["2.5.29.31"]="cRLDistributionPoints",e["2.5.29.32"]="certificatePolicies",e["2.5.29.33"]="policyMappings",e["2.5.29.34"]="policyConstraints",e["2.5.29.35"]="authorityKeyIdentifier",e["2.5.29.36"]="policyConstraints",e["2.5.29.37"]="extKeyUsage",e.extKeyUsage="2.5.29.37",e["2.5.29.46"]="freshestCRL",e["2.5.29.54"]="inhibitAnyPolicy"}(),function(){var e=Mc,t=e.asn1;e.pki=e.pki||{},e.pki.rsa=e.pki.rsa||{};var r=e.pki,i=function(r){var i;if(!(r.algorithm in e.pki.oids))throw{message:"Unknown message digest algorithm.",algorithm:r.algorithm};i=e.pki.oids[r.algorithm];var n=t.oidToDer(i).getBytes(),s=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);a.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,n)),a.value.push(t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,""));var o=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.digest().getBytes());return s.value.push(a),s.value.push(o),t.toDer(s).getBytes()},n=function(e,t,r){var i;if(r)i=e.modPow(t.e,t.n);else{t.dP||(t.dP=t.d.mod(t.p.subtract(pt.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(pt.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s)}return i};r.rsa.encrypt=function(t,r,i){var s=i,a=e.util.createBuffer(),o=Math.ceil(r.n.bitLength()/8);if(i!==!1&&i!==!0){if(t.length>o-11)throw{message:"Message is too long to encrypt.",length:t.length,max:o-11};a.putByte(0),a.putByte(i);var c,l=o-3-t.length;if(0===i||1===i){s=!1,c=0===i?0:255;for(var h=0;l>h;++h)a.putByte(c)}else{s=!0;for(var h=0;l>h;++h)c=Math.floor(255*Math.random())+1,a.putByte(c)}a.putByte(0)}a.putBytes(t);for(var u=new pt(a.toHex(),16),d=n(u,r,s),f=d.toString(16),p=e.util.createBuffer(),_=o-Math.ceil(f.length/2);_>0;)p.putByte(0),--_;return p.putBytes(e.util.hexToBytes(f)),p.getBytes()},r.rsa.decrypt=function(t,r,i,s){e.util.createBuffer();var a=Math.ceil(r.n.bitLength()/8);if(t.length!=a)throw{message:"Encrypted message length is invalid.",length:t.length,expected:a};for(var o=new pt(e.util.createBuffer(t).toHex(),16),c=n(o,r,i),l=c.toString(16),h=e.util.createBuffer(),u=a-Math.ceil(l.length/2);u>0;)h.putByte(0),--u;if(h.putBytes(e.util.hexToBytes(l)),s!==!1){var d=h.getByte(),f=h.getByte();if(0!==d||i&&0!==f&&1!==f||!i&&2!=f||i&&0===f&&"undefined"==typeof s)throw{message:"Encryption block is invalid."};var p=0;if(0===f){p=a-3-s;for(var _=0;p>_;++_)if(0!==h.getByte())throw{message:"Encryption block is invalid."}}else if(1===f)for(p=0;h.length()>1;){if(255!==h.getByte()){--h.read;break}++p}else if(2===f)for(p=0;h.length()>1;){if(0===h.getByte()){--h.read;break}++p}var g=h.getByte();if(0!==g||p!==a-3-h.length())throw{message:"Encryption block is invalid."}}return h.getBytes()},r.rsa.createKeyPairGenerationState=function(t,r){"string"==typeof t&&(t=parseInt(t,10)),t=t||1024;var i={nextBytes:function(t){+new Date;for(var r=e.random.getBytes(t.length),i=0;i>1,pBits:t-(t>>1),pqState:0,num:null,six:new pt(null),addNext:2,keys:null};return n.six.fromInt(6),n},r.rsa.stepKeyPairGenerationState=function(t,r){for(var i,n=+new Date,s=0;null===t.keys&&(0>=r||r>s);){if(0===t.state){var a=null===t.p?t.pBits:t.qBits,o=a-1;if(0===t.pqState)t.itrs=0,t.num=new pt(a,t.rng),t.r=null,t.num.isEven()&&t.num.dAddOffset(1,0),t.num.testBit(o)||t.num.bitwiseTo(pt.ONE.shiftLeft(o),function(e,t){return e|t },t.num),++t.pqState;else if(1===t.pqState){if(null===t.addNext){var c=t.num.mod(t.six).byteValue();3===c&&(t.num.mod.dAddOffset(2),c=5),t.addNext=1===c?2:4}var l=t.num.isProbablePrime(1);l?++t.pqState:t.itrsa?(t.addNext=null,t.num.subTo(pt.ONE.shiftLeft(o),t.num)):t.addNext=4===t.addNext?2:4,++t.itrs):t.pqState=0}else 2===t.pqState?t.pqState=0===t.num.subtract(pt.ONE).gcd(t.e).compareTo(pt.ONE)?3:0:3===t.pqState&&(t.pqState=0,t.num.isProbablePrime(10)&&(null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state),t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(pt.ONE),t.q1=t.q.subtract(pt.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(pt.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var h=t.e.modInverse(t.phi);t.keys={privateKey:e.pki.rsa.setPrivateKey(t.n,t.e,h,t.p,t.q,h.mod(t.p1),h.mod(t.q1),t.q.modInverse(t.p)),publicKey:e.pki.rsa.setPublicKey(t.n,t.e)}}i=+new Date,s+=i-n,n=i}return null!==t.keys},r.rsa.generateKeyPair=function(e,t){var i=r.rsa.createKeyPairGenerationState(e,t);return r.rsa.stepKeyPairGenerationState(i,0),i.keys},r.rsa.setPublicKey=function(e,i){var n={n:e,e:i};return n.encrypt=function(e){return r.rsa.encrypt(e,n,2)},n.verify=function(e,i,s){var a=void 0===s?void 0:!1,o=r.rsa.decrypt(i,n,!0,a);if(void 0===s){var c=t.fromDer(o);return e===c.value[1].value}return s.verify(e,o,n.n.bitLength())},n},r.rsa.setPrivateKey=function(e,t,n,s,a,o,c,l){var h={n:e,e:t,d:n,p:s,q:a,dP:o,dQ:c,qInv:l};return h.decrypt=function(e){return r.rsa.decrypt(e,h,!1)},h.sign=function(e,t){var n=!1;void 0===t&&(t={encode:i},n=1);var s=t.encode(e,h.n.bitLength());return r.rsa.encrypt(s,h,n)},h}}(),function(){function e(e){function t(t){for(var r,i,n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=t.attributes,a=0;an;++s,n+=16)i.push(a(i[s-1]+e+t));return i.join("").substr(0,r)}function a(t){return e.md.md5.create().update(t).digest().getBytes()}"undefined"==typeof pt&&(pt=e.jsbn.BigInteger);var o=e.asn1,c=e.pki=e.pki||{},l=c.oids;c.pbe={};var h={};h.CN=l.commonName,h.commonName="CN",h.C=l.countryName,h.countryName="C",h.L=l.localityName,h.localityName="L",h.ST=l.stateOrProvinceName,h.stateOrProvinceName="ST",h.O=l.organizationName,h.organizationName="O",h.OU=l.organizationalUnitName,h.organizationalUnitName="OU",h.E=l.emailAddress,h.emailAddress="E";var u={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f={name:"Certificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:o.Class.UNIVERSAL,type:o.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:o.Class.UNIVERSAL,type:o.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},u,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"certSignature"}]},p={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},_={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},g={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},m={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,onstructed:!0,capture:"kdfIterationCount"}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},y={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]},v={name:"rsapss",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:o.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:o.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:o.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:o.Class.UNIVERSAL,type:o.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},u,{name:"CertificationRequestInfo.attributes",tagClass:o.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:o.Class.UNIVERSAL,type:o.Type.SET,constructed:!0}]}]}]},w={name:"CertificationRequest",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[b,{name:"CertificationRequest.signatureAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,capture:"csrSignature"}]};c.RDNAttributesAsArray=function(e,t){for(var r,i,n,s=[],a=0;a1&&(u=h.value.charCodeAt(1),d=h.value.length>2?h.value.charCodeAt(2):0),r.digitalSignature=128===(128&u),r.nonRepudiation=64===(64&u),r.keyEncipherment=32===(32&u),r.dataEncipherment=16===(16&u),r.keyAgreement=8===(8&u),r.keyCertSign=4===(4&u),r.cRLSign=2===(2&u),r.encipherOnly=1===(1&u),r.decipherOnly=128===(128&d)}else if("basicConstraints"===r.name){var h=o.fromDer(r.value);if(r.cA=h.value.length>0?0!==h.value[0].value.charCodeAt(0):!1,h.value.length>1){var f=e.util.createBuffer(h.value[1].value);r.pathLenConstraint=f.getInt(f.length()<<3)}}else if("extKeyUsage"===r.name)for(var h=o.fromDer(r.value),p=0;p="8"&&(r="00"+r),e.util.hexToBytes(r)},A=function(e,t,r){var i={};if(e!==l["RSASSA-PSS"])return i;r&&(i={hash:{algorithmOid:l.sha1},mgf:{algorithmOid:l.mgf1,hash:{algorithmOid:l.sha1}},saltLength:20});var n={},s=[];if(!o.validate(t,v,n,s))throw{message:"Cannot read RSASSA-PSS parameter block.",errors:s};return void 0!==n.hashOid&&(i.hash=i.hash||{},i.hash.algorithmOid=o.derToOid(n.hashOid)),void 0!==n.maskGenOid&&(i.mgf=i.mgf||{},i.mgf.algorithmOid=o.derToOid(n.maskGenOid),i.mgf.hash=i.mgf.hash||{},i.mgf.hash.algorithmOid=o.derToOid(n.maskGenHashOid)),void 0!==n.saltLength&&(i.saltLength=n.saltLength.charCodeAt(0)),i};c.certificateFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE"!==n.type&&"X509 CERTIFICATE"!==n.type&&"TRUSTED CERTIFICATE"!==n.type)throw{message:'Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certificate from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificateFromAsn1(s,r)},c.certificateToPem=function(t,r){var i={type:"CERTIFICATE",body:o.toDer(c.certificateToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PUBLIC KEY"!==r.type&&"RSA PUBLIC KEY"!==r.type)throw{message:'Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert public key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.publicKeyFromAsn1(i)},c.publicKeyToPem=function(t,r){var i={type:"PUBLIC KEY",body:o.toDer(c.publicKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.publicKeyToRSAPublicKeyPem=function(t,r){var i={type:"RSA PUBLIC KEY",body:o.toDer(c.publicKeyToRSAPublicKey(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.privateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("PRIVATE KEY"!==r.type&&"RSA PRIVATE KEY"!==r.type)throw{message:'Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert private key from PEM; PEM is encrypted."};var i=o.fromDer(r.body);return c.privateKeyFromAsn1(i)},c.privateKeyToPem=function(t,r){var i={type:"RSA PRIVATE KEY",body:o.toDer(c.privateKeyToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.certificationRequestFromPem=function(t,r,i){var n=e.pem.decode(t)[0];if("CERTIFICATE REQUEST"!==n.type)throw{message:'Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type)throw{message:"Could not convert certification request from PEM; PEM is encrypted."};var s=o.fromDer(n.body,i);return c.certificationRequestFromAsn1(s,r)},c.certificationRequestToPem=function(t,r){var i={type:"CERTIFICATE REQUEST",body:o.toDer(c.certificationRequestToAsn1(t)).getBytes()};return e.pem.encode(i,{maxline:r})},c.createCertificate=function(){var t={};t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return E(t.issuer,e)},t.issuer.addField=function(e){r([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return E(t.subject,e)},t.subject.addField=function(e){r([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null;var r=function(e){for(var t,r=0;r2)throw{message:"Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate."};if(_.length<2)throw{message:"Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime."};if(u.validity.notBefore=_[0],u.validity.notAfter=_[1],u.tbsCertificate=i.tbsCertificate,r){if(u.md=null,u.signatureOid in l){var h=l[u.signatureOid];switch(h){case"sha1withRSAEncryption":u.md=e.md.sha1.create();break;case"md5withRSAEncryption":u.md=e.md.md5.create();break;case"sha256WithRSAEncryption":u.md=e.md.sha256.create();break;case"RSASSA-PSS":u.md=e.md.sha256.create()}}if(null===u.md)throw{message:"Could not compute certificate digest. Unknown signature OID.",signatureOid:u.signatureOid};var g=o.toDer(u.tbsCertificate);u.md.update(g.getBytes())}var m=e.md.sha1.create();u.issuer.getField=function(e){return E(u.issuer,e)},u.issuer.addField=function(e){_fillMissingFields([e]),u.issuer.attributes.push(e)},u.issuer.attributes=c.RDNAttributesAsArray(i.certIssuer,m),i.certIssuerUniqueId&&(u.issuer.uniqueId=i.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var y=e.md.sha1.create();return u.subject.getField=function(e){return E(u.subject,e)},u.subject.addField=function(e){_fillMissingFields([e]),u.subject.attributes.push(e)},u.subject.attributes=c.RDNAttributesAsArray(i.certSubject,y),i.certSubjectUniqueId&&(u.subject.uniqueId=i.certSubjectUniqueId),u.subject.hash=y.digest().toHex(),u.extensions=i.certExtensions?C(i.certExtensions):[],u.publicKey=c.publicKeyFromAsn1(i.subjectPublicKeyInfo),u},c.certificationRequestFromAsn1=function(t,r){var i={},n=[];if(!o.validate(t,w,i,n))throw{message:"Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.",errors:n};if("string"!=typeof i.csrSignature){for(var s="\x00",a=0;a0&&s.value.push(r(n.extensions)),s},c.getCertificationRequestInfo=function(e){var r=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(e.version)),t(e.subject),c.publicKeyToAsn1(e.publicKey),n(e)]);return r},c.distinguishedNameToAsn1=function(e){return t(e)},c.certificateToAsn1=function(e){var t=e.tbsCertificate||c.getTBSCertificate(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||c.getCertificationRequestInfo(e);return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[t,o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(e.signatureOid).getBytes()),i(e.signatureOid,e.signatureParameters)]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},c.createCaStore=function(r){var i={certs:{}};if(i.getIssuer=function(r){var n=null;if(!r.issuer.hash){var s=e.md.sha1.create();r.issuer.attributes=c.RDNAttributesAsArray(t(r.issuer),s),r.issuer.hash=s.digest().toHex()}if(r.issuer.hash in i.certs&&(n=i.certs[r.issuer.hash],e.util.isArray(n)))throw{message:"Resolving multiple issuer matches not implemented yet."};return n},i.addCertificate=function(r){if("string"==typeof r&&(r=e.pki.certificateFromPem(r)),!r.subject.hash){var n=e.md.sha1.create();r.subject.attributes=c.RDNAttributesAsArray(t(r.subject),n),r.subject.hash=n.digest().toHex()}if(r.subject.hash in i.certs){var s=i.certs[r.subject.hash];e.util.isArray(s)||(s=[s]),s.push(r)}else i.certs[r.subject.hash]=r},r)for(var n=0;nu.validity.notAfter)o={message:"Certificate is not valid yet or has expired.",error:c.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:s};else{var d=!1;if(r.length>0){h=r[0];try{d=h.verify(u)}catch(f){}}else{var p=t.getIssuer(u);if(null===p)o={message:"Certificate is not trusted.",error:c.certificateError.unknown_ca};else for(e.util.isArray(p)||(p=[p]);!d&&p.length>0;){h=p.shift();try{d=h.verify(u)}catch(f){}}}null!==o||d||(o={message:"Certificate signature is invalid.",error:c.certificateError.bad_certificate})}if(null!==o||u.isIssuer(h)||(o={message:"Certificate issuer is invalid.",error:c.certificateError.bad_certificate}),null===o)for(var _={keyUsage:!0,basicConstraints:!0},g=0;null===o&&g0);return!0},c.publicKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,u,r,i)){var n=o.derToOid(r.publicKeyOid);if(n!==c.oids.rsaEncryption)throw{message:"Cannot read public key. Unknown OID.",oid:n};t=r.rsaPublicKey}if(i=[],!o.validate(t,d,r,i))throw{message:"Cannot read public key. ASN.1 object does not contain an RSAPublicKey.",errors:i};var s=e.util.createBuffer(r.publicKeyModulus).toHex(),a=e.util.createBuffer(r.publicKeyExponent).toHex();return c.setRsaPublicKey(new pt(s,16),new pt(a,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.e))])},c.privateKeyFromAsn1=function(t){var r={},i=[];if(o.validate(t,p,r,i)&&(t=o.fromDer(e.util.createBuffer(r.privateKey))),r={},i=[],!o.validate(t,_,r,i))throw{message:"Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.",errors:i};var n,s,a,l,h,u,d,f;return n=e.util.createBuffer(r.privateKeyModulus).toHex(),s=e.util.createBuffer(r.privateKeyPublicExponent).toHex(),a=e.util.createBuffer(r.privateKeyPrivateExponent).toHex(),l=e.util.createBuffer(r.privateKeyPrime1).toHex(),h=e.util.createBuffer(r.privateKeyPrime2).toHex(),u=e.util.createBuffer(r.privateKeyExponent1).toHex(),d=e.util.createBuffer(r.privateKeyExponent2).toHex(),f=e.util.createBuffer(r.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new pt(n,16),new pt(s,16),new pt(a,16),new pt(l,16),new pt(h,16),new pt(u,16),new pt(d,16),new pt(f,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,String.fromCharCode(0)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,S(e.qInv))])},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,"\x00"),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.encryptPrivateKeyInfo=function(t,r,i){i=i||{},i.saltSize=i.saltSize||8,i.count=i.count||2048,i.algorithm=i.algorithm||"aes128";var n=e.random.getBytes(i.saltSize),s=i.count,a=e.util.createBuffer();a.putInt16(s);var c,h,u;if(0===i.algorithm.indexOf("aes")){var d;if("aes128"===i.algorithm)c=16,d=l["aes128-CBC"];else if("aes192"===i.algorithm)c=24,d=l["aes192-CBC"];else{if("aes256"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=32,d=l["aes256-CBC"]}var f=e.pkcs5.pbkdf2(r,n,s,c),p=e.random.getBytes(16),_=e.aes.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBKDF2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(d).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,p)])])])}else{if("3des"!==i.algorithm)throw{message:"Cannot encrypt private key. Unknown encryption algorithm.",algorithm:i.algorithm};c=24;var g=new e.util.ByteBuffer(n),f=e.pkcs12.generateKey(r,g,1,s,c),p=e.pkcs12.generateKey(r,g,2,s,c),_=e.des.createEncryptionCipher(f);_.start(p),_.update(o.toDer(t)),_.finish(),u=_.output.getBytes(),h=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,n),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.getBytes())])])}var m=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[h,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)]);return m},c.pbe.getCipherForPBES2=function(t,r,i){var n={},s=[];if(!o.validate(r,m,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};if(t=o.derToOid(n.kdfOid),t!==c.oids.pkcs5PBKDF2)throw{message:"Cannot read encrypted private key. Unsupported key derivation function OID.",oid:t,supportedOids:["pkcs5PBKDF2"]};if(t=o.derToOid(n.encOid),t!==c.oids["aes128-CBC"]&&t!==c.oids["aes192-CBC"]&&t!==c.oids["aes256-CBC"])throw{message:"Cannot read encrypted private key. Unsupported encryption scheme OID.",oid:t,supportedOids:["aes128-CBC","aes192-CBC","aes256-CBC"]};var a=n.kdfSalt,l=e.util.createBuffer(n.kdfIterationCount);l=l.getInt(l.length()<<3);var h;t===c.oids["aes128-CBC"]?h=16:t===c.oids["aes192-CBC"]?h=24:t===c.oids["aes256-CBC"]&&(h=32);var u=e.pkcs5.pbkdf2(i,a,l,h),d=n.encIv,f=e.aes.createDecryptionCipher(u);return f.start(d),f},c.pbe.getCipherForPKCS12PBE=function(t,r,i){var n={},s=[];if(!o.validate(r,y,n,s))throw{message:"Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=e.util.createBuffer(n.salt),l=e.util.createBuffer(n.iterations);l=l.getInt(l.length()<<3);var h,u,d;switch(t){case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:h=24,u=8,d=e.des.startDecrypting;break;case c.oids["pbewithSHAAnd40BitRC2-CBC"]:h=5,u=8,d=function(t,r){var i=e.rc2.createDecryptionCipher(t,40);return i.start(r,null),i};break;default:throw{message:"Cannot read PKCS #12 PBE data block. Unsupported OID.",oid:t}}var f=e.pkcs12.generateKey(i,a,1,l,h),p=e.pkcs12.generateKey(i,a,2,l,u);return d(f,p)},c.pbe.getCipher=function(e,t,r){switch(e){case c.oids.pkcs5PBES2:return c.pbe.getCipherForPBES2(e,t,r);case c.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case c.oids["pbewithSHAAnd40BitRC2-CBC"]:return c.pbe.getCipherForPKCS12PBE(e,t,r);default:throw{message:"Cannot read encrypted PBE data block. Unsupported OID.",oid:e,supportedOids:["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"]}}},c.decryptPrivateKeyInfo=function(t,r){var i=null,n={},s=[];if(!o.validate(t,g,n,s))throw{message:"Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.",errors:s};var a=o.derToOid(n.encryptionOid),l=c.pbe.getCipher(a,n.encryptionParams,r),h=e.util.createBuffer(n.encryptedData);return l.update(h),l.finish()&&(i=o.fromDer(l.output)),i},c.encryptedPrivateKeyToPem=function(t,r){var i={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(t).getBytes()};return e.pem.encode(i,{maxline:r})},c.encryptedPrivateKeyFromPem=function(t){var r=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==r.type)throw{message:'Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".',headerType:r.type};if(r.procType&&"ENCRYPTED"===r.procType.type)throw{message:"Could not convert encrypted private key from PEM; PEM is encrypted."};return o.fromDer(r.body)},c.encryptRsaPrivateKey=function(t,r,i){if(i=i||{},!i.legacy){var n=c.wrapRsaPrivateKey(c.privateKeyToAsn1(t));return n=c.encryptPrivateKeyInfo(n,r,i),c.encryptedPrivateKeyToPem(n)}var a,l,h,u;switch(i.algorithm){case"aes128":a="AES-128-CBC",h=16,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",h=24,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",h=32,l=e.random.getBytes(16),u=e.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",h=24,l=e.random.getBytes(8),u=e.des.createEncryptionCipher;break;default:throw{message:'Could not encrypt RSA private key; unsupported encryption algorithm "'+i.algorithm+'".',algorithm:i.algorithm}}var d=s(r,l.substr(0,8),h),f=u(d);f.start(l),f.update(o.toDer(c.privateKeyToAsn1(t))),f.finish();var p={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:e.util.bytesToHex(l).toUpperCase()},body:f.output.getBytes()};return e.pem.encode(p)},c.decryptRsaPrivateKey=function(t,r){var i=null,n=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==n.type&&"PRIVATE KEY"!==n.type&&"RSA PRIVATE KEY"!==n.type)throw{message:'Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".',headerType:n.type};if(n.procType&&"ENCRYPTED"===n.procType.type){var a,l;switch(n.dekInfo.algorithm){case"DES-EDE3-CBC":a=24,l=e.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,l=e.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,l=e.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,l=e.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,l=function(t){return e.rc2.createDecryptionCipher(t,40)};break;case"RC2-64-CBC":a=8,l=function(t){return e.rc2.createDecryptionCipher(t,64)};break;case"RC2-128-CBC":a=16,l=function(t){return e.rc2.createDecryptionCipher(t,128)};break;default:throw{message:'Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".',algorithm:n.dekInfo.algorithm}}var h=e.util.hexToBytes(n.dekInfo.parameters),u=s(r,h.substr(0,8),a),d=l(u);if(d.start(h),d.update(e.util.createBuffer(n.body)),!d.finish())return i;i=d.output.getBytes()}else i=n.body;return i="ENCRYPTED PRIVATE KEY"===n.type?c.decryptPrivateKeyInfo(o.fromDer(i),r):o.fromDer(i),null!==i&&(i=c.privateKeyFromAsn1(i)),i},c.setRsaPublicKey=c.rsa.setPublicKey,c.setRsaPrivateKey=c.rsa.setPrivateKey}var t="pki",r=["./aes","./asn1","./des","./jsbn","./md","./mgf","./oids","./pem","./pbkdf2","./pkcs12","./pss","./random","./rc2","./rsa","./util"],i=null;if("function"!=typeof define)return e(Mc),void 0;var n=["require","module"].concat(r),s=function(i,n){n.exports=function(n){var s=r.map(function(e){return i(e)}).concat(e);if(n=n||{},n.defined=n.defined||{},n.defined[t])return n[t];n.defined[t]=!0;for(var a=0;a65&&-1!==s){var a=t[s];","===a&&(++s,a=" "),t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),n=i-s-1,s=-1,++i}(" "===t[i]||" "===t[i]||","===t[i])&&(s=i)}return t}function r(e){return e.replace(/^\s+/,"")}var i=e.pem=e.pem||{};i.encode=function(r,i){i=i||{};var n,s="-----BEGIN "+r.type+"-----\r\n";if(r.procType&&(n={name:"Proc-Type",values:[String(r.procType.version),r.procType.type]},s+=t(n)),r.contentDomain&&(n={name:"Content-Domain",values:[r.contentDomain]},s+=t(n)),r.dekInfo&&(n={name:"DEK-Info",values:[r.dekInfo.algorithm]},r.dekInfo.parameters&&n.values.push(r.dekInfo.parameters),s+=t(n)),r.headers)for(var a=0;a>1,o=a+(1&t.length),c=t.substr(0,o),l=t.substr(a,o),h=e.util.createBuffer(),u=e.hmac.create();i=r+i;var d=Math.ceil(n/16),f=Math.ceil(n/20);u.start("MD5",c);var p=e.util.createBuffer();h.putBytes(i);for(var _=0;d>_;++_)(new Date).valueOf(),u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),p.putBuffer(u.digest());u.start("SHA1",l);var g=e.util.createBuffer();h.clear(),h.putBytes(i);for(var _=0;f>_;++_)u.start(null,null),u.update(h.getBytes()),h.putBuffer(u.digest()),u.start(null,null),u.update(h.bytes()+i),g.putBuffer(u.digest());return s.putBytes(e.util.xorBytes(p.getBytes(),g.getBytes(),n)),s},i=function(t,r,i){var n=e.hmac.create();n.start("SHA1",t);var s=e.util.createBuffer();s.putInt32(r[0]),s.putInt32(r[1]),s.putByte(i.type),s.putByte(i.version.major),s.putByte(i.version.minor),s.putInt16(i.length),s.putBytes(i.fragment.bytes());var a=s.getBytes();n.update(a);var o=n.digest().getBytes();return o},n=function(t,r){var i=!1;try{var n=t.deflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},s=function(t,r){var i=!1;try{var n=t.inflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(n),r.length=n.length,i=!0}catch(s){}return i},a=function(e,t){var r=!1,i=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(i),t.updateSequenceNumber();var n=t.cipherState.init?null:t.cipherState.iv;t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start(n),s.update(e.fragment),s.finish(o)&&(e.fragment=s.output,e.length=e.fragment.length(),r=!0),r},o=function(e,t,r){if(!r){var i=t.length()==e?e-1:e-t.length()-1;t.fillWithByte(i,i+1)}return!0},c=function(e,t,r){var i=!0;if(r){for(var n=t.length(),s=t.last(),a=n-1-s;n-1>a;++a)i=i&&t.at(a)==s;i&&t.truncate(s+1)}return i},l=function(t,r){var i=!1,n=r.cipherState.init?null:r.cipherState.iv;r.cipherState.init=!0;var s=r.cipherState.cipher;s.start(n),s.update(t.fragment),i=s.finish(c);for(var a=r.macLength,o="",l=0;a>l;++l)o+=String.fromCharCode(0);var h=s.output.length();h>=a?(t.fragment=s.output.getBytes(h-a),o=s.output.getBytes(a)):t.fragment=s.output.getBytes(),t.fragment=e.util.createBuffer(t.fragment),t.length=t.fragment.length();var u=r.macFunction(r.macKey,r.sequenceNumber,t);return r.updateSequenceNumber(),i=u===o&&i},h=function(t,r){var i=0;switch(r){case 1:i=t.getByte();break;case 2:i=t.getInt16();break;case 3:i=t.getInt24();break;case 4:i=t.getInt32()}return e.util.createBuffer(t.getBytes(i))},u=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},d={};d.Version={major:3,minor:1},d.MaxFragment=15360,d.ConnectionEnd={server:0,client:1},d.PRFAlgorithm={tls_prf_sha256:0},d.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},d.CipherType={stream:0,block:1,aead:2},d.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},d.CompressionMethod={none:0,deflate:1},d.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23},d.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},d.Alert={},d.Alert.Level={warning:1,fatal:2},d.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},d.CipherSuites={TLS_RSA_WITH_AES_128_CBC_SHA:[0,47],TLS_RSA_WITH_AES_256_CBC_SHA:[0,53],TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:[192,10],TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:[192,20],TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,136],TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA:[0,135],TLS_DHE_RSA_WITH_AES_256_CBC_SHA:[0,57],TLS_DHE_DSS_WITH_AES_256_CBC_SHA:[0,56],TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:[192,15],TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:[192,5],TLS_RSA_WITH_CAMELLIA_256_CBC_SHA:[0,132],TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:[192,7],TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:[192,9],TLS_ECDHE_RSA_WITH_RC4_128_SHA:[192,17],TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:[192,19],TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,69],TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA:[0,68],TLS_DHE_RSA_WITH_AES_128_CBC_SHA:[0,51],TLS_DHE_DSS_WITH_AES_128_CBC_SHA:[0,50],TLS_ECDH_RSA_WITH_RC4_128_SHA:[192,12],TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:[192,14],TLS_ECDH_ECDSA_WITH_RC4_128_SHA:[192,2],TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:[192,4],TLS_RSA_WITH_SEED_CBC_SHA:[0,150],TLS_RSA_WITH_CAMELLIA_128_CBC_SHA:[0,65],TLS_RSA_WITH_RC4_128_MD5:[0,4],TLS_RSA_WITH_RC4_128_SHA:[0,5],TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,8],TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:[192,18],TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:[0,22],TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:[0,19],TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:[192,13],TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:[192,3],SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA:[254,255],TLS_RSA_WITH_3DES_EDE_CBC_SHA:[0,10]};var f=function(e,t,r){if(r>0){var i=t.fragment,n=e.session.sp.DHE={};n.prime=i.getBytes(i.getInt(16)),n.g=i.getBytes(i.getInt(16)),n.server_public_key=i.getBytes(i.getInt(16)),n.signature=i.getBytes(i.getInt(16))}e.expect=y,e.process()},p=function(r){var i,n=r.session.sp;if(n.DHE){var s=n.DHE,a=new pt(No(128).toString("hex"),16),o=new pt(new t(s.prime,"binary").toString("hex"),16),c=new pt(new t(s.g,"binary").toString("hex"),16),l=new pt(new t(s.server_public_key,"binary").toString("hex"),16),h=new t(l.modPow(a,o).toString(16),"hex");n.pre_master_secret=h.toString("binary"),i=Os?new t(c.modPow(a,o).toString(16),"hex").toString("binary"):new t(c.modPow(a,o).toString(16),"hex")}else{i=e.util.createBuffer(),i.putByte(d.Version.major),i.putByte(d.Version.minor),i.putBytes(e.random.getBytes(46)),n.pre_master_secret=i.getBytes();var u=r.session.serverCertificate.publicKey;i=u.encrypt(n.pre_master_secret)}var f=i.length+2,p=e.util.createBuffer();return p.putByte(d.HandshakeType.client_key_exchange),p.putInt24(f),p.putInt16(i.length),p.putBytes(i),p};d.getCipherSuite=function(e){var t=null;for(var r in d.CipherSuites){var i=d.CipherSuites[r];if(i[0]===e.charCodeAt(0)&&i[1]===e.charCodeAt(1)){t=i;break}}return t},d.handleUnexpected=function(e){var t=!e.open&&e.entity===d.ConnectionEnd.client;console.log("unexpected message ----------------"),t=!0,t||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.unexpected_message}})},d.handleHelloRequest=function(e){!e.handshaking&&e.handshakes>0&&(d.queue(e,d.createAlert({level:d.Alert.Level.warning,description:d.Alert.Description.no_renegotiation})),d.flush(e)),e.process()},d.parseHelloMessage=function(t,r,i){var n=null,s=t.entity==d.ConnectionEnd.client;if(38>i)t.error(t,{message:s?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var a=r.fragment;if(n={version:{major:a.getByte(),minor:a.getByte()},random:e.util.createBuffer(a.getBytes(32)),session_id:h(a,1),extensions:[]},s?(n.cipher_suite=a.getBytes(2),n.compression_method=a.getByte()):(n.cipher_suites=h(a,2),n.compression_methods=h(a,1)),a.length()>0){for(var o=h(a,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:h(o,2)});if(!s)for(var c=0;c0;){var f=u.getByte();if(0!==f)break;t.session.serverNameList.push(h(u,2).getBytes())}}}if(s)t.session.cipherSuite=d.getCipherSuite(n.cipher_suite);else for(var p=e.util.createBuffer(n.cipher_suites.bytes());p.length()>0&&(t.session.cipherSuite=d.getCipherSuite(p.getBytes(2)),null===t.session.cipherSuite););null===t.session.cipherSuite&&t.error(t,{message:"No cipher suites in common.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.handshake_failure},cipherSuite:e.util.bytesToHex(n.cipher_suite)}),t.session.compressionMethod=s?n.compression_method:d.CompressionMethod.none}return n},d.createSecurityParameters=function(e,t){var r;switch(e.session.cipherSuite){case d.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA:r=16;break;case d.CipherSuites.TLS_DHE_RSA_WITH_AES_128_CBC_SHA:r=16;break;case d.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA:r=32;break;case d.CipherSuites.TLS_DHE_RSA_WITH_AES_256_CBC_SHA:r=32}var i=e.entity===d.ConnectionEnd.client,n=t.random.bytes(),s=i?e.session.sp.client_random:n,a=i?n:d.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:d.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:d.BulkCipherAlgorithm.aes,cipher_type:d.CipherType.block,enc_key_length:r,block_length:16,fixed_iv_length:16,record_iv_length:16,mac_algorithm:d.MACAlgorithm.hmac_sha1,mac_length:20,mac_key_length:20,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:s,server_random:a}},d.handleServerHello=function(e,t,r){var i=d.parseHelloMessage(e,t,r);if(!e.fail){var n=i.session_id.bytes();n&&n===e.session.id?(e.expect=b,e.session.resuming=!0,e.session.sp.server_random=i.random.bytes()):(e.expect=g,e.session.resuming=!1,d.createSecurityParameters(e,i)),e.session.id=n,e.process()}},d.handleClientHello=function(t,r,i){var n=d.parseHelloMessage(t,r,i);if(!t.fail){var s=n.session_id.bytes(),a=null;t.sessionCache&&(a=t.sessionCache.getSession(s),null===a&&(s="")),0===s.length&&(s=e.random.getBytes(32)),t.session.id=s,t.session.clientHelloVersion=n.version,t.session.sp=a?a.sp:{},null!==a?(t.expect=x,t.session.resuming=!0,t.session.sp.client_random=n.random.bytes()):(t.expect=t.verifyClient!==!1?A:I,t.session.resuming=!1,d.createSecurityParameters(t,n)),t.open=!0,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createServerHello(t)})),t.session.resuming?(d.queue(t,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),t.state.pending=d.createConnectionState(t),t.state.current.write=t.state.pending.write,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(t)}))):(d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createCertificate(t)})),t.verifyClient!==!1&&d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createCertificateRequest(t)})),d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createServerHelloDone(t)}))),d.flush(t),t.process() }},d.handleCertificate=function(t,r,i){if(3>i)t.error(t,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var n,s,a=r.fragment,o={certificate_list:h(a,3)},c=[];try{for(;o.certificate_list.length()>0;)n=h(o.certificate_list,3),s=e.asn1.fromDer(n),n=e.pki.certificateFromAsn1(s,!0),c.push(n)}catch(l){t.error(t,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.bad_certificate}})}if(!t.fail){var u=t.entity===d.ConnectionEnd.client;!u&&t.verifyClient!==!0||0!==c.length?0===c.length?t.expect=u?m:I:(u?t.session.serverCertificate=c[0]:t.session.clientCertificate=c[0],d.verifyCertificateChain(t,c)&&(t.expect=u?m:I)):t.error(t,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}}),t.process()}}},d.handleServerKeyExchange=f,d.handleClientKeyExchange=function(t,r,i){if(48>i)t.error(t,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.unsupported_certificate}});else{var n=r.fragment;msg={enc_pre_master_secret:h(n,2).getBytes()};var s=null;if(t.getPrivateKey)try{s=t.getPrivateKey(t,t.session.serverCertificate),s=e.pki.privateKeyFromPem(s)}catch(a){t.error(t,{message:"Could not get private key.",cause:a,send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}})}if(null===s)t.error(t,{message:"No private key set.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}});else try{var o=t.session.sp;o.pre_master_secret=s.decrypt(msg.enc_pre_master_secret);var c=t.session.clientHelloVersion;if(c.major!==o.pre_master_secret.charCodeAt(0)||c.minor!==o.pre_master_secret.charCodeAt(1))throw{message:"TLS version rollback attack detected."}}catch(a){o.pre_master_secret=e.random.getBytes(48)}}t.fail||(t.expect=x,null!==t.session.clientCertificate&&(t.expect=T),t.process())},d.handleCertificateRequest=function(e,t,r){if(3>r)e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var i=t.fragment,n={certificate_types:h(i,1),certificate_authorities:h(i,2)};e.session.certificateRequest=n,e.expect=v,e.process()}},d.handleCertificateVerify=function(t,r,i){if(2>i)t.error(t,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var n=r.fragment;n.read-=4;var s=n.bytes();n.read+=4,msg={signature:h(n,2).getBytes()};var a=e.util.createBuffer();a.putBuffer(t.session.md5.digest()),a.putBuffer(t.session.sha1.digest()),a=a.getBytes();try{var o=t.session.clientCertificate;if(n=e.pki.rsa.decrypt(msg.signature,o.publicKey,!0,a.length),n!==a)throw{message:"CertificateVerify signature does not match."};t.session.md5.update(s),t.session.sha1.update(s)}catch(c){t.error(t,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.handshake_failure}})}t.fail||(t.expect=x,t.process())}},d.handleServerHelloDone=function(e,t,r){if(r>0)e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.record_overflow}});else if(null===e.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.insufficient_security}},n=e.verify(e,i.alert.description,depth,[]);n===!0?i=null:((n||0===n)&&(n.constructor==Object?(n.message&&(i.message=n.message),n.alert&&(i.alert.description=n.alert)):n.constructor==Number&&(i.alert.description=n)),e.error(e,i))}if(e.fail||null===e.session.certificateRequest||(t=d.createRecord({type:d.ContentType.handshake,data:d.createCertificate(e)}),d.queue(e,t)),!e.fail){t=d.createRecord({type:d.ContentType.handshake,data:d.createClientKeyExchange(e)}),d.queue(e,t),e.expect=C;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&d.queue(e,d.createRecord({type:d.ContentType.handshake,data:d.createCertificateVerify(e,t)})),d.queue(e,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),e.state.pending=d.createConnectionState(e),e.state.current.write=e.state.pending.write,d.queue(e,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(e)})),e.expect=b,d.flush(e),e.process()};null===e.session.certificateRequest||null===e.session.clientCertificate?s(e,null):d.getClientSignature(e,s)}},d.handleChangeCipherSpec=function(e,t){if(1!=t.fragment.getByte())e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.illegal_parameter}});else{var r=e.entity===d.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=d.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?w:B,e.process()}},d.handleFinished=function(t,i){var n=i.fragment;n.read-=4;var s=n.bytes();n.read+=4;var a=i.fragment.getBytes();n=e.util.createBuffer(),n.putBuffer(t.session.md5.digest()),n.putBuffer(t.session.sha1.digest());var o=t.entity===d.ConnectionEnd.client,c=o?"server finished":"client finished",l=t.session.sp,h=12,u=r;n=u(l.master_secret,c,n.getBytes(),h),n.getBytes()!==a?t.error(t,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.decrypt_error}}):(t.session.md5.update(s),t.session.sha1.update(s),(t.session.resuming&&o||!t.session.resuming&&!o)&&(d.queue(t,d.createRecord({type:d.ContentType.change_cipher_spec,data:d.createChangeCipherSpec()})),t.state.current.write=t.state.pending.write,t.state.pending=null,d.queue(t,d.createRecord({type:d.ContentType.handshake,data:d.createFinished(t)}))),t.expect=o?E:k,t.handshaking=!1,++t.handshakes,t.peerCertificate=o?t.session.serverCertificate:t.session.clientCertificate,t.sessionCache?(t.session={id:t.session.id,sp:t.session.sp},t.session.sp.keys=null):t.session=null,d.flush(t),t.isConnected=!0,t.connected(t),t.process())},d.handleAlert=function(e,t){var r,i=t.fragment,n={level:i.getByte(),description:i.getByte()};switch(n.description){case d.Alert.Description.close_notify:r="Connection closed.";break;case d.Alert.Description.unexpected_message:r="Unexpected message.";break;case d.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case d.Alert.Description.decryption_failed:r="Decryption failed.";break;case d.Alert.Description.record_overflow:r="Record overflow.";break;case d.Alert.Description.decompression_failure:r="Decompression failed.";break;case d.Alert.Description.handshake_failure:r="Handshake failure.";break;case d.Alert.Description.bad_certificate:r="Bad certificate.";break;case d.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case d.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case d.Alert.Description.certificate_expired:r="Certificate expired.";break;case d.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case d.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case d.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case d.Alert.Description.access_denied:r="Access denied.";break;case d.Alert.Description.decode_error:r="Decode error.";break;case d.Alert.Description.decrypt_error:r="Decrypt error.";break;case d.Alert.Description.export_restriction:r="Export restriction.";break;case d.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case d.Alert.Description.insufficient_security:r="Insufficient security.";break;case d.Alert.Description.internal_error:r="Internal error.";break;case d.Alert.Description.user_canceled:r="User canceled.";break;case d.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}n.description===d.Alert.Description.close_notify?e.close():(e.error(e,{message:r,send:!1,origin:e.entity===d.ConnectionEnd.client?"server":"client",alert:n}),e.process())},d.handleHandshake=function(t,r){var i=r.fragment,n=i.getByte(),s=i.getInt24();if(s>i.length())t.fragmented=r,r.fragment=e.util.createBuffer(),i.read-=4,t.process();else{t.fragmented=null,i.read-=4;var a=i.bytes(s+4);i.read+=4,n in V[t.entity][t.expect]?(t.entity!==d.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={serverNameList:[],cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:e.md.md5.create(),sha1:e.md.sha1.create()}),n!==d.HandshakeType.hello_request&&n!==d.HandshakeType.certificate_verify&&n!==d.HandshakeType.finished&&(t.session.md5.update(a),t.session.sha1.update(a)),V[t.entity][t.expect][n](t,r,s)):d.handleUnexpected(t,r)}},d.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};var _=0,g=1,m=2,y=3,v=4,b=5,w=6,E=7,C=8,S=0,A=1,I=2,T=3,x=4,B=5,k=6,R=d.handleUnexpected,U=d.handleChangeCipherSpec,D=d.handleAlert,N=d.handleHandshake,L=d.handleApplicationData,O=[];O[d.ConnectionEnd.client]=[[R,R,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[U,D,R,R],[R,D,N,R],[R,D,N,L],[R,D,N,R]],O[d.ConnectionEnd.server]=[[R,R,N,R],[R,D,N,R],[R,D,N,R],[R,D,N,R],[U,D,R,R],[R,D,N,R],[R,D,N,L],[R,D,N,R]];var P=d.handleHelloRequest,F=d.handleServerHello,q=d.handleCertificate,H=d.handleServerKeyExchange,M=d.handleCertificateRequest,j=d.handleServerHelloDone,z=d.handleFinished,V=[];V[d.ConnectionEnd.client]=[[R,R,F,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,q,H,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,H,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,M,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,j,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,z],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[P,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R]];var K=d.handleClientHello,G=d.handleClientKeyExchange,Y=d.handleCertificateVerify;V[d.ConnectionEnd.server]=[[R,K,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,q,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,G,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,Y,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,z],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R],[R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R,R]],d.generateKeys=function(e,t){var i=r,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=i(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var s=2*t.mac_key_length+2*t.enc_key_length+2*t.fixed_iv_length,a=i(t.master_secret,"key expansion",n,s);return{client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length),client_write_IV:a.getBytes(t.fixed_iv_length),server_write_IV:a.getBytes(t.fixed_iv_length)}},d.createConnectionState=function(t){var r=t.entity===d.ConnectionEnd.client,o=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(){return!0},compressionState:null,compressFunction:function(){return!0},updateSequenceNumber:function(){4294967295==e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},c={read:o(),write:o()};if(c.read.update=function(e,t){return c.read.cipherFunction(t,c.read)?c.read.compressFunction(e,t,c.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.bad_record_mac}}),!e.fail},c.write.update=function(e,t){return c.write.compressFunction(e,t,c.write)?c.write.cipherFunction(t,c.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:d.Alert.Level.fatal,description:d.Alert.Description.internal_error}}),!e.fail},t.session){var h=t.session.sp;switch(h.keys=d.generateKeys(t,h),c.read.macKey=r?h.keys.server_write_MAC_key:h.keys.client_write_MAC_key,c.write.macKey=r?h.keys.client_write_MAC_key:h.keys.server_write_MAC_key,c.read.macLength=c.write.macLength=h.mac_length,h.mac_algorithm){case d.MACAlgorithm.hmac_sha1:c.read.macFunction=c.write.macFunction=i;break;default:throw{message:"Unsupported MAC algorithm."}}switch(h.bulk_cipher_algorithm){case d.BulkCipherAlgorithm.aes:c.read.cipherState={init:!1,cipher:e.aes.createDecryptionCipher(r?h.keys.server_write_key:h.keys.client_write_key),iv:r?h.keys.server_write_IV:h.keys.client_write_IV},c.write.cipherState={init:!1,cipher:e.aes.createEncryptionCipher(r?h.keys.client_write_key:h.keys.server_write_key),iv:r?h.keys.client_write_IV:h.keys.server_write_IV},c.read.cipherFunction=l,c.write.cipherFunction=a;break;default:throw{message:"Unsupported cipher algorithm."}}switch(h.cipher_type){case d.CipherType.block:break;default:throw{message:"Unsupported cipher type."}}switch(h.compression_algorithm){case d.CompressionMethod.none:break;case d.CompressionMethod.deflate:c.read.compressFunction=s,c.write.compressFunction=n;break;default:throw{message:"Unsupported compression algorithm."}}}return c},d.createRandom=function(){var t=new Date,r=+t+6e4*t.getTimezoneOffset(),i=e.util.createBuffer();return i.putInt32(r),i.putBytes(e.random.getBytes(28)),i},d.createRecord=function(e){var t={type:e.type,version:{major:d.Version.major,minor:d.Version.minor},length:e.data.length(),fragment:e.data};return t},d.createAlert=function(t){var r=e.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),d.createRecord({type:d.ContentType.alert,data:r})},d.createClientHello=function(t){for(var r=e.util.createBuffer(),i=0;i0&&(p+=2);var _=t.session.id,g=_.length+1+2+4+28+2+s+1+o+p,m=e.util.createBuffer();return m.putByte(d.HandshakeType.client_hello),m.putInt24(g),m.putByte(d.Version.major),m.putByte(d.Version.minor),m.putBytes(t.session.sp.client_random),u(m,1,e.util.createBuffer(_)),u(m,2,r),u(m,1,a),p>0&&u(m,2,c),m},d.createServerHello=function(t){var r=t.session.id,i=r.length+1+2+4+28+2+1,n=e.util.createBuffer();return n.putByte(d.HandshakeType.server_hello),n.putInt24(i),n.putByte(d.Version.major),n.putByte(d.Version.minor),n.putBytes(t.session.sp.server_random),u(n,1,e.util.createBuffer(r)),n.putByte(t.session.cipherSuite[0]),n.putByte(t.session.cipherSuite[1]),n.putByte(t.session.compressionMethod),n},d.createCertificate=function(t){var r=t.entity===d.ConnectionEnd.client,i=null;t.getCertificate&&(i=t.getCertificate(t,r?t.session.certificateRequest:t.session.serverNameList));var n=e.util.createBuffer();if(null!==i)try{(Array.isArray&&!Array.isArray(i)||i.constructor!==Array)&&(i=[i]);for(var s=null,a=0;ad.MaxFragment;)n.push(d.createRecord({type:r.type,data:e.util.createBuffer(s.slice(0,d.MaxFragment))})),s=s.slice(d.MaxFragment);s.length>0&&n.push(d.createRecord({type:r.type,data:e.util.createBuffer(s)}))}for(var a=0;a0&&(n=i.order[0]),null!==n&&n in i.cache){r=i.cache[n],delete i.cache[n];for(var s in i.order)if(i.order[s]===n){i.order.splice(s,1);break}}return r},i.setSession=function(t,r){if(i.order.length===i.capacity){var n=i.order.shift();delete i.cache[n]}var n=e.util.bytesToHex(t);i.order.push(n),i.cache[n]=r}}return i},d.createConnection=function(t){var r=null;r=t.caStore?Array.isArray&&Array.isArray(t.caStore)||t.caStore.constructor==Array?e.pki.createCaStore(t.caStore):t.caStore:e.pki.createCaStore();var i=t.cipherSuites||null;null===i&&(i=[],i.push(d.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA),i.push(d.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA));var n=t.server?d.ConnectionEnd.server:d.ConnectionEnd.client,s=t.sessionCache?d.createSessionCache(t.sessionCache):null,a={entity:n,sessionId:t.sessionId,caStore:r,sessionCache:s,cipherSuites:i,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(e,t){return t},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:e.util.createBuffer(),tlsData:e.util.createBuffer(),data:e.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===d.ConnectionEnd.client?"client":"server"),r.send&&(d.queue(e,d.createAlert(r.alert)),d.flush(e));var i=r.fatal!==!1;i&&(e.fail=!0),t.error(e,r),i&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null};a.reset=function(e){a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=a.entity===d.ConnectionEnd.client?_:S,a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||"undefined"==typeof e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=d.createConnectionState(a)},a.reset();var o=function(e,t){var r=t.type-d.ContentType.change_cipher_spec,i=O[e.entity][e.expect];r in i?i[r](e,t):d.handleUnexpected(e,t)},c=function(t){var r=0,i=t.input,n=i.length();return 5>n?r=5-n:t.record={type:i.getByte(),version:{major:i.getByte(),minor:i.getByte()},length:i.getInt16(),fragment:e.util.createBuffer(),ready:!1},r},l=function(e){var t=0,r=e.input,i=r.length();if(i0&&(a.sessionCache&&(r=a.sessionCache.getSession(t)),null===r&&(t="")),0===t.length&&a.sessionCache&&(r=a.sessionCache.getSession(),null!==r&&(t=r.id)),a.session={id:t,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:r?r.sp:{},md5:e.md.md5.create(),sha1:e.md.sha1.create()},a.session.sp.client_random=d.createRandom().getBytes(),a.open=!0,d.queue(a,d.createRecord({type:d.ContentType.handshake,data:d.createClientHello(a)})),d.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.record&&(t=c(a)),a.fail||null===a.record||a.record.ready||(t=l(a)),!a.fail&&null!==a.record&&a.record.ready&&o(a,a.record)),t},a.prepare=function(t){return d.queue(a,d.createRecord({type:d.ContentType.application_data,data:e.util.createBuffer(t)})),d.flush(a)},a.close=function(e){!a.fail&&a.sessionCache&&a.session&&a.sessionCache.setSession(a.session.id,a.session),a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,d.queue(a,d.createAlert({level:d.Alert.Level.warning,description:d.Alert.Description.close_notify})),d.flush(a)),a.closed(a)),a.reset(e)},a},e.tls.prf_tls1=r,e.tls.Alert=d.Alert,e.tls.CipherSuites=d.CipherSuites,e.tls.createSessionCache=d.createSessionCache,e.tls.createConnection=d.createConnection}(),function(){var e={},t=Mc;t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},t.md.md5=t.md.algorithms.md5=e;var r=null,i=null,n=null,s=null,a=!1,o=function(){r=String.fromCharCode(128),r+=t.util.fillString(String.fromCharCode(0),64),i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=new Array(64);for(var e=0;64>e;++e)s[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));a=!0},c=function(e,t,r){for(var a,o,c,l,h,u,d,f,p=r.length();p>=64;){for(o=e.h0,c=e.h1,l=e.h2,h=e.h3,f=0;16>f;++f)t[f]=r.getInt32Le(),u=h^c&(l^h),a=o+u+s[f]+t[f],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;32>f;++f)u=l^h&(c^l),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;48>f;++f)u=c^l^h,a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;for(;64>f;++f)u=l^(c|~h),a=o+u+s[f]+t[i[f]],d=n[f],o=h,h=l,l=c,c+=a<>>32-d;e.h0=4294967295&e.h0+o,e.h1=4294967295&e.h1+c,e.h2=4294967295&e.h2+l,e.h3=4294967295&e.h3+h,p-=64}};e.create=function(){a||o();var e=null,i=t.util.createBuffer(),n=new Array(16),s={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0};return s.start=function(){s.messageLength=0,i=t.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878}},s.start(),s.update=function(r,a){"utf8"===a&&(r=t.util.encodeUtf8(r)),s.messageLength+=r.length,i.putBytes(r),c(e,n,i),(i.read>2048||0===i.length())&&i.compact()},s.digest=function(){var a=s.messageLength,o=t.util.createBuffer();o.putBytes(i.bytes()),o.putBytes(r.substr(0,64-(a+8)%64)),o.putInt32Le(4294967295&a<<3),o.putInt32Le(255&a>>>29);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};c(l,n,o);var h=t.util.createBuffer();return h.putInt32Le(l.h0),h.putInt32Le(l.h1),h.putInt32Le(l.h2),h.putInt32Le(l.h3),h},s}}();var nl=function(e){for(var t=e.length,r=[],i=0;t>i;i++){var n=e[i].charCodeAt().toString(16);r.push(n.length>1?n:"0"+n)}return r.join("")},sl=function(e){for(var t=e.length,r=[],i=0;t>i;i+=2)r.push(String.fromCharCode(parseInt(e[i]+e[i+1],16)));return r.join("")},al=function(e,t,r,i,n,s,a,o){var c=Mc.pki.publicKeyFromPem(Ri.readFileSync(e).toString("utf8")),l=Mc.pki.privateKeyFromPem(Ri.readFileSync(t).toString("utf8"));if(!o){var o=Mc.pki.createCertificate();o.serialNumber=i;var h=new Date(n.valueOf());h.setHours(h.getHours()-2),o.validity.notBefore=h,o.validity.notAfter=new Date(o.validity.notBefore.valueOf()),o.validity.notAfter.setFullYear(o.validity.notBefore.getFullYear()+1);var u=[{name:"commonName",value:s||"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com"}],d=[{name:"commonName",value:a||"www."+No(Math.floor(20*Math.random()+4)).toString("hex")+".com"}];o.setSubject(u),o.setIssuer(d)}o.publicKey=c,o.sign(l);var f=Mc.pki.certificateToPem(o);return"pem"===r?f:"der"===r?Os?Mc.pki.pemToDer(f).toHex():Mc.pki.pemToDer(f).data.toString("hex"):o},ol=function(e){console.log('Generating 512-bit key-pair and certificate for "'+e+'".');var t=Mc.pki.rsa.generateKeyPair(512);console.log("Key-pair created.");var r=Mc.pki.createCertificate();r.serialNumber=Date.now().toString(),r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+1);var i=[{name:"commonName",value:e},{name:"countryName",value:"US"},{shortName:"ST",value:"Virginia"},{name:"localityName",value:"Blacksburg"},{name:"organizationName",value:"Internet Widgits Pty Ltd"},{shortName:"OU",value:"Internet Widgits Pty Ltd"}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"subjectAltName",altNames:[{type:6,value:"http://www.ianonym.com"}]}]),r.publicKey=t.publicKey,r.sign(t.privateKey),console.log('Certificate created for "'+e+'", signature :

    '+nl(r.signature).toUpperCase()),{cert:Mc.pki.certificateToPem(r),privateKey:Mc.pki.privateKeyToPem(t.privateKey)}},cl=function(e,r,i){var n,s=i?"server":"client";return i?Fs[r]?n=Fs[r]:(n=ol(i?r:"client"),Fs[r]=n):n={cert:{},privateKey:{}},Mc.tls.createConnection({server:i?!0:!1,caStore:i?[n.cert]:"",sessionCache:{},cipherSuites:[[0,47],[0,53],[192,10],[192,20],[0,136],[0,135],[0,57],[0,56],[192,15],[192,5],[0,132],[192,7],[192,9],[192,17],[192,19],[0,69],[0,68],[0,51],[0,50],[192,12],[192,14],[192,2],[192,4],[0,150],[0,65],[0,4],[0,5],[192,8],[192,18],[0,22],[0,19],[192,13],[192,3],[254,255],[0,10]],virtualHost:i?"":r,verifyClient:!1,verify:function(e,t,r,i){return!0},connected:function(e){console.log("TLS "+s+" "+r+" connected..."),setTimeout(function(){var t=Mc.util.encodeUtf8("Hello "+("server"===s?"client":"server")+" I want 100 € ");e.prepare(t)},1)},getCertificate:function(){return n.cert},getPrivateKey:function(){return n.privateKey},tlsDataReady:function(r){if(Os){var i=r.tlsData.getBytes();Ps?"server"===s?e.write_s(new t(nl(i),"hex")):e.write_c(new t(nl(i),"hex")):"server"===s?e.write_s(i):e.write_c(i)}else{var n=r.tlsData.data.slice(0,r.tlsData.length_);n.length&&0!==n[0]&&(r.tlsData.clear(),"server"===s?e.write_s(n):e.write_c(n))}},dataReady:function(e){if(Os)console.log(s+" "+r+" received : "+Mc.util.decodeUtf8(e.data.getBytes()));else{var t=e.data.data.toString("utf8");console.log(s+" "+r+" received : "+t)}},closed:function(){console.log(s+" "+r+" disconnected.")},error:function(e,t){console.log(s+" "+r+" notification: "+t.message),-1===t.message.indexOf("Unknown")?console.log("Unexpected error - please retry"):console.log("Normal error message, so far, so good."),e.close()}})}}var ll=function(e,t,r){for(var i="",n="",s="",a=0,o=0;r>0;--r,++a)n=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(i+=s,s="",o=0),s+=String.fromCharCode(n),++o;return i+=s},hl=function(e,r,i){for(var n,s="",a=Math.ceil(r/i),o=0;a>o;++o){var c=String.fromCharCode(255&o>>24,255&o>>16,255&o>>8,255&o);n=new fn("sha1"),n.update(new t(e+c,"binary")),s+=new t(n.digest("hex"),"hex").toString("binary")}return s.substring(0,r)},ul=function(e,r,i){var n,s,a="",o=20; i&&(a=i.label,n=i.seed),s=new fn("sha1");var c=e-2*o-2;if(r.length>c)throw{message:"RSAES-OAEP input message length is too long.",length:r.length,maxLength:c};s.update(new t(a,"binary"));var l=s.digest("hex");l=new t(l,"hex").toString("binary");for(var h="",u=c-r.length,d=0;u>d;d++)h+="\x00";var f=l+h+""+r;n||(n=No(o).toString("binary"));var p=hl(n,e-o-1,o),_=ll(f,p,f.length),g=hl(_,o,o),m=ll(n,g,n.length);return"\x00"+m+_},dl=function(e,r,i){var n,s="",a=20;if(i&&(s=i.label,n=i.md),r.length!==e)throw{message:"RSAES-OAEP encoded message length is invalid.",length:r.length,expectedLength:e};if(n=new fn("sha1"),2*a+2>e)throw{message:"RSAES-OAEP key is too short for the hash function."};n.update(new t(s,"binary"));var o=n.digest("hex");o=new t(o,"hex").toString("binary");for(var c=r.charAt(0),l=r.substring(1,a+1),h=r.substring(1+a),u=hl(h,a,a),d=Mc.util.xorBytes(l,u,l.length),f=hl(d,e-a-1,a),p=Mc.util.xorBytes(h,f,h.length),_=p.substring(0,a),g="\x00"!==c,m=0;a>m;++m)g|=o.charAt(m)!==_.charAt(m);for(var y=1,v=a,b=a;b=t)return t>this._byteLength&&(this._byteLength=t),void 0;for(1>r&&(r=1);t>r;)r*=2;var i=new ArrayBuffer(r),n=new Uint8Array(this._buffer),s=new Uint8Array(i,0,n.length);s.set(n),this.buffer=i,this._byteLength=t}},pl.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var e=new ArrayBuffer(this._byteLength),t=new Uint8Array(e),r=new Uint8Array(this._buffer,0,t.length);t.set(r),this.buffer=e}},pl.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t},pl.prototype.isEof=function(){return this.position>=this._byteLength},pl.prototype.mapInt32Array=function(e,t){this._realloc(4*e);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.mapInt16Array=function(e,t){this._realloc(2*e);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},pl.prototype.mapInt8Array=function(e){this._realloc(1*e);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},pl.prototype.mapUint32Array=function(e,t){this._realloc(4*e);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.mapUint16Array=function(e,t){this._realloc(2*e);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=2*e,r},pl.prototype.mapUint8Array=function(e){this._realloc(1*e);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=1*e,t},pl.prototype.mapFloat64Array=function(e,t){this._realloc(8*e);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=8*e,r},pl.prototype.mapFloat32Array=function(e,t){this._realloc(4*e);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);return pl.arrayToNative(r,null==t?this.endianness:t),this.position+=4*e,r},pl.prototype.readInt32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Int32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readInt16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Int16Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readInt8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Int8Array(e);return pl.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},pl.prototype.readUint32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Uint32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readUint16Array=function(e,t){e=null==e?this.byteLength-this.position/2:e;var r=new Uint16Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readUint8Array=function(e){e=null==e?this.byteLength-this.position:e;var t=new Uint8Array(e);return pl.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT),this.position+=t.byteLength,t},pl.prototype.readFloat64Array=function(e,t){e=null==e?this.byteLength-this.position/8:e;var r=new Float64Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.readFloat32Array=function(e,t){e=null==e?this.byteLength-this.position/4:e;var r=new Float32Array(e);return pl.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT),pl.arrayToNative(r,null==t?this.endianness:t),this.position+=r.byteLength,r},pl.prototype.writeInt32Array=function(e,t){if(this._realloc(4*e.length),e instanceof Int32Array&&0==this.byteOffset+this.position%e.BYTES_PER_ELEMENT)pl.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,t);else for(var r=0;r0,pl.memcpy=function(e,t,r,i,n){var s=new Uint8Array(e,t,n),a=new Uint8Array(r,i,n);s.set(a)},pl.arrayToNative=function(e,t){return t==this.endianness?e:this.flipArrayEndianness(e)},pl.nativeToEndian=function(e,t){return this.endianness==t?e:this.flipArrayEndianness(e)},pl.flipArrayEndianness=function(e){for(var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=0;rn;i--,n++){var s=t[n];t[n]=t[i],t[i]=s}return e},pl.prototype.failurePosition=0,pl.prototype.readStruct=function(e){for(var t,r,i={},n=this.position,s=0;si;i++)this.writeUint16(e.charCodeAt(i),t);for(;r>i;i++)this.writeUint16(0)},pl.prototype.readString=function(e,t){return null==t||"ASCII"==t?String.fromCharCode.apply(null,this.mapUint8Array(null==e?this.byteLength-this.position:e)):new ft(t).decode(this.mapUint8Array(e))},pl.prototype.writeString=function(e,t,r){if(null==t||"ASCII"==t)if(null!=r){var i=0,n=Math.min(e.length,r);for(i=0;n>i;i++)this.writeUint8(e.charCodeAt(i));for(;r>i;i++)this.writeUint8(0)}else for(var i=0;in&&0!=r[n];n++);var s=String.fromCharCode.apply(null,this.mapUint8Array(n));return null!=e?this.position+=i-n:n!=t&&(this.position+=1),s},pl.prototype.writeCString=function(e,t){if(null!=t){var r=0,i=Math.min(e.length,t);for(r=0;i>r;r++)this.writeUint8(e.charCodeAt(r));for(;t>r;r++)this.writeUint8(0)}else{for(var r=0;rf;f++)r[f]=this.readType(o,t)}}}else if("*"==c)for(r=[],this.buffer;;){var p=this.position;try{var _=this.readType(o,t);if(null==_){this.position=p;break}r.push(_)}catch(g){this.position=p;break}}else{r=new Array(l);for(var f=0;l>f;f++){var d=this.readType(o,t);if(null==d)return null;r[f]=d}}break}}return null!=i&&(this.position=s+i),r},pl.prototype.writeStruct=function(e,t){for(var r=0;r>16),this.writeUint8((65280&e)>>8),this.writeUint8(255&e)},pl.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e),this.writeUint32(t),this.seek(r)};var gl={ERR_NOT_ENOUGH_DATA:0,boxCodes:["mdat","avcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt"]}],initialize:function(){var e,t,r;for(gl.FullBox.prototype=new gl.Box,gl.ContainerBox.prototype=new gl.Box,gl.stsdBox.prototype=new gl.FullBox,gl.SampleEntry.prototype=new gl.FullBox,r=gl.boxCodes.length,e=0;r>e;e++)gl[gl.boxCodes[e]+"Box"]=function(e){return function(t){gl.Box.call(this,gl.boxCodes[e],t)}}(e),gl[gl.boxCodes[e]+"Box"].prototype=new gl.Box;for(r=gl.fullBoxCodes.length,e=0;r>e;e++)gl[gl.fullBoxCodes[e]+"Box"]=function(e){return function(t){gl.FullBox.call(this,gl.fullBoxCodes[e],t)}}(e),gl[gl.fullBoxCodes[e]+"Box"].prototype=new gl.FullBox;for(r=gl.containerBoxCodes.length,e=0;r>e;e++)gl[gl.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){if(gl.ContainerBox.call(this,gl.containerBoxCodes[e][0],r),t){this.subBoxNames=t;for(var i=t.length,n=0;i>n;n++)this[t[n]+"s"]=new Array}}}(e,gl.containerBoxCodes[e][1]),gl[gl.containerBoxCodes[e][0]+"Box"].prototype=new gl.ContainerBox;for(r=gl.sampleEntryCodes.length,t=0;r>t;t++){var i=gl.sampleEntryCodes[t].prefix,n=gl.sampleEntryCodes[t].types,s=n.length;for(gl[i+"SampleEntry"]=function(e,t){gl.SampleEntry.call(this,e,t)},gl[i+"SampleEntry"].prototype=new gl.SampleEntry,e=0;s>e;e++)gl[n[e]+"Box"]=function(e,t){return function(r){gl[gl.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,gl.sampleEntryCodes[e].types[t],r)}}(t,e),gl[n[e]+"Box"].prototype=new gl[i+"SampleEntry"]}},Box:function(e,t){this.type=e,this.size=t},FullBox:function(e,t){gl.Box.call(this,e,t),this.flags=0,this.version=0},ContainerBox:function(e,t){gl.Box.call(this,e,t),this.boxes=new Array},SampleEntry:function(e,t){gl.Box.call(this,e,t),this.boxes=new Array},stsdBox:function(e){gl.FullBox.call(this,"stsd",e),this.entries=new Array},parseOneBox:function(e){var t,r=e.position,i=0;if(e.byteLength<8)return gl.ERR_NOT_ENOUGH_DATA;var n=e.readUint32(),s=e.readString(4);if(i=8,"uuid"==s)throw"UUID not supported";return 1==n&&(n=e.readUint64(),i+=8),r+n-i>e.byteLength?(e.seek(r),gl.ERR_NOT_ENOUGH_DATA):(t=gl[s+"Box"]?new gl[s+"Box"](n-i):new gl.Box(s,n-i),t.inputStart=r,t.parse(e),t)}};gl.initialize(),gl.Box.prototype.parse=function(e){this.data=e.readUint8Array(this.size)},gl.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8(),this.flags=e.readUint24(),this.size-=4},gl.ContainerBox.prototype.parse=function(e){var t,r;for(r=e.position;e.position=4;)this.compatible_brands[t]=e.readString(4),this.size-=4,t++},gl.mvhdBox.prototype.parse=function(e){this.flags=0,this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.rate=e.readUint32(),this.volume=e.readUint16()>>8,e.readUint16(),e.readUint32Array(2),this.matrix=e.readUint32Array(9),e.readUint32Array(6),this.next_track_id=e.readUint32()},gl.TKHD_FLAG_ENABLED=1,gl.TKHD_FLAG_IN_MOVIE=2,gl.TKHD_FLAG_IN_PREVIEW=4,gl.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.track_id=e.readUint32(),e.readUint32(),this.duration=e.readUint32()),e.readUint32Array(2),this.layer=e.readInt16(),this.alternate_group=e.readInt16(),this.volume=e.readInt16()>>8,e.readUint16(),this.matrix=e.readInt32Array(9),this.width=e.readUint32(),this.height=e.readUint32()},gl.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e),1==this.version?(this.creation_time=e.readUint64(),this.modification_time=e.readUint64(),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.creation_time=e.readUint32(),this.modification_time=e.readUint32(),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16();var t=[];t[0]=31&this.language>>10,t[1]=31&this.language>>5,t[2]=31&this.language,this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96),e.readUint16()},gl.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e),0==this.version?(e.readUint32(),this.handler=e.readString(4),e.readUint32Array(3),this.name=e.readCString()):this.data=e.readUint8Array(size)},gl.stsdBox.prototype.parse=function(e){var t,r;for(this.parseFullHeader(e),r=e.readUint32(),i=1;r>=i;i++){var t=gl.parseOneBox(e);this.entries.push(t)}},gl.avcCBox.prototype.parse=function(e){var t,r,i;for(this.configurationVersion=e.readUint8(),this.AVCProfileIndication=e.readUint8(),this.profile_compatibility=e.readUint8(),this.AVCLevelIndication=e.readUint8(),this.lengthSizeMinusOne=3&e.readUint8(),r=31&e.readUint8(),this.size-=6,this.SPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.SPS[t]=e.readUint8Array(i),this.size-=2+i;for(r=e.readUint8(),this.size--,this.PPS=new Array(r),t=0;r>t;t++)i=e.readUint16(),this.PPS[t]=e.readUint8Array(i),this.size-=2+i;this.size>0&&(this.ext=e.readUint8Array(this.size))},gl.avc1Box.prototype.getCodec=function(){var e=gl.SampleEntry.prototype.getCodec.call(this);return this.avcC?e+"."+Ti(this.avcC.AVCProfileIndication)+Ti(this.avcC.profile_compatibility)+Ti(this.avcC.AVCLevelIndication):e},gl.mp4aBox.prototype.getCodec=function(){var e=gl.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI(),r=this.esds.esd.getAudioConfig();return e+"."+Ti(t)+(r?"."+r:"")}return e},gl.esdsBox.prototype.parse=function(e){this.parseFullHeader(e),this.data=e.readUint8Array(this.size),this.size=0;var t=new xi;this.esd=t.parseOneDescriptor(new pl(this.data.buffer,0,pl.BIG_ENDIAN))},gl.cttsBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.sample_counts=new Array,this.sample_offsets=new Array,0==this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readUint32());else if(1==this.version)for(r=0;t>r;r++)this.sample_counts.push(e.readUint32()),this.sample_offsets.push(e.readInt32());else this.data=e.readUint8Array(this.size-4)},gl.cttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;tr;r++)this.sample_counts.push(e.readUint32()),this.sample_deltas.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.sttsBox.prototype.unpack=function(e){var t,r,i;for(i=0,t=0;tr;r++)this.shadowed_sample_numbers.push(e.readUint32()),this.sync_sample_numbers.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e),t=e.readUint32(),0==this.version?this.chunk_offsets=e.readUint32Array(t):this.data=e.readUint8Array(this.size-4)},gl.stcoBox.prototype.unpack=function(e){var t;for(t=0;tr;r++)this.chunk_offsets.push(e.readUint64());else this.data=e.readUint8Array(this.size-4) -},gl.stscBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.first_chunk=new Array,this.samples_per_chunk=new Array,this.sample_description_index=new Array,0==this.version)for(r=0;t>r;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;tt;t++)this.sample_sizes[t]=r;else this.data=e.readUint8Array(this.size)},gl.stszBox.prototype.unpack=function(e){var t;for(t=0;tt&&this.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0},gl.TRUN_FLAGS_DATA_OFFSET=1,gl.TRUN_FLAGS_FIRST_FLAG=4,gl.TRUN_FLAGS_DURATION=256,gl.TRUN_FLAGS_SIZE=512,gl.TRUN_FLAGS_FLAGS=1024,gl.TRUN_FLAGS_CTS_OFFSET=2048,gl.trunBox.prototype.parse=function(e){var t=0;if(this.parseFullHeader(e),this.sample_count=e.readUint32(),t+=4,this.size>t&&this.flags&gl.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size>t&&this.flags&gl.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=new Array,this.sample_size=new Array,this.sample_flags=new Array,this.sample_composition_time_offset=new Array,this.size>t)for(var r=0;rt;t++){var s={};if(this.samples[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],n=e.readUint16(),n>0)for(r=0;n>r;r++){var a={};s.subsamples.push(a),a.size=1==this.version?e.readUint32():e.readUint16(),a.priority=e.readUint8(),a.discardable=e.readUint8(),a.reserved=e.readUint32()}}},gl.Box.prototype.writeHeader=function(e){this.size+=8,this.size>_l&&(this.size+=8),this.size>_l?e.writeUint32(1):(this.sizePosition=e.position,e.writeUint32(this.size)),e.writeString(this.type,null,4),this.size>_l&&e.writeUint64(this.size)},gl.FullBox.prototype.writeHeader=function(e){this.size+=4,gl.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},gl.Box.prototype.write=function(e){this.size=this.data.length,this.writeHeader(e),this.data&&e.writeUint8Array(this.data)},gl.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t-1&&this.moov.boxes.splice(t,1)}var n=new gl.mvexBox;this.moov.boxes.push(n);var s=new gl.mehdBox;n.boxes.push(s),s.fragment_duration=this.initial_duration;for(var r=0;r0?this.moov.traks[r].samples[0].duration:0,a.default_sample_size=0,a.default_sample_flags=65536}this.moov.write(e)},Bi.prototype.resetTables=function(){var e,t,r,i,n,s,a,o;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;et?(w.chunk_index=d,w.chunk_run_index=u):(p=0,d++,w.chunk_index=d,f>d?w.chunk_run_index=u:u=g&&(m++,0>g&&(g=0),g+=a.sample_counts[m]),t>0?(w.dts=r.samples[t-1].dts+a.sample_deltas[m],r.samples[t-1].duration=w.dts-r.samples[t-1].dts):w.dts=0,o?(t>=y&&(v++,0>y&&(y=0),y+=o.sample_counts[v]),w.cts=r.samples[t].dts+o.sample_offsets[v]):w.cts=w.dts,c?t==c.sample_numbers[b]-1?(w.is_rap=!0,b++):w.is_rap=!1:w.is_rap=!0,h&&h.samples[subs_entry_index].sample_delta+last_subs_sample_index==t&&(w.subsamples=h.samples[subs_entry_index].subsamples,last_subs_sample_index+=h.samples[subs_entry_index].sample_delta)}t>0&&(r.samples[t-1].duration=r.mdia.mdhd.duration-r.samples[t-1].dts)}},Bi.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t0?p.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(p.dts=h.tfdt?h.tfdt.baseMediaDecodeTime:0,u.first_traf_merged=!0),p.cts=p.dts,f.flags&gl.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+f.sample_composition_time_offset[r]),sample_flags=a,f.flags&gl.TRUN_FLAGS_FLAGS?sample_flags=f.sample_flags[r]:0==r&&f.flags&gl.TRUN_FLAGS_FIRST_FLAG&&(sample_flags=f.first_sample_flags),p.is_rap=1&sample_flags>>16?!1:!0;var _=h.tfhd.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?!0:!1,g=h.tfhd.flags&gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?!0:!1,m=f.flags&gl.TRUN_FLAGS_DATA_OFFSET?!0:!1,y=0;y=_?tfhd.base_data_offset:g?l.inputStart:0==t?l.inputStart:o,p.offset=0==t&&0==r?m?y+f.data_offset:y:o,o=p.offset+p.size}}if(h.subs){var v=h.first_sample_index;for(t=0;t0&&(t+=","),t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t},Bi.prototype.getTrackById=function(e){for(var t=0;t=this.log_level&&console.log("[MP4Box] "+t)},ki.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.stream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples),void 0!=r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},ki.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r-1&&this.fragmentedTracks.splice(t,1)},ki.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples)}},ki.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r-1&&this.extractedTracks.splice(t,1)},ki.prototype.createSingleSampleMoof=function(e){var t=new gl.moofBox,r=new gl.mfhdBox;r.sequence_number=this.nextMoofNumber,this.nextMoofNumber++,t.boxes.push(r);var i=new gl.trafBox;t.boxes.push(i);var n=new gl.tfhdBox;i.boxes.push(n),n.track_id=e.track_id,n.flags=gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new gl.tfdtBox;i.boxes.push(s),s.baseMediaDecodeTime=e.dts;var a=new gl.trunBox;return i.boxes.push(a),t.trun=a,a.flags=gl.TRUN_FLAGS_DATA_OFFSET|gl.TRUN_FLAGS_DURATION|gl.TRUN_FLAGS_SIZE|gl.TRUN_FLAGS_FLAGS|gl.TRUN_FLAGS_CTS_OFFSET,a.data_offset=0,a.first_sample_flags=0,a.sample_count=1,a.sample_duration=new Array,a.sample_duration[0]=e.duration,a.sample_size=new Array,a.sample_size[0]=e.size,a.sample_flags=new Array,a.sample_flags[0]=0,a.sample_composition_time_offset=new Array,a.sample_composition_time_offset[0]=e.cts-e.dts,t},ki.prototype.createFragment=function(e,t,r,i){var n=this.inputIsoFile.getTrackById(t),s=n.samples[r];if(this.inputStream.byteLength=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending fragmented data on track #"+t.id+" for sample "+t.nextSample),this.onSegment(t.id,t.user,t.stream.buffer),t.stream=null)}for(var e=0;e=s.offset+s.size))return;n.nextSample++,this.inputStream.seek(s.offset),s.data=this.inputStream.readUint8Array(s.size),n.samples.push(s),this.onSamples&&(0==n.nextSample%n.nb_samples||n.nextSample>=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending samples on track #"+n.id+" for sample "+n.nextSample),this.onSamples(n.id,n.user,n.samples),n.samples=[])}},ki.prototype.appendBuffer=function(e){var t=this.open(e);t&&this.processSamples()},ki.prototype.getInfo=function(){var e={};e.duration=this.inputIsoFile.moov.mvhd.duration,e.timescale=this.inputIsoFile.moov.mvhd.timescale,e.isFragmented=null!=this.inputIsoFile.moov.mvex,e.isFragmented&&(e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration),e.isProgressive=this.inputIsoFile.isProgressive,e.hasIOD=null!=this.inputIsoFile.moov.iods,e.brands=[],e.brands.push(this.inputIsoFile.ftyp.major_brand),e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);var t=new Date(4,0,1,0,0,0,0).getTime();for(e.created=new Date(t+1e3*this.inputIsoFile.moov.mvhd.creation_time),e.modified=new Date(t+1e3*this.inputIsoFile.moov.mvhd.modification_time),e.tracks=new Array,e.audioTracks=new Array,e.videoTracks=new Array,e.subtitleTracks=new Array,e.metadataTracks=new Array,e.hintTracks=new Array,i=0;i1)for(i=0;iWebsocket was closed by remote party for unknown reasons, this might be a temporary network problem, if the system does not recover please refresh the page

    "),Cl=wc($i)})};if(El&&(js||(El.associate=function(e,r){var i=ho(fo(r.split(".")[1]));i=i.host,console.log("real domain requested "+i);var n=i.split("."),s=n.length>1?[n[n.length-2],n[n.length-1]].join("."):i;bs[r]={real_domain:i,real_domain_a:n,real_domain_s:s,associated:!0},console.log("OP SEND ASSOCIATE CID "+Cs.circId+" "+r); -var a=new t(r,"utf8"),o=new qo(qo.prototype.RELAY_ASSOCIATE,0,a,e.Df_hash),c=new Po(e.circId,Po.prototype.RELAY,e.stream_encrypt_forward(o));e.send(c)}),El.connect(Dn)),s&&!function(){var e=function(){var e={};Xo.call(e),e.params_={},e.params_.OP=!0,e.params_.nb_hop=Hn,e.params_.one_c=!0,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),e.i_id=Vs,Vs++,e.params_.host="www.kickstarter.com:80";var r=new Date,i="GET /projects/450023/ianonym-internet-privacy-everywhere-from-any-devic/pledge/new?clicked_reward=false&ref=category HTTP/1.1\r\n";if(i+="Host: www.kickstarter.com\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="last_page=http%3A%2F%2Fwww.kickstarter.com%2Fprojects%2F450023%2Fianonym-internet-privacy-everywhere-from-any-devic%3Fref%3Dcategory; request_time=Sun%2C+30+Jun+2013+"+r.getHours()+"%3A"+r.getMinutes()+"%3A"+r.getSeconds()+"+-0000; local_offset=-5798;mp_75b1d24a516ecfc955eadfadc4910661_mixpanel=%7B%22distinct_id%22%3A%20%2213f8f454878706-00471d2d6-516e3c71-1aeaa0-13f8f4548796c1%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D",i+="\r\n",e.params_.stream=new t(i,"utf8"),e.remotePort="60000",e.remoteAddress="1.2.3.4",e.write=function(){},e.end=function(){},e.destroy=function(){},e.close=function(){},e._init_=Xo,e._write_=e.write,Qn>=5){rc(e);var n=function(){e.cid_.destroy()};setTimeout(n,1e4)}};setInterval(e,1e4+Math.floor(6e4*Math.random()))}(),A&&!I){var Tl=function(e){return 13==e.keyCode?(this.blur(),!0):!1};if(ks){var xl,Bl=new t("00112233445566778899001122334455","hex"),kl=document.body,Rl=document.getElementsByTagName("head"),Ul="http://www.lepoint.fr",Dl=function(){var e=Nl();return e.className="rounded",kl.appendChild(e),e},Nl=function(){var e=document.createElement("div"),t=e.style;return t.marginLeft="1%",Ll(e,"left"),t.width="98%",t.textAlign="center",t.color="#000",t.fontWeight="800",t.fontSize="1em",t.background="white",t.borderWidth="1px",t.borderStyle="solid",t.borderColor="rgb(217,217,217)",e},Ll=function(e,t){var r=e.style;r.styleFloat=t,r.cssFloat=t},Ol=function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)};Rl.length&&Ol(Rl.item(0)),Ol(kl);var Pl=' html { border:0; padding:0; border:0; } body { font-family: Arial,"Trebuchet MS",helvetica,sans serif; font-size: 14px; font-style: normal; font-weight: normal; text-decoration: none; height: 100%; width:100%; margin:auto; padding:0; background-color:black !important; } p { margin-left:1%; margin-right:1%; } a { margin:1%; } div.ew{ border:0; margin:0; padding:0; -webkit-tap-highlight-color:rgba(0,0,0,0); } .rounded { -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; } input.ew{ font-size:1.2em; -webkit-border-radius:7px; -moz-border-radius:7px; border-radius:7px; border:1px solid; }',Fl=document.createElement("STYLE");Fl.appendChild(document.createTextNode(Pl)),kl.appendChild(Fl);var ql=Dl(),Hl=document.createElement("INPUT"),Ml=Hl.style;Hl.className="ew",Ml.width="80%",Ml.padding="1%",Ml.marginTop="1%",Ml.marginBottom="1%",Ml.marginLeft="1%",Ml.textAlign="center",Ml.color="#000",Hl.value=xl||Ul,ql.appendChild(Hl),Hl.onkeydown=function(e){Tl.call(this,e||window.event)&&""!==this.value&&Gl(this.value)},Hl.onmousedown=function(){this.value===Ul&&(this.value="")};var jl=document.createElement("SPAN"),zl=jl.style;jl.className="ew",zl.padding="1%",zl.width="8%",zl.cursor="pointer",jl.className="rounded",zl.marginTop="1%",zl.marginLeft="1%",zl.backgroundColor="#387BAF",zl.color="white",jl.innerHTML="OK",ql.appendChild(jl),jl.onmousedown=function(){""!==Hl.value&&Gl(Hl.value)};var Vl=Dl();Vl.style.marginTop="1%",Vl.style.textAlign="left",Vl.innerHTML='

    How to use it :

    First please set your proxy settings (Options/Advanced/Network/Settings) to "Automatic proxy configuration" with the value "http://www.ianonym.com/proxy.pac". Then, reload this page. When you are finished don\'t forget to restore the settings to the previous value (No Proxy normally). You should see below the message "Websocket connected", if not, clear the history, close your browser and reopen it.

    Replace "www.example.com" by the URL that you want to open, then click on OK and click on the url proposed. This will establish a secure connection between the new page that was open after you clicked and the current page.

    The new page should indicate that you have initiated an untrusted connection because the certificate created for this connection is self signed, click that you "understand the risks", "Add Exception", and confirm.

    The page will reload and you can start surfing anonymously. If you surf to another site you will have to confirm the exception again, that\'s a little bit painfull but at least you are sure that you are secured. If you have some doubts about your connection, you can first try the Interception Detector.

    This will ensure that you are not intercepted and you can be totally sure to be anonym since all exchanges are encrypted and the domain where you are going looks the same as the link that you clicked, so is hidden, nobody except your browser (the initial page) can decrypt the messages and know the real domain.

    ';var Kl=Dl();Kl.style.marginTop="1%",Kl.style.paddingBottom="1%",Kl.style.textAlign="left",r&&(Vl.style.display="none");var Gl=function(e){var t=ho(e);t.host&&(protocol=t.protocol,Es="www."+fo(t.host,!0)+ms,Qn>=2&&Cs?(console.log("START PAGE real "+e+" fake http://"+Es),El.associate(Cs,Es),Kl.innerHTML='

    Click on the link below :

    http'+Ds+"://"+Es+"/"+t.rest+""):alert("Not enough circuits established : "+Qn+" - Please wait and retry"))};try{var Yl=128,Wl=5,Ql=256,Xl=document.createElement("canvas");Xl.width=4*Ql,Xl.height=4*Ql,Xl.style.position="absolute",Xl.style.zIndex=-1,Xl.style.top="70%",Xl.style.left="50%",Xl.style.marginLeft=-(Xl.width/2)+"px",Xl.style.marginTop=-(Xl.height/2)+"px",document.body.appendChild(Xl);var Jl=Xl.getContext("2d"),Zl=document.createElement("canvas");Zl.width=Ql,Zl.height=Ql;var $l=Zl.getContext("2d");$l.beginPath(),$l.arc(Ql/2,Ql/2,Ql/2,0,2*Math.PI,!0);var eh=function(e){$l.fillStyle=e,$l.fill();for(var t=0;Yl>t;t++){var r=Ql+t*Wl,i=.5*r,n=2*Ql-i,s=2*Ql-i;Jl.globalAlpha=2*Ql/(20*(t+4)*(t+4)),Jl.drawImage(Zl,n,s,r,r)}};eh("rgb(106,253,123)")}catch(th){document.body.style.backgroundColor="black",document.body.style.backgroundColor="radial-gradient(circle at center top, #bdd8df, black)"}}if(Us){var vl,rh,ih,nh,sh,ah,oh,ch,lh,Ya,hh,uh,dh,fh,ph,_h,gh,mh,yh,vh,bh,wh,Eh,Ch,Sh,Ah,Ih,Qi,Th={},xh=0,Bh=0,kh=0,Rh=100,Uh=function(e,t){Wa("prompt_box").style.display="block",Wa("prompt-message").innerHTML=e,Wa("prompt-input").value="",Wa("prompt-input").submit=t,$a(Wa("prompt-input"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1),$a(Wa("prompt-input"),"keydown",function(e){Tl.call(this,e||window.event)&&""!==this.value&&(Wa("prompt_box").style.display="none",this.submit())},!1)},Dh=Wa("close_prompt");$a(Dh,"mousedown",function(){Wa("prompt_box").style.display="none",Wa("prompt-input").submit()},!1);var Nh=Wa("close_alert");$a(Nh,"mousedown",function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},!1);var Lh=function(e){setTimeout(function(){Wa("alert_box").style.display="block"},500),Wa("dialog-message").innerHTML=e},Oh=function(e){e.style.display="none"},Ph=function(e){e.style.display="block"},Fh=function(e){e&&e.forEach(function(e){clearTimeout(e)}),e=[]},qh='var forge={};(function(){var a=forge.util=forge.util||{};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){a.setImmediate=setImmediate;a.nextTick=function(b){return setImmediate(b)}}else{a.setImmediate=function(b){setTimeout(b,0)};a.nextTick=a.setImmediate}}else{a.nextTick=process.nextTick;if(typeof setImmediate==="function"){a.setImmediate=setImmediate}else{a.setImmediate=a.nextTick}}a.isArray=Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"};a.ByteBuffer=function(c){this.data=c||"";this.read=0};a.ByteBuffer.prototype.length=function(){return this.data.length-this.read};a.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0};a.ByteBuffer.prototype.putByte=function(c){this.data+=String.fromCharCode(c);return this};a.ByteBuffer.prototype.fillWithByte=function(c,f){c=String.fromCharCode(c);var e=this.data;while(f>0){if(f&1){e+=c}f>>>=1;if(f>0){c+=c}}this.data=e;return this};a.ByteBuffer.prototype.putBytes=function(b){this.data+=b;return this};a.ByteBuffer.prototype.putString=function(b){this.data+=a.encodeUtf8(b);return this};a.ByteBuffer.prototype.putInt16=function(b){this.data+=String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt24=function(b){this.data+=String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt32=function(b){this.data+=String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt16Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255);return this};a.ByteBuffer.prototype.putInt24Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255);return this};a.ByteBuffer.prototype.putInt32Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>24&255);return this};a.ByteBuffer.prototype.putInt=function(b,c){do{c-=8;this.data+=String.fromCharCode((b>>c)&255)}while(c>0);return this};a.ByteBuffer.prototype.putSignedInt=function(b,c){if(b<0){b+=2<<(c-1)}return this.putInt(b,c)};a.ByteBuffer.prototype.putBuffer=function(b){this.data+=b.getBytes();return this};a.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};a.ByteBuffer.prototype.getInt16=function(){var b=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return b};a.ByteBuffer.prototype.getInt24=function(){var b=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return b};a.ByteBuffer.prototype.getInt32=function(){var b=(this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3));this.read+=4;return b};a.ByteBuffer.prototype.getInt16Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8);this.read+=2;return b};a.ByteBuffer.prototype.getInt24Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16);this.read+=3;return b};a.ByteBuffer.prototype.getInt32Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24);this.read+=4;return b};a.ByteBuffer.prototype.getInt=function(c){var b=0;do{b=(b<<8)+this.data.charCodeAt(this.read++);c-=8}while(c>0);return b};a.ByteBuffer.prototype.getSignedInt=function(d){var c=this.getInt(d);var b=2<<(d-2);if(c>=b){c-=b<<1}return c};a.ByteBuffer.prototype.getBytes=function(b){var c;if(b){b=Math.min(this.length(),b);c=this.data.slice(this.read,this.read+b);this.read+=b}else{if(b===0){c=""}else{c=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return c};a.ByteBuffer.prototype.bytes=function(b){return(typeof(b)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+b))};a.ByteBuffer.prototype.at=function(b){return this.data.charCodeAt(this.read+b)};a.ByteBuffer.prototype.setAt=function(d,c){this.data=this.data.substr(0,this.read+d)+String.fromCharCode(c)+this.data.substr(this.read+d+1);return this};a.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};a.ByteBuffer.prototype.copy=function(){var b=a.createBuffer(this.data);b.read=this.read;return b};a.ByteBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};a.ByteBuffer.prototype.clear=function(){this.data="";this.read=0;return this};a.ByteBuffer.prototype.truncate=function(c){var b=Math.max(0,this.length()-c);this.data=this.data.substr(this.read,b);this.read=0;return this};a.ByteBuffer.prototype.toHex=function(){var e="";for(var d=this.read;d0){if(d&1){b+=e}d>>>=1;if(d>0){e+=e}}return b};a.xorBytes=function(j,f,l){var e="";var d="";var h="";var g=0;var k=0;for(;l>0;--l,++g){d=j.charCodeAt(g)^f.charCodeAt(g);if(k>=10){e+=h;h="";k=0}h+=String.fromCharCode(d);++k}e+=h;return e};a.hexToBytes=function(c){var d="";var b=0;if(c.length&1==1){b=1;d+=String.fromCharCode(parseInt(c[0],16))}for(;b>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255))};a.encodeUtf8=function(b){return unescape(encodeURIComponent(b))};a.decodeUtf8=function(b){return decodeURIComponent(escape(b))};a.deflate=function(e,c,d){c=a.decode64(e.deflate(a.encode64(c)).rval);if(d){var f=2;var b=c.charCodeAt(1);if(b&32){f=6}c=c.substring(f,c.length-4)}return c};a.inflate=function(d,b,c){var e=d.inflate(a.encode64(b)).rval;return(e===null)?null:a.decode64(e)}})();(function(){var e=forge.sha1=forge.sha1||{};forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};forge.md.sha1=forge.md.algorithms.sha1=e;var c=null;var b=false;var d=function(){c=String.fromCharCode(128);c+=forge.util.fillString(String.fromCharCode(0),64);b=true};var a=function(r,p,u){var q,o,n,m,l,k,j,g;var h=u.length();while(h>=64){o=r.h0;n=r.h1;m=r.h2;l=r.h3;k=r.h4;for(g=0;g<16;++g){q=u.getInt32();p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<20;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<32;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<40;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<60;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=(n&m)|(l&(n^m));q=((o<<5)|(o>>>27))+j+k+2400959708+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<80;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+3395469782+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}r.h0+=o;r.h1+=n;r.h2+=m;r.h3+=l;r.h4+=k;h-=64}};e.create=function(){if(!b){d()}var f=null;var i=forge.util.createBuffer();var g=new Array(80);var h={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};h.start=function(){h.messageLength=0;i=forge.util.createBuffer();f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return h};h.start();h.update=function(k,j){if(j==="utf8"){k=forge.util.encodeUtf8(k)}h.messageLength+=k.length;i.putBytes(k);a(f,g,i);if(i.read>2048||i.length()===0){i.compact()}return h};h.digest=function(){var j=h.messageLength;var m=forge.util.createBuffer();m.putBytes(i.bytes());m.putBytes(c.substr(0,64-((j+8)%64)));m.putInt32((j>>>29)&255);m.putInt32((j<<3)&4294967295);var k={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(k,g,m);var l=forge.util.createBuffer();l.putInt32(k.h0);l.putInt32(k.h1);l.putInt32(k.h2);l.putInt32(k.h3);l.putInt32(k.h4);return l};h.digest2=function(){var j=h.messageLength;var o=forge.util.createBuffer();var k=forge.util.createBuffer(i.data.slice(i.read));var m=g.slice(0);o.putBytes(i.bytes());o.putBytes(c.substr(0,64-((j+8)%64)));o.putInt32((j>>>29)&255);o.putInt32((j<<3)&4294967295);var l={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(l,g,o);var n=forge.util.createBuffer();n.putInt32(l.h0);n.putInt32(l.h1);n.putInt32(l.h2);n.putInt32(l.h3);n.putInt32(l.h4);i=k;g=m;return n};return h};e.createhash=function(){var g=e.create();var f=g.update;g.update=function(h){return f(h.toString("binary"))};g.digest=function(){return g.digest2().toHex()};return g}})();(function(){var j=false;var h=4;var f;var b;var d;var k;var g;var e=function(){j=true;d=[0,1,2,4,8,16,32,64,128,27,54];var x=new Array(256);for(var p=0;p<128;++p){x[p]=p<<1;x[p+128]=(p+128)<<1^283}f=new Array(256);b=new Array(256);k=new Array(4);g=new Array(4);for(var p=0;p<4;++p){k[p]=new Array(256);g[p]=new Array(256)}var s=0,o=0,v,t,q,w,l,u,r;for(var p=0;p<256;++p){w=o^(o<<1)^(o<<2)^(o<<3)^(o<<4);w=(w>>8)^(w&255)^99;f[s]=w;b[w]=s;l=x[w];v=x[s];t=x[v];q=x[t];u=(l<<24)^(w<<16)^(w<<8)^(w^l);r=(v^t^q)<<24^(s^q)<<16^(s^t^q)<<8^(s^v^q);for(var m=0;m<4;++m){k[m][s]=u;g[m][w]=r;u=u<<24|u>>>8;r=r<<24|r>>>8}if(s===0){s=o=1}else{s=v^x[x[x[v^q]]];o^=x[x[o]]}}};var a=function(z,o){var x=z.slice(0);var B,m=1;var r=x.length;var p=r+6+1;var s=h*p;for(var u=r;u>>16&255]<<24^f[B>>>8&255]<<16^f[B&255]<<8^f[B>>>24]^(d[m]<<24);m++}else{if(r>6&&(u%r===4)){B=f[B>>>24]<<24^f[B>>>16&255]<<16^f[B>>>8&255]<<8^f[B&255]}}x[u]=x[u-r]^B}if(o){var t;var D=g[0];var C=g[1];var A=g[2];var y=g[3];var v=x.slice(0);var s=x.length;for(var u=0,l=s-h;u>>24]]^C[f[t>>>16&255]]^A[f[t>>>8&255]]^y[f[t&255]]}}}x=v}return x};var c=function(u,v,t,o){var q=u.length/4-1;var p,n,m,l,s;if(o){p=g[0];n=g[1];m=g[2];l=g[3];s=b}else{p=k[0];n=k[1];m=k[2];l=k[3];s=f}var D,C,A,z,E,r,x;D=v[0]^u[0];C=v[o?3:1]^u[1];A=v[2]^u[2];z=v[o?1:3]^u[3];var y=3;for(var B=1;B>>24]^n[C>>>16&255]^m[A>>>8&255]^l[z&255]^u[++y];r=p[C>>>24]^n[A>>>16&255]^m[z>>>8&255]^l[D&255]^u[++y];x=p[A>>>24]^n[z>>>16&255]^m[D>>>8&255]^l[C&255]^u[++y];z=p[z>>>24]^n[D>>>16&255]^m[C>>>8&255]^l[A&255]^u[++y];D=E;C=r;A=x}t[0]=(s[D>>>24]<<24)^(s[C>>>16&255]<<16)^(s[A>>>8&255]<<8)^(s[z&255])^u[++y];t[o?3:1]=(s[C>>>24]<<24)^(s[A>>>16&255]<<16)^(s[z>>>8&255]<<8)^(s[D&255])^u[++y];t[2]=(s[A>>>24]<<24)^(s[z>>>16&255]<<16)^(s[D>>>8&255]<<8)^(s[C&255])^u[++y];t[o?1:3]=(s[z>>>24]<<24)^(s[D>>>16&255]<<16)^(s[C>>>8&255]<<8)^(s[A&255])^u[++y]};var i=function(H,r,u,o,v){var m=null;if(!j){e()}v=(v||"CBC").toUpperCase();if(typeof H==="string"&&(H.length===16||H.length===24||H.length===32)){H=forge.util.createBuffer(H)}else{if(forge.util.isArray(H)&&(H.length===16||H.length===24||H.length===32)){var B=H;var H=forge.util.createBuffer();for(var x=0;x>>2;for(var x=0;x=w||(n.length()>0&&l)){F()}};m.update2=function(J){if(J){if(J.length()){n.data=n.data.substr(n.read);n.read=0;n.putBuffer(J)}}while(n.length()>=w){F()}if(m.overflow){y.getBytes(m.overflow)}var M=n.length()%w;if(M){var K=forge.util.createBuffer(n.data.slice(n.read));var L=s.slice(0);while(n.length()>0){F()}n=K;s=L;y.truncate(w-M)}else{n.data="";n.read=0};m.overflow=M};m.finish=function(N){var M=true;var O=n.length()%w;if(!o){if(N){M=N(w,n,o)}else{if(p){var L=(n.length()===w)?w:(w-n.length());n.fillWithByte(L,L)}}}if(M){l=true;m.update()}if(o){if(p){M=(O===0)}if(M){if(N){M=N(w,y,o)}else{if(p){var J=y.length();var K=y.at(J-1);if(K>(h<<2)){M=false}else{y.truncate(K)}}}}}if(!p&&!N&&O>0){y.truncate(w-O)}return M};m.start=function(K,J){if(K===null){K=q.slice(0)}if(typeof K==="string"&&K.length===16){K=forge.util.createBuffer(K)}else{if(forge.util.isArray(K)&&K.length===16){var M=K;var K=forge.util.createBuffer();for(var L=0;L<16;++L){K.putByte(M[L])}}}if(!forge.util.isArray(K)){var M=K;K=new Array(4);K[0]=M.getInt32();K[1]=M.getInt32();K[2]=M.getInt32();K[3]=M.getInt32()}n=forge.util.createBuffer();y=J||forge.util.createBuffer();q=K.slice(0);s=new Array(h);D=new Array(h);l=false;m.output=y;if(["CFB","OFB","CTR"].indexOf(v)!==-1){for(var L=0;L=0;--J){if(s[J]===4294967295){s[J]=0}else{++s[J];break}}for(var J=0;JLoading...please wait

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%",Ih=new t(this.value,"hex");var i=Ih;if(16===i.length){var n=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),s=0,a=Yi.length/2,o="";n.onmessage=function(e){var n=e.data,c=n.pop?n[0]:n;if(s+=c.length/2,Wa("progint-alert").style.width=parseInt(100*(s/a))+"%",n.pop||(o+=c.toString("utf8")),n.pop){Wa("progress-alert").style.display="none";var l=c,h=sn.createcipheriv("aes-128-ctr",i,Ln),u=h.update(new t(l,"hex"),"hex","hex");if(r===u.toString("hex")){Yi="var FindProxyForUrl="+o,eval(Yi);var d,f=FindProxyForUrl("http://"+Es,Es,!0),p=document.location.href.split("#");if(2===p.length){var _=p[1].split("-");2===_.length?(d=_[0].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge"},d=_[1].split(":"),ka={ip:d[0],port:d[1],wsport:0,fing:d[2],o_modulus:d[3],name:"Tor Bridge"}):(d=p[1].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge - "+d[0]})}else Zi=f[1][_o(f[1].length)];if(ka||(ka=f[2]),Zi!==ka&&(Js=!0),on=Guards,$i&&(vl=new pr,vl.setPublic($i.o_modulus,Nn)),setTimeout(function(){Wa("alert_box").style.display="none"},1e4),!ph&&wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.put({k:i.toString("hex")})}else if(!wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.delete(i.toString("hex"))}Ch?Ph(Wa("debug")):Oh(Wa("debug")),setInterval(Qi,ss),Il(),Mh()}else Uh("

    Wrong key or someone is trying to hack your connection, please retry:

    ",Ah),Wa("prompt-input").type="password"}},n.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),i,Ln])}else Uh("

    Wrong key length, please retry:

    ",Ah),Wa("prompt-input").type="password"}}},Qi=function(){console.log("updating proxy ----"),Yi=Xi("proxy.pac");var e=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),r="";e.onmessage=function(e){var t=e.data,i=t.pop?t[0]:t;t.pop||(r+=i.toString("utf8")),t.pop&&(Yi="var FindProxyForUrl="+r,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0))},e.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),Ih,Ln])},Wa("alert_box").style.display="none",Wa("prompt-input").type="password","peersm"===Xa?(Uh("

    Public version, click on OK to start the Peersm application:

    ",Ah),Wa("prompt-input").value="00112233445566778899aabbccddeeff",Wa("save").checked="checked"):Uh("

    Enter your key:

    ",Ah);try{Ha=indexedDB.open(Xa,6)}catch(th){return Wa("prompt_box").style.display="none",Lh("

    Your browser does not seem to support all the features required for Peersm. It is recommended to use Firefox version 26 or superior, or Chrome version 32 or superior.

    "),void 0}Ha.onupgradeneeded=function(e){console.log("onupgradeneeded------------------");var t=e.target.result;t.objectStoreNames.contains(Xa+"_")&&t.deleteObjectStore(Xa+"_"),t.objectStoreNames.contains(Xa)&&t.deleteObjectStore(Xa),t.createObjectStore(Xa,{keyPath:"name_hash"}),t.createObjectStore(Xa+"_",{keyPath:"k"})},Ha.onsuccess=function(e){Ha.db=e.target.result;var t=Ha.db.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");oh={},Ji=-1!==Ba.userAgent.indexOf("Chrome")?!0:!1,t.openCursor().onsuccess=function(e){var t=e.target.result;if(t){var r=t.value.k;if(r instanceof Array){var i=t.value,n=i.k[0];oh.hasOwnProperty(n)||(console.log("restoring chunks "+n),oh[n]=i)}else Wa("prompt-input").value=r,Wa("save").checked="checked",ph=!0;t.continue()}else ah?Hh():ch=!0},Wa("debug").checked="checked"},Ha.onerror=function(){console.log("Error opening database")};var Mh=function(){var e=function(){mh=new google.visualization.DataTable,mh.addColumn("datetime","Time"),mh.addColumn("number","Received (KB)"),mh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),mh.addRow([r,0,0])}gh={title:"Direct Download : "+(Qn>=0?Qn:0)+" circuits",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:mh.getValue(5,0),max:mh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["green","yellow"]},_h=new google.visualization.LineChart(Wa("chart1")),_h.index=null,_h.dynRow={},_h.dynRow2={},_h.draw(mh,gh)},r=function(){bh=new google.visualization.DataTable,bh.addColumn("datetime","Time"),bh.addColumn("number","Received (KB)"),bh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),bh.addRow([r,0,0])}vh={title:"Peer to peer",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:bh.getValue(5,0),max:bh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["red","orange"]},yh=new google.visualization.LineChart(Wa("chart2")),yh.index=null,yh.dynRow={},yh.dynRow2={},yh.draw(bh,vh)},i=function(e,t,r){for(var i=5,n=go(t.getValue(69,0)).getTime(),s=0;i>s;s++){var a=new Date;a.setTime(n+1e3*(s+1)),t.removeRow(0),t.addRow([a,e.dynRow[a.getTime()]||0,e.dynRow2[a.getTime()]||0]),delete e.dynRow[a.getTime()],delete e.dynRow2[a.getTime()]}-1!==r.title.indexOf("Direct")&&(r.title="Direct Download : "+(Qn>=0?Qn:0)+(Qn>1?" circuits":" circuit")),-1!==r.title.indexOf("Peer")&&(r.title="Peer to Peer : "+(Ss?1:0)+" circuit"),r.hAxis.viewWindow.min=t.getValue(i,0),r.hAxis.viewWindow.max=t.getValue(64,0),r.hAxis.viewWindowMode="explicit",r.animation={duration:4e3,easing:"linear"},e.draw(t,r)},n=Wa("input"),s=document.createElement("input");s.id="url",s.value="Enter_url_or_hash_name_or_magnet_link_or_infohash",n.appendChild(s),Ul=s.value,s.onkeydown=function(e){$a(document.body,"mousedown",function(){},!1),Tl.call(this,e||window.event)&&""!==this.value&&($a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(this.value))};var a=Wa("ok");$a(a,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value)},!1);var o=Wa("stream");$a(o,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value.trim(),!0)},!1),Ya=function(){var e=Ha.db;return e.transaction([Xa],"readwrite").objectStore(Xa)},hh=function(){var e=Ha.db;return e.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_")};var c=function(){var e=sn.createhash("sha1");return e.update(new t(Date.now().toString()+Xa,"utf8")),e.digest("hex")},h=function(e){return e=e.split("."),e.length>1&&e[e.length-1]===Qs&&e.pop(),e.join(".")},u=function(e){setTimeout(function(){Wa("alert_box").style.display="none"},1e4); -var t=Wa(e.hash_ini);e.thumb2_=_(e,e.hash_ini),t?Wa("local").insertBefore(e.thumb2_,t):Wa("local").appendChild(e.thumb2_),e.d_length!==e.clength_&&(e.thumb2_.firstChild.style.backgroundColor="orange",e.thumb_&&(e.thumb_.firstChild.style.backgroundColor="orange")),$a(e.thumb2_,"mousedown",P.bind({file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,url:url,thumb2_:e.thumb2_,thumb_:e.thumb_,clength_:e.clength_,d_length:e.d_length,content_:e.content_,url_:e.url_,key:e.key,content_chrome:e.content_chrome,blob_:e.blob_}),!1),lh(t)},d=function(e){var t=e.thumb_;e.thumb_=_(e),t?t.parentNode?(Wa("downloaded").insertBefore(e.thumb_,t),lh(t)):Wa("downloaded").appendChild(e.thumb_):Wa("downloaded").appendChild(e.thumb_),$a(e.thumb_,"mousedown",O.bind(e),!1)},f=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,lh(Th),lh(nh),$a(document.body,"mousedown",function(){},!1),Lh("

    Uploading file from your disk to your browser storage...please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=this.files[0],i=[],n={},s=r.name.split("#");if(s.length>1){var a=s[1].split(".");n.name_=s[0]+(a.length>1?"."+a[1]:"")}else n.name_=r.name;n.blob_=Ji?new t(0):r,n.content_=r.type,n.clength_=r.size,n.d_length=r.size,n.url_="",n.queue_=[],n.hash_ini=s.length>1?s[1].split(".")[0]:c();var o=r.size,l=0,h=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"})));h.onmessage=function(e){var r=e.data,s=r.pop?Ji?new t(0):0:r;l+=Ji?s.length:parseInt(s);var a=l;if(Ji){if(i.push(s),0===l%$s||l===o){var c=i,h=function(){Wa("progint-alert").style.width=parseInt(100*a/o)+"%",r.pop?(n.check_hash=!0,n.file_hash=r[0],$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0)):(n.file_hash="00",n.d_length=l,b(n,c))};i=[],n.queue_.push(h),1===n.queue_.length&&n.queue_[0]()}}else Wa("progint-alert").style.width=parseInt(100*a/o)+"%",e.data.pop&&(n.check_hash=!0,n.file_hash=e.data[0],Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0))},h.postMessage([Ji?"hashc":"hash",r])},p=Wa("file_upload");$a(p,"change",f,!1),uh=function(e,t){var r=t.d_length||0,i=t.clength_||0,n=0;i&&(n=parseInt(100*(r/i)));var s=document.createElement("div");s.className="progress";var a=document.createElement("p");a.className="bar",a.innerHTML=Gs+n+"%";var o=document.createElement("div");o.className="progcont";var c=document.createElement("div");return c.className="progint",c.style.width=n+"%",o.appendChild(c),s.appendChild(a),s.appendChild(o),e.appendChild(s),s.progtxt=a,s.progbar=c,$a(s,"mousedown",dh.bind(t),!1),s};var _=function(e,t){var r=e.name_||e.name,i=e.blob_||e.data||new Blob([]),n=Bo(r),s=i.type||e.content_chrome||e.content_||e.type,a=La[n]?La[n]:-1!==ro.indexOf(n)&&-1!==s.indexOf("image")?URL.createObjectURL(i):La.exe,o=document.createElement("div");o.className="thumbwrap",t&&(o.id=t);var c=document.createElement("div");c.className="thumb";var l=document.createElement("img");l.className="thumbimg",l.src=a;var h=document.createElement("div");h.align="center";var u=document.createElement("span");return u.className="thumbspan",u.innerHTML=r,c.appendChild(l),o.appendChild(c),h.appendChild(u),o.appendChild(h),o},g=function(e,t){console.log("compute hash"),e.file_hash=0,$a(document.body,"mousedown",function(){},!1),Lh("

    Calculating hash for a resumed file, please wait...

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e.blob_,i=new Worker(URL.createObjectURL(new Blob([qh],{type:"text/javascript"}))),n=r.size,s=0;i.onmessage=function(r){var i=r.data.pop?0:parseInt(r.data);if(s+=i,Wa("progint-alert").style.width=parseInt(100*s/n)+"%",r.data.pop){Wa("progress-alert").style.display="none",setTimeout(function(){Wa("alert_box").style.display="none"},1e4),e.file_hash=r.data[0];var a=function(){d(e),u(e),m(e,t)};e.queue_.push(a),$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),1===e.queue_.length&&e.queue_[0]()}},i.postMessage(["hash",r])};ah=function(e,t,r){console.log("store_DB "),$a(document.body,"mousedown",function(){},!1),e.nb_try===Bs||e.reason_||Lh("

    Storing file, please wait that the file appears in Local Files (for large files this can take some time)

    "),Ha.store=function(){var i,n=Ji?[]:null,s=0,a=hh();e.file_id=e.file_id||0;var o=a.get([e.file_id,s]),c=e.blob_?e.blob_.type:e.content_chrome?e.content_chrome:e.content_,h=new Blob([],{type:c});if(l)var i=Date.now();o.onsuccess=function(o){var l=o.target.result;if(l){var f=l.data;f instanceof Array?(f.unshift(h),h=new Blob(f,{type:c})):h=new Blob([h,f],{type:c}),Ji&&(f instanceof Array?(f.shift(),n=n.concat(f)):n.push(f)),a.delete([e.file_id,s]),s++,_=a.get([e.file_id,s]),_.onsuccess=this.onsuccess}else{console.log("Saving chunks size "+h.size+(i?" time to read all chunks "+(Date.now()-i):"")),Ji&&(e.blob_ instanceof Array?n=n.concat(e.blob_):n.push(e.blob_)),e.blob_=new Blob([h,e.blob_],{type:c});var p=Ya(),_=p.get(e.hash_ini);console.log("store_DB open");var y=Date.now();_.onsuccess=function(i){console.log("store_DB success "+(Date.now()-y));var s=i.target.result;if(s?(lh(Wa(s.name_hash)),Ji?(f=s.data.concat(n),e.blob_=new Blob(f,{type:e.content_chrome?e.content_chrome:e.content_})):(f=new Blob([s.data,e.blob_],{type:c}),e.blob_=f)):f=Ji?n:e.blob_,!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_hash=e.file_hash||0,e.d_length=e.blob_.size,t||d(e),r||u(e),e.check_hash||e.clength_!==e.d_length?m(e,f,r):g(e,f),console.log("Chunks saved "+(Date.now()-y)),Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)}}}},Ha.store()};var m=function(e,t,r){e.file_hash=e.file_hash||0;var i=Ya();Ji?i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t,enc:e.content_chrome||""}):i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t}),r?r(e):(e.d_length===e.clength_&&Ss&&Ss.send_db_info(),ko(e))},b=function(e,t){if(y)var r=Date.now();var i=Ha.db,n=i.transaction([Xa+"_"],"readwrite"),s=n.objectStore(Xa+"_");if(!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_id?e.chunk_nb++:(e.file_id=Date.now(),e.chunk_nb=0),s.put({k:[e.file_id,e.chunk_nb],file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,content_:e.content_,clength_:e.clength_,d_length:e.d_length,url_:e.url_,key:e.key?e.key:"",data:t}),r&&console.log("db_perf "+(Date.now()-r));var o=e.queue_;o.shift(),o.length&&o[0]()},w=function(e){var t=e.split("PT"),r=t[1].split("H"),i=parseFloat(r[1].split("M")[1].split("S")[0]);return t=t[1].split("H")[0],r=r[1].split("M")[0],3600*t+60*r+i},E=function(){try{log("addsourcebuffer "+this._stream_.readyState),this._source_=this._stream_.addSourceBuffer(this.mime_codec)}catch(e){console.log("wait open addsourcebuffer failed")}},C=function(e,t){if(e.received_===t)Wa("alert_box").style.display="none",e._source_.addEventListener("updateend",function(){Do(e)}),Do(e);else if(e.received_>t&&(0===e.append_cursor&&(e.wait_chunk=!0),e.wait_chunk)){var r=Math.min(Math.ceil((e.clength_-e.d_length)/Da),Ea/4);e.append_cursor++,e.append_cursor>=r&&(delete e.wait_chunk,console.log("updateend called "+e._source_.updating),Do(e))}},S=function(e,r){if(r._stream_&&!r._streaming_){if(r.d_length+=e.length,r._json_+=e.toString("utf8"),r.d_length>=r.clength_){console.log("json "+r._json_);var i=JSON.parse(r._json_);for(var n in i)if("Duration"!==n){var s=H(i[n].Representation.BaseURL,null,!0);if(r.nb_sources.push(s),s._streaming_=!0,s.mime_codec=i[n].Representation.mimeType+'; codecs="'+i[n].Representation.codecs+'"',s._stream_=r._stream_,s._parent_=r,s._bandwidth_=i[n].Representation.bandwidth,s._width_=i[n].Representation.width,s._height_=i[n].Representation.height,"open"===r._stream_.readyState)try{s._source_=r._stream_.addSourceBuffer(s.mime_codec)}catch(a){console.log("addsourcebuffer failed"),r._wait_open.push(E.bind(s))}else r._wait_open.push(E.bind(s));rc(s)}else r._stream_.duration=w(i[n]);console.log("Queue fin json "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,fin_.call(r)}}else if(r._streaming_){if(r.d_length+=e.length,r.append_buffer.push(e),r._source_)C(r,Math.min(Ea,r.pieces));else if(r.mp4box){var o=r.append_buffer.length;if(o>=Ca||r.d_length>=r.clength_){for(var c=r.append_buffer.concatBuffers(),l=0;o>l;l++)r.append_buffer.shift();r.mp4box.appendBuffer(c.buffer)}}r.d_length>=r.clength_&&(console.log("Queue fin streaming "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),console.log("queue length "+r.append_buffer.length+" cursor "+r.append_cursor+" received "+r.received_),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,r.mp4box&&r.mp4box.flush(),fin_.call(r))}else if(r.eof_)console.log("EOF");else{var h=function(e){return function(){if(r.d_length+=e.length,!r.blob_){r.content_=r.content_||"application/octet-binary";var i=r.content_.split(";");if(i.length>1&&(r.content_=i[0],r.content_chrome=i[1]||"application/octet-binary"),r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),!r.reload2_&&!r.reload_){r.check_hash=new fn("sha1");var n=Ya();n.delete(r.hash_ini)}r.clength_||lh(r.bar_)}if(r.blob_=Ji?r.blob_.length?[r.blob_,e].concatBuffers():e:new Blob([r.blob_,e],{type:r.content_chrome?r.content_chrome:r.content_}),r.check_hash&&r.check_hash.update(e),r.clength_){var s=r.blob_.size||r.blob_.length||r.blob_.byteLength;if(s>=Zs&&r.d_length=r.clength_&&(console.log("Queue fin "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")+(r.blob_.size||r.blob_.length||r.blob_.byteLength)),Fh(r.sendme_tout),Fh(r.waiting_),r.eof_=!0,r.queue_.push(fin_.bind(r)),1===r.queue_.length&&r.queue_[0]());if(r.clength_||r.d_length>=r.clength_){var o=parseInt(100*(r.d_length/r.clength_));r.bar_.progtxt.innerHTML=Gs+parseInt(r.d_length/1e3)+" kB",r.bar_.progbar.style.width=o+"%"}r.queue_s.shift(),r.queue_s.length&&r.queue_s[0]()}}};r.queue_s=r.queue_s||[],r.queue_s.push(h(e)),1===r.queue_s.length&&r.queue_s[0]()}};lh=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},fin_=function(){console.log("execute fin"),this.eof_=!0,this.queue_=[],this.queue_s=[],this.cid_&&(this.cid_===Ss?(console.log("sending db_end CIC "+this.cid_.circId+" sid "+this.sid_),this.cid_.send_db_end(1,this.sid_)):this.d_lengthStopping download, please wait that pending data are processed, use resume to restart

    ")},500)),1===this.queue_.length&&this.queue_[0]())};var A=function(e,t){Lh('

    Error: '+t+" - This media can not be streamed, please use Download

    "),lh(nh),dh.call(e)};fh=function(e){var t=e.content_;if(console.log("init_media "+t),-1===t.indexOf("json")&&(-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||e._streaming_))-1===t.indexOf("video")&&-1===t.indexOf("audio")||!e._parent_?(Lh('

    Error: not an audio/video file - This media can not be streamed, please use Download

    '),document.body.removeChild(nh),dh.call(e)):(e._parent_.connected_sources++,e._parent_.connected_sources===e._parent_.nb_sources.length&&(console.log("play media"),Lh('

    Connected... the video is going to start, please wait

    '),Th.play()));else if(!Th.parentNode){console.log("stream"),lh(Th),Th=document.createElement("video"),Th.className="mediasrc",Th.controls=!0,e._json_="",e._stream_=new ih,Th.src=URL.createObjectURL(e._stream_),Th._stream_=e._stream_,nh.appendChild(Th),$a(sh,"mousedown",function(){lh(nh),lh(Th),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!0);var r=function(){if(-1===t.indexOf("json"))-1!==t.indexOf("webm")?(e.nb_sources=[],e._streaming_=!0,e._source_=e._stream_.addSourceBuffer('video/webm; codecs="vp8,vorbis"'),console.log("play media"),Lh('

    Connected... the video is going to start, please wait

    '),Th.play()):(e.nb_sources=[],e._streaming_=!0,e.mp4box=new ki,Lh('

    Connected... Analyzing if this video can be streamed, please wait

    '),e.mp4box_t0=setTimeout(function(){A(e,"mp4box timeout")},Sa),e.mp4box.onReady=function(t){if(clearTimeout(e.mp4box_t0),console.log("play media"),Lh('

    Connected... the video is going to start, please wait

    '),Th.play(),t.tracks){for(;t.tracks.length;){var r=t.tracks.shift();if(r){console.log(r.codec);var i='video/mp4; codecs=" '+r.codec+'"',n=!1;if(ih.isTypeSupported(i)){n=!0;var s={append_buffer:[]};s._stream_=e._stream_,s._source_=e._stream_.addSourceBuffer(i),s.pieces=e.pieces,s.received_=0,s.append_cursor=0,s.clength_=e.clength_,s.d_length_=0,e.mp4box.onSegment=function(e,t,r){r=new Uint8Array(r),t.received_++,t.append_buffer.push(r),1===t.received_&&(Wa("alert_box").style.display="none",t._source_.addEventListener("updateend",function(){Do(t)})),Do(t)},e.mp4box.setSegmentOptions(r.id,s)}n||A(e,"codec not supported")}}for(var a=e.mp4box.initializeSegmentation();a.length;){var o=a.shift();o.user.append_buffer.push(new Uint8Array(o.buffer))}}},e.mp4box.onError=function(){console.log("mp4box error"),A(e,"mp4box error")});else for(;e._wait_open.length;)e._wait_open.shift()()};$a(e._stream_,"webkitsourceopen",r,!1),$a(e._stream_,"sourceopen",r,!1),e._stream_.addEventListener("sourceclose",function(){console.log("SOURCE CLOSED"),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!1),Th.addEventListener("seeking",function(){}),Th.addEventListener("pause",function(){}),Th.addEventListener("play",function(){}),Th.addEventListener("error",function(){Lh('

    Error: Media Source error - This media can not be streamed or something unexpected happened

    '),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e);try{e._stream_.endOfStream()}catch(t){}})}};var I=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu"),lh(this.thumb_)},T=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=this,r=function(){if(this.value){var e=Ya(),r=e.get(t.hash_ini);r.onsuccess=function(r){r.target.result&&(r.target.result.name=this.value,t.name_=this.value,e.put(r.target.result),t.thumb_&&d(t),u(t))}.bind(this)}};Uh("

    Enter new name:

    ",r)},x=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=Ya();t.delete(this.hash_ini),lh(this.thumb2_),lh(this.thumb_)},B=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=this;r.nb_try++,r.db_try=0,r.params_.db_=!0,r.reload_=!0,r.sid_&&(delete r.cid_[r.sid_],delete r.sid_),delete r.cid_,delete r.eof_,delete r.check_hash,delete r.last_saved,delete r.file_id,delete r.start_t0,Fh(r.query_t0),r.name_=this.name_||"",r.queue_=[],r.queue_s=[],r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu"),lh(r.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},k=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=H(this.url_,this.hash_ini);r.clength_=this.clength_,r.d_length=this.d_length,r.content_=this.content_,r.reload2_=!0,r.thumb2_=this.thumb2_,delete r.eof_,delete r.last_saved,delete r.file_id,delete r.start_t0,r.queue_=[],r.queue_s=[],r.name_=this.name_||"",Fh(r.query_t0),r.nb_try++,r.db_try=0,r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu2"),lh(this.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},R=function(){var e=this.key;F("menu2"),$a(document.body,"mousedown",function(){},!1),e?setTimeout(function(){Lh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    ")},800):Lh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e?new t(e,"hex"):No(16),i=this.blob_,n=i.size,s={file_hash:"00",hash_ini:c(),name_:e?h(this.name_):this.name_+"."+Qs,clength_:n,d_length:0,content_:this.content_,url_:this.url_,key:e?"":r.toString("hex"),content_chrome:e?null:Ji?"application/binary":null,blob_:Ji?new t(0):new Blob([],{type:e?this.content_:"application/octet-binary"}),queue_:[]},a=0;if(e){var o=Ya(),l=o.get(this.hash_ini);l.onsuccess=function(t){if(t.target.result){var r=t.target.result;r.key=e,this.key=e,$a(this.thumb2_,"mousedown",P.bind({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,content_chrome:this.content_chrome,blob_:this.blob_}),!1),o.put(r)}}.bind(this)}var u=new Worker(URL.createObjectURL(new Blob([qh]))),d=[];if(v)var f=Date.now();u.onmessage=function(t){var r=t.data,i=r instanceof Array?r[0]:r;r instanceof Array||(a+=i.length);var s=a;if(f&&(console.log("worker perf "+(Date.now()-f)),f=Date.now()),d.push(i),0===a%$s||a===n){var o=d,c=function(){Wa("progint-alert").style.width=parseInt(100*(s/n))+"%",r instanceof Array?(this.check_hash=!0,this.file_hash=i,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",ah(this,!0)):(this.file_hash="00",this.d_length=s,b(this,Ji?o:new Blob(o,{type:e?this.content_:"application/octet-binary"})))}.bind(this);d=[],this.queue_.push(c),1===this.queue_.length&&this.queue_[0]()}}.bind(s),u.postMessage(["aes-128-ctr",i,r,Ln])},U=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,R.call({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_})},D=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t={file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,content_:this.content_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_};if(this.blob_.type!==this.content_||"enc"===Bo(this.name_))if(this.key)R.call(t);else{var r=function(){var e=this.value;32===e.length?(t.key=e,R.call(t)):setTimeout(function(){Lh("

    Please enter a valid key

    ")},800)};Uh("

    Enter key:

    ",r)}else Lh("

    This is not an encrypted file

    ")},N=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Lh("
  • Hash Name: "+this.hash_ini+"
  • File hash: "+this.file_hash+"
  • File Type: "+this.content_+"
  • File size: "+this.clength_+" bytes
  • Current size: "+this.d_length+" bytes
  • Key: "+((this.content_chrome?1:this.content_!==this.blob_.type||"enc"===Bo(this.name_))?this.key?this.key:"Get the encryption key from peer":"Not encrypted")+"
  • ")},L=function(e,t){var r=Wa(e);r&&(r.event_&&eo(r,"mousedown",r.event_,!1),r.event_=t.bind(this),$a(r,"mousedown",r.event_,!1))},O=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=Wa("menu2");t.style.display="none",t=Wa("menu"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete",I),L.call(this,"reload",B),this.clength_===this.d_length?Oh(Wa("reload")):Ph(Wa("reload"))},P=function(e){if(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Ss&&Qn>=1){var t=Wa("menu");t.style.display="none",t=Wa("menu2"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open2").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete2",x),L.call(this,"rename2",T),L.call(this,"property2",N),this.d_length===this.clength_?Oh(Wa("reload2")):(Ph(Wa("reload2")),L.call(this,"reload2",k));var r=this.blob_.type||(this.content_chrome?this.content_chrome:this.content_);this.key||r!==this.content_||"enc"===Bo(this.name_)?(Oh(Wa("encrypt2")),Ph(Wa("decrypt2")),L.call(this,"decrypt2",D)):(Ph(Wa("encrypt2")),L.call(this,"encrypt2",U),Oh(Wa("decrypt2")))}else Lh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},F=function(e){var t=Wa(e);t.style.display="none"};Sh=function(){var e=Wa("menu");e.style.display="none",e=Wa("menu2"),e.style.display="none",Wa("alert_box").style.display="none",Wa("prompt_box").style.display="none"},rh=function(e){e.blob_?(e.check_hash&&(e.file_hash=e.check_hash.digest("hex")),console.log("Blob loaded "+e.d_length+" "+(e.file_hash||"")),ah(e),lh(e.bar_)):lh(e.bar_)},$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),$a(Wa("dialog-message"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1);var q=function(e,t){if(Ss&&Qn>1){console.log("Start loading url");var r=H(e,null,t);r.d_length=0,lh(r.thumb_),lh(Wa(r.hash_ini)),t?Th.parentNode||M(r):(r.bar_=uh(Wa("downloaded"),r),lh(Th),lh(nh)),(r.bar_||r._stream_&&ih&&!Th.parentNode)&&rc(r)}else Lh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},H=function(e,r,i){if(!r){var n=so(e);if(n)r=n,e="";else if(-1!==e.indexOf("http")||-1!==e.indexOf("https")){var s=sn.createhash("sha1");s.update(new t(e,"utf8")),r=s.digest("hex")}else r=e,e=""}var a=Jo(e);a.params_.hash_=new t(r,"hex"),a.hash_ini=r,a.url_=e,e=ho(e),a.params_.stream=yo(e.host,e.rest),a.params_.host=e.host+":"+("https"===e.protcol?"443":"80"),a.params_.db_=!0,a.cid_=Ss,a.download_=[],a.d_length=0,a.nb_try=0;var o=e.rest.split("/");return a.name_=o.length?o[o.length-1]:"",a._write_=function(e){S(e,this)},a.queue_=[],a.db_try=0,a.sendme_tout=[],a.waiting_=[],a.queue_s=[],a._stream_=i||!1,i&&(a.stream_buffer=[],a.append_buffer=[],a.append_cursor=0,a.append_wait=new t(0),a.nb_sources=[],a.connected_sources=0,a.debug_chunk=[],a.append_to=[],a._wait_open=[]),a},M=function(e){ih=window.MediaSource||window.webkitMediaSource||window.WebKitMediaSource||window.webkitMediaSource||window.MozMediaSource||!1,ih?(nh=document.createElement("div"),nh.className="media",document.body.appendChild(nh),sh=document.createElement("div"),sh.className="boxclose",nh.appendChild(sh),$a(sh,"mousedown",function(){lh(nh),lh(Th),dh.call(e)},!0)):Lh('

    Media Source is not available in your browser, so streaming is not possible, please update it or try with Chrome browser.

    ')},j=function(){e(),r(),chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),$a(Wa("chart1"),"mousedown",function(){Ys?clearInterval(chart1_int):chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),Ys=!Ys},!1),$a(Wa("chart2"),"mousedown",function(){Ws?clearInterval(chart2_int):chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),Ws=!Ws},!1)},z=function(){Ha.list=function(e){var t=Ha.db.transaction([Xa],"readwrite").objectStore(Xa);t.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;e(i),r.continue()}else ch&&Hh()}},Ha.list(V)},V=function(e){Ji&&(e.data=new Blob(e.data,{type:e.enc?e.enc:e.type}));var t=_(e,e.name_hash);Wa("local").appendChild(t),$a(t,"mousedown",P.bind({file_hash:e.hash,hash_ini:e.name_hash,name_:e.name,thumb2_:t,clength_:e.file_length,d_length:e.current_length,content_:e.type,url_:e.file_url,key:e.key,content_chrome:e.enc||"",blob_:e.data}),!1),e.file_length!==e.current_length&&(t.firstChild.style.backgroundColor="orange")};if(Eh){var K=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="Direct, P2P and bittorrent anonymized circuits : "+K+(K>1?" circuits":" circuit"),Ph(Wa("direct_text")),Ph(Wa("peer_text"))}else{var G=document.createElement("script");G.src="http://www.peersm.com/gchart.js",G.onload=j,document.body.appendChild(G)}Wa("prompt-input").removeAttribute("type"),z()}}}})}(); \ No newline at end of file +},gl.stscBox.prototype.parse=function(e){var t,r;if(this.parseFullHeader(e),t=e.readUint32(),this.first_chunk=new Array,this.samples_per_chunk=new Array,this.sample_description_index=new Array,0==this.version)for(r=0;t>r;r++)this.first_chunk.push(e.readUint32()),this.samples_per_chunk.push(e.readUint32()),this.sample_description_index.push(e.readUint32());else this.data=e.readUint8Array(this.size-4)},gl.stscBox.prototype.unpack=function(e){var t,r,i,n,s;for(n=0,s=0,t=0;tt;t++)this.sample_sizes[t]=r;else this.data=e.readUint8Array(this.size)},gl.stszBox.prototype.unpack=function(e){var t;for(t=0;tt&&this.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=e.readUint64(),t+=8):this.base_data_offset=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=e.readUint32(),t+=4):this.default_sample_description_index=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=e.readUint32(),t+=4):this.default_sample_duration=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=e.readUint32(),t+=4):this.default_sample_size=0,this.size>t&&this.flags&gl.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=e.readUint32(),t+=4):this.default_sample_flags=0},gl.TRUN_FLAGS_DATA_OFFSET=1,gl.TRUN_FLAGS_FIRST_FLAG=4,gl.TRUN_FLAGS_DURATION=256,gl.TRUN_FLAGS_SIZE=512,gl.TRUN_FLAGS_FLAGS=1024,gl.TRUN_FLAGS_CTS_OFFSET=2048,gl.trunBox.prototype.parse=function(e){var t=0;if(this.parseFullHeader(e),this.sample_count=e.readUint32(),t+=4,this.size>t&&this.flags&gl.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=e.readInt32(),t+=4):this.data_offset=0,this.size>t&&this.flags&gl.TRUN_FLAGS_FIRST_FLAG?(this.first_sample_flags=e.readUint32(),t+=4):this.first_sample_flags=0,this.sample_duration=new Array,this.sample_size=new Array,this.sample_flags=new Array,this.sample_composition_time_offset=new Array,this.size>t)for(var r=0;rt;t++){var s={};if(this.samples[t]=s,s.sample_delta=e.readUint32(),s.subsamples=[],n=e.readUint16(),n>0)for(r=0;n>r;r++){var a={};s.subsamples.push(a),a.size=1==this.version?e.readUint32():e.readUint16(),a.priority=e.readUint8(),a.discardable=e.readUint8(),a.reserved=e.readUint32()}}},gl.Box.prototype.writeHeader=function(e){this.size+=8,this.size>_l&&(this.size+=8),this.size>_l?e.writeUint32(1):(this.sizePosition=e.position,e.writeUint32(this.size)),e.writeString(this.type,null,4),this.size>_l&&e.writeUint64(this.size)},gl.FullBox.prototype.writeHeader=function(e){this.size+=4,gl.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags),e.writeUint8(this.version),e.writeUint24(this.flags)},gl.Box.prototype.write=function(e){this.size=this.data.length,this.writeHeader(e),this.data&&e.writeUint8Array(this.data)},gl.ContainerBox.prototype.write=function(e){this.size=0,this.writeHeader(e);for(var t=0;t-1&&this.moov.boxes.splice(t,1)}var n=new gl.mvexBox;this.moov.boxes.push(n);var s=new gl.mehdBox;n.boxes.push(s),s.fragment_duration=this.initial_duration;for(var r=0;r0?this.moov.traks[r].samples[0].duration:0,a.default_sample_size=0,a.default_sample_flags=65536}this.moov.write(e)},Bi.prototype.resetTables=function(){var e,t,r,i,n,s,a,o;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,e=0;et?(w.chunk_index=d,w.chunk_run_index=u):(p=0,d++,w.chunk_index=d,f>d?w.chunk_run_index=u:u=g&&(m++,0>g&&(g=0),g+=a.sample_counts[m]),t>0?(w.dts=r.samples[t-1].dts+a.sample_deltas[m],r.samples[t-1].duration=w.dts-r.samples[t-1].dts):w.dts=0,o?(t>=y&&(v++,0>y&&(y=0),y+=o.sample_counts[v]),w.cts=r.samples[t].dts+o.sample_offsets[v]):w.cts=w.dts,c?t==c.sample_numbers[b]-1?(w.is_rap=!0,b++):w.is_rap=!1:w.is_rap=!0,h&&h.samples[subs_entry_index].sample_delta+last_subs_sample_index==t&&(w.subsamples=h.samples[subs_entry_index].subsamples,last_subs_sample_index+=h.samples[subs_entry_index].sample_delta)}t>0&&(r.samples[t-1].duration=r.mdia.mdhd.duration-r.samples[t-1].dts)}},Bi.prototype.getTrexById=function(e){var t;if(!this.moov||!this.moov.mvex)return null;for(t=0;t0?p.dts=u.samples[u.samples.length-2].dts+u.samples[u.samples.length-2].duration:(p.dts=h.tfdt?h.tfdt.baseMediaDecodeTime:0,u.first_traf_merged=!0),p.cts=p.dts,f.flags&gl.TRUN_FLAGS_CTS_OFFSET&&(p.cts=p.dts+f.sample_composition_time_offset[r]),sample_flags=a,f.flags&gl.TRUN_FLAGS_FLAGS?sample_flags=f.sample_flags[r]:0==r&&f.flags&gl.TRUN_FLAGS_FIRST_FLAG&&(sample_flags=f.first_sample_flags),p.is_rap=1&sample_flags>>16?!1:!0;var _=h.tfhd.flags&gl.TFHD_FLAG_BASE_DATA_OFFSET?!0:!1,g=h.tfhd.flags&gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?!0:!1,m=f.flags&gl.TRUN_FLAGS_DATA_OFFSET?!0:!1,y=0;y=_?tfhd.base_data_offset:g?l.inputStart:0==t?l.inputStart:o,p.offset=0==t&&0==r?m?y+f.data_offset:y:o,o=p.offset+p.size}}if(h.subs){var v=h.first_sample_index;for(t=0;t0&&(t+=","),t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t},Bi.prototype.getTrackById=function(e){for(var t=0;t=this.log_level&&console.log("[MP4Box] "+t)},ki.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.stream=null,n.nb_samples=1e3,n.rapAlignement=!0,r&&(void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples),void 0!=r.rapAlignement&&(n.rapAlignement=r.rapAlignement))}},ki.prototype.unsetSegmentOptions=function(e){for(var t=-1,r=0;r-1&&this.fragmentedTracks.splice(t,1)},ki.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n),n.id=e,n.user=t,n.nextSample=0,n.nb_samples=1e3,n.samples=[],r&&void 0!=r.nb_samples&&(n.nb_samples=r.nbSamples)}},ki.prototype.unsetExtractionOptions=function(e){for(var t=-1,r=0;r-1&&this.extractedTracks.splice(t,1)},ki.prototype.createSingleSampleMoof=function(e){var t=new gl.moofBox,r=new gl.mfhdBox;r.sequence_number=this.nextMoofNumber,this.nextMoofNumber++,t.boxes.push(r);var i=new gl.trafBox;t.boxes.push(i);var n=new gl.tfhdBox;i.boxes.push(n),n.track_id=e.track_id,n.flags=gl.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new gl.tfdtBox;i.boxes.push(s),s.baseMediaDecodeTime=e.dts;var a=new gl.trunBox;return i.boxes.push(a),t.trun=a,a.flags=gl.TRUN_FLAGS_DATA_OFFSET|gl.TRUN_FLAGS_DURATION|gl.TRUN_FLAGS_SIZE|gl.TRUN_FLAGS_FLAGS|gl.TRUN_FLAGS_CTS_OFFSET,a.data_offset=0,a.first_sample_flags=0,a.sample_count=1,a.sample_duration=new Array,a.sample_duration[0]=e.duration,a.sample_size=new Array,a.sample_size[0]=e.size,a.sample_flags=new Array,a.sample_flags[0]=0,a.sample_composition_time_offset=new Array,a.sample_composition_time_offset[0]=e.cts-e.dts,t},ki.prototype.createFragment=function(e,t,r,i){var n=this.inputIsoFile.getTrackById(t),s=n.samples[r];if(this.inputStream.byteLength=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending fragmented data on track #"+t.id+" for sample "+t.nextSample),this.onSegment(t.id,t.user,t.stream.buffer),t.stream=null)}for(var e=0;e=s.offset+s.size))return;n.nextSample++,this.inputStream.seek(s.offset),s.data=this.inputStream.readUint8Array(s.size),n.samples.push(s),this.onSamples&&(0==n.nextSample%n.nb_samples||n.nextSample>=r.samples.length)&&(this.log(ki.LOG_LEVEL_INFO,"Sending samples on track #"+n.id+" for sample "+n.nextSample),this.onSamples(n.id,n.user,n.samples),n.samples=[])}},ki.prototype.appendBuffer=function(e){var t=this.open(e);t&&this.processSamples()},ki.prototype.getInfo=function(){var e={};e.duration=this.inputIsoFile.moov.mvhd.duration,e.timescale=this.inputIsoFile.moov.mvhd.timescale,e.isFragmented=null!=this.inputIsoFile.moov.mvex,e.isFragmented&&(e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration),e.isProgressive=this.inputIsoFile.isProgressive,e.hasIOD=null!=this.inputIsoFile.moov.iods,e.brands=[],e.brands.push(this.inputIsoFile.ftyp.major_brand),e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);var t=new Date(4,0,1,0,0,0,0).getTime();for(e.created=new Date(t+1e3*this.inputIsoFile.moov.mvhd.creation_time),e.modified=new Date(t+1e3*this.inputIsoFile.moov.mvhd.modification_time),e.tracks=new Array,e.audioTracks=new Array,e.videoTracks=new Array,e.subtitleTracks=new Array,e.metadataTracks=new Array,e.hintTracks=new Array,i=0;i1)for(i=0;iWebsocket was closed by remote party for unknown reasons, this might be a temporary network problem, if the system does not recover please refresh the page

    "),Cl=wc($i)})};if(El&&(js||(El.associate=function(e,r){var i=ho(fo(r.split(".")[1]));i=i.host,console.log("real domain requested "+i);var n=i.split("."),s=n.length>1?[n[n.length-2],n[n.length-1]].join("."):i;bs[r]={real_domain:i,real_domain_a:n,real_domain_s:s,associated:!0},console.log("OP SEND ASSOCIATE CID "+Cs.circId+" "+r); +var a=new t(r,"utf8"),o=new qo(qo.prototype.RELAY_ASSOCIATE,0,a,e.Df_hash),c=new Po(e.circId,Po.prototype.RELAY,e.stream_encrypt_forward(o));e.send(c)}),El.connect(Dn)),s&&!function(){var e=function(){var e={};Xo.call(e),e.params_={},e.params_.OP=!0,e.params_.nb_hop=Hn,e.params_.one_c=!0,e.nb_try=0,e.no_exit=[],e.squeue_=[],e.wsqueue_=[],e._date_=Date.now(),e.i_id=Vs,Vs++,e.params_.host="www.kickstarter.com:80";var r=new Date,i="GET /projects/450023/ianonym-internet-privacy-everywhere-from-any-devic/pledge/new?clicked_reward=false&ref=category HTTP/1.1\r\n";if(i+="Host: www.kickstarter.com\r\n",i+="User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0.1\r\n",i+="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n",i+="Accept-Language: en\r\n",i+="Accept-Encoding: gzip, deflate\r\n",i+="Connection: keep-alive\r\n",i+="last_page=http%3A%2F%2Fwww.kickstarter.com%2Fprojects%2F450023%2Fianonym-internet-privacy-everywhere-from-any-devic%3Fref%3Dcategory; request_time=Sun%2C+30+Jun+2013+"+r.getHours()+"%3A"+r.getMinutes()+"%3A"+r.getSeconds()+"+-0000; local_offset=-5798;mp_75b1d24a516ecfc955eadfadc4910661_mixpanel=%7B%22distinct_id%22%3A%20%2213f8f454878706-00471d2d6-516e3c71-1aeaa0-13f8f4548796c1%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D",i+="\r\n",e.params_.stream=new t(i,"utf8"),e.remotePort="60000",e.remoteAddress="1.2.3.4",e.write=function(){},e.end=function(){},e.destroy=function(){},e.close=function(){},e._init_=Xo,e._write_=e.write,Qn>=5){rc(e);var n=function(){e.cid_.destroy()};setTimeout(n,1e4)}};setInterval(e,1e4+Math.floor(6e4*Math.random()))}(),A&&!I){var Tl=function(e){return 13==e.keyCode?(this.blur(),!0):!1};if(ks){var xl,Bl=new t("00112233445566778899001122334455","hex"),kl=document.body,Rl=document.getElementsByTagName("head"),Ul="http://www.lepoint.fr",Dl=function(){var e=Nl();return e.className="rounded",kl.appendChild(e),e},Nl=function(){var e=document.createElement("div"),t=e.style;return t.marginLeft="1%",Ll(e,"left"),t.width="98%",t.textAlign="center",t.color="#000",t.fontWeight="800",t.fontSize="1em",t.background="white",t.borderWidth="1px",t.borderStyle="solid",t.borderColor="rgb(217,217,217)",e},Ll=function(e,t){var r=e.style;r.styleFloat=t,r.cssFloat=t},Ol=function(e){if(e)for(;e.firstChild;)e.removeChild(e.firstChild)};Rl.length&&Ol(Rl.item(0)),Ol(kl);var Pl=' html { border:0; padding:0; border:0; } body { font-family: Arial,"Trebuchet MS",helvetica,sans serif; font-size: 14px; font-style: normal; font-weight: normal; text-decoration: none; height: 100%; width:100%; margin:auto; padding:0; background-color:black !important; } p { margin-left:1%; margin-right:1%; } a { margin:1%; } div.ew{ border:0; margin:0; padding:0; -webkit-tap-highlight-color:rgba(0,0,0,0); } .rounded { -webkit-border-radius:8px; -moz-border-radius:8px; border-radius:8px; } input.ew{ font-size:1.2em; -webkit-border-radius:7px; -moz-border-radius:7px; border-radius:7px; border:1px solid; }',Fl=document.createElement("STYLE");Fl.appendChild(document.createTextNode(Pl)),kl.appendChild(Fl);var ql=Dl(),Hl=document.createElement("INPUT"),Ml=Hl.style;Hl.className="ew",Ml.width="80%",Ml.padding="1%",Ml.marginTop="1%",Ml.marginBottom="1%",Ml.marginLeft="1%",Ml.textAlign="center",Ml.color="#000",Hl.value=xl||Ul,ql.appendChild(Hl),Hl.onkeydown=function(e){Tl.call(this,e||window.event)&&""!==this.value&&Gl(this.value)},Hl.onmousedown=function(){this.value===Ul&&(this.value="")};var jl=document.createElement("SPAN"),zl=jl.style;jl.className="ew",zl.padding="1%",zl.width="8%",zl.cursor="pointer",jl.className="rounded",zl.marginTop="1%",zl.marginLeft="1%",zl.backgroundColor="#387BAF",zl.color="white",jl.innerHTML="OK",ql.appendChild(jl),jl.onmousedown=function(){""!==Hl.value&&Gl(Hl.value)};var Vl=Dl();Vl.style.marginTop="1%",Vl.style.textAlign="left",Vl.innerHTML='

    How to use it :

    First please set your proxy settings (Options/Advanced/Network/Settings) to "Automatic proxy configuration" with the value "http://www.ianonym.com/proxy.pac". Then, reload this page. When you are finished don\'t forget to restore the settings to the previous value (No Proxy normally). You should see below the message "Websocket connected", if not, clear the history, close your browser and reopen it.

    Replace "www.example.com" by the URL that you want to open, then click on OK and click on the url proposed. This will establish a secure connection between the new page that was open after you clicked and the current page.

    The new page should indicate that you have initiated an untrusted connection because the certificate created for this connection is self signed, click that you "understand the risks", "Add Exception", and confirm.

    The page will reload and you can start surfing anonymously. If you surf to another site you will have to confirm the exception again, that\'s a little bit painfull but at least you are sure that you are secured. If you have some doubts about your connection, you can first try the Interception Detector.

    This will ensure that you are not intercepted and you can be totally sure to be anonym since all exchanges are encrypted and the domain where you are going looks the same as the link that you clicked, so is hidden, nobody except your browser (the initial page) can decrypt the messages and know the real domain.

    ';var Kl=Dl();Kl.style.marginTop="1%",Kl.style.paddingBottom="1%",Kl.style.textAlign="left",r&&(Vl.style.display="none");var Gl=function(e){var t=ho(e);t.host&&(protocol=t.protocol,Es="www."+fo(t.host,!0)+ms,Qn>=2&&Cs?(console.log("START PAGE real "+e+" fake http://"+Es),El.associate(Cs,Es),Kl.innerHTML='

    Click on the link below :

    http'+Ds+"://"+Es+"/"+t.rest+""):alert("Not enough circuits established : "+Qn+" - Please wait and retry"))};try{var Yl=128,Wl=5,Ql=256,Xl=document.createElement("canvas");Xl.width=4*Ql,Xl.height=4*Ql,Xl.style.position="absolute",Xl.style.zIndex=-1,Xl.style.top="70%",Xl.style.left="50%",Xl.style.marginLeft=-(Xl.width/2)+"px",Xl.style.marginTop=-(Xl.height/2)+"px",document.body.appendChild(Xl);var Jl=Xl.getContext("2d"),Zl=document.createElement("canvas");Zl.width=Ql,Zl.height=Ql;var $l=Zl.getContext("2d");$l.beginPath(),$l.arc(Ql/2,Ql/2,Ql/2,0,2*Math.PI,!0);var eh=function(e){$l.fillStyle=e,$l.fill();for(var t=0;Yl>t;t++){var r=Ql+t*Wl,i=.5*r,n=2*Ql-i,s=2*Ql-i;Jl.globalAlpha=2*Ql/(20*(t+4)*(t+4)),Jl.drawImage(Zl,n,s,r,r)}};eh("rgb(106,253,123)")}catch(th){document.body.style.backgroundColor="black",document.body.style.backgroundColor="radial-gradient(circle at center top, #bdd8df, black)"}}if(Us){var vl,rh,ih,nh,sh,ah,oh,ch,lh,Ya,hh,uh,dh,fh,ph,_h,gh,mh,yh,vh,bh,wh,Eh,Ch,Sh,Ah,Ih,Qi,Th=!1,xh={},Bh=0,kh=0,Rh=0,Uh=100,Dh=function(e,t){Wa("prompt_box").style.display="block",Wa("prompt-message").innerHTML=e,Wa("prompt-input").value="",Wa("prompt-input").submit=t,$a(Wa("prompt-input"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1),$a(Wa("prompt-input"),"keydown",function(e){Tl.call(this,e||window.event)&&""!==this.value&&(Wa("prompt_box").style.display="none",this.submit())},!1)},Nh=Wa("close_prompt");$a(Nh,"mousedown",function(){Wa("prompt_box").style.display="none",Wa("prompt-input").submit()},!1);var Lh=Wa("close_alert");$a(Lh,"mousedown",function(){Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)},!1);var Oh=function(e){setTimeout(function(){Wa("alert_box").style.display="block"},500),Wa("dialog-message").innerHTML=e},Ph=function(e){e.style.display="none"},Fh=function(e){e.style.display="block"},qh=function(e){e&&e.forEach(function(e){clearTimeout(e)}),e=[]},Hh='var forge={};(function(){var a=forge.util=forge.util||{};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){a.setImmediate=setImmediate;a.nextTick=function(b){return setImmediate(b)}}else{a.setImmediate=function(b){setTimeout(b,0)};a.nextTick=a.setImmediate}}else{a.nextTick=process.nextTick;if(typeof setImmediate==="function"){a.setImmediate=setImmediate}else{a.setImmediate=a.nextTick}}a.isArray=Array.isArray||function(b){return Object.prototype.toString.call(b)==="[object Array]"};a.ByteBuffer=function(c){this.data=c||"";this.read=0};a.ByteBuffer.prototype.length=function(){return this.data.length-this.read};a.ByteBuffer.prototype.isEmpty=function(){return this.length()<=0};a.ByteBuffer.prototype.putByte=function(c){this.data+=String.fromCharCode(c);return this};a.ByteBuffer.prototype.fillWithByte=function(c,f){c=String.fromCharCode(c);var e=this.data;while(f>0){if(f&1){e+=c}f>>>=1;if(f>0){c+=c}}this.data=e;return this};a.ByteBuffer.prototype.putBytes=function(b){this.data+=b;return this};a.ByteBuffer.prototype.putString=function(b){this.data+=a.encodeUtf8(b);return this};a.ByteBuffer.prototype.putInt16=function(b){this.data+=String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt24=function(b){this.data+=String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt32=function(b){this.data+=String.fromCharCode(b>>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return this};a.ByteBuffer.prototype.putInt16Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255);return this};a.ByteBuffer.prototype.putInt24Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255);return this};a.ByteBuffer.prototype.putInt32Le=function(b){this.data+=String.fromCharCode(b&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>24&255);return this};a.ByteBuffer.prototype.putInt=function(b,c){do{c-=8;this.data+=String.fromCharCode((b>>c)&255)}while(c>0);return this};a.ByteBuffer.prototype.putSignedInt=function(b,c){if(b<0){b+=2<<(c-1)}return this.putInt(b,c)};a.ByteBuffer.prototype.putBuffer=function(b){this.data+=b.getBytes();return this};a.ByteBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};a.ByteBuffer.prototype.getInt16=function(){var b=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return b};a.ByteBuffer.prototype.getInt24=function(){var b=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return b};a.ByteBuffer.prototype.getInt32=function(){var b=(this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3));this.read+=4;return b};a.ByteBuffer.prototype.getInt16Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8);this.read+=2;return b};a.ByteBuffer.prototype.getInt24Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16);this.read+=3;return b};a.ByteBuffer.prototype.getInt32Le=function(){var b=(this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24);this.read+=4;return b};a.ByteBuffer.prototype.getInt=function(c){var b=0;do{b=(b<<8)+this.data.charCodeAt(this.read++);c-=8}while(c>0);return b};a.ByteBuffer.prototype.getSignedInt=function(d){var c=this.getInt(d);var b=2<<(d-2);if(c>=b){c-=b<<1}return c};a.ByteBuffer.prototype.getBytes=function(b){var c;if(b){b=Math.min(this.length(),b);c=this.data.slice(this.read,this.read+b);this.read+=b}else{if(b===0){c=""}else{c=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return c};a.ByteBuffer.prototype.bytes=function(b){return(typeof(b)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+b))};a.ByteBuffer.prototype.at=function(b){return this.data.charCodeAt(this.read+b)};a.ByteBuffer.prototype.setAt=function(d,c){this.data=this.data.substr(0,this.read+d)+String.fromCharCode(c)+this.data.substr(this.read+d+1);return this};a.ByteBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};a.ByteBuffer.prototype.copy=function(){var b=a.createBuffer(this.data);b.read=this.read;return b};a.ByteBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};a.ByteBuffer.prototype.clear=function(){this.data="";this.read=0;return this};a.ByteBuffer.prototype.truncate=function(c){var b=Math.max(0,this.length()-c);this.data=this.data.substr(this.read,b);this.read=0;return this};a.ByteBuffer.prototype.toHex=function(){var e="";for(var d=this.read;d0){if(d&1){b+=e}d>>>=1;if(d>0){e+=e}}return b};a.xorBytes=function(j,f,l){var e="";var d="";var h="";var g=0;var k=0;for(;l>0;--l,++g){d=j.charCodeAt(g)^f.charCodeAt(g);if(k>=10){e+=h;h="";k=0}h+=String.fromCharCode(d);++k}e+=h;return e};a.hexToBytes=function(c){var d="";var b=0;if(c.length&1==1){b=1;d+=String.fromCharCode(parseInt(c[0],16))}for(;b>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255))};a.encodeUtf8=function(b){return unescape(encodeURIComponent(b))};a.decodeUtf8=function(b){return decodeURIComponent(escape(b))};a.deflate=function(e,c,d){c=a.decode64(e.deflate(a.encode64(c)).rval);if(d){var f=2;var b=c.charCodeAt(1);if(b&32){f=6}c=c.substring(f,c.length-4)}return c};a.inflate=function(d,b,c){var e=d.inflate(a.encode64(b)).rval;return(e===null)?null:a.decode64(e)}})();(function(){var e=forge.sha1=forge.sha1||{};forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};forge.md.sha1=forge.md.algorithms.sha1=e;var c=null;var b=false;var d=function(){c=String.fromCharCode(128);c+=forge.util.fillString(String.fromCharCode(0),64);b=true};var a=function(r,p,u){var q,o,n,m,l,k,j,g;var h=u.length();while(h>=64){o=r.h0;n=r.h1;m=r.h2;l=r.h3;k=r.h4;for(g=0;g<16;++g){q=u.getInt32();p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<20;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=l^(n&(m^l));q=((o<<5)|(o>>>27))+j+k+1518500249+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<32;++g){q=(p[g-3]^p[g-8]^p[g-14]^p[g-16]);q=(q<<1)|(q>>>31);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<40;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+1859775393+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<60;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=(n&m)|(l&(n^m));q=((o<<5)|(o>>>27))+j+k+2400959708+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}for(;g<80;++g){q=(p[g-6]^p[g-16]^p[g-28]^p[g-32]);q=(q<<2)|(q>>>30);p[g]=q;j=n^m^l;q=((o<<5)|(o>>>27))+j+k+3395469782+q;k=l;l=m;m=(n<<30)|(n>>>2);n=o;o=q}r.h0+=o;r.h1+=n;r.h2+=m;r.h3+=l;r.h4+=k;h-=64}};e.create=function(){if(!b){d()}var f=null;var i=forge.util.createBuffer();var g=new Array(80);var h={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0};h.start=function(){h.messageLength=0;i=forge.util.createBuffer();f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};return h};h.start();h.update=function(k,j){if(j==="utf8"){k=forge.util.encodeUtf8(k)}h.messageLength+=k.length;i.putBytes(k);a(f,g,i);if(i.read>2048||i.length()===0){i.compact()}return h};h.digest=function(){var j=h.messageLength;var m=forge.util.createBuffer();m.putBytes(i.bytes());m.putBytes(c.substr(0,64-((j+8)%64)));m.putInt32((j>>>29)&255);m.putInt32((j<<3)&4294967295);var k={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(k,g,m);var l=forge.util.createBuffer();l.putInt32(k.h0);l.putInt32(k.h1);l.putInt32(k.h2);l.putInt32(k.h3);l.putInt32(k.h4);return l};h.digest2=function(){var j=h.messageLength;var o=forge.util.createBuffer();var k=forge.util.createBuffer(i.data.slice(i.read));var m=g.slice(0);o.putBytes(i.bytes());o.putBytes(c.substr(0,64-((j+8)%64)));o.putInt32((j>>>29)&255);o.putInt32((j<<3)&4294967295);var l={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};a(l,g,o);var n=forge.util.createBuffer();n.putInt32(l.h0);n.putInt32(l.h1);n.putInt32(l.h2);n.putInt32(l.h3);n.putInt32(l.h4);i=k;g=m;return n};return h};e.createhash=function(){var g=e.create();var f=g.update;g.update=function(h){return f(h.toString("binary"))};g.digest=function(){return g.digest2().toHex()};return g}})();(function(){var j=false;var h=4;var f;var b;var d;var k;var g;var e=function(){j=true;d=[0,1,2,4,8,16,32,64,128,27,54];var x=new Array(256);for(var p=0;p<128;++p){x[p]=p<<1;x[p+128]=(p+128)<<1^283}f=new Array(256);b=new Array(256);k=new Array(4);g=new Array(4);for(var p=0;p<4;++p){k[p]=new Array(256);g[p]=new Array(256)}var s=0,o=0,v,t,q,w,l,u,r;for(var p=0;p<256;++p){w=o^(o<<1)^(o<<2)^(o<<3)^(o<<4);w=(w>>8)^(w&255)^99;f[s]=w;b[w]=s;l=x[w];v=x[s];t=x[v];q=x[t];u=(l<<24)^(w<<16)^(w<<8)^(w^l);r=(v^t^q)<<24^(s^q)<<16^(s^t^q)<<8^(s^v^q);for(var m=0;m<4;++m){k[m][s]=u;g[m][w]=r;u=u<<24|u>>>8;r=r<<24|r>>>8}if(s===0){s=o=1}else{s=v^x[x[x[v^q]]];o^=x[x[o]]}}};var a=function(z,o){var x=z.slice(0);var B,m=1;var r=x.length;var p=r+6+1;var s=h*p;for(var u=r;u>>16&255]<<24^f[B>>>8&255]<<16^f[B&255]<<8^f[B>>>24]^(d[m]<<24);m++}else{if(r>6&&(u%r===4)){B=f[B>>>24]<<24^f[B>>>16&255]<<16^f[B>>>8&255]<<8^f[B&255]}}x[u]=x[u-r]^B}if(o){var t;var D=g[0];var C=g[1];var A=g[2];var y=g[3];var v=x.slice(0);var s=x.length;for(var u=0,l=s-h;u>>24]]^C[f[t>>>16&255]]^A[f[t>>>8&255]]^y[f[t&255]]}}}x=v}return x};var c=function(u,v,t,o){var q=u.length/4-1;var p,n,m,l,s;if(o){p=g[0];n=g[1];m=g[2];l=g[3];s=b}else{p=k[0];n=k[1];m=k[2];l=k[3];s=f}var D,C,A,z,E,r,x;D=v[0]^u[0];C=v[o?3:1]^u[1];A=v[2]^u[2];z=v[o?1:3]^u[3];var y=3;for(var B=1;B>>24]^n[C>>>16&255]^m[A>>>8&255]^l[z&255]^u[++y];r=p[C>>>24]^n[A>>>16&255]^m[z>>>8&255]^l[D&255]^u[++y];x=p[A>>>24]^n[z>>>16&255]^m[D>>>8&255]^l[C&255]^u[++y];z=p[z>>>24]^n[D>>>16&255]^m[C>>>8&255]^l[A&255]^u[++y];D=E;C=r;A=x}t[0]=(s[D>>>24]<<24)^(s[C>>>16&255]<<16)^(s[A>>>8&255]<<8)^(s[z&255])^u[++y];t[o?3:1]=(s[C>>>24]<<24)^(s[A>>>16&255]<<16)^(s[z>>>8&255]<<8)^(s[D&255])^u[++y];t[2]=(s[A>>>24]<<24)^(s[z>>>16&255]<<16)^(s[D>>>8&255]<<8)^(s[C&255])^u[++y];t[o?1:3]=(s[z>>>24]<<24)^(s[D>>>16&255]<<16)^(s[C>>>8&255]<<8)^(s[A&255])^u[++y]};var i=function(H,r,u,o,v){var m=null;if(!j){e()}v=(v||"CBC").toUpperCase();if(typeof H==="string"&&(H.length===16||H.length===24||H.length===32)){H=forge.util.createBuffer(H)}else{if(forge.util.isArray(H)&&(H.length===16||H.length===24||H.length===32)){var B=H;var H=forge.util.createBuffer();for(var x=0;x>>2;for(var x=0;x=w||(n.length()>0&&l)){F()}};m.update2=function(J){if(J){if(J.length()){n.data=n.data.substr(n.read);n.read=0;n.putBuffer(J)}}while(n.length()>=w){F()}if(m.overflow){y.getBytes(m.overflow)}var M=n.length()%w;if(M){var K=forge.util.createBuffer(n.data.slice(n.read));var L=s.slice(0);while(n.length()>0){F()}n=K;s=L;y.truncate(w-M)}else{n.data="";n.read=0};m.overflow=M};m.finish=function(N){var M=true;var O=n.length()%w;if(!o){if(N){M=N(w,n,o)}else{if(p){var L=(n.length()===w)?w:(w-n.length());n.fillWithByte(L,L)}}}if(M){l=true;m.update()}if(o){if(p){M=(O===0)}if(M){if(N){M=N(w,y,o)}else{if(p){var J=y.length();var K=y.at(J-1);if(K>(h<<2)){M=false}else{y.truncate(K)}}}}}if(!p&&!N&&O>0){y.truncate(w-O)}return M};m.start=function(K,J){if(K===null){K=q.slice(0)}if(typeof K==="string"&&K.length===16){K=forge.util.createBuffer(K)}else{if(forge.util.isArray(K)&&K.length===16){var M=K;var K=forge.util.createBuffer();for(var L=0;L<16;++L){K.putByte(M[L])}}}if(!forge.util.isArray(K)){var M=K;K=new Array(4);K[0]=M.getInt32();K[1]=M.getInt32();K[2]=M.getInt32();K[3]=M.getInt32()}n=forge.util.createBuffer();y=J||forge.util.createBuffer();q=K.slice(0);s=new Array(h);D=new Array(h);l=false;m.output=y;if(["CFB","OFB","CTR"].indexOf(v)!==-1){for(var L=0;L=0;--J){if(s[J]===4294967295){s[J]=0}else{++s[J];break}}for(var J=0;JLoading...please wait

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%",Ih=new t(this.value,"hex");var i=Ih;if(16===i.length){var n=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),s=0,a=Yi.length/2,o="";n.onmessage=function(e){var n=e.data,c=n.pop?n[0]:n;if(s+=c.length/2,Wa("progint-alert").style.width=parseInt(100*(s/a))+"%",n.pop||(o+=c.toString("utf8")),n.pop){Wa("progress-alert").style.display="none";var l=c,h=sn.createcipheriv("aes-128-ctr",i,Ln),u=h.update(new t(l,"hex"),"hex","hex");if(r===u.toString("hex")){Yi="var FindProxyForUrl="+o,eval(Yi);var d,f=FindProxyForUrl("http://"+Es,Es,!0),p=document.location.href.split("#");if(2===p.length){var _=p[1].split("-");2===_.length?(d=_[0].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge"},d=_[1].split(":"),ka={ip:d[0],port:d[1],wsport:0,fing:d[2],o_modulus:d[3],name:"Tor Bridge"}):(d=p[1].split(":"),Zi={ip:d[0],port:0,wsport:d[1],fing:"",o_modulus:"",name:"Tor Bridge - "+d[0]})}else Zi=f[1][_o(f[1].length)];if(ka||(ka=f[2]),Zi!==ka&&(Js=!0),on=Guards,$i&&(vl=new pr,vl.setPublic($i.o_modulus,Nn)),setTimeout(function(){Wa("alert_box").style.display="none"},1e4),!ph&&wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.put({k:i.toString("hex")})}else if(!wh){var g=Ha.db,m=g.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");m.delete(i.toString("hex"))}Ch?Fh(Wa("debug")):Ph(Wa("debug")),setInterval(Qi,ss),Il(),jh()}else Dh("

    Wrong key or someone is trying to hack your connection, please retry:

    ",Ah),Wa("prompt-input").type="password"}},n.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),i,Ln])}else Dh("

    Wrong key length, please retry:

    ",Ah),Wa("prompt-input").type="password"}}},Qi=function(){console.log("updating proxy ----"),Yi=Xi("proxy.pac");var e=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),r="";e.onmessage=function(e){var t=e.data,i=t.pop?t[0]:t;t.pop||(r+=i.toString("utf8")),t.pop&&(Yi="var FindProxyForUrl="+r,eval(Yi),FindProxyForUrl("http://"+Es,Es,!0))},e.postMessage(["aes-128-ctr",new Blob([new t(Yi,"hex")]),Ih,Ln])},Wa("alert_box").style.display="none",Wa("prompt-input").type="password","peersm"===Xa?(Dh("

    Public version, click on OK to start the Peersm application:

    ",Ah),Wa("prompt-input").value="00112233445566778899aabbccddeeff",Wa("save").checked="checked"):Dh("

    Enter your key:

    ",Ah);try{Ha=indexedDB.open(Xa,6)}catch(th){return Wa("prompt_box").style.display="none",Oh("

    Your browser does not seem to support all the features required for Peersm. It is recommended to use Firefox version 26 or superior, or Chrome version 32 or superior.

    "),void 0}Ha.onupgradeneeded=function(e){console.log("onupgradeneeded------------------");var t=e.target.result;t.objectStoreNames.contains(Xa+"_")&&t.deleteObjectStore(Xa+"_"),t.objectStoreNames.contains(Xa)&&t.deleteObjectStore(Xa),t.createObjectStore(Xa,{keyPath:"name_hash"}),t.createObjectStore(Xa+"_",{keyPath:"k"})},Ha.onsuccess=function(e){Ha.db=e.target.result;var t=Ha.db.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_");oh={},Ji=-1!==Ba.userAgent.indexOf("Chrome")?!0:!1,t.openCursor().onsuccess=function(e){var t=e.target.result;if(t){var r=t.value.k;if(r instanceof Array){var i=t.value,n=i.k[0];oh.hasOwnProperty(n)||(console.log("restoring chunks "+n),oh[n]=i)}else Wa("prompt-input").value=r,Wa("save").checked="checked",ph=!0;t.continue()}else ah?Mh():ch=!0},Wa("debug").checked="checked"},Ha.onerror=function(){console.log("Error opening database")};var jh=function(){var e=function(){mh=new google.visualization.DataTable,mh.addColumn("datetime","Time"),mh.addColumn("number","Received (KB)"),mh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),mh.addRow([r,0,0])}gh={title:"Direct Download : "+(Qn>=0?Qn:0)+" circuits",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:mh.getValue(5,0),max:mh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["green","yellow"]},_h=new google.visualization.LineChart(Wa("chart1")),_h.index=null,_h.dynRow={},_h.dynRow2={},_h.draw(mh,gh)},r=function(){bh=new google.visualization.DataTable,bh.addColumn("datetime","Time"),bh.addColumn("number","Received (KB)"),bh.addColumn("number","Sent (KB)");for(var e=new Date,t=70;t>0;t--){var r=new Date;r.setTime(e.getTime()-1e3*t),bh.addRow([r,0,0])}vh={title:"Peer to peer",hAxis:{title:"Time",titleTextStyle:{color:"green"},textStyle:{fontSize:10},viewWindow:{min:bh.getValue(5,0),max:bh.getValue(64,0)}},vAxis:{title:"Bytes",titleTextStyle:{color:"green"},textStyle:{fontSize:10},minValue:0,maxValue:1e3},colors:["red","orange"]},yh=new google.visualization.LineChart(Wa("chart2")),yh.index=null,yh.dynRow={},yh.dynRow2={},yh.draw(bh,vh)},i=function(e,t,r){for(var i=5,n=go(t.getValue(69,0)).getTime(),s=0;i>s;s++){var a=new Date;a.setTime(n+1e3*(s+1)),t.removeRow(0),t.addRow([a,e.dynRow[a.getTime()]||0,e.dynRow2[a.getTime()]||0]),delete e.dynRow[a.getTime()],delete e.dynRow2[a.getTime()]}-1!==r.title.indexOf("Direct")&&(r.title="Direct Download : "+(Qn>=0?Qn:0)+(Qn>1?" circuits":" circuit")),-1!==r.title.indexOf("Peer")&&(r.title="Peer to Peer : "+(Ss?1:0)+" circuit"),r.hAxis.viewWindow.min=t.getValue(i,0),r.hAxis.viewWindow.max=t.getValue(64,0),r.hAxis.viewWindowMode="explicit",r.animation={duration:4e3,easing:"linear"},e.draw(t,r)},n=Wa("input"),s=document.createElement("input");s.id="url",s.value="Enter_url_or_hash_name_or_magnet_link_or_infohash",n.appendChild(s),Ul=s.value,s.onkeydown=function(e){$a(document.body,"mousedown",function(){},!1),Tl.call(this,e||window.event)&&""!==this.value&&($a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(this.value))};var a=Wa("ok");$a(a,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value)},!1);var o=Wa("stream");$a(o,"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),q(s.value.trim(),!0)},!1),Ya=function(){var e=Ha.db;return e.transaction([Xa],"readwrite").objectStore(Xa)},hh=function(){var e=Ha.db;return e.transaction([Xa+"_"],"readwrite").objectStore(Xa+"_")};var c=function(){var e=sn.createhash("sha1");return e.update(new t(Date.now().toString()+Xa,"utf8")),e.digest("hex")},h=function(e){return e=e.split("."),e.length>1&&e[e.length-1]===Qs&&e.pop(),e.join(".")},u=function(e){setTimeout(function(){Wa("alert_box").style.display="none" +},1e4);var t=Wa(e.hash_ini);e.thumb2_=_(e,e.hash_ini),t?Wa("local").insertBefore(e.thumb2_,t):Wa("local").appendChild(e.thumb2_),e.d_length!==e.clength_&&(e.thumb2_.firstChild.style.backgroundColor="orange",e.thumb_&&(e.thumb_.firstChild.style.backgroundColor="orange")),$a(e.thumb2_,"mousedown",P.bind({file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,url:url,thumb2_:e.thumb2_,thumb_:e.thumb_,clength_:e.clength_,d_length:e.d_length,content_:e.content_,url_:e.url_,key:e.key,content_chrome:e.content_chrome,blob_:e.blob_}),!1),lh(t)},d=function(e){var t=e.thumb_;e.thumb_=_(e),t?t.parentNode?(Wa("downloaded").insertBefore(e.thumb_,t),lh(t)):Wa("downloaded").appendChild(e.thumb_):Wa("downloaded").appendChild(e.thumb_),$a(e.thumb_,"mousedown",O.bind(e),!1)},f=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,lh(xh),lh(nh),$a(document.body,"mousedown",function(){},!1),Oh("

    Uploading file from your disk to your browser storage...please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=this.files[0],i=[],n={},s=r.name.split("#");if(s.length>1){var a=s[1].split(".");n.name_=s[0]+(a.length>1?"."+a[1]:"")}else n.name_=r.name;n.blob_=Ji?new t(0):r,n.content_=r.type,n.clength_=r.size,n.d_length=r.size,n.url_="",n.queue_=[],n.hash_ini=s.length>1?s[1].split(".")[0]:c();var o=r.size,l=0,h=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"})));h.onmessage=function(e){var r=e.data,s=r.pop?Ji?new t(0):0:r;l+=Ji?s.length:parseInt(s);var a=l;if(Ji){if(i.push(s),0===l%$s||l===o){var c=i,h=function(){Wa("progint-alert").style.width=parseInt(100*a/o)+"%",r.pop?(n.check_hash=!0,n.file_hash=r[0],$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0)):(n.file_hash="00",n.d_length=l,b(n,c))};i=[],n.queue_.push(h),1===n.queue_.length&&n.queue_[0]()}}else Wa("progint-alert").style.width=parseInt(100*a/o)+"%",e.data.pop&&(n.check_hash=!0,n.file_hash=e.data[0],Wa("progress-alert").style.display="none",console.log("uploaded "+n.file_hash),ah(n,!0))},h.postMessage([Ji?"hashc":"hash",r])},p=Wa("file_upload");$a(p,"change",f,!1),uh=function(e,t){var r=t.d_length||0,i=t.clength_||0,n=0;i&&(n=parseInt(100*(r/i)));var s=document.createElement("div");s.className="progress";var a=document.createElement("p");a.className="bar",a.innerHTML=Gs+n+"%";var o=document.createElement("div");o.className="progcont";var c=document.createElement("div");return c.className="progint",c.style.width=n+"%",o.appendChild(c),s.appendChild(a),s.appendChild(o),e.appendChild(s),s.progtxt=a,s.progbar=c,$a(s,"mousedown",dh.bind(t),!1),s};var _=function(e,t){var r=e.name_||e.name,i=e.blob_||e.data||new Blob([]),n=Bo(r),s=i.type||e.content_chrome||e.content_||e.type,a=La[n]?La[n]:-1!==ro.indexOf(n)&&-1!==s.indexOf("image")?URL.createObjectURL(i):La.exe,o=document.createElement("div");o.className="thumbwrap",t&&(o.id=t);var c=document.createElement("div");c.className="thumb";var l=document.createElement("img");l.className="thumbimg",l.src=a;var h=document.createElement("div");h.align="center";var u=document.createElement("span");return u.className="thumbspan",u.innerHTML=r,c.appendChild(l),o.appendChild(c),h.appendChild(u),o.appendChild(h),o},g=function(e,t){console.log("compute hash"),e.file_hash=0,$a(document.body,"mousedown",function(){},!1),Oh("

    Calculating hash for a resumed file, please wait...

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e.blob_,i=new Worker(URL.createObjectURL(new Blob([Hh],{type:"text/javascript"}))),n=r.size,s=0;i.onmessage=function(r){var i=r.data.pop?0:parseInt(r.data);if(s+=i,Wa("progint-alert").style.width=parseInt(100*s/n)+"%",r.data.pop){Wa("progress-alert").style.display="none",setTimeout(function(){Wa("alert_box").style.display="none"},1e4),e.file_hash=r.data[0];var a=function(){d(e),u(e),m(e,t)};e.queue_.push(a),$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),1===e.queue_.length&&e.queue_[0]()}},i.postMessage(["hash",r])};ah=function(e,t,r){console.log("store_DB "),$a(document.body,"mousedown",function(){},!1),e.nb_try===Bs||e.reason_||Oh("

    Storing file, please wait that the file appears in Local Files (for large files this can take some time)

    "),Ha.store=function(){var i,n=Ji?[]:null,s=0,a=hh();e.file_id=e.file_id||0;var o=a.get([e.file_id,s]),c=e.blob_?e.blob_.type:e.content_chrome?e.content_chrome:e.content_,h=new Blob([],{type:c});if(l)var i=Date.now();o.onsuccess=function(o){var l=o.target.result;if(l){var f=l.data;f instanceof Array?(f.unshift(h),h=new Blob(f,{type:c})):h=new Blob([h,f],{type:c}),Ji&&(f instanceof Array?(f.shift(),n=n.concat(f)):n.push(f)),a.delete([e.file_id,s]),s++,_=a.get([e.file_id,s]),_.onsuccess=this.onsuccess}else{console.log("Saving chunks size "+h.size+(i?" time to read all chunks "+(Date.now()-i):"")),Ji&&(e.blob_ instanceof Array?n=n.concat(e.blob_):n.push(e.blob_)),e.blob_=new Blob([h,e.blob_],{type:c});var p=Ya(),_=p.get(e.hash_ini);console.log("store_DB open");var y=Date.now();_.onsuccess=function(i){console.log("store_DB success "+(Date.now()-y));var s=i.target.result;if(s?(lh(Wa(s.name_hash)),Ji?(f=s.data.concat(n),e.blob_=new Blob(f,{type:e.content_chrome?e.content_chrome:e.content_})):(f=new Blob([s.data,e.blob_],{type:c}),e.blob_=f)):f=Ji?n:e.blob_,!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_hash=e.file_hash||0,e.d_length=e.blob_.size,t||d(e),r||u(e),e.check_hash||e.clength_!==e.d_length?m(e,f,r):g(e,f),console.log("Chunks saved "+(Date.now()-y)),Wa("alert_box").style.display="none",$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1)}}}},Ha.store()};var m=function(e,t,r){e.file_hash=e.file_hash||0;var i=Ya();Ji?i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t,enc:e.content_chrome||""}):i.put({hash:e.file_hash,name_hash:e.hash_ini,name:e.name_,type:e.content_,file_length:e.clength_,current_length:e.d_length,file_url:e.url_,key:e.key?e.key:"",data:t}),r?r(e):(e.d_length===e.clength_&&Ss&&Ss.send_db_info(),ko(e))},b=function(e,t){if(y)var r=Date.now();var i=Ha.db,n=i.transaction([Xa+"_"],"readwrite"),s=n.objectStore(Xa+"_");if(!e.name_){var a=e.blob_.type||(e.content_chrome?e.content_chrome:e.content_);e.name_=e.hash_ini.substr(0,8),a!==e.content_&&(e.name_=e.name_+"."+Qs)}e.file_id?e.chunk_nb++:(e.file_id=Date.now(),e.chunk_nb=0),s.put({k:[e.file_id,e.chunk_nb],file_hash:e.file_hash,hash_ini:e.hash_ini,name_:e.name_,content_:e.content_,clength_:e.clength_,d_length:e.d_length,url_:e.url_,key:e.key?e.key:"",data:t}),r&&console.log("db_perf "+(Date.now()-r));var o=e.queue_;o.shift(),o.length&&o[0]()},w=function(e){var t=e.split("PT"),r=t[1].split("H"),i=parseFloat(r[1].split("M")[1].split("S")[0]);return t=t[1].split("H")[0],r=r[1].split("M")[0],3600*t+60*r+i},E=function(){try{log("addsourcebuffer "+this._stream_.readyState),this._source_=this._stream_.addSourceBuffer(this.mime_codec)}catch(e){console.log("wait open addsourcebuffer failed")}},C=function(e,t){if(e.received_===t)Wa("alert_box").style.display="none",e._source_.addEventListener("updateend",function(){Do(e)}),Do(e);else if(e.received_>t&&(0===e.append_cursor&&(e.wait_chunk=!0),e.wait_chunk)){var r=Math.min(Math.ceil((e.clength_-e.d_length)/Da),Ea/4);e.append_cursor++,e.append_cursor>=r&&(delete e.wait_chunk,Do(e))}},S=function(e,r){if(r._stream_&&!r._streaming_){if(r.d_length+=e.length,r._json_+=e.toString("utf8"),r.d_length>=r.clength_){console.log("json "+r._json_);try{var i=JSON.parse(r._json_)}catch(n){return console.log("wrong json file, retrying"),r=H(r.hash_ini,null,!0),rc(r),void 0}for(var s in i)if("Duration"!==s){var a=H(i[s].Representation.BaseURL,null,!0);if(r.nb_sources.push(a),a._streaming_=!0,a.mime_codec=i[s].Representation.mimeType+'; codecs="'+i[s].Representation.codecs+'"',a._stream_=r._stream_,a._parent_=r,a._bandwidth_=i[s].Representation.bandwidth,a._width_=i[s].Representation.width,a._height_=i[s].Representation.height,"open"===r._stream_.readyState)try{a._source_=r._stream_.addSourceBuffer(a.mime_codec)}catch(n){console.log("addsourcebuffer failed"),r._wait_open.push(E.bind(a))}else r._wait_open.push(E.bind(a));rc(a)}else r._stream_.duration=w(i[s]);console.log("Queue fin json "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,fin_.call(r)}}else if(r._streaming_){if(r.d_length+=e.length,r.append_buffer.push(e),r._source_)C(r,Math.min(Ea,r.pieces));else if(r.mp4box){var o=r.append_buffer.length;if(o>=Ca||r.d_length>=r.clength_){for(var c=r.append_buffer.concatBuffers(),l=0;o>l;l++)r.append_buffer.shift();r.mp4box.appendBuffer(c.buffer)}}r.d_length>=r.clength_&&(console.log("Queue fin streaming "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")),console.log("queue length "+r.append_buffer.length+" cursor "+r.append_cursor+" received "+r.received_),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,r.mp4box&&r.mp4box.flush(),fin_.call(r))}else if(r.eof_)console.log("EOF");else{var h=function(e){return function(){if(r.d_length+=e.length,!r.blob_){r.content_=r.content_||"application/octet-binary";var i=r.content_.split(";");if(i.length>1&&(r.content_=i[0],r.content_chrome=i[1]||"application/octet-binary"),r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),!r.reload2_&&!r.reload_){r.check_hash=new fn("sha1");var n=Ya();n.delete(r.hash_ini)}r.clength_||lh(r.bar_)}if(r.blob_=Ji?r.blob_.length?[r.blob_,e].concatBuffers():e:new Blob([r.blob_,e],{type:r.content_chrome?r.content_chrome:r.content_}),r.check_hash&&r.check_hash.update(e),r.clength_){var s=r.blob_.size||r.blob_.length||r.blob_.byteLength;if(s>=Zs&&r.d_length=r.clength_&&(console.log("Queue fin "+r.d_length+" "+r.clength_+" "+(parseInt(8*Da*r.received_/((Date.now()-r.start_t0)/1e3))+" bps ")+(r.blob_.size||r.blob_.length||r.blob_.byteLength)),qh(r.sendme_tout),qh(r.waiting_),r.eof_=!0,r.queue_.push(fin_.bind(r)),1===r.queue_.length&&r.queue_[0]());if(r.clength_||r.d_length>=r.clength_){var o=parseInt(100*(r.d_length/r.clength_));r.bar_.progtxt.innerHTML=Gs+parseInt(r.d_length/1e3)+" kB",r.bar_.progbar.style.width=o+"%"}r.queue_s.shift(),r.queue_s.length&&r.queue_s[0]()}}};r.queue_s=r.queue_s||[],r.queue_s.push(h(e)),1===r.queue_s.length&&r.queue_s[0]()}};lh=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},fin_=function(){console.log("execute fin"),this.eof_=!0,this.queue_=[],this.queue_s=[],this.cid_&&(this.cid_===Ss?(console.log("sending db_end CIC "+this.cid_.circId+" sid "+this.sid_),this.cid_.send_db_end(1,this.sid_)):this.d_lengthStopping download, please wait that pending data are processed, use resume to restart

    ")},500)),1===this.queue_.length&&this.queue_[0]())};var A=function(e,t){Oh('

    Error: '+t+" - This media can not be streamed, please use Download

    "),lh(nh),dh.call(e)};fh=function(e){var t=e.content_;if(console.log("init_media "+t),-1===t.indexOf("json")&&(-1===t.indexOf("video")&&-1===t.indexOf("audio")&&-1===t.indexOf("binary")||e._streaming_))-1===t.indexOf("video")&&-1===t.indexOf("audio")||!e._parent_?(Oh('

    Error: not an audio/video file - This media can not be streamed, please use Download

    '),document.body.removeChild(nh),dh.call(e)):(e._parent_.connected_sources++,e._parent_.connected_sources===e._parent_.nb_sources.length&&(console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play()));else{lh(xh),xh=document.createElement("video"),xh.className="mediasrc",xh.controls=!0,e._stream_=new ih,xh.src=URL.createObjectURL(e._stream_),xh._stream_=e._stream_,nh.appendChild(xh),$a(sh,"mousedown",function(){lh(nh),lh(xh),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!0);var r=function(){if(-1===t.indexOf("json"))-1!==t.indexOf("webm")?(e.nb_sources=[],e._streaming_=!0,e._source_=e._stream_.addSourceBuffer('video/webm; codecs="vp8,vorbis"'),console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play()):(e.nb_sources=[],e._streaming_=!0,e.mp4box=new ki,Oh('

    Connected... Analyzing if this video can be streamed, please wait

    '),e.mp4box_t0=setTimeout(function(){A(e,"mp4box timeout")},Sa),e.mp4box.onReady=function(t){if(clearTimeout(e.mp4box_t0),console.log("play media"),Oh('

    Connected... the video is going to start, please wait

    '),xh.play(),t.tracks){for(;t.tracks.length;){var r=t.tracks.shift();if(r){console.log(r.codec);var i='video/mp4; codecs=" '+r.codec+'"',n=!1;if(ih.isTypeSupported(i)){n=!0;var s={append_buffer:[]};s._stream_=e._stream_,s._source_=e._stream_.addSourceBuffer(i),s.pieces=e.pieces,s.received_=0,s.append_cursor=0,s.clength_=e.clength_,s.d_length_=0,e.mp4box.onSegment=function(e,t,r){r=new Uint8Array(r),t.received_++,t.append_buffer.push(r),1===t.received_&&(Wa("alert_box").style.display="none",t._source_.addEventListener("updateend",function(){Do(t)})),Do(t)},e.mp4box.setSegmentOptions(r.id,s)}n||A(e,"codec not supported")}}for(var a=e.mp4box.initializeSegmentation();a.length;){var o=a.shift();o.user.append_buffer.push(new Uint8Array(o.buffer))}}},e.mp4box.onError=function(){console.log("mp4box error"),A(e,"mp4box error")});else for(;e._wait_open.length;)e._wait_open.shift()()};$a(e._stream_,"webkitsourceopen",r,!1),$a(e._stream_,"sourceopen",r,!1),e._stream_.addEventListener("sourceclose",function(){console.log("SOURCE CLOSED"),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e)},!1),xh.addEventListener("seeking",function(){}),xh.addEventListener("pause",function(){}),xh.addEventListener("play",function(){}),xh.addEventListener("error",function(){Oh('

    Error: Media Source error - This media can not be streamed or something unexpected happened

    '),e.nb_sources.forEach(function(e){dh.call(e)}),dh.call(e);try{e._stream_.endOfStream()}catch(t){}})}};var I=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu"),lh(this.thumb_)},T=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=this,r=function(){if(this.value){var e=Ya(),r=e.get(t.hash_ini);r.onsuccess=function(r){r.target.result&&(r.target.result.name=this.value,t.name_=this.value,e.put(r.target.result),t.thumb_&&d(t),u(t))}.bind(this)}};Dh("

    Enter new name:

    ",r)},x=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,F("menu2");var t=Ya();t.delete(this.hash_ini),lh(this.thumb2_),lh(this.thumb_)},B=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=this;r.nb_try++,r.db_try=0,r.params_.db_=!0,r.reload_=!0,r.sid_&&(delete r.cid_[r.sid_],delete r.sid_),delete r.cid_,delete r.eof_,delete r.check_hash,delete r.last_saved,delete r.file_id,delete r.start_t0,qh(r.query_t0),r.name_=this.name_||"",r.queue_=[],r.queue_s=[],r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu"),lh(r.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},k=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var r=H(this.url_,this.hash_ini);r.clength_=this.clength_,r.d_length=this.d_length,r.content_=this.content_,r.reload2_=!0,r.thumb2_=this.thumb2_,delete r.eof_,delete r.last_saved,delete r.file_id,delete r.start_t0,r.queue_=[],r.queue_s=[],r.name_=this.name_||"",qh(r.query_t0),r.nb_try++,r.db_try=0,r.blob_=Ji?new t(0):new Blob([],{type:r.content_chrome?r.content_chrome:r.content_}),r.cid_=Ss,F("menu2"),lh(this.thumb_),r.bar_=uh(Wa("downloaded"),r),rc(r)},R=function(){var e=this.key;F("menu2"),$a(document.body,"mousedown",function(){},!1),e?setTimeout(function(){Oh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    ")},800):Oh("

    "+(e?"De":"En")+"crypting file... Please wait until the file appears in the Local files box, this can take some time depending on the size of the file

    "),Wa("progress-alert").style.display="block",Wa("progint-alert").style.width="0%";var r=e?new t(e,"hex"):No(16),i=this.blob_,n=i.size,s={file_hash:"00",hash_ini:c(),name_:e?h(this.name_):this.name_+"."+Qs,clength_:n,d_length:0,content_:this.content_,url_:this.url_,key:e?"":r.toString("hex"),content_chrome:e?null:Ji?"application/binary":null,blob_:Ji?new t(0):new Blob([],{type:e?this.content_:"application/octet-binary"}),queue_:[]},a=0;if(e){var o=Ya(),l=o.get(this.hash_ini);l.onsuccess=function(t){if(t.target.result){var r=t.target.result;r.key=e,this.key=e,$a(this.thumb2_,"mousedown",P.bind({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,content_chrome:this.content_chrome,blob_:this.blob_}),!1),o.put(r)}}.bind(this)}var u=new Worker(URL.createObjectURL(new Blob([Hh]))),d=[];if(v)var f=Date.now();u.onmessage=function(t){var r=t.data,i=r instanceof Array?r[0]:r;r instanceof Array||(a+=i.length);var s=a;if(f&&(console.log("worker perf "+(Date.now()-f)),f=Date.now()),d.push(i),0===a%$s||a===n){var o=d,c=function(){Wa("progint-alert").style.width=parseInt(100*(s/n))+"%",r instanceof Array?(this.check_hash=!0,this.file_hash=i,$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),Wa("progress-alert").style.display="none",ah(this,!0)):(this.file_hash="00",this.d_length=s,b(this,Ji?o:new Blob(o,{type:e?this.content_:"application/octet-binary"})))}.bind(this);d=[],this.queue_.push(c),1===this.queue_.length&&this.queue_[0]()}}.bind(s),u.postMessage(["aes-128-ctr",i,r,Ln])},U=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,R.call({file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_})},D=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t={file_hash:this.file_hash,hash_ini:this.hash_ini,name_:this.name_,content_:this.content_,url:url,thumb2_:this.thumb2_,thumb_:this.thumb_,clength_:this.clength_,d_length:this.d_length,content_:this.content_,url_:this.url_,key:this.key,blob_:this.blob_};if(this.blob_.type!==this.content_||"enc"===Bo(this.name_))if(this.key)R.call(t);else{var r=function(){var e=this.value;32===e.length?(t.key=e,R.call(t)):setTimeout(function(){Oh("

    Please enter a valid key

    ")},800)};Dh("

    Enter key:

    ",r)}else Oh("

    This is not an encrypted file

    ")},N=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Oh("
  • Hash Name: "+this.hash_ini+"
  • File hash: "+this.file_hash+"
  • File Type: "+this.content_+"
  • File size: "+this.clength_+" bytes
  • Current size: "+this.d_length+" bytes
  • Key: "+((this.content_chrome?1:this.content_!==this.blob_.type||"enc"===Bo(this.name_))?this.key?this.key:"Get the encryption key from peer":"Not encrypted")+"
  • ")},L=function(e,t){var r=Wa(e);r&&(r.event_&&eo(r,"mousedown",r.event_,!1),r.event_=t.bind(this),$a(r,"mousedown",r.event_,!1))},O=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0;var t=Wa("menu2");t.style.display="none",t=Wa("menu"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete",I),L.call(this,"reload",B),this.clength_===this.d_length?Ph(Wa("reload")):Fh(Wa("reload"))},P=function(e){if(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,Ss&&Qn>=1){var t=Wa("menu");t.style.display="none",t=Wa("menu2"),t.style.top=Ja(e)+"px",t.style.left=Za(e)+"px",t.style.display="block",Wa("open2").getElementsByTagName("a").item(0).href=URL.createObjectURL(this.blob_),L.call(this,"delete2",x),L.call(this,"rename2",T),L.call(this,"property2",N),this.d_length===this.clength_?Ph(Wa("reload2")):(Fh(Wa("reload2")),L.call(this,"reload2",k));var r=this.blob_.type||(this.content_chrome?this.content_chrome:this.content_);this.key||r!==this.content_||"enc"===Bo(this.name_)?(Ph(Wa("encrypt2")),Fh(Wa("decrypt2")),L.call(this,"decrypt2",D)):(Fh(Wa("encrypt2")),L.call(this,"encrypt2",U),Ph(Wa("decrypt2")))}else Oh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},F=function(e){var t=Wa(e);t.style.display="none"};Sh=function(){var e=Wa("menu");e.style.display="none",e=Wa("menu2"),e.style.display="none",Wa("alert_box").style.display="none",Wa("prompt_box").style.display="none"},rh=function(e){e.blob_?(e.check_hash&&(e.file_hash=e.check_hash.digest("hex")),console.log("Blob loaded "+e.d_length+" "+(e.file_hash||"")),ah(e),lh(e.bar_)):lh(e.bar_)},$a(document.body,"mousedown",function(){setTimeout(Sh,1e3)},!1),$a(Wa("dialog-message"),"mousedown",function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},!1);var q=function(e,t){if(!t||t&&(xh.parentNode?!1:!Th))if(Ss&&Qn>1){console.log("Start loading url");var r=H(e,null,t);r.d_length=0,lh(r.thumb_),lh(Wa(r.hash_ini)),t?(Th=!0,M(r)):(r.bar_=uh(Wa("downloaded"),r),lh(xh),lh(nh),Th=!1),(r.bar_||r._stream_&&ih)&&rc(r)}else Oh('

    Not enough circuits established - Please wait to see at least one Peer to Peer circuit and one Direct Download circuit

    ')},H=function(e,r,i){if(!r){var n=so(e);if(n)r=n,e="";else if(-1!==e.indexOf("http")||-1!==e.indexOf("https")){var s=sn.createhash("sha1");s.update(new t(e,"utf8")),r=s.digest("hex")}else r=e,e=""}var a=Jo(e);a.params_.hash_=new t(r,"hex"),a.hash_ini=r,a.url_=e,e=ho(e),a.params_.stream=yo(e.host,e.rest),a.params_.host=e.host+":"+("https"===e.protcol?"443":"80"),a.params_.db_=!0,a.cid_=Ss,a.download_=[],a.d_length=0,a.nb_try=0;var o=e.rest.split("/");return a.name_=o.length?o[o.length-1]:"",a._write_=function(e){S(e,this)},a.queue_=[],a.db_try=0,a.sendme_tout=[],a.waiting_=[],a.queue_s=[],a._stream_=i||!1,i&&(a.stream_buffer=[],a.append_buffer=[],a.append_cursor=0,a.append_wait=new t(0),a.nb_sources=[],a.connected_sources=0,a.debug_chunk=[],a.append_to=[],a._wait_open=[],a._json_=""),a},M=function(e){ih=window.MediaSource||window.webkitMediaSource||window.WebKitMediaSource||window.webkitMediaSource||window.MozMediaSource||!1,ih?(nh=document.createElement("div"),nh.className="media",document.body.appendChild(nh),sh=document.createElement("div"),sh.className="boxclose",nh.appendChild(sh),$a(sh,"mousedown",function(){lh(nh),lh(xh),dh.call(e)},!0)):Oh('

    Media Source is not available in your browser, so streaming is not possible, please update it or try with Chrome browser.

    ')},j=function(){e(),r(),chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),$a(Wa("chart1"),"mousedown",function(){Ys?clearInterval(chart1_int):chart1_int=setInterval(function(){i(_h,mh,gh)},5e3),Ys=!Ys},!1),$a(Wa("chart2"),"mousedown",function(){Ws?clearInterval(chart2_int):chart2_int=setInterval(function(){i(yh,bh,vh)},5e3),Ws=!Ws},!1)},z=function(){Ha.list=function(e){var t=Ha.db.transaction([Xa],"readwrite").objectStore(Xa);t.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;e(i),r.continue()}else ch&&Mh()}},Ha.list(V)},V=function(e){Ji&&(e.data=new Blob(e.data,{type:e.enc?e.enc:e.type}));var t=_(e,e.name_hash);Wa("local").appendChild(t),$a(t,"mousedown",P.bind({file_hash:e.hash,hash_ini:e.name_hash,name_:e.name,thumb2_:t,clength_:e.file_length,d_length:e.current_length,content_:e.type,url_:e.file_url,key:e.key,content_chrome:e.enc||"",blob_:e.data}),!1),e.file_length!==e.current_length&&(t.firstChild.style.backgroundColor="orange")};if(Eh){var K=(Ss?1:0)+(Qn>=0?Qn:0);Wa("direct_text").innerHTML="Direct, P2P and bittorrent anonymized circuits : "+K+(K>1?" circuits":" circuit"),Fh(Wa("direct_text")),Fh(Wa("peer_text"))}else{var G=document.createElement("script");G.src="http://www.peersm.com/gchart.js",G.onload=j,document.body.appendChild(G)}Wa("prompt-input").removeAttribute("type"),z()}}}})}(); \ No newline at end of file