mh288 protokolü oluşturuldu

This commit is contained in:
abdussamedulutas 2025-08-01 21:17:28 +03:00
parent bcdbe5f3fd
commit 473dd62789
7 changed files with 434 additions and 5 deletions

View File

@ -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")));

View File

@ -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);
}

View File

@ -9,5 +9,15 @@
"jsecho",
"set"
]
},
"rtc": {
"endpoints": [
"./rtc/mwse-socket.js",
"./rtc/mwse-close.js"
],
"commands": [
"mwse-socket",
"mwse-close"
]
}
}

View File

@ -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(`ı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);

View File

@ -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);

208
public/m.h.2.8.8.js Normal file
View File

@ -0,0 +1,208 @@
function HostListItem()
{
let item = $(`
<tr>
<td class="text-nowrap">
<button class="btn btn-outline-primary btn-sm action-download">
İndir
</button>
<button class="btn btn-outline-danger btn-sm action-remove">
Kaldır
</button>
</td>
<td class="text-nowrap">
<button class="btn btn-outline-secondary btn-sm action-sha1">
Hesapla
</button>
</td>
<td class="text-nowrap">
<span class="action-filename">DCIM_AMG_25TEM2025.png</span>
<br>
<span class="text-muted">
(Sizin cihazda)
</span>
</td>
<td class="text-nowrap">
<div class="progress" style="height:30px">
<div class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</td>
</tr>
`);
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 = $(`
<tr>
<td class="text-nowrap">
<button class="btn btn-outline-primary btn-sm action-download">
İndir
</button>
<button class="btn btn-outline-secondary btn-sm action-hide">
Gizle
</button>
</td>
<td class="text-nowrap">
<button class="btn btn-outline-secondary btn-sm action-sha1">
Hesapla
</button>
</td>
<td class="text-nowrap">
<span class="action-filename">DCIM.mp4</span>
<br>
<span class="text-muted">
(Karşı cihazda)
</span>
</td>
<td class="text-nowrap">
<div class="progress" style="height:30px">
<div class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</td>
</tr>
`);
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 $(`
<tr>
<td class="text-center text-muted" colspan="4">
Gönderilecek veya alınacak dosya bulunmuyor
</td>
</tr>
`)
}
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 + " <span class='text-muted'>" + formatBytes(this.file.size) + "</span>"
);
}
};
$("#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
});
})

64
public/transfer.html Normal file
View File

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dosya Transfer Sistem</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container" style="max-width: 1200px">
<h2 class="text-center mb-2 mt-5">Dosya Transfer Sistemi</h2>
<h1 class="text-center mb-5 mt-3 text-bold fw-bold">
<span>Ağ Adresiniz</span>
<span class="text-danger network-id">
#.#.#.#
</span>
</h1>
<div class="mx-auto d-flex flex-row mb-5" style="max-width: 800px;gap:20px">
<div class="flex-fill">
<input
type="file"
id="files"
multiple
class="form-control"
>
</div>
<div class="flex-fill d-flex" style="gap:5px">
<input
type="text"
class="form-control"
placeholder="Farklı bir ağa katıl"
id="remoteadress"
>
<button class="btn btn-outline-success joinroom">
Katıl
</button>
</div>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-nowrap" width="1%">İşlem</th>
<th class="text-nowrap" width="1%">SHA-1</th>
<th class="text-nowrap" width="49%">Dosya İsmi</th>
<th class="text-nowrap" width="50%">İşlem</th>
</tr>
</thead>
<tbody id="thelist">
<tr class="empty">
<td class="text-center text-muted" colspan="4">
Gönderilecek veya alınacak dosya bulunmuyor
</td>
</tr>
</tbody>
</table>
</div>
<script src="https://ws.saqut.com/script"></script>
<script src="m.h.2.8.8.js"></script>
</body>
</html>