From f61aa6068bf1ab321d207ab4a6c7f949959aa058 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 8 Apr 2018 12:33:13 -0400 Subject: [PATCH] Added additional server commands, fixed a crash --- core/assets/version.properties | 2 +- .../io/anuke/mindustry/core/NetServer.java | 2 ++ .../anuke/mindustry/net/Administration.java | 12 +++++++ .../anuke/mindustry/server/ServerControl.java | 35 +++++++++++++++++-- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index c0b83ff852..1f97dce33e 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -4,4 +4,4 @@ version=release androidBuildCode=503 name=Mindustry code=3.5 -build=custom build +build=37 diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 77c5a8b650..e431288aab 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -73,6 +73,8 @@ public class NetServer extends Module{ return; } + Log.info("Recieved connect packet for player '{0}' / UUID {1} / IP {2}", packet.name, uuid, trace.ip); + String ip = Net.getConnection(id).address; admins.updatePlayerJoined(uuid, ip, packet.name); diff --git a/core/src/io/anuke/mindustry/net/Administration.java b/core/src/io/anuke/mindustry/net/Administration.java index 59aa64fb75..00355d78f9 100644 --- a/core/src/io/anuke/mindustry/net/Administration.java +++ b/core/src/io/anuke/mindustry/net/Administration.java @@ -184,6 +184,18 @@ public class Administration { return result; } + public Array findByIPs(String ip){ + Array result = new Array<>(); + + for(PlayerInfo info : playerInfo.values()){ + if(info.ips.contains(ip, false)){ + result.add(info); + } + } + + return result; + } + public PlayerInfo getInfo(String id){ return getCreateInfo(id); } diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index aec207eb5a..f971330d4a 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -343,7 +343,9 @@ public class ServerControl extends Module { info("Banned player by IP: {0}.", arg[0]); for(Player player : playerGroup.all()){ - if(Net.getConnection(player.clientid).address.equals(arg[0])){ + if(Net.getConnection(player.clientid) != null && + Net.getConnection(player.clientid).address != null && + Net.getConnection(player.clientid).address.equals(arg[0])){ netServer.kick(player.clientid, KickReason.banned); break; } @@ -537,8 +539,8 @@ public class ServerControl extends Module { } }); - handler.register("find", " [check-all-names]", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> { - boolean checkAll = arg.length == 2 && arg[1].equals("true"); + handler.register("find", "", "Find player info(s) by name. Can optionally check for all names a player has had.", arg -> { + boolean checkAll = true; Array infos = netServer.admins.findByName(arg[0], checkAll); @@ -564,6 +566,33 @@ public class ServerControl extends Module { } }); + handler.register("findip", "", "Find player info(s) by IP.", arg -> { + + Array infos = netServer.admins.findByIPs(arg[0]); + + if(infos.size == 1) { + PlayerInfo info = infos.peek(); + Log.info("&lcTrace info for player '{0}' / UUID {1}:", info.lastName, info.id); + Log.info(" &lyall names used: {0}", info.names); + Log.info(" &lyIP: {0}", info.lastIP); + Log.info(" &lyall IPs used: {0}", info.ips); + Log.info(" &lytimes joined: {0}", info.timesJoined); + Log.info(" &lytimes kicked: {0}", info.timesKicked); + Log.info(""); + Log.info(" &lytotal blocks broken: {0}", info.totalBlocksBroken); + Log.info(" &lytotal blocks placed: {0}", info.totalBlockPlaced); + }else if(infos.size > 1){ + Log.info("&lcMultiple people have been found with that IP:"); + for(PlayerInfo info : infos){ + Log.info(" &ly{0}", info.id); + } + Log.info("&lcUse the info command to examine each person individually."); + }else{ + info("Nobody with that name could be found."); + } + }); + + handler.register("info", "", "Get global info for a player's UUID.", arg -> { PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);