ipstack.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848
  1. "use strict";
  2. /*Compiled using Cheerp (R) by Leaning Technologies Ltd*/
  3. var __imul=Math.imul;
  4. var __fround=Math.fround;
  5. var oSlot=0;var nullArray=[null];var nullObj={d:nullArray,o:0};
  6. function fetchBuffer(p){
  7. return (typeof fetch==='function')?
  8. fetch(p).then(r=>r.arrayBuffer()):
  9. new Promise((y,n)=>{
  10. import('fs').then(r=>r.readFile(p,(e,d)=>{
  11. if(e)n(e);
  12. else y(d);
  13. }));
  14. });
  15. }
  16. function ___cxx_global_var_init$p2(){
  17. __ZN7IpStackL7chanMapE=_cheerpCreate_ZN6client4TMapIiPNS_14MessageChannelEEC2Ev();
  18. }
  19. function ___cxx_global_var_init$p3(){
  20. __ZN7IpStackL11listenerMapE=_cheerpCreate_ZN6client4TMapIiPNS_13EventListenerEEC2Ev();
  21. }
  22. function _cheerpCreate_ZN6client4TMapIiPNS_13EventListenerEEC2Ev(){
  23. return new Map();
  24. }
  25. function _cheerpCreate_ZN6client4TMapIiPNS_14MessageChannelEEC2Ev(){
  26. return new Map();
  27. }
  28. function __Z13createPromisev(Lagg$presult){
  29. var LretConstructor=null,LretConstructor7=null;
  30. LretConstructor=_cheerpCreate_ZN6client9CheerpRefINS_13EventListenerEEC2Ev();
  31. LretConstructor7=_cheerpCreate_ZN6client9CheerpRefINS_13EventListenerEEC2Ev();
  32. Lagg$presult.a0=new Promise(function(__f,__r){LretConstructor.inner=__f;LretConstructor7.inner=__r;});;
  33. Lagg$presult.a1=LretConstructor.inner;
  34. Lagg$presult.a2=LretConstructor7.inner;
  35. }
  36. function _cheerpCreate_ZN6client9CheerpRefINS_13EventListenerEEC2Ev(){
  37. return new Object();
  38. }
  39. function _sys_now(){
  40. return ~~ +performance.now()|0;
  41. }
  42. function __Z9output_jsPhi(Lbuf,Mbuf,Llen){
  43. var LretConstructor=null;
  44. LretConstructor=new Uint8Array((+(Llen|0)));
  45. LretConstructor.set(__ZN6cheerp14MakeTypedArrayIhN6client10Uint8ArrayEEEPT0_PKT_j(Lbuf,Mbuf,Llen));
  46. __ZL9output_cb(LretConstructor);
  47. }
  48. function __ZN6cheerp14MakeTypedArrayIhN6client10Uint8ArrayEEEPT0_PKT_j(Lptr,Mptr,Lsize){
  49. var tmp0=0,tmp1=null;
  50. tmp0=Mptr;
  51. tmp1=Lptr;
  52. tmp1=tmp1;
  53. if((Lsize|0)!==0){
  54. if((tmp0|0)===0)if( +tmp1.length===(+(Lsize>>>0)))return tmp1;
  55. return tmp1.subarray((+(tmp0>>>0)),(+(tmp0+Lsize>>>0)));
  56. }
  57. if((tmp0|0)===0)return tmp1;
  58. return tmp1.subarray((+(tmp0>>>0)));
  59. }
  60. function __Z14start_timeoutsv(){
  61. +setInterval(__ZN6cheerp8CallbackIZ14start_timeoutsvE3$_0EEPN6client13EventListenerEOT_(),10);
  62. }
  63. function __ZN6cheerp8CallbackIZ14start_timeoutsvE3$_0EEPN6client13EventListenerEOT_(){
  64. var Lref$ptmp=null,Lcall1=null;
  65. Lref$ptmp={a0:null,a1:null,a2:null};
  66. __ZN6cheerp12make_closureIZ14start_timeoutsvE3$_0EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS2_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS2_Efp_EEEOS2_(Lref$ptmp);
  67. Lcall1=__ZN6cheerp7ClosureIFvvEEcvPN6client13EventListenerEEv(Lref$ptmp);
  68. __ZN6cheerp7ClosureIFvvEED2Ev(Lref$ptmp);
  69. return Lcall1;
  70. }
  71. function __ZN6cheerp12make_closureIZ14start_timeoutsvE3$_0EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS2_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS2_Efp_EEEOS2_(Lagg$presult){
  72. __ZN6cheerp13ClosureHelperIZ14start_timeoutsvE3$_0MS1_KFvvEE12make_closureEOS1_(Lagg$presult);
  73. }
  74. function __ZN6cheerp7ClosureIFvvEEcvPN6client13EventListenerEEv(Lthis){
  75. var tmp0=null;
  76. if(Lthis.a1!==null){
  77. tmp0=[{a0:null,a1:null}];
  78. tmp0[0].a0=Lthis.a1;
  79. tmp0[0].a1=Lthis.a2;
  80. tmp0=cheerpCreateClosure(__ZN6cheerp7ClosureIFvvEE14deleter_helperEPNS2_13DeleterHelperE,tmp0[0]);
  81. __ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE3addEPS2_PNS1_6ObjectE(Lthis.a0,tmp0);
  82. Lthis.a1=null;
  83. }
  84. return Lthis.a0;
  85. }
  86. function __ZN6cheerp7ClosureIFvvEED2Ev(Lthis){
  87. var tmp0=null;
  88. tmp0=Lthis.a1;
  89. if(tmp0!==null)tmp0(Lthis.a2);
  90. }
  91. function __ZN6cheerp7ClosureIFvvEE14deleter_helperEPNS2_13DeleterHelperE(Lh){
  92. Lh.a0(Lh.a1);
  93. }
  94. function __ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE3addEPS2_PNS1_6ObjectE(Lr,Ld){
  95. if(__ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE9resourcesE===null)__ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE9resourcesE=new Map();
  96. __ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE9resourcesE.set(Lr,Ld);
  97. }
  98. function __ZN6cheerp13ClosureHelperIZ14start_timeoutsvE3$_0MS1_KFvvEE12make_closureEOS1_(Lagg$presult){
  99. __ZN6cheerp7ClosureIFvvEEC2IZ14start_timeoutsvE3$_0EET_PNSt9enable_ifIXsr3std14is_convertibleIS5_PS1_EE5valueEvE4typeE(Lagg$presult);
  100. }
  101. function __ZN6cheerp7ClosureIFvvEEC2IZ14start_timeoutsvE3$_0EET_PNSt9enable_ifIXsr3std14is_convertibleIS5_PS1_EE5valueEvE4typeE(Lthis){
  102. var tmp0=null;
  103. tmp0=__ZZ14start_timeoutsvEN3$_08__invokeEv;
  104. Lthis.a0=tmp0;
  105. Lthis.a1=null;
  106. Lthis.a2=null;
  107. }
  108. function __ZZ14start_timeoutsvEN3$_08__invokeEv(){
  109. __ZZ14start_timeoutsvENK3$_0clEv();
  110. }
  111. function __ZZ14start_timeoutsvENK3$_0clEv(){
  112. _sys_check_timeouts();
  113. }
  114. function __ZN7IpStack4initEPN6client9UpOptionsE(Lopts){
  115. __Z4initv();
  116. __Z16udpecho_raw_initv();
  117. __Z16tcpecho_raw_initv();
  118. }
  119. function __ZN7IpStack2upEPN6client9UpOptionsE(Lopts){
  120. var LsavedStack=null,tmp1=null,Lip=0,LipMapStr=0,Lcall1=null,Lcall2=null,Lref$ptmp7=0,Lref$ptmp8=0,Lcall6=null,Li$p03=0,Lcall5=null,Lcall5o=0;
  121. LsavedStack=___getStackPtr();
  122. tmp1=-80+LsavedStack|0;
  123. ___setStackPtr(tmp1);
  124. Lip=64+tmp1|0;
  125. __ZNK6client6StringcvSsEv(Lip,Lopts.localIp);
  126. LipMapStr=40+tmp1|0;
  127. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEEC2Ev(LipMapStr);
  128. Lcall1=Lopts.ipMap;
  129. if(Lcall1!==undefined){
  130. Lcall2=Object.keys(Lcall1);
  131. if(((Lcall2.length)|0)>0){
  132. Lref$ptmp7=24+tmp1|0;
  133. Lref$ptmp8=8+tmp1|0;
  134. Li$p03=0;
  135. while(1){
  136. Lcall5=__ZN6client5ArrayixEi(Lcall2,Li$p03);
  137. Lcall5o=oSlot;
  138. Lcall5=Lcall5[Lcall5o];
  139. Lcall6=Lcall1[Lcall5];
  140. __ZNK6client6StringcvSsEv(Lref$ptmp7,Lcall5);
  141. __ZNK6client6StringcvSsEv(Lref$ptmp8,Lcall6);
  142. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEE7emplaceIJSsSsEEES4_ISt19__hash_map_iteratorISt15__hash_iteratorIPSt11__hash_nodeISt17__hash_value_typeISsSsEPvEEEbEDpOT_(tmp1|0,LipMapStr,Lref$ptmp7,Lref$ptmp8);
  143. __ZNSsD2Ev(Lref$ptmp8);
  144. __ZNSsD2Ev(Lref$ptmp7);
  145. Li$p03=Li$p03+1|0;
  146. if((Li$p03|0)<((Lcall2.length)|0))continue;
  147. break;
  148. }
  149. }
  150. }
  151. __Z2upRKSsRKSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIS_SsEEE(Lip,LipMapStr);
  152. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEED2Ev(LipMapStr);
  153. __ZNSsD2Ev(Lip);
  154. ___setStackPtr(LsavedStack);
  155. }
  156. function __ZNK6client6StringcvSsEv(Lagg$presult,Lthis){
  157. var Lcall2=null,Lcall2o=0,Li$p03=0;
  158. __ZNSsC2Ev(Lagg$presult|0);
  159. __ZNSs6resizeEj(Lagg$presult|0,Lthis.length);
  160. Lcall2=HEAP8;
  161. Lcall2o=__ZNSsixEj_icf(Lagg$presult|0)|0;
  162. if(((Lthis.length)|0)>0){
  163. Li$p03=0;
  164. while(1){
  165. Lcall2[Lcall2o+Li$p03|0]=Lthis.charCodeAt(Li$p03);
  166. Li$p03=Li$p03+1|0;
  167. if((Li$p03|0)<((Lthis.length)|0))continue;
  168. break;
  169. }
  170. }
  171. }
  172. function __ZN6client5ArrayixEi(Lthis,Lindex){
  173. oSlot=0+Lindex|0;
  174. return Lthis;
  175. }
  176. function __ZN7IpStack4downEv(){
  177. __Z4downv();
  178. }
  179. function __ZN7IpStack5inputEPN6client10Uint8ArrayE(Lpkt){
  180. var Lconv=0,Lcall2=0,tmp2=null,tmp2o=0;
  181. Lconv=~~ +Lpkt.length;
  182. Lcall2=_pbuf_alloc(0,Lconv)|0;
  183. if((Lcall2|0)!=(0|0)){
  184. tmp2o=HEAP32[4+Lcall2>>2];
  185. tmp2=HEAP8;
  186. __ZN6cheerp14MakeTypedArrayIhN6client10Uint8ArrayEEEPT0_PKT_j(tmp2,tmp2o,Lconv).set(Lpkt);
  187. __ZN7IpStackL7doInputEP4pbuf(Lcall2);
  188. }
  189. }
  190. function __ZN7IpStack6outputEPFvPN6client10Uint8ArrayEE(Lcallback){
  191. __ZL9output_cb=Lcallback;
  192. }
  193. function __ZN7IpStack11recvAdapterEPN3tcp6SocketEPhj(Ls,Ldata,Mdata,Llen){
  194. var Lcall1=null;
  195. Lcall1=__ZN6client4TMapIiPNS_14MessageChannelEE3getEi(__ZN7IpStackL7chanMapE,((Ls|0)|0)).port2;
  196. if(__ZN7IpStack10isWasmNullIhEEbPT_(Ldata,Mdata)|0){
  197. __ZN3tcp6Socket5closeEv(Ls|0);
  198. Lcall1.postMessage(null);
  199. return;
  200. }
  201. Lcall1.postMessage(__ZN6cheerp14MakeTypedArrayIhN6client10Uint8ArrayEEEPT0_PKT_j(Ldata,Mdata,Llen));
  202. }
  203. function __ZN6client4TMapIiPNS_14MessageChannelEE3getEi(Lthis,Lk){
  204. return Lthis.get(Lk);
  205. }
  206. function __ZN7IpStack10isWasmNullIhEEbPT_(Lp,Mp){
  207. var tmp0=0;
  208. tmp0=(Lp.buffer===__heap);
  209. if(tmp0){
  210. tmp0=Mp;
  211. return ((tmp0|0)===0?1:0)|0;
  212. }
  213. return 0|0;
  214. }
  215. function __ZN7IpStack11connAdapterEPN3tcp6SocketEi(Ls,Lerr){
  216. var tmp0=0,Lcall=null,Lcall2=null;
  217. tmp0=((Ls|0)|0);
  218. Lcall=__ZN6client4TMapIiPNS_13EventListenerEE3getEi(__ZN7IpStackL11listenerMapE,tmp0);
  219. Lcall2=__ZN6client4TMapIiPNS_14MessageChannelEE3getEi(__ZN7IpStackL7chanMapE,tmp0).port1;
  220. if((Lerr|0)!==0)Lcall(null);
  221. Lcall(Lcall2);
  222. }
  223. function __ZN6client4TMapIiPNS_13EventListenerEE3getEi(Lthis,Lk){
  224. return Lthis.get(Lk);
  225. }
  226. function __ZN7IpStack7parseIPEPN6client6StringE(LjsStr){
  227. var LsavedStack=null,tmp1=null,Lstr=0,Lcall=0;
  228. LsavedStack=___getStackPtr();
  229. tmp1=-16+LsavedStack|0;
  230. ___setStackPtr(tmp1);
  231. Lstr=tmp1|0;
  232. __ZNK6client6StringcvSsEv(Lstr,LjsStr);
  233. Lcall=__ZN2ip4stonERKSs(Lstr)|0;
  234. __ZNSsD2Ev(Lstr);
  235. ___setStackPtr(LsavedStack);
  236. return Lcall|0;
  237. }
  238. function __ZN7IpStack7connectEiii(LlocalPort,Lip,Lport){
  239. var Lcall=0,tmp1=0,Lp=null;
  240. Lcall=__ZL6map_ipj(Lip)|0;
  241. tmp1=_malloc(88)|0;
  242. __ZN3tcp6SocketC2Ev(tmp1);
  243. __ZN7IpStackL12setupChannelEPN3tcp6SocketE(tmp1);
  244. if(((__ZN3tcp6Socket4bindEii(tmp1,LlocalPort)|0)&255)===0){
  245. Lp={a0:null,a1:null,a2:null};
  246. __Z13createPromisev(Lp);
  247. __ZN6client4TMapIiPNS_13EventListenerEE3setEiS2_(__ZN7IpStackL11listenerMapE,(tmp1|0),Lp.a1);
  248. if(((__ZN7IpStack11connectWasmEPN3tcp6SocketEii(tmp1,Lcall,Lport)|0)|0)===0)return Lp.a0;
  249. }
  250. __ZN3tcp6SocketD2Ev(tmp1);
  251. _free(tmp1|0);
  252. return null;
  253. }
  254. function __ZN7IpStackL12setupChannelEPN3tcp6SocketE(Ls){
  255. var Lcall1=null,LretConstructor=null;
  256. LretConstructor=new MessageChannel();
  257. LretConstructor.port1;
  258. Lcall1=LretConstructor.port2;
  259. __ZN6client4TMapIiPNS_14MessageChannelEE3setEiS2_(__ZN7IpStackL7chanMapE,((Ls|0)|0),LretConstructor);
  260. __ZN7IpStack8recvWasmEPN3tcp6SocketE(Ls|0);
  261. LretConstructor={a0:null,a1:0};
  262. LretConstructor.a0=Lcall1;
  263. LretConstructor.a1=(Ls|0);
  264. Lcall1.onmessage=__ZN6cheerp8CallbackIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEPN6client13EventListenerEOT_(LretConstructor);
  265. }
  266. function __ZN6client4TMapIiPNS_13EventListenerEE3setEiS2_(Lthis,Lk,Lv){
  267. Lthis.set(Lk,Lv);
  268. }
  269. function __ZN6client4TMapIiPNS_14MessageChannelEE3setEiS2_(Lthis,Lk,Lv){
  270. Lthis.set(Lk,Lv);
  271. }
  272. function __ZN6cheerp8CallbackIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEPN6client13EventListenerEOT_(Lfunc){
  273. var Lref$ptmp=null,Lcall1=null;
  274. Lref$ptmp={a0:null,a1:null,a2:null};
  275. __ZN6cheerp12make_closureIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS6_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS6_Efp_EEEOS6_(Lref$ptmp,Lfunc);
  276. Lcall1=__ZN6cheerp7ClosureIFvPN6client12MessageEventEEEcvPNS1_13EventListenerEEv(Lref$ptmp);
  277. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEED2Ev(Lref$ptmp);
  278. return Lcall1;
  279. }
  280. function __ZN6cheerp12make_closureIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS6_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS6_Efp_EEEOS6_(Lagg$presult,Lfunc){
  281. __ZN6cheerp13ClosureHelperIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7MS5_KFvPN6client12MessageEventEEE12make_closureEOS5_(Lagg$presult,Lfunc);
  282. }
  283. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEcvPNS1_13EventListenerEEv(Lthis){
  284. var tmp0=null;
  285. if(Lthis.a1!==null){
  286. tmp0=[{a0:null,a1:null}];
  287. tmp0[0].a0=Lthis.a1;
  288. tmp0[0].a1=Lthis.a2;
  289. tmp0=cheerpCreateClosure(__ZN6cheerp7ClosureIFvPN6client12MessageEventEEE14deleter_helperEPNS5_13DeleterHelperE,tmp0[0]);
  290. __ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE3addEPS2_PNS1_6ObjectE(Lthis.a0,tmp0);
  291. Lthis.a1=null;
  292. }
  293. return Lthis.a0;
  294. }
  295. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEED2Ev(Lthis){
  296. var tmp0=null;
  297. tmp0=Lthis.a1;
  298. if(tmp0!==null)tmp0(Lthis.a2);
  299. }
  300. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEE14deleter_helperEPNS5_13DeleterHelperE(Lh){
  301. Lh.a0(Lh.a1);
  302. }
  303. function __ZN6cheerp13ClosureHelperIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7MS5_KFvPN6client12MessageEventEEE12make_closureEOS5_(Lagg$presult,Lfunc){
  304. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEOT_PNSt9enable_ifIXntsr3std14is_convertibleISC_PS4_EE5valueEvE4typeEPNSE_IXntsrNS5_13_must_destroyISC_EE5valueEvE4typeE(Lagg$presult,Lfunc);
  305. }
  306. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7EEOT_PNSt9enable_ifIXntsr3std14is_convertibleISC_PS4_EE5valueEvE4typeEPNSE_IXntsrNS5_13_must_destroyISC_EE5valueEvE4typeE(Lthis,Lf){
  307. var tmp0=null,tmp1=null;
  308. tmp0=[{a0:null,a1:0}];
  309. tmp0[0].a0=Lf.a0;
  310. tmp0[0].a1=(Lf.a1|0);
  311. tmp1=cheerpCreateClosure(__ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7JPN6client12MessageEventEEEEvPT_DpT0_,tmp0[0]);
  312. Lthis.a0=tmp1;
  313. Lthis.a1=null;
  314. Lthis.a2=tmp0[0];
  315. }
  316. function __ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStackL12setupChannelEPN3tcp6SocketEE3$_7JPN6client12MessageEventEEEEvPT_DpT0_(Lfunc,Largs){
  317. __ZZN7IpStackL12setupChannelEPN3tcp6SocketEENK3$_7clEPN6client12MessageEventE(Lfunc,Largs);
  318. }
  319. function __ZZN7IpStackL12setupChannelEPN3tcp6SocketEENK3$_7clEPN6client12MessageEventE(Lthis,Lev){
  320. var LsavedStack=null,Lcall=null,Lbuf=0,Lcall8=null,Lcall8o=0,Lcall7=null,Lcall7o=0,Li$p03=0;
  321. LsavedStack=___getStackPtr();
  322. Lcall7=-16+LsavedStack|0;
  323. ___setStackPtr(Lcall7);
  324. Lcall=Lev.data;
  325. if(Lcall!==null){
  326. Lbuf=Lcall7|0;
  327. __ZNSt6vectorIhSaIhEEC2Ej(Lbuf,~~ +Lcall.length);
  328. if( +Lcall.length>0){
  329. Li$p03=0;
  330. while(1){
  331. Lcall7=__ZN6client10Uint8ArrayixEi(Lcall,Li$p03);
  332. Lcall7o=oSlot;
  333. Lcall8=HEAP8;
  334. Lcall8o=__ZNSt6vectorIhSaIhEEixEj(Lbuf,Li$p03)|0;
  335. Lcall8[Lcall8o]=Lcall7[Lcall7o]|0;
  336. Li$p03=Li$p03+1|0;
  337. if( +Lcall.length>(+(Li$p03|0)))continue;
  338. break;
  339. }
  340. }
  341. __ZN7IpStack8sendWasmEPN3tcp6SocketERKSt6vectorIhSaIhEE(Lthis.a1|0,Lbuf);
  342. __ZNSt6vectorIhSaIhEED2Ev(Lbuf);
  343. }else{
  344. __ZN3tcp6Socket5closeEv(Lthis.a1|0);
  345. Lthis.a0.onmessage=null;
  346. }
  347. ___setStackPtr(LsavedStack);
  348. }
  349. function __ZN6client10Uint8ArrayixEi(Lthis,Lindex){
  350. oSlot=0+Lindex|0;
  351. return Lthis;
  352. }
  353. function __ZN7IpStack13acceptAdapterEPN3tcp6SocketES2_iii(LlistenSock,LnewSock,Laddr,Lport){
  354. var Lcall=0,Lcall2=null,Lcall4=null,tmp3=null;
  355. Lcall=__ZL6map_ipj(Laddr)|0;
  356. __ZN7IpStackL12setupChannelEPN3tcp6SocketE(LnewSock|0);
  357. Lcall2=__ZN6client4TMapIiPNS_14MessageChannelEE3getEi(__ZN7IpStackL7chanMapE,((LlistenSock|0)|0)).port2;
  358. Lcall4=__ZN6client4TMapIiPNS_14MessageChannelEE3getEi(__ZN7IpStackL7chanMapE,((LnewSock|0)|0)).port1;
  359. tmp3={addr: Lcall, port: Lport, arg1: Lcall4};
  360. Lcall2.postMessage(tmp3,new Array(Lcall4));
  361. }
  362. function __ZN7IpStack6listenEi(LlocalPort){
  363. var tmp0=0,Lcall9=null,Lcall10=null,LretConstructor=null;
  364. tmp0=_malloc(88)|0;
  365. __ZN3tcp6SocketC2Ev(tmp0);
  366. if(((__ZN3tcp6Socket4bindEii(tmp0,LlocalPort)|0)&255)===0)if(((__ZN3tcp6Socket6listenEv(tmp0)|0)&255)===0){
  367. LretConstructor=new MessageChannel();
  368. Lcall9=LretConstructor.port1;
  369. Lcall10=LretConstructor.port2;
  370. __ZN6client4TMapIiPNS_14MessageChannelEE3setEiS2_(__ZN7IpStackL7chanMapE,(tmp0|0),LretConstructor);
  371. __ZN7IpStack10acceptWasmEPN3tcp6SocketE(tmp0);
  372. LretConstructor={a0:0};
  373. LretConstructor.a0=tmp0;
  374. Lcall10.onmessage=__ZN6cheerp8CallbackIZN7IpStack6listenEiE3$_4EEPN6client13EventListenerEOT_(LretConstructor);
  375. return Lcall9;
  376. }
  377. __ZN3tcp6SocketD2Ev(tmp0);
  378. _free(tmp0|0);
  379. return null;
  380. }
  381. function __ZN6cheerp8CallbackIZN7IpStack6listenEiE3$_4EEPN6client13EventListenerEOT_(Lfunc){
  382. var Lref$ptmp=null,Lcall1=null;
  383. Lref$ptmp={a0:null,a1:null,a2:null};
  384. __ZN6cheerp12make_closureIZN7IpStack6listenEiE3$_4EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS3_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS3_Efp_EEEOS3_(Lref$ptmp,Lfunc);
  385. Lcall1=__ZN6cheerp7ClosureIFvPN6client12MessageEventEEEcvPNS1_13EventListenerEEv(Lref$ptmp);
  386. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEED2Ev(Lref$ptmp);
  387. return Lcall1;
  388. }
  389. function __ZN6cheerp12make_closureIZN7IpStack6listenEiE3$_4EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS3_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS3_Efp_EEEOS3_(Lagg$presult,Lfunc){
  390. __ZN6cheerp13ClosureHelperIZN7IpStack6listenEiE3$_4MS2_KFvPN6client12MessageEventEEE12make_closureEOS2_(Lagg$presult,Lfunc);
  391. }
  392. function __ZN6cheerp13ClosureHelperIZN7IpStack6listenEiE3$_4MS2_KFvPN6client12MessageEventEEE12make_closureEOS2_(Lagg$presult,Lfunc){
  393. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStack6listenEiE3$_4EEOT_PNSt9enable_ifIXntsr3std14is_convertibleIS9_PS4_EE5valueEvE4typeEPNSB_IXntsrNS5_13_must_destroyIS9_EE5valueEvE4typeE(Lagg$presult,Lfunc);
  394. }
  395. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStack6listenEiE3$_4EEOT_PNSt9enable_ifIXntsr3std14is_convertibleIS9_PS4_EE5valueEvE4typeEPNSB_IXntsrNS5_13_must_destroyIS9_EE5valueEvE4typeE(Lthis,Lf){
  396. var tmp0=null,tmp1=null;
  397. tmp0=[{a0:0}];
  398. tmp0[0].a0=(Lf.a0|0);
  399. tmp1=cheerpCreateClosure(__ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStack6listenEiE3$_4JPN6client12MessageEventEEEEvPT_DpT0_,tmp0[0]);
  400. Lthis.a0=tmp1;
  401. Lthis.a1=null;
  402. Lthis.a2=tmp0[0];
  403. }
  404. function __ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStack6listenEiE3$_4JPN6client12MessageEventEEEEvPT_DpT0_(Lfunc,Largs){
  405. __ZZN7IpStack6listenEiENK3$_4clEPN6client12MessageEventE(Lfunc);
  406. }
  407. function __ZZN7IpStack6listenEiENK3$_4clEPN6client12MessageEventE(Lthis){
  408. __ZN3tcp6Socket5closeEv(Lthis.a0|0);
  409. }
  410. function __ZN7IpStack14recvAdapterUdpEPN3udp6SocketEPhjii(Ls,Ldata,Mdata,Llen,Laddr,Lport){
  411. var Lcall=0,Lcall2=null;
  412. Lcall=__ZL6map_ipj(Laddr)|0;
  413. Lcall2=__ZN6client4TMapIiPNS_14MessageChannelEE3getEi(__ZN7IpStackL7chanMapE,((Ls|0)|0)).port2;
  414. Lcall2.postMessage({addr: Lcall, port: Lport, data: __ZN6cheerp14MakeTypedArrayIhN6client10Uint8ArrayEEEPT0_PKT_j(Ldata,Mdata,Llen)});
  415. }
  416. function __ZN7IpStack4bindEi(LlocalPort){
  417. var tmp0=0,Lcall1=null,Lcall2=null,LretConstructor=null;
  418. tmp0=_malloc(32)|0;
  419. __ZN3udp6SocketC2Ev(tmp0);
  420. if(((__ZN3udp6Socket4bindEii(tmp0,LlocalPort)|0)&255)!==0){
  421. __ZN3udp6SocketD2Ev(tmp0);
  422. _free(tmp0|0);
  423. return null;
  424. }
  425. LretConstructor=new MessageChannel();
  426. Lcall1=LretConstructor.port1;
  427. Lcall2=LretConstructor.port2;
  428. __ZN6client4TMapIiPNS_14MessageChannelEE3setEiS2_(__ZN7IpStackL7chanMapE,(tmp0|0),LretConstructor);
  429. __ZN7IpStack11recvWasmUdpEPN3udp6SocketE(tmp0);
  430. LretConstructor={a0:0};
  431. LretConstructor.a0=tmp0;
  432. Lcall2.onmessage=__ZN6cheerp8CallbackIZN7IpStack4bindEiE3$_6EEPN6client13EventListenerEOT_(LretConstructor);
  433. return Lcall1;
  434. }
  435. function __ZN6cheerp8CallbackIZN7IpStack4bindEiE3$_6EEPN6client13EventListenerEOT_(Lfunc){
  436. var Lref$ptmp=null,Lcall1=null;
  437. Lref$ptmp={a0:null,a1:null,a2:null};
  438. __ZN6cheerp12make_closureIZN7IpStack4bindEiE3$_6EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS3_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS3_Efp_EEEOS3_(Lref$ptmp,Lfunc);
  439. Lcall1=__ZN6cheerp7ClosureIFvPN6client12MessageEventEEEcvPNS1_13EventListenerEEv(Lref$ptmp);
  440. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEED2Ev(Lref$ptmp);
  441. return Lcall1;
  442. }
  443. function __ZN6cheerp12make_closureIZN7IpStack4bindEiE3$_6EEDTclsr13ClosureHelperIT_DTadsr3std16remove_referenceIS3_E4typeEonclEEE12make_closureclgssr6cheerpE7forwardIS3_Efp_EEEOS3_(Lagg$presult,Lfunc){
  444. __ZN6cheerp13ClosureHelperIZN7IpStack4bindEiE3$_6MS2_KFvPN6client12MessageEventEEE12make_closureEOS2_(Lagg$presult,Lfunc);
  445. }
  446. function __ZN6cheerp13ClosureHelperIZN7IpStack4bindEiE3$_6MS2_KFvPN6client12MessageEventEEE12make_closureEOS2_(Lagg$presult,Lfunc){
  447. __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStack4bindEiE3$_6EEOT_PNSt9enable_ifIXntsr3std14is_convertibleIS9_PS4_EE5valueEvE4typeEPNSB_IXntsrNS5_13_must_destroyIS9_EE5valueEvE4typeE(Lagg$presult,Lfunc);
  448. }
  449. function __ZN6cheerp7ClosureIFvPN6client12MessageEventEEEC2IZN7IpStack4bindEiE3$_6EEOT_PNSt9enable_ifIXntsr3std14is_convertibleIS9_PS4_EE5valueEvE4typeEPNSB_IXntsrNS5_13_must_destroyIS9_EE5valueEvE4typeE(Lthis,Lf){
  450. var tmp0=null,tmp1=null;
  451. tmp0=[{a0:0}];
  452. tmp0[0].a0=(Lf.a0|0);
  453. tmp1=cheerpCreateClosure(__ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStack4bindEiE3$_6JPN6client12MessageEventEEEEvPT_DpT0_,tmp0[0]);
  454. Lthis.a0=tmp1;
  455. Lthis.a1=null;
  456. Lthis.a2=tmp0[0];
  457. }
  458. function __ZN6cheerp12InvokeHelperIvE6invokeIZN7IpStack4bindEiE3$_6JPN6client12MessageEventEEEEvPT_DpT0_(Lfunc,Largs){
  459. __ZZN7IpStack4bindEiENK3$_6clEPN6client12MessageEventE(Lfunc,Largs);
  460. }
  461. function __ZZN7IpStack4bindEiENK3$_6clEPN6client12MessageEventE(Lthis,Lev){
  462. var LsavedStack=null,Lcall=null,Lcall3=null,Lbuf=0,Lcall9=null,Lcall9o=0,Lcall11=0,Lcall8=null,Lcall8o=0,Li$p03=0;
  463. LsavedStack=___getStackPtr();
  464. Lcall8=-16+LsavedStack|0;
  465. ___setStackPtr(Lcall8);
  466. Lcall=Lev.data;
  467. if(Lcall!==null){
  468. Lcall3=Lcall.data;
  469. Lbuf=Lcall8|0;
  470. __ZNSt6vectorIhSaIhEEC2Ej(Lbuf,~~ +Lcall3.length);
  471. if( +Lcall3.length>0){
  472. Li$p03=0;
  473. while(1){
  474. Lcall8=__ZN6client10Uint8ArrayixEi(Lcall3,Li$p03);
  475. Lcall8o=oSlot;
  476. Lcall9=HEAP8;
  477. Lcall9o=__ZNSt6vectorIhSaIhEEixEj(Lbuf,Li$p03)|0;
  478. Lcall9[Lcall9o]=Lcall8[Lcall8o]|0;
  479. Li$p03=Li$p03+1|0;
  480. if( +Lcall3.length>(+(Li$p03|0)))continue;
  481. break;
  482. }
  483. }
  484. Li$p03=Lcall.addr;
  485. Lcall11=Lcall.port;
  486. __ZN7IpStack11sendWasmUdpEPN3udp6SocketERKSt6vectorIhSaIhEEjj(Lthis.a0|0,Lbuf,Li$p03,Lcall11);
  487. __ZNSt6vectorIhSaIhEED2Ev(Lbuf);
  488. }else __ZN3udp6Socket5closeEv(Lthis.a0|0);
  489. ___setStackPtr(LsavedStack);
  490. }
  491. function __ZN10__cxxabiv1L24__cxa_throw_wasm_adapterEjPSt9type_infoj(Lthrown_object){
  492. var Ldest$paddr=null,Lref$ptmp=null,Ltinfo$paddr=null;
  493. Ltinfo$paddr=[0];
  494. Ltinfo$paddr[0]=(1051752|0);
  495. Ldest$paddr=[0];
  496. Ldest$paddr[0]=((58|0)|0);
  497. Lref$ptmp=[nullObj];
  498. Lref$ptmp[0]={d:null,o:Lthrown_object};
  499. Ltinfo$paddr=__ZN10__cxxabiv19Exception8allocateIJPvRPSt9type_infoRjEEEPS0_DpOT_(Lref$ptmp,0,Ltinfo$paddr,0,Ldest$paddr,0);
  500. __ZN10__cxxabiv1L8do_throwEPNS_9ExceptionE(Ltinfo$paddr);
  501. ;
  502. }
  503. function __ZN10__cxxabiv19Exception8allocateIJPvRPSt9type_infoRjEEEPS0_DpOT_(Largs,Margs,Largs1,Margs1,Largs3,Margs3){
  504. var tmp0=0,Lid$p0$plcssa28$pi$pi=0,tmp2=null,Lid$p022$pi$pi=0,tmp4=null;
  505. Lid$p0$plcssa28$pi$pi=__ZN10__cxxabiv19Exception9allocatorE$p2|0;
  506. a:{
  507. b:{
  508. if((Lid$p0$plcssa28$pi$pi|0)>1){
  509. tmp2=__ZN10__cxxabiv19Exception9allocatorE$p1;
  510. Lid$p022$pi$pi=1;
  511. while(1){
  512. if((tmp2[Lid$p022$pi$pi]&255)!==0){
  513. Lid$p022$pi$pi=Lid$p022$pi$pi+1|0;
  514. if((Lid$p022$pi$pi|0)===(Lid$p0$plcssa28$pi$pi|0))break b;
  515. continue;
  516. }
  517. break;
  518. }
  519. }else{
  520. Lid$p022$pi$pi=1;
  521. }
  522. if((Lid$p022$pi$pi|0)!==(Lid$p0$plcssa28$pi$pi|0)){
  523. Lid$p0$plcssa28$pi$pi=Lid$p022$pi$pi;
  524. break a;
  525. }
  526. }
  527. __ZN10__cxxabiv19Exception9allocatorE$p2=Lid$p0$plcssa28$pi$pi<<1;
  528. tmp2=__ZN10__cxxabiv19Exception9allocatorE$p0;
  529. Lid$p022$pi$pi=__imul(Lid$p0$plcssa28$pi$pi,88)|0;
  530. if(tmp2!==nullArray||0!==0)tmp2=resizeArray_struct$p_ZN10__cxxabiv19ExceptionE(tmp2,tmp2.length,Lid$p022$pi$pi/44|0);
  531. else tmp2=createArray_struct$p_ZN10__cxxabiv19ExceptionE(Lid$p022$pi$pi/44|0);
  532. __ZN10__cxxabiv19Exception9allocatorE$p0=tmp2;
  533. Lid$p022$pi$pi=__ZN10__cxxabiv19Exception9allocatorE$p2|0;
  534. tmp2=__ZN10__cxxabiv19Exception9allocatorE$p1;
  535. if(tmp2!==nullArray||0!==0)tmp2=(function(){var __old__=tmp2;
  536. var __ret__=new Uint8Array(Lid$p022$pi$pi/1|0);
  537. __ret__.set(__old__.subarray(0, Math.min(__ret__.length,__old__.length)));
  538. return __ret__;})();
  539. else tmp2=new Uint8Array(Lid$p022$pi$pi/1|0);
  540. __ZN10__cxxabiv19Exception9allocatorE$p1=tmp2;
  541. }
  542. tmp2=__ZN10__cxxabiv19Exception9allocatorE$p0;
  543. tmp4=Largs[Margs];
  544. Lid$p022$pi$pi=Largs1[Margs1]|0;
  545. tmp0=Largs3[Margs3]|0;
  546. tmp2[Lid$p0$plcssa28$pi$pi].a1=tmp4.d[tmp4.o];
  547. tmp2[Lid$p0$plcssa28$pi$pi].a2=null;
  548. tmp2[Lid$p0$plcssa28$pi$pi].a3=Lid$p022$pi$pi;
  549. tmp2[Lid$p0$plcssa28$pi$pi].a4=null;
  550. tmp2[Lid$p0$plcssa28$pi$pi].i5=tmp0;
  551. tmp2[Lid$p0$plcssa28$pi$pi].i6=1;
  552. tmp2[Lid$p0$plcssa28$pi$pi].i7=0;
  553. tmp2[Lid$p0$plcssa28$pi$pi].a9=null;
  554. tmp2[Lid$p0$plcssa28$pi$pi].a10=null;
  555. tmp4=__ZN10__cxxabiv19Exception9allocatorE$p1;
  556. tmp4[Lid$p0$plcssa28$pi$pi]=1;
  557. return tmp2[Lid$p0$plcssa28$pi$pi];
  558. }
  559. function __ZN10__cxxabiv1L8do_throwEPNS_9ExceptionE(Lex){
  560. var tmp0=0,LretConstructor8=null,LretConstructor=null,LretConstructoro=0;
  561. tmp0=Lex.a3|0;
  562. LretConstructoro=HEAP32[4+tmp0>>2];
  563. LretConstructor=HEAP8;
  564. LretConstructor=_cheerpCreate_ZN6client6StringC2EPKc(LretConstructor,LretConstructoro);
  565. LretConstructor8=new CheerpException(LretConstructor);
  566. Lex.a0=LretConstructor8;
  567. throw LretConstructor8;
  568. ;
  569. }
  570. function _cheerpCreate_ZN6client6StringC2EPKc(Larg0,Marg0){
  571. var LretConstructor$pi=null,Lgeptoindexphi=0,LcheerpPtrAlloca$p07$pi=null;
  572. LretConstructor$pi=String();
  573. if((Larg0[Marg0]&255)===0)return String(LretConstructor$pi);
  574. Lgeptoindexphi=0;
  575. while(1){
  576. LcheerpPtrAlloca$p07$pi=String.fromCharCode(Larg0[Marg0+Lgeptoindexphi|0]<<24>>24);
  577. LretConstructor$pi=LretConstructor$pi.concat(LcheerpPtrAlloca$p07$pi);
  578. Lgeptoindexphi=Lgeptoindexphi+1|0;
  579. if((Larg0[Marg0+Lgeptoindexphi|0]&255)!==0)continue;
  580. break;
  581. }
  582. return String(LretConstructor$pi);
  583. }
  584. function _print(Lbuf,Mbuf,Llen){
  585. var Lcall=null,Lsub=0;
  586. Lcall=__ZN6client6String8fromUtf8EPKcj(Lbuf,Mbuf,Llen);
  587. Lsub=(Lcall.length)-1|0;
  588. if(((Lcall.charCodeAt(Lsub))|0)===10){
  589. console.log(Lcall.substr(0,Lsub));
  590. return;
  591. }
  592. console.log(Lcall);
  593. }
  594. function __ZN6client6String8fromUtf8EPKcj(Lin,Min,Llen){
  595. var tmp0=0,LretConstructor=null,Lgeptoindexphi=0,Llen$paddr$p06=0,Lcodepoint$p03=0,Lconv2=0;
  596. LretConstructor=String();
  597. if((Llen|0)===0)return LretConstructor;
  598. Llen$paddr$p06=Llen;
  599. Lgeptoindexphi=0;
  600. while(1){
  601. tmp0=Lin[Min+Lgeptoindexphi|0]|0;
  602. if((tmp0&255)!==0){
  603. Lconv2=tmp0&255;
  604. if(tmp0<<24<=-16777216)if((tmp0&255)<192){
  605. Lconv2=(Lconv2&63)+(Lcodepoint$p03<<6)|0;
  606. }else if((tmp0&255)<224){
  607. Lconv2&=31;
  608. }else if((tmp0&255)<240){
  609. Lconv2&=15;
  610. }else{
  611. Lconv2&=7;
  612. }
  613. Llen$paddr$p06=Llen$paddr$p06-1|0;
  614. Lgeptoindexphi=Lgeptoindexphi+1|0;
  615. a:{
  616. if((Llen$paddr$p06|0)!==0)if((Lin[Min+Lgeptoindexphi|0]&192)===128){
  617. Lcodepoint$p03=Lconv2;
  618. break a;
  619. }
  620. if(Lconv2>>>0<65536){
  621. Lcodepoint$p03=Lconv2;
  622. }else{
  623. Lcodepoint$p03=Lconv2-65536|0;
  624. LretConstructor=LretConstructor.concat(String.fromCharCode((Lcodepoint$p03>>>10)+55296|0));
  625. Lconv2=(Lconv2&1023)+56320|0;
  626. }
  627. LretConstructor=LretConstructor.concat(String.fromCharCode(Lconv2));
  628. }
  629. if((Llen$paddr$p06|0)!==0)continue;
  630. return LretConstructor;
  631. }
  632. break;
  633. }
  634. return LretConstructor;
  635. }
  636. function __start(){
  637. ___cxx_global_var_init();
  638. ___cxx_global_var_init$p2();
  639. ___cxx_global_var_init$p3();
  640. }
  641. function ___wrapper__print(Larg0,Larg1){
  642. _print(HEAP8,Larg0>>0,Larg1);
  643. }
  644. function ___wrapper___ZN7IpStack14recvAdapterUdpEPN3udp6SocketEPhjii(Larg0,Larg1,Larg2,Larg3,Larg4){
  645. __ZN7IpStack14recvAdapterUdpEPN3udp6SocketEPhjii(Larg0|0,HEAP8,Larg1>>0,Larg2,Larg3,Larg4);
  646. }
  647. function ___wrapper___ZN7IpStack11recvAdapterEPN3tcp6SocketEPhj(Larg0,Larg1,Larg2){
  648. __ZN7IpStack11recvAdapterEPN3tcp6SocketEPhj(Larg0|0,HEAP8,Larg1>>0,Larg2);
  649. }
  650. function ___wrapper___Z9output_jsPhi(Larg0,Larg1){
  651. __Z9output_jsPhi(HEAP8,Larg0>>0,Larg1);
  652. }
  653. var __ZN7IpStackL11listenerMapE=null;
  654. var __ZN7IpStackL7chanMapE=null;
  655. var __ZN6cheerp20EscapedResourcesListIN6client13EventListenerEE9resourcesE=null;
  656. var __ZL9output_cb=null;
  657. var __ZN10__cxxabiv19Exception9allocatorE$p2=16;
  658. var _promotedMalloc$p6=new Uint8Array(16);
  659. var __ZN10__cxxabiv19Exception9allocatorE$p1=_promotedMalloc$p6;
  660. var _promotedMalloc$p5=createArray_struct$p_ZN10__cxxabiv19ExceptionE(16);
  661. var __ZN10__cxxabiv19Exception9allocatorE$p0=_promotedMalloc$p5;
  662. function constructor_struct$p_ZN10__cxxabiv19ExceptionE(){
  663. this.a0=null;
  664. this.a1=null;
  665. this.a2=null;
  666. this.a3=0;
  667. this.a4=null;
  668. this.i5=0;
  669. this.i6=0;
  670. this.i7=0;
  671. this.a8=null;
  672. this.a9=null;
  673. this.a10=null;
  674. }
  675. function createArray_struct$p_ZN10__cxxabiv19ExceptionE(e){
  676. var r=[];
  677. for(var i=0;i<e;i++)
  678. r[i]=new constructor_struct$p_ZN10__cxxabiv19ExceptionE();
  679. return r;
  680. }
  681. function resizeArray_struct$p_ZN10__cxxabiv19ExceptionE(r,s,e){
  682. for(var i=s;i<e;i++)
  683. r[i]=new constructor_struct$p_ZN10__cxxabiv19ExceptionE();
  684. return r;
  685. }
  686. function cheerpCreateClosure(func, obj){return function(){var a=Array.prototype.slice.call(arguments);a.unshift(obj);return func.apply(null,a);};}
  687. function cheerpCreateClosureSplit(func, obj, objo){return function(){var a=Array.prototype.slice.call(arguments);a.unshift(obj,objo);return func.apply(null,a);};}
  688. function CheerpException(m){
  689. var instance=new Error('Uncaught C++ exception: '+m);
  690. instance.name='CheerpException';
  691. Object.setPrototypeOf(instance,Object.getPrototypeOf(this));
  692. if(Error.captureStackTrace){
  693. Error.captureStackTrace(instance, CheerpException);
  694. }
  695. return instance;
  696. }
  697. CheerpException.prototype=Object.create(Error.prototype);
  698. function growLinearMemory(bytes){
  699. var pages=(bytes+65535)>>16;
  700. try{
  701. __asm.memory.grow(pages);
  702. __heap=__asm.memory.buffer;
  703. assignHeaps(__heap);
  704. return pages<<16;
  705. }catch(e){
  706. return -1;
  707. }
  708. }
  709. var IpStack={
  710. bind:null,
  711. connect:null,
  712. down:null,
  713. init:null,
  714. input:null,
  715. listen:null,
  716. output:null,
  717. parseIP:null,
  718. up:null,
  719. };
  720. var HEAP8=null,HEAP32=null,__asm=null,__heap=null;function __dummy(){throw new Error('this should be unreachable');};
  721. var ___cxx_global_var_init=null;
  722. var _malloc=null;
  723. var __ZN3udp6SocketC2Ev=null;
  724. var __ZN3udp6Socket4bindEii=null;
  725. var __ZN3udp6SocketD2Ev=null;
  726. var __ZN7IpStack11recvWasmUdpEPN3udp6SocketE=null;
  727. var __ZN3udp6Socket5closeEv=null;
  728. var __ZNSt6vectorIhSaIhEEC2Ej=null;
  729. var __ZNSt6vectorIhSaIhEEixEj=null;
  730. var __ZN7IpStack11sendWasmUdpEPN3udp6SocketERKSt6vectorIhSaIhEEjj=null;
  731. var __ZNSt6vectorIhSaIhEED2Ev=null;
  732. var __ZL6map_ipj=null;
  733. var __ZN3tcp6SocketC2Ev=null;
  734. var __ZN3tcp6Socket4bindEii=null;
  735. var __ZN3tcp6Socket6listenEv=null;
  736. var __ZN7IpStack10acceptWasmEPN3tcp6SocketE=null;
  737. var __ZN3tcp6SocketD2Ev=null;
  738. var __ZN3tcp6Socket5closeEv=null;
  739. var __ZN7IpStack8recvWasmEPN3tcp6SocketE=null;
  740. var __ZN7IpStack8sendWasmEPN3tcp6SocketERKSt6vectorIhSaIhEE=null;
  741. var __ZN7IpStack11connectWasmEPN3tcp6SocketEii=null;
  742. var __ZN2ip4stonERKSs=null;
  743. var __ZNSsD2Ev=null;
  744. var __ZNSsC2Ev=null;
  745. var __ZNSs6resizeEj=null;
  746. var __ZNSsixEj_icf=null;
  747. var _pbuf_alloc=null;
  748. var __ZN7IpStackL7doInputEP4pbuf=null;
  749. var __Z4downv=null;
  750. var __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEEC2Ev=null;
  751. var __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEE7emplaceIJSsSsEEES4_ISt19__hash_map_iteratorISt15__hash_iteratorIPSt11__hash_nodeISt17__hash_value_typeISsSsEPvEEEbEDpOT_=null;
  752. var __Z2upRKSsRKSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIS_SsEEE=null;
  753. var __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEED2Ev=null;
  754. var __Z4initv=null;
  755. var __Z16udpecho_raw_initv=null;
  756. var __Z16tcpecho_raw_initv=null;
  757. var _sys_check_timeouts=null;
  758. var _free=null;
  759. var ___getStackPtr=null;
  760. var ___setStackPtr=null;
  761. export default function(Lh){
  762. return (Lh&&Lh.buffer)?
  763. Promise.resolve(Lh.buffer):
  764. fetchBuffer((Lh&&Lh.absPath)?Lh.absPath:new URL('ipstack.wasm', import.meta.url)).then(Lh=>
  765. WebAssembly.instantiate(Lh,
  766. {i:{
  767. ___syscall_rt_sigprocmask:__dummy,
  768. ___syscall_rt_sigaction:__dummy,
  769. ___syscall_tkill:__dummy,
  770. ___syscall_exit_group:__dummy,
  771. ___syscall_exit:__dummy,
  772. ___syscall_futex:__dummy,
  773. ___syscall__llseek:__dummy,
  774. ___wrapper___Z9output_jsPhi:___wrapper___Z9output_jsPhi,
  775. ___syscall_close:__dummy,
  776. ___wrapper___ZN7IpStack11recvAdapterEPN3tcp6SocketEPhj:___wrapper___ZN7IpStack11recvAdapterEPN3tcp6SocketEPhj,
  777. __ZN7IpStack13acceptAdapterEPN3tcp6SocketES2_iii:__ZN7IpStack13acceptAdapterEPN3tcp6SocketES2_iii,
  778. ___wrapper___ZN7IpStack14recvAdapterUdpEPN3udp6SocketEPhjii:___wrapper___ZN7IpStack14recvAdapterUdpEPN3udp6SocketEPhjii,
  779. __ZN7IpStack11connAdapterEPN3tcp6SocketEi:__ZN7IpStack11connAdapterEPN3tcp6SocketEi,
  780. _sys_now:_sys_now,
  781. __ZN10__cxxabiv1L24__cxa_throw_wasm_adapterEjPSt9type_infoj:__ZN10__cxxabiv1L24__cxa_throw_wasm_adapterEjPSt9type_infoj,
  782. __Z14start_timeoutsv:__Z14start_timeoutsv,
  783. ___wrapper__print:___wrapper__print,
  784. growLinearMemory:growLinearMemory,
  785. }})
  786. ).then(Lh=>{
  787. __asm=Lh.instance.exports;
  788. __heap=__asm.memory.buffer;
  789. assignHeaps(__heap);
  790. ___cxx_global_var_init=__asm.___cxx_global_var_init;
  791. _malloc=__asm._malloc;
  792. __ZN3udp6SocketC2Ev=__asm.__ZN3udp6SocketC2Ev;
  793. __ZN3udp6Socket4bindEii=__asm.__ZN3udp6Socket4bindEii;
  794. __ZN3udp6SocketD2Ev=__asm.__ZN3udp6SocketD2Ev;
  795. __ZN7IpStack11recvWasmUdpEPN3udp6SocketE=__asm.__ZN7IpStack11recvWasmUdpEPN3udp6SocketE;
  796. __ZN3udp6Socket5closeEv=__asm.__ZN3udp6Socket5closeEv;
  797. __ZNSt6vectorIhSaIhEEC2Ej=__asm.__ZNSt6vectorIhSaIhEEC2Ej;
  798. __ZNSt6vectorIhSaIhEEixEj=__asm.__ZNSt6vectorIhSaIhEEixEj;
  799. __ZN7IpStack11sendWasmUdpEPN3udp6SocketERKSt6vectorIhSaIhEEjj=__asm.__ZN7IpStack11sendWasmUdpEPN3udp6SocketERKSt6vectorIhSaIhEEjj;
  800. __ZNSt6vectorIhSaIhEED2Ev=__asm.__ZNSt6vectorIhSaIhEED2Ev;
  801. __ZL6map_ipj=__asm.__ZL6map_ipj;
  802. __ZN3tcp6SocketC2Ev=__asm.__ZN3tcp6SocketC2Ev;
  803. __ZN3tcp6Socket4bindEii=__asm.__ZN3tcp6Socket4bindEii;
  804. __ZN3tcp6Socket6listenEv=__asm.__ZN3tcp6Socket6listenEv;
  805. __ZN7IpStack10acceptWasmEPN3tcp6SocketE=__asm.__ZN7IpStack10acceptWasmEPN3tcp6SocketE;
  806. __ZN3tcp6SocketD2Ev=__asm.__ZN3tcp6SocketD2Ev;
  807. __ZN3tcp6Socket5closeEv=__asm.__ZN3tcp6Socket5closeEv;
  808. __ZN7IpStack8recvWasmEPN3tcp6SocketE=__asm.__ZN7IpStack8recvWasmEPN3tcp6SocketE;
  809. __ZN7IpStack8sendWasmEPN3tcp6SocketERKSt6vectorIhSaIhEE=__asm.__ZN7IpStack8sendWasmEPN3tcp6SocketERKSt6vectorIhSaIhEE;
  810. __ZN7IpStack11connectWasmEPN3tcp6SocketEii=__asm.__ZN7IpStack11connectWasmEPN3tcp6SocketEii;
  811. __ZN2ip4stonERKSs=__asm.__ZN2ip4stonERKSs;
  812. __ZNSsD2Ev=__asm.__ZNSsD2Ev;
  813. __ZNSsC2Ev=__asm.__ZNSsC2Ev;
  814. __ZNSs6resizeEj=__asm.__ZNSs6resizeEj;
  815. __ZNSsixEj_icf=__asm.__ZNSsixEj_icf;
  816. _pbuf_alloc=__asm._pbuf_alloc;
  817. __ZN7IpStackL7doInputEP4pbuf=__asm.__ZN7IpStackL7doInputEP4pbuf;
  818. __Z4downv=__asm.__Z4downv;
  819. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEEC2Ev=__asm.__ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEEC2Ev;
  820. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEE7emplaceIJSsSsEEES4_ISt19__hash_map_iteratorISt15__hash_iteratorIPSt11__hash_nodeISt17__hash_value_typeISsSsEPvEEEbEDpOT_=__asm.__ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEE7emplaceIJSsSsEEES4_ISt19__hash_map_iteratorISt15__hash_iteratorIPSt11__hash_nodeISt17__hash_value_typeISsSsEPvEEEbEDpOT_;
  821. __Z2upRKSsRKSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIS_SsEEE=__asm.__Z2upRKSsRKSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIS_SsEEE;
  822. __ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEED2Ev=__asm.__ZNSt13unordered_mapISsSsSt4hashISsESt8equal_toISsESaISt4pairIKSsSsEEED2Ev;
  823. __Z4initv=__asm.__Z4initv;
  824. __Z16udpecho_raw_initv=__asm.__Z16udpecho_raw_initv;
  825. __Z16tcpecho_raw_initv=__asm.__Z16tcpecho_raw_initv;
  826. _sys_check_timeouts=__asm._sys_check_timeouts;
  827. _free=__asm._free;
  828. ___getStackPtr=__asm.___getStackPtr;
  829. ___setStackPtr=__asm.___setStackPtr;
  830. IpStack.bind=__ZN7IpStack4bindEi;
  831. IpStack.connect=__ZN7IpStack7connectEiii;
  832. IpStack.down=__ZN7IpStack4downEv;
  833. IpStack.init=__ZN7IpStack4initEPN6client9UpOptionsE;
  834. IpStack.input=__ZN7IpStack5inputEPN6client10Uint8ArrayE;
  835. IpStack.listen=__ZN7IpStack6listenEi;
  836. IpStack.output=__ZN7IpStack6outputEPFvPN6client10Uint8ArrayEE;
  837. IpStack.parseIP=__ZN7IpStack7parseIPEPN6client6StringE;
  838. IpStack.up=__ZN7IpStack2upEPN6client9UpOptionsE;
  839. __start();
  840. return{
  841. IpStack:IpStack,
  842. };
  843. });
  844. }
  845. function assignHeaps(Lh){
  846. HEAP8=new Uint8Array(Lh);
  847. HEAP32=new Int32Array(Lh);
  848. }