diff --git a/Source/HTTPServer.js b/Source/HTTPServer.js index 1d5ef46..787c588 100644 --- a/Source/HTTPServer.js +++ b/Source/HTTPServer.js @@ -45,9 +45,7 @@ app.get("/console",(request, response)=>{ response.sendFile(resolve("./console/index.html")) }); app.get("/console/lib.js",(request, response)=>{ - setTimeout(()=> { - response.sendFile(resolve("./console/lib.js")) - }, Math.random() * 5_000 | 0) + response.sendFile(resolve("./console/lib.js")) }); app.use("/stream",express.static(resolve("./public"))); app.use("/console/",express.static(resolve("./console"))); diff --git a/console/lib.js b/console/lib.js index 6ef7b0e..046cb31 100644 --- a/console/lib.js +++ b/console/lib.js @@ -608,7 +608,18 @@ function generatepipe() }, async writeln(...args){ term.writeln(args.map(e => e.toString()).join(' ')) - } + }, + COLOR_RESET, + COLOR_TEXT, + COLOR_BACKGROUND, + CURSOR_MOVE, + CURSOR_MOVE_UP, + CURSOR_MOVE_DOWN, + CURSOR_MOVE_RIGHT, + CURSOR_MOVE_LEFT, + CLEAR_SCREEN, + CLEAR_LINE, + CLEAR_STYLING }, stderr: { async write(...args){ @@ -892,7 +903,8 @@ class SystemLoad{ (new Function(script))(); this.stdout.writeln(`Process success`); await wait(100); - }catch{ + }catch(error){ + debugger; this.stderr.writeln(`Process error`); await wait(100); } diff --git a/console/official/packages.json b/console/official/packages.json index 4bf3217..5e7fea8 100644 --- a/console/official/packages.json +++ b/console/official/packages.json @@ -9,5 +9,15 @@ "jsecho", "set" ] + }, + "rtc": { + "endpoints": [ + "./rtc/mwse-socket.js", + "./rtc/mwse-close.js" + ], + "commands": [ + "mwse-socket", + "mwse-close" + ] } } \ No newline at end of file diff --git a/console/official/rtc/mwse-close.js b/console/official/rtc/mwse-close.js new file mode 100644 index 0000000..d1143de --- /dev/null +++ b/console/official/rtc/mwse-close.js @@ -0,0 +1,44 @@ +class MWSECloser{ + stdin = null; + stdout = null; + stderr = null; + + endpoint = null; + static mwse = null; + + constructor(pipe){ + this.stdin = pipe.stdin; + this.stdout = pipe.stdout; + this.stderr = pipe.stderr; + } + greenText(text){ + this.stdout.writeln(`${this.stdout.COLOR_TEXT(0,255,0)}${text}${this.stdout.COLOR_RESET()}`); + } + redText(text){ + this.stdout.writeln(`${this.stdout.COLOR_TEXT(255,0,0)}${text}${this.stdout.COLOR_RESET()}`); + } + async main(args) + { + let mwseConnector = CommandNamespace.namespaces.get('mwse-socket'); + if(mwseConnector == null){ + this.stderr.writeln(`mwse-socket yok`); + return this.exit(); + } + if(mwseConnector.mwse == null){ + this.stderr.writeln(`Açık bir soket bulunamadı`); + return this.exit(); + } + if(mwseConnector.mwse.server?.disconnect == null){ + this.stderr.writeln(`MWSE bağlayıcısında hata oluştu`); + return this.exit(); + } + mwseConnector.mwse.server.disconnect(); + this.greenText("MWSE socketi başarılı bir şekilde kapatıldı"); + this.redText(`\n\n${mwseConnector.mwse.server.endpoint.host} sunucusuyla MWSE bağlantısı kesildi\n\n`); + return this.exit(); + + } +}; + + +CommandNamespace.namespaces.set('mwse-close', MWSECloser); \ No newline at end of file diff --git a/console/official/rtc/mwse-socket.js b/console/official/rtc/mwse-socket.js new file mode 100644 index 0000000..56bc4d4 --- /dev/null +++ b/console/official/rtc/mwse-socket.js @@ -0,0 +1,93 @@ +class MWSECloser{ + stdin = null; + stdout = null; + stderr = null; + + endpoint = null; + static mwse = null; + + constructor(pipe){ + this.stdin = pipe.stdin; + this.stdout = pipe.stdout; + this.stderr = pipe.stderr; + } + greenText(text){ + this.stdout.writeln(`${this.stdout.COLOR_TEXT(0,255,0)}${text}${this.stdout.COLOR_RESET()}`); + } + async main(args) + { + this.stdout.write("Endpoint: "); + let answer = await this.stdin.readline(); + let url; + + try{ + url = new URL(answer) + }catch{ + this.stderr.writeln('Bilinmeyen path yapısı'); + return this.exit(); + }; + + this.greenText('Path doğrulandı'); + + if(url.protocol.toLowerCase() != 'wss:' && url.protocol.toLowerCase() != 'ws:'){ + this.stderr.writeln('Bilinmeyen protokol'); + return this.exit(); + } + + this.greenText('Şema doğrulandı'); + + this.endpoint = url; + + try{ + await this.scriptImport(); + }catch{ + this.stderr.writeln('MWSE bağlayıcısı indirilemedi'); + return this.exit(); + }; + + this.greenText(`${url.host} üzerinden bağlanılıyor : ${url.href}`); + let mwse; + try{ + mwse = new MWSE({ + endpoint: url.href + }); + + await new Promise(ok => { + mwse.scope(async ()=>{ + this.greenText(`\n\nMWSE üzerinden ${url.host} makinesine bağlısınız\n\n`); + ok(); + }) + }); + + MWSECloser.mwse = mwse; + }catch{ + this.stderr.writeln(`${url.host} makinesine bağlanırken bir sorun oluştu`); + return this.exit(); + }finally{ + this.exit(); + } + } + async scriptImport() + { + let t = new URL("script",this.endpoint); + if(t.protocol == 'wss:'){ + t.protocol = 'https:'; + }else{ + t.protocol = 'http:'; + } + let script = document.createElement("script"); + await new Promise((ok,rej) => { + script.onload = () => ok(); + script.onerror = () => rej(); + script.setAttribute("src",t.href); + document.head.appendChild(script); + }); + if(window.MWSE === void 0){ + this.stderr.writeln('MWSE bağlayıcısı indirilemedi'); + return this.exit(); + } + } +}; + + +CommandNamespace.namespaces.set('mwse-socket', MWSECloser); \ No newline at end of file diff --git a/public/m.h.2.8.8.js b/public/m.h.2.8.8.js new file mode 100644 index 0000000..70ff182 --- /dev/null +++ b/public/m.h.2.8.8.js @@ -0,0 +1,208 @@ +function HostListItem() +{ + let item = $(` + + + + + + + + + + DCIM_AMG_25TEM2025.png +
+ + (Sizin cihazda) + + + +
+
+
+ + + `); + return { + download: item.find(".action-download"), + hide: item.find(".action-hide"), + remove: item.find(".action-remove"), + sha1: item.find(".action-sha1"), + filename: item.find(".action-filename"), + progress: item.find(".progress"), + container: item + } +} + +function RemoteListItem() +{ + let item = $(` + + + + + + + + + + DCIM.mp4 +
+ + (Karşı cihazda) + + + +
+
+
+ + + `); + return { + download: item.find(".action-download"), + hide: item.find(".action-hide"), + remove: item.find(".action-remove"), + sha1: item.find(".action-sha1"), + filename: item.find(".action-filename"), + progress: item.find(".progress"), + container: item + } +} + +function EmptyListItem() +{ + return $(` + + + Gönderilecek veya alınacak dosya bulunmuyor + + + `) +} + +function formatBytes(a,b=2){if(!+a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return`${parseFloat((a/Math.pow(1024,d)).toFixed(c))} ${["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"][d]}`} + + +const endpoint = `wss://ws.saqut.com/socket/webserver/${("000000"+(Math.random() * 512 | 0)).slice(-6)}.sock`; + +let mwse = new MWSE({ + endpoint, + autoReconnect: true, + autoReconnectTimeout: 60_000 +}); + +mwse.scope(Connect); + +let room; +let ip; + +async function Connect() +{ + await genRoom(); + $(".network-id").text(ip); +} + +async function genRoom() +{ + do{ + let vip = ip = [ + (Math.random() * 16 | 0) + 10, + (Math.random() * 8 | 0), + (Math.random() * 4 | 0), + (Math.random() * 254 | 0) + 1 + ].join('.'); + room = mwse.room({ + name: `WEB3-Smash [${vip}] RO CONNECT:2`, + description: "Web3 Smash saQut Server Application", + joinType: "free", + notifyActionJoined: true, + notifyActionEjected: true, + ifexistsJoin: false + }); + try{ + await room.createRoom(); + break; + }catch{ + continue; + } + }while(1); +} + +class FileDescriptor { + static hostfiles = new Map(); + static remotefiles = new Map(); + static hostindex = 0; + static remoteindex = 0; + + file = null; + listItem = null; + + constructor(isHost, item,file){ + this.file = file; + this.listItem = item; + $("#thelist").append(item.container); + if(isHost) + { + FileDescriptor.hostfiles.set( + ++FileDescriptor.hostindex, + this + ); + }else{ + FileDescriptor.remotefiles.set( + ++FileDescriptor.remoteindex, + this + ); + } + this.init(); + } + init(){ + this.listItem.filename.html( + this.file.name + " " + formatBytes(this.file.size) + "" + ); + } +}; + +$("#files").on('change',function(){ + for (const file of this.files) { + $("#thelist .empty").remove(); + new FileDescriptor( + true, + HostListItem(), + file + ) + }; + $("#files").val(''); +}); + +$(".joinroom").on("chnage",function(){ + + let ip = $("#remoteadress").val(); + + if(!/^\d+\.\d+\.\d+$/.test(ip)){ + return alert(" ") + } + + $("#thelist .empty").remove(); + + room = mwse.room({ + name: `WEB3-Smash [${vip}] RO CONNECT:2`, + description: "Web3 Smash saQut Server Application", + joinType: "free", + notifyActionJoined: true, + notifyActionEjected: true, + ifexistsJoin: false + }); +}) \ No newline at end of file diff --git a/public/transfer.html b/public/transfer.html new file mode 100644 index 0000000..2941199 --- /dev/null +++ b/public/transfer.html @@ -0,0 +1,64 @@ + + + + + + Dosya Transfer Sistem + + + + +
+ +

Dosya Transfer Sistemi

+

+ Ağ Adresiniz + + #.#.#.# + +

+ +
+
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + +
İşlemSHA-1Dosya İsmiİşlem
+ Gönderilecek veya alınacak dosya bulunmuyor +
+
+ + + + \ No newline at end of file