ipstack.js 35 KB

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