Archive eaglerproxy (server, 1.8.8, clean)
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export const config = {
|
||||
bindInternalServerPort: 25569,
|
||||
bindInternalServerIp: "127.0.0.1",
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
import metadata from "./metadata.json" assert { type: "json" };
|
||||
import { createServer } from "minecraft-protocol";
|
||||
import { config } from "./config.js";
|
||||
const PluginManager = PLUGIN_MANAGER;
|
||||
const Logger = PluginManager.Logger;
|
||||
const Enums = PluginManager.Enums;
|
||||
const Chat = PluginManager.Chat;
|
||||
const Constants = PluginManager.Constants;
|
||||
const Motd = PluginManager.Motd;
|
||||
const Player = PluginManager.Player;
|
||||
const MineProtocol = PluginManager.MineProtocol;
|
||||
const EaglerSkins = PluginManager.EaglerSkins;
|
||||
const Util = PluginManager.Util;
|
||||
const logger = new Logger("AutoKicker");
|
||||
logger.info(`Starting ${metadata.name} v${metadata.version}...`);
|
||||
logger.info(`(internal server port: ${config.bindInternalServerPort}, internal server IP: ${config.bindInternalServerPort})`);
|
||||
logger.info("Starting internal server...");
|
||||
let server = createServer({
|
||||
host: config.bindInternalServerIp,
|
||||
port: config.bindInternalServerPort,
|
||||
motdMsg: `${Enums.ChatColor.GOLD}EaglerProxy as a Service`,
|
||||
"online-mode": false,
|
||||
version: "1.8.9",
|
||||
});
|
||||
server.on("login", (client) => {
|
||||
logger.info(`Client ${client.username} has connected to the dummy server.`);
|
||||
client.write("kick_disconnect", {
|
||||
reason: "NO",
|
||||
});
|
||||
});
|
||||
logger.info("Redirecting backend server IP... (this is required for the plugin to function)");
|
||||
CONFIG.adapter.server = {
|
||||
host: config.bindInternalServerIp,
|
||||
port: config.bindInternalServerPort,
|
||||
};
|
||||
CONFIG.adapter.motd = {
|
||||
l1: Enums.ChatColor.RED + "Server Under Maintenance",
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "AutoKick",
|
||||
"id": "autokick",
|
||||
"version": "1.2.0",
|
||||
"entry_point": "index.js",
|
||||
"load_after": [],
|
||||
"requirements": [],
|
||||
"incompatibilities": [
|
||||
{
|
||||
"id": "eagpaas",
|
||||
"version": "^0.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
const logger = new PLUGIN_MANAGER.Logger("ExamplePlugin");
|
||||
logger.info("Hi!");
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Example Plugin",
|
||||
"id": "examplePlugin",
|
||||
"version": "1.0.0",
|
||||
"entry_point": "index.js",
|
||||
"requirements": [],
|
||||
"incompatibilities": [],
|
||||
"load_after": []
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
const oldWs = globalThis.WebSocket;
|
||||
const route = "ws://localhost:8080"; // Replace with your proxy URL
|
||||
const transformUrl = (url) => {
|
||||
let { host: ip, port, protocol, searchParams } = new URL(url);
|
||||
port = port || 25565;
|
||||
let proto = null,
|
||||
token = null;
|
||||
if (protocol) {
|
||||
if (protocol === "vanilla+offline:") {
|
||||
proto = "&authType=OFFLINE";
|
||||
} else if (protocol === "vanilla+online:") {
|
||||
proto = "&authType=ONLINE";
|
||||
} else if (protocol === "vanilla+altening:") {
|
||||
proto = "&authType=THEALTENING";
|
||||
}
|
||||
}
|
||||
return `${route}/?ip=${ip}&port=${port}${proto || ""}`;
|
||||
};
|
||||
|
||||
class ShimmedWebSocket extends oldWs {
|
||||
constructor(url, ...args) {
|
||||
if (url.startsWith("ws://") || url.startsWith("wss://")) {
|
||||
const trimmedUrl = url.startsWith("wss://") ? url.substring(6) : url.substring(5);
|
||||
if (trimmedUrl.startsWith("vanilla://") || trimmedUrl.startsWith("vanilla+offline://") || trimmedUrl.startsWith("vanilla+online://") || trimmedUrl.startsWith("vanilla+altening://")) {
|
||||
const transformedUrl = transformUrl(trimmedUrl);
|
||||
console.log(`Using proxy for vanilla URL: ${transformedUrl}`);
|
||||
url = transformedUrl;
|
||||
}
|
||||
}
|
||||
super(url, args);
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.WebSocket = ShimmedWebSocket;
|
||||
Reference in New Issue
Block a user