Added /domain command to EaglerXBungee (1.0.2)

This commit is contained in:
LAX1DUDE 2023-01-03 22:51:38 -08:00
parent 2492001c19
commit 0f6f976d85
7 changed files with 65 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.auth.DefaultAuthSystem;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandConfirmCode;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandDomain;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandEaglerPurge;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandEaglerRegister;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command.CommandRatelimit;
@ -104,6 +105,7 @@ public class EaglerXBungee extends Plugin {
mgr.registerListener(this, new EaglerPacketEventListener(this));
mgr.registerCommand(this, new CommandRatelimit());
mgr.registerCommand(this, new CommandConfirmCode());
mgr.registerCommand(this, new CommandDomain());
EaglerAuthConfig authConf = conf.getAuthConfig();
if(authConf.isEnableAuthentication() && authConf.isUseBuiltInAuthentication()) {
if(!BungeeCord.getInstance().getConfig().isOnlineMode()) {

View File

@ -0,0 +1,55 @@
package net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.command;
import net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.server.EaglerInitialHandler;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
/**
* Copyright (c) 2023 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class CommandDomain extends Command {
public CommandDomain() {
super("domain", "eaglercraft.command.domain");
}
@Override
public void execute(CommandSender var1, String[] var2) {
if(var2.length != 1) {
var1.sendMessage(new TextComponent(ChatColor.RED + "How to use: " + ChatColor.WHITE + "/domain <player>"));
}else {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(var2[0]);
if(player == null) {
var1.sendMessage(new TextComponent(ChatColor.RED + "That user is not online"));
return;
}
PendingConnection conn = player.getPendingConnection();
if(!(conn instanceof EaglerInitialHandler)) {
var1.sendMessage(new TextComponent(ChatColor.RED + "That user is not using Eaglercraft"));
return;
}
String origin = ((EaglerInitialHandler)conn).origin;
if(origin != null) {
var1.sendMessage(new TextComponent(ChatColor.BLUE + "Domain of " + var2[0] + " is '" + origin + "'"));
}else {
var1.sendMessage(new TextComponent(ChatColor.RED + "That user's browser did not send an origin header"));
}
}
}
}

View File

@ -52,14 +52,17 @@ public class EaglerInitialHandler extends InitialHandler {
public final SimpleRateLimiter skinLookupRateLimiter;
public final SimpleRateLimiter skinUUIDLookupRateLimiter;
public final SimpleRateLimiter skinTextureDownloadRateLimiter;
public final String origin;
public EaglerInitialHandler(BungeeCord bungee, ListenerInfo listener, final ChannelWrapper ch,
int gameProtocolVersion, String username, UUID playerUUID, InetSocketAddress address, String host) {
int gameProtocolVersion, String username, UUID playerUUID, InetSocketAddress address, String host,
String origin) {
super(bungee, listener);
this.gameProtocolVersion = gameProtocolVersion;
this.username = username;
this.playerUUID = playerUUID;
this.eaglerAddress = address;
this.origin = origin;
this.skinLookupRateLimiter = new SimpleRateLimiter();
this.skinUUIDLookupRateLimiter = new SimpleRateLimiter();
this.skinTextureDownloadRateLimiter = new SimpleRateLimiter();

View File

@ -701,7 +701,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
ch.setRemoteAddress(baseAddress);
}
final EaglerInitialHandler initialHandler = new EaglerInitialHandler(bungee, conf, ch, gameProtocolVersion,
usernameStr, clientUUID, baseAddress, ctx.channel().attr(EaglerPipeline.HOST).get());
usernameStr, clientUUID, baseAddress, ctx.channel().attr(EaglerPipeline.HOST).get(),
ctx.channel().attr(EaglerPipeline.ORIGIN).get());
final Callback<LoginEvent> complete = (Callback<LoginEvent>) new Callback<LoginEvent>() {
public void done(final LoginEvent result, final Throwable error) {
if (result.isCancelled()) {

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee
main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee
version: 1.0.1
version: 1.0.2
description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks
author: lax1dude

View File

@ -1 +1 @@
1.0.1
1.0.2