Archive ayunmultiport (server, 1.5.2, 1.8.8, clean)

This commit is contained in:
2026-11-27 22:13:31 -06:00
parent fed8ba63fe
commit 6d44d49580
17 changed files with 17928 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
bukkit_command/
node_modules/
package-lock.json
+29
View File
@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2022, ayunami2000
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+7
View File
@@ -0,0 +1,7 @@
# ayunMultiPort
primarily for eaglercraft, but basically proxies minecraft to http web server and for eaglercraft also creates a websocket for it, all on the same port!!
eagler_only.js is the eagler piece alone, without java forwarding on the same port
## Tutorial (thanks fnaf69!)
https://docs.google.com/document/d/1cvHK_SnNuUgf6RLMoT0fLQGxELqaWrAIzJuxXe6A7wE/edit
+70
View File
@@ -0,0 +1,70 @@
const Net = require('net');
const listenPort = 25565;
const mcHost = "freedom.play.totalfreedom.me";
const mcPort = 25565;
const httpHost = "localhost";
const httpPort = 8080;
const timeout = 10000;
const server = new Net.Server();
server.listen(listenPort, function() {
//
});
server.on('connection', function(socket) {
let client = null;
let determinedClient = false;
socket.on('data', function(chunk) {
if(!determinedClient){
let req = chunk.toString();
if(req.startsWith("GET ")||req.startsWith("HEAD ")||req.startsWith("POST ")||req.startsWith("PUT ")||req.startsWith("DELETE ")||req.startsWith("CONNECT ")||req.startsWith("OPTIONS ")||req.startsWith("TRACE ")||req.startsWith("PATCH ")){
makeClient(httpHost,httpPort,socket,c=>client=c);
}else{
makeClient(mcHost,mcPort,socket,c=>client=c);
}
determinedClient=true;
}
writeData(chunk);
});
socket.on('end', function() {
if(client!=null)client.end();
});
socket.on('error', function(err) {
//console.log(`Server Error: ${err}`);
});
async function writeData(chunk){
let i=Date.now();
while(client==null&&(Date.now()-i<timeout/10)){
await new Promise(a=>setTimeout(a,10));
}
if(client==null&&socket!=null)return socket.end();
client.write(chunk);
}
});
function makeClient(host,port,socket,cb){
const client = new Net.Socket();
client.connect({ port: port, host: host }, function() {
cb(client);
});
client.on('end', function() {
if(socket!=null)socket.end();
});
client.on('data', function(chunk) {
if(socket!=null)socket.write(chunk);
});
client.on('error', function(err) {
//console.log(`Client Error: ${err}`);
});
}
+216
View File
@@ -0,0 +1,216 @@
const Net = require('net');
const { WebSocketServer, WebSocket } = require('ws');
const fs = require("fs");
const path = require("path");
const mime = require("mime-types");
const bufferReplace = require('buffer-replace');
const crypto = require('crypto');
const Jimp = require('jimp');
const listenPort = 25565;
const mcHost = "localhost";
const mcPort = 25569;
const serverName = "ayunMultiPort Server";
const serverMotd = ["line1", "line2"];
const serverMaxPlayers = 20;
const serverOnlinePlayers = 4;
const serverPlayers = ["Welcome to my", "ayunMultiPort-powered", "Eaglercraft server!"];
const serverIcon = "icon.png"; // set to null for no icon. MUST be 64x64. can be a url, if you want...
const httpPort = 8080;
const timeout = 10000;
const changeProtocol = true;
const removeSkin = true;
const prefix = "www";
let iconBuff = null;
if(serverIcon!=null){
Jimp.read(serverIcon, function (err, image) {
if(!err)iconBuff=Buffer.from(image.bitmap.data);
});
}
let files = [];
let cache = {};
function throughDirectory(directory) {
fs.readdirSync(directory).forEach(file => {
const absolute = path.join(directory, file);
if (fs.statSync(absolute).isDirectory()) return throughDirectory(absolute);
else return files.push(absolute.toString().slice(prefix.length+1).replace(/\\/g,"/"));
});
}
throughDirectory(prefix);
const httpsrv = require("http").createServer((req,res)=>{
let url = req.url;
if (url.includes("?")) url = url.slice(0, url.indexOf("?"));
if(url.startsWith("/"))url=url.slice(1);
if(url=="")url = "index.html";
if(files.includes(url)){
res.writeHead(200,{"Content-Type":mime.contentType(url)});
if(!(url in cache)){
cache[url]=fs.readFileSync(prefix+"/"+url);
}
res.end(cache[url]);
}else{
res.writeHead(404,{"Content-Type":"text/plain"});
res.end("404 Not Found");
}
});
const wss = new WebSocketServer({ server: httpsrv });
const motdBase = {data:{motd:serverMotd,cache:true,max:serverMaxPlayers,players:serverPlayers,icon:serverIcon!=null,online:serverOnlinePlayers},vers:"0.2.0",name:serverName,time:0,type:"motd",brand:"Eagtek",uuid:crypto.randomUUID(),cracked:true};
function getMotd(){
motdBase.time = Date.now();
return JSON.stringify(motdBase);
}
wss.on('connection', function(ws) {
ws.on('error', function(er) {});
let client = null;
makeWsMcClient(ws,c=>client=c);
let msgNum = 0;
ws.on('message', function(data) {
if(msgNum==0){
msgNum++;
if(data.toString()=="Accept: MOTD"){
ws.send(getMotd());
if(iconBuff!=null)ws.send(iconBuff);
closeIt();
return;
}
if(changeProtocol)data=bufferReplace(data,Buffer.from("0245","hex"),Buffer.from("023d","hex"));
}else if(msgNum==1){
msgNum++;
if(removeSkin)return;//eaglercraft skin
}
writeData(data);
});
ws.on('close', function(){
closeIt();
});
async function writeData(chunk){
if(await waitForIt())client.write(chunk);
}
async function closeIt(){
if(await waitForIt())client.end();
}
async function waitForIt(){
let i=Date.now();
while(client==null&&(Date.now()-i<timeout/10)){
await new Promise(a=>setTimeout(a,10));
}
if(client==null){
if(ws.readyState==WebSocket.OPEN)ws.close();
return false;
}
return true;
}
});
httpsrv.listen(httpPort);
const server = new Net.Server();
server.listen(listenPort, function() {
//
});
server.on('connection', function(socket) {
let client = null;
let determinedClient = false;
socket.on('data', function(chunk) {
if(!determinedClient){
let req = chunk.toString();
if(req.startsWith("GET ")||req.startsWith("HEAD ")||req.startsWith("POST ")||req.startsWith("PUT ")||req.startsWith("DELETE ")||req.startsWith("CONNECT ")||req.startsWith("OPTIONS ")||req.startsWith("TRACE ")||req.startsWith("PATCH ")){
makeClient("localhost",httpPort,socket,c=>client=c);
}else{
makeClient(mcHost,mcPort,socket,c=>client=c);
}
determinedClient=true;
}
writeData(chunk);
});
socket.on('end', function() {
if(client!=null)client.end();
});
socket.on('error', function(err) {
//console.log(`Server Error: ${err}`);
});
async function writeData(chunk){
if(await waitForIt())client.write(chunk);
}
async function closeIt(){
if(await waitForIt())client.end();
}
async function waitForIt(){
let i=Date.now();
while(client==null&&(Date.now()-i<timeout/10)){
await new Promise(a=>setTimeout(a,10));
}
if(client==null){
socket.end();
return false;
}
return true;
}
});
function makeClient(host,port,socket,cb){
const client = new Net.Socket();
client.connect({ port: port, host: host }, function() {
cb(client);
});
client.on('end', function() {
socket.end();
});
client.on('data', function(chunk) {
socket.write(chunk);
});
client.on('error', function(err) {
//console.log(`Client Error: ${err}`);
});
}
function makeWsMcClient(ws,cb){
const client = new Net.Socket();
client.connect({ port: mcPort, host: mcHost }, function() {
cb(client);
});
client.on('end', function() {
if(ws.readyState==WebSocket.OPEN)ws.close();
});
client.on('data', function(chunk) {
if(ws.readyState==WebSocket.OPEN)ws.send(chunk);
});
client.on('error', function(err) {
//console.log(`Client Error: ${err}`);
});
}
+141
View File
@@ -0,0 +1,141 @@
const Net = require('net');
const { WebSocketServer, WebSocket } = require('ws');
const fs = require("fs");
const path = require("path");
const mime = require("mime-types");
const bufferReplace = require('buffer-replace');
const crypto = require('crypto');
const Jimp = require('jimp');
const listenPort = 25565;
const mcHost = "localhost";
const mcPort = 25569;
const serverName = "ayunMultiPort Server";
const serverMotd = ["line1", "line2"];
const serverMaxPlayers = 20;
const serverOnlinePlayers = 4;
const serverPlayers = ["Welcome to my", "ayunMultiPort-powered", "Eaglercraft server!"];
const serverIcon = "icon.png"; // set to null for no icon. MUST be 64x64. can be a url, if you want...
const timeout = 10000;
const changeProtocol = true;
const removeSkin = true;
const prefix = "www";
let iconBuff = null;
if(serverIcon!=null){
Jimp.read(serverIcon, function (err, image) {
if(!err)iconBuff=Buffer.from(image.bitmap.data);
});
}
let files = [];
let cache = {};
function throughDirectory(directory) {
fs.readdirSync(directory).forEach(file => {
const absolute = path.join(directory, file);
if (fs.statSync(absolute).isDirectory()) return throughDirectory(absolute);
else return files.push(absolute.toString().slice(prefix.length+1).replace(/\\/g,"/"));
});
}
throughDirectory(prefix);
const httpsrv = require("http").createServer((req,res)=>{
let url = req.url;
if (url.includes("?")) url = url.slice(0, url.indexOf("?"));
if(url.startsWith("/"))url=url.slice(1);
if(url=="")url = "index.html";
if(files.includes(url)){
res.writeHead(200,{"Content-Type":mime.contentType(url)});
if(!(url in cache)){
cache[url]=fs.readFileSync(prefix+"/"+url);
}
res.end(cache[url]);
}else{
res.writeHead(404,{"Content-Type":"text/plain"});
res.end("404 Not Found");
}
});
const wss = new WebSocketServer({ server: httpsrv });
const motdBase = {data:{motd:serverMotd,cache:true,max:serverMaxPlayers,players:serverPlayers,icon:serverIcon!=null,online:serverOnlinePlayers},vers:"0.2.0",name:serverName,time:0,type:"motd",brand:"Eagtek",uuid:crypto.randomUUID(),cracked:true};
function getMotd(){
motdBase.time = Date.now();
return JSON.stringify(motdBase);
}
wss.on('connection', function(ws) {
ws.on('error', function(er) {});
let client = null;
makeWsMcClient(ws,c=>client=c);
let msgNum = 0;
ws.on('message', function(data) {
if(msgNum==0){
msgNum++;
if(data.toString()=="Accept: MOTD"){
ws.send(getMotd());
if(iconBuff!=null)ws.send(iconBuff);
closeIt();
return;
}
if(changeProtocol)data=bufferReplace(data,Buffer.from("0245","hex"),Buffer.from("023d","hex"));
}else if(msgNum==1){
msgNum++;
if(removeSkin)return;//eaglercraft skin
}
writeData(data);
});
ws.on('close', function(){
closeIt();
});
async function writeData(chunk){
if(await waitForIt())client.write(chunk);
}
async function closeIt(){
if(await waitForIt())client.end();
}
async function waitForIt(){
let i=Date.now();
while(client==null&&(Date.now()-i<timeout/10)){
await new Promise(a=>setTimeout(a,10));
}
if(client==null){
if(ws.readyState==WebSocket.OPEN)ws.close();
return false;
}
return true;
}
});
httpsrv.listen(listenPort);
function makeWsMcClient(ws,cb){
const client = new Net.Socket();
client.connect({ port: mcPort, host: mcHost }, function() {
cb(client);
});
client.on('end', function() {
if(ws.readyState==WebSocket.OPEN)ws.close();
});
client.on('data', function(chunk) {
if(ws.readyState==WebSocket.OPEN)ws.send(chunk);
});
client.on('error', function(err) {
//console.log(`Client Error: ${err}`);
});
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

+8
View File
@@ -0,0 +1,8 @@
{
"dependencies": {
"buffer-replace": "^1.0.0",
"jimp": "^0.16.1",
"mime-types": "^2.1.35",
"ws": "^8.5.0"
}
}
+3
View File
@@ -0,0 +1,3 @@
@echo off
node app.js
pause
+3
View File
@@ -0,0 +1,3 @@
@echo off
node eagler.js
pause
+3
View File
@@ -0,0 +1,3 @@
@echo off
node eagler_only.js
pause
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+40
View File
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>eagler</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Eaglercraft is real Minecraft 1.5.2 that you can play in any regular web browser. That includes school chromebooks, it works on all chromebooks. You can join real Minecraft 1.5.2 servers with it through a custom proxy based on Bungeecord." />
<meta name="keywords" content="minecraft, applet, chromebook, lax1dude, games, eaglercraft, eagler" />
<meta name="author" content="LAX1DUDE" />
<meta property="og:title" content="Eaglercraft" />
<meta property="og:locale" content="en-US" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://media.discordapp.net/attachments/378764518081429506/932053915061587978/thumbnail2.png" />
<meta property="og:description" content="Eaglercraft is real Minecraft 1.5.2 that you can play in any regular web browser. That includes school chromebooks, it works on all chromebooks. You can join real Minecraft 1.5.2 servers with it through a custom proxy based on Bungeecord." />
<!-- Change this: <meta property="og:url" content="https://g.eags.us/eaglercraft/" /> -->
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript">
if(document.location.href.startsWith("file:")) {
alert("You're not supposed to 'open' this file in your browser. Please upload this folder to your HTTP(s) server and access it via the internet. This is not a bug, please read the documentation");
}else {
window.addEventListener("load", function(){
window.minecraftOpts = [
"game_frame","assets.epk",
"CgAACQAHc2VydmVycwoAAAABCAACaXAAIHdzKHMpOi8vIChhZGRyZXNzIGhlcmUpOihwb3J0KSAvCAAEbmFtZQAIdGVtcGxhdGUBAAtoaWRlQWRkcmVzcwEIAApmb3JjZWRNT1REABl0aGlzIGlzIG5vdCBhIHJlYWwgc2VydmVyAAA="
];
(function(){
var q = window.location.search;
if(typeof q === 'string' && q.startsWith("?")) {
q = new URLSearchParams(q);
var s = q.get("server");
if(s) window.minecraftOpts.push(s);
}
})();
main();
});}
</script>
</head>
<body style="margin:0px;width:100vw;height:100vh;" id="game_frame">
</body>
</html>