-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmembrane.min.js
3 lines (3 loc) · 7.52 KB
/
membrane.min.js
1
2
3
/*! For license information please see membrane.min.js.LICENSE.txt */
(()=>{"use strict";var e={147:e=>{e.exports=require("fs")},685:e=>{e.exports=require("http")},687:e=>{e.exports=require("https")},808:e=>{e.exports=require("net")},17:e=>{e.exports=require("path")}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}(()=>{const{Socket:e}=n(808),{request:t}=n(687),{createServer:o}=n(685),{existsSync:r,readFileSync:i}=n(147),{dirname:s,basename:c}=n(17),l=s(__filename),a=c(__filename),u=process.argv.slice(2),f=[u.indexOf("--help"),u.indexOf("-h"),u.indexOf("--silent"),u.indexOf("-s")],p=f[0]>=0||f[1]>=0,d=f[2]>=0||f[3]>=0,g={},h=l+"/membrane.json",m=l+"/bad_words_latin.txt",$=l+"/bad_words_cyrillic.txt",x=l+"/exceptions_latin.txt",w=l+"/exceptions_cyrillic.txt",y=`АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп${" ".repeat(48)}рстуфхцчшщъыьэюяЁё${" ".repeat(14)}`,b=new Map,T=[()=>{},async function(e){q(`[${e}] handshake`),k(e)},async function(e,n,o){const r={},i=n.readUInt8(o),s=b.get(e),c=s.games,l=[];let a=0;for(;o<n.length&&a<i;){const e=[];let t="";const i=n.readUInt32LE(o+1);for(o+=5;0!==n[o];)e.push(n[o]),o+=1;t=e.reduce(((e,t)=>e+function(e){return e<128?String.fromCharCode(e):y[e-128]}(t)),""),t=t.split(" "),r[i]={name:t.filter(((e,n)=>n<t.length-3)).join(" ").slice(0,-1),players:Number.parseInt(t[t.length-3],10),mode:g.gameModes[g.gameLetters.indexOf(t[t.length-2])],time:t[t.length-1].split(":").reduce(((e,t,n)=>e+t*[3600,60,1][n]),0),isNew:!!s.gamesRead&&!c[i]},a+=1}q(`[${e}] games:`,r),Object.entries(r).forEach((([e,t])=>{t.isNew&&l.push({...t,id:e})})),l.length&&function(e,n){q(`[tg] sendToChat ${e}: ${n}`);const o=JSON.stringify({chat_id:e,parse_mode:"HTML",disable_web_page_preview:!0,text:n}),r=t({host:"api.telegram.org",port:g.tgPort,path:`/bot${g.tgToken}/sendMessage`,method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}},B);r.write(o),r.end()}(g.tgChats[0],(l.length>1?`Созданы новые игры:${l.reduce(((e,t)=>e+"\n"+U(s,t)),"")}`:`Создана новая игра: ${U(s,l[0])}`)+"\n\nНажмите по названию игры, чтобы присоединиться к ней (требуется установленная из Steam игра)"),s.games=r,s.gamesRead=!0,globalThis.clearTimeout(s.lastTimeout),s.lastTimeout=globalThis.setTimeout((()=>k(e)),l.length?g.gameRequestCooldown:g.gameRequestTimeout)}],v=[(e,t,n,o)=>t===`Enter, my son, please...\0${b.get(e).protocol}`,(e,t,n,o)=>n&&193===o],O={cyr:[],lat:[]},E={cyr:[],lat:[]},S={lat:{a:["a","а","@"],b:["b","6"],c:["c","с","("],d:["d"],e:["e","е"],f:["f"],g:["g"],h:["h","н"],i:["i","!"],j:["j"],k:["k","к"],l:["l"],m:["m","м"],n:["n","п"],o:["o","о"],p:["p","р"],q:["q"],r:["r","г"],s:["s","$"],t:["t","+","7","т"],u:["u","и","ц"],v:["v"],w:["w"],x:["x","х"],y:["y","у"],z:["z"]},cyr:{а:["а","a","@"],б:["б","6","b"],в:["в","b","v"],г:["г","r","g"],д:["д","d","g"],е:["е","e"],ё:["ё","e"],ж:["ж","*"],з:["з","3","z"],и:["и","u","i"],й:["й","u","i","y"],к:["к","k"],л:["л","l"],м:["м","m"],н:["н","h","n"],о:["о","o","0"],п:["п","n","p"],р:["р","r","p"],с:["с","c","s","("],т:["т","m","t","+"],у:["у","y","u"],ф:["ф","f"],х:["х","x","h"],ц:["ц","c"],ч:["ч","4"],ш:["ш"],щ:["щ"],ь:["ь","b"],ы:["ы"],ъ:["ъ"],э:["э","e"],ю:["ю"],я:["я","r"]}},_={};let C;function q(...e){if(d)return;const t=new Date,n=["FullYear","Month","Date","Hours","Minutes","Seconds","Milliseconds"].map(((e,n)=>function(e,t=2){return e.toString(10).padStart(t,"0")}(t[`getUTC${e}`]()+(1===n?1:0),n&&6!==n?2:4))).reduce(((e,t,n)=>e+t+".. ::: "[n]),"");console.log(n,...e)}function I(e,t){const n=e.length,o=t.length,r=[[],[]],i=[0,0,0];let s=0,c=0,l=0,a=1;for(c=0;c<=o;c++)r[1][c]=c;for(s=1;s<=n;s++)for(l=+!l,a=+!a,r[a][0]=s,c=1;c<=o;c++)i[0]=r[l][c]+1,i[1]=r[a][c-1]+1,i[2]=r[l][c-1]+(e[s-1]===t[c-1]?0:1),r[a][c]=Math.min(i[0],i[1],i[2]);return r[a][o]}function j(e){return i(e,{encoding:"utf8",flag:"r"}).split("\n")}function L(t,{host:n,port:o,type:r,protocol:i}){if(b.get(t)?.alive)return;q(`[${t}] initClient`);const s=new e;b.set(t,{client:s,host:n,port:o,type:r,protocol:i,games:{},lastTimeout:null,alive:!0,gamesRead:!1}),s.on("data",(async function(e){const n=e.toString(),o=e,r=o.readUInt16LE(0);let i,s=2;r&&(i=o.readUInt8(s),s+=1),T[v.findIndex((e=>!!e(t,n,r,i)))+1](t,o,s)})),s.on("error",(function(){q(`[${t}] error`),M(t)})),s.on("timeout",(function(){q(`[${t}] timeout`),M(t)})),s.on("close",(function(){q(`[${t}] connection closed, try again in ${g.reconnectTimeout/1e3/60} min`),b.get(t).alive=!1,globalThis.clearTimeout(b.get(t).lastTimeout),b.get(t).lastTimeout=globalThis.setTimeout((()=>L(t,{host:n,port:o,type:r,protocol:i})),g.reconnectTimeout)})),function(e){const{port:t,host:n,protocol:o,client:r}=b.get(e);r.connect(t,n,(()=>{r.write(`Vivat Sicher, Rock'n'Roll forever!!!\0${o}`)}))}(t)}function M(e){R(e,134,Buffer.alloc(0)),b.get(e).client.destroy()}function R(e,t,n){const o=Buffer.alloc(2);o.writeInt16LE(1+n.length),b.get(e).client.write(Buffer.concat([o,Buffer.from([t]),n]))}function k(e){R(e,129,Buffer.alloc(0))}function B(e){let t="";e.on("data",(e=>t+=e)),e.on("end",(()=>{q(`[tg] response status code: ${e.statusCode}`),q("[tg] response body:",t)}))}function U(e,t){return`<a href="${g.redirectHost}:${g.redirectPort}/r?s=${e.host}&p=${e.port}&g=${t.id}">${function(e){const t=[],n=[];let o=0,r="",i="",s="";return["cyr","lat"].forEach((c=>{r=e.slice().toLowerCase(),E[c].forEach((t=>{for(s=t.toLowerCase(),o=0;o<=r.length-t.length;o+=1)i=r.slice(o,o+t.length),I(i,s)<=s.length*g.exceptionSensitivity&&(q(`[filter exception] Found word "${t}" as "${i}" in string "${e}"`),n.push([o,e.slice(o,o+t.length)]),r=r.slice(0,o)+" ".repeat(t.length)+r.slice(o+t.length))})),Object.entries(S[c]).forEach((([t,n])=>{n.forEach((n=>{for(o=0;o<e.length;o+=1)r=r.replaceAll(n,t)}))})),O[c].forEach((n=>{for(s=n.toLowerCase(),o=0;o<=r.length-n.length;o+=1)i=r.slice(o,o+n.length),I(i,s)<=s.length*g.censorSensitivity&&(q(`[filter censor] Found word "${n}" as "${i}" in string "${e}"`),t.push([o,o+n.length]))}))})),i=e.slice(),t.forEach((([e,t])=>{i=i.slice(0,e)+function(e){let t="";for(let n=0;n<e;n+=1)t+="█▄▀"[3*Math.random()|0];return t}(t-e)+i.slice(t)})),n.forEach((([e,t])=>{i=i.slice(0,e)+t+i.slice(e+t.length)})),i}(t.name.slice())}</a> (${t.mode})`}function N(e,t){const n=decodeURIComponent(e.url);if("/r?"===n.slice(0,3)&&~n.indexOf("s=")&&~n.indexOf("p=")&&~n.indexOf("g=")){const{s:e,p:o,g:r}=n.split("&").map((e=>e.slice(e.indexOf("=")-1).split("="))).reduce(((e,[t,n])=>({...e,[t]:n})),{});t.writeHead(302,{Location:`steam://run/264080//-server ${e} -port ${o} -game ${r}/`})}else t.writeHead(400),t.write("Invalid redirect request format");return t.end()}(async function(){var e;p&&([`Usage: node ${a} [OPTIONS]`,"","Options:"," --help, -h Print this"," --silent, -s Disable output"].forEach((e=>console.log(e))),process.exit(0)),[[h,"Configuration file"],[m,"Bad words file"],[$,"Bad words file"],[x,"Exception words file"],[w,"Exception words file"]].forEach(((e,t)=>{r(e)||(q(`${t} ${e} was not found, aborting`),process.exit(1))})),Object.assign(g,(e=h,JSON.parse(i(e,{encoding:"utf8",flag:"r"})))),O.lat.push(...j(m)),O.cyr.push(...j($)),E.lat.push(...j(x)),E.cyr.push(...j(w)),C=o(_,N),C.listen(g.redirectPort),g.servers.forEach((e=>L(`${e.host}:${e.port}`,e)))})().then((e=>{q("All clients in the pool were initialized")}))})()})();
//# sourceMappingURL=membrane.min.js.map