mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-10-29 22:59:54 +01:00
135 lines
5.8 KiB
Diff
135 lines
5.8 KiB
Diff
From 0d6d91e54aa7e1112a193107d52c1cf4de6e6214 Mon Sep 17 00:00:00 2001
|
|
From: Janmm14 <computerjanimaus@yahoo.de>
|
|
Date: Sat, 12 Dec 2015 23:43:30 +0100
|
|
Subject: [PATCH] Optional server list ping logging.
|
|
|
|
Add IPs to the log where user names are shown.
|
|
|
|
This avoids spamming the logs with connection notices.
|
|
Server list pings are only logged if the log_server_list_pings config.yml option is true, defaults to false
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
index 08d2a870..72f35bd6 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
@@ -84,6 +84,11 @@ public interface ProxyConfig
|
|
// Waterfall Options
|
|
//
|
|
|
|
+ /**
|
|
+ * Whether we log server list pings
|
|
+ */
|
|
+ boolean isLogServerListPing();
|
|
+
|
|
// Throttling options
|
|
|
|
/**
|
|
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
index 91743f01..a5db82b8 100644
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
@@ -7,6 +7,13 @@ import java.io.File;
|
|
|
|
public class WaterfallConfiguration extends Configuration {
|
|
|
|
+ /**
|
|
+ * Whether we log server list pings
|
|
+ * <p>
|
|
+ * Default is false (don't log)
|
|
+ */
|
|
+ private boolean logServerListPing = false;
|
|
+
|
|
/*
|
|
* Throttling options
|
|
* Helps prevent players from overloading the servers behind us
|
|
@@ -26,11 +33,17 @@ public class WaterfallConfiguration extends Configuration {
|
|
super.load();
|
|
YamlConfig config = new YamlConfig(new File("waterfall.yml"));
|
|
config.load(false); // Load, but no permissions
|
|
+ logServerListPing = config.getBoolean( "log_server_list_ping", logServerListPing );
|
|
// Throttling options
|
|
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
}
|
|
|
|
+ @Override
|
|
+ public boolean isLogServerListPing() {
|
|
+ return logServerListPing;
|
|
+ }
|
|
+
|
|
@Override
|
|
public int getTabThrottle() {
|
|
return tabThrottle;
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
index f7bace0e..e7869cfb 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -410,6 +410,6 @@ public class ServerConnector extends PacketHandler
|
|
@Override
|
|
public String toString()
|
|
{
|
|
- return "[" + user.getName() + "] <-> ServerConnector [" + target.getName() + "]";
|
|
+ return "[" + user.getName() + "|" + user.getAddress() + "] <-> ServerConnector [" + target.getName() + "]";
|
|
}
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index b54e7b9b..54be8954 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -567,6 +567,6 @@ public class DownstreamBridge extends PacketHandler
|
|
@Override
|
|
public String toString()
|
|
{
|
|
- return "[" + con.getName() + "] <-> DownstreamBridge <-> [" + server.getInfo().getName() + "]";
|
|
+ return "[" + con.getAddress() + "|" + con.getName() + "] <-> DownstreamBridge <-> [" + server.getInfo().getName() + "]";
|
|
}
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
index 13215254..4e1a4413 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
@@ -296,16 +296,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|
}
|
|
|
|
this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() );
|
|
- if ( bungee.getConfig().isLogPings() )
|
|
- {
|
|
- bungee.getLogger().log( Level.INFO, "{0} has connected", this );
|
|
- }
|
|
|
|
bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
|
|
|
switch ( handshake.getRequestedProtocol() )
|
|
{
|
|
case 1:
|
|
+ if (bungee.getConfig().isLogPings() || BungeeCord.getInstance().getConfig().isLogServerListPing()) {
|
|
+ bungee.getLogger().log( Level.INFO, "{0} is pinging", this );
|
|
+ }
|
|
// Ping
|
|
thisState = State.STATUS;
|
|
ch.setProtocol( Protocol.STATUS );
|
|
@@ -629,7 +628,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|
@Override
|
|
public String toString()
|
|
{
|
|
- return "[" + ( ( getName() != null ) ? getName() : getAddress() ) + "] <-> InitialHandler";
|
|
+ return "[" + getAddress() + ( getName() != null ? "|" + getName() : "" ) + "] <-> InitialHandler";
|
|
}
|
|
|
|
@Override
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
index 54ccaa49..4bb61f63 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
@@ -267,6 +267,6 @@ public class UpstreamBridge extends PacketHandler
|
|
@Override
|
|
public String toString()
|
|
{
|
|
- return "[" + con.getName() + "] -> UpstreamBridge";
|
|
+ return "[" + con.getAddress() + "|" + con.getName() + "] -> UpstreamBridge";
|
|
}
|
|
}
|
|
--
|
|
2.20.1
|
|
|