mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-02-03 05:21:50 +01:00
Update upstream (#41)
This commit is contained in:
parent
68fa9d3c9f
commit
2a9bac3c50
@ -1 +1 @@
|
||||
Subproject commit a8c529eca574efc0d98f3f9a480e804fef334f02
|
||||
Subproject commit 1250088f98fc59d28736932fac88586594329ec2
|
@ -1,4 +1,4 @@
|
||||
From 19eb33404cbd686f8361f691520885331852481d Mon Sep 17 00:00:00 2001
|
||||
From 85d4b2dd2289a9c7abfe027d9cc31d0338c3ad4f Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@techcable.net>
|
||||
Date: Thu, 19 May 2016 10:55:20 -0700
|
||||
Subject: [PATCH] Configurable Waterfall Metrics
|
||||
@ -17,46 +17,143 @@ index b30541b..293ec4e 100644
|
||||
+ */
|
||||
+ boolean isMetrics();
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/Metrics.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
|
||||
similarity index 96%
|
||||
rename from proxy/src/main/java/net/md_5/bungee/Metrics.java
|
||||
rename to proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
|
||||
index 9523987..ae5a2a9 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
|
||||
new file mode 100644
|
||||
index 0000000..ae5a2a9
|
||||
--- /dev/null
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/Metrics.java
|
||||
@@ -1,4 +1,4 @@
|
||||
-package net.md_5.bungee;
|
||||
@@ -0,0 +1,131 @@
|
||||
+package io.github.waterfallmc.waterfall;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -9,6 +9,8 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.TimerTask;
|
||||
+
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStreamReader;
|
||||
+import java.io.OutputStreamWriter;
|
||||
+import java.io.UnsupportedEncodingException;
|
||||
+import java.net.URL;
|
||||
+import java.net.URLConnection;
|
||||
+import java.net.URLEncoder;
|
||||
+import java.util.TimerTask;
|
||||
+
|
||||
+import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class Metrics extends TimerTask
|
||||
@@ -29,7 +31,7 @@ public class Metrics extends TimerTask
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
- final static int PING_INTERVAL = 10;
|
||||
+import net.md_5.bungee.api.ProxyServer;
|
||||
+
|
||||
+public class Metrics extends TimerTask
|
||||
+{
|
||||
+
|
||||
+ /**
|
||||
+ * The current revision number
|
||||
+ */
|
||||
+ private final static int REVISION = 5;
|
||||
+ /**
|
||||
+ * The base url of the metrics domain
|
||||
+ */
|
||||
+ private static final String BASE_URL = "http://mcstats.org";
|
||||
+ /**
|
||||
+ * The url used to report a server's status
|
||||
+ */
|
||||
+ private static final String REPORT_URL = "/report/%s";
|
||||
+ /**
|
||||
+ * Interval of time to ping (in minutes)
|
||||
+ */
|
||||
+ public final static int PING_INTERVAL = 10;
|
||||
boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
@@ -71,7 +73,7 @@ public class Metrics extends TimerTask
|
||||
}
|
||||
|
||||
// Create the url
|
||||
- URL url = new URL( BASE_URL + String.format( REPORT_URL, encode( "BungeeCord" ) ) );
|
||||
+ boolean firstPost = true;
|
||||
+
|
||||
+ @Override
|
||||
+ public void run()
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ // We use the inverse of firstPost because if it is the first time we are posting,
|
||||
+ // it is not a interval ping, so it evaluates to FALSE
|
||||
+ // Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
+ postPlugin( !firstPost );
|
||||
+
|
||||
+ // After the first post we set firstPost to false
|
||||
+ // Each post thereafter will be a ping
|
||||
+ firstPost = false;
|
||||
+ } catch ( IOException ex )
|
||||
+ {
|
||||
+ // ProxyServer.getInstance().getLogger().info( "[Metrics] " + ex.getMessage() );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Generic method that posts a plugin to the metrics website
|
||||
+ */
|
||||
+ private void postPlugin(boolean isPing) throws IOException
|
||||
+ {
|
||||
+ // Construct the post data
|
||||
+ final StringBuilder data = new StringBuilder();
|
||||
+ data.append( encode( "guid" ) ).append( '=' ).append( encode( BungeeCord.getInstance().config.getUuid() ) );
|
||||
+ encodeDataPair( data, "version", ProxyServer.getInstance().getVersion() );
|
||||
+ encodeDataPair( data, "server", "0" );
|
||||
+ encodeDataPair( data, "players", Integer.toString( ProxyServer.getInstance().getOnlineCount() ) );
|
||||
+ encodeDataPair( data, "revision", String.valueOf( REVISION ) );
|
||||
+
|
||||
+ // If we're pinging, append it
|
||||
+ if ( isPing )
|
||||
+ {
|
||||
+ encodeDataPair( data, "ping", "true" );
|
||||
+ }
|
||||
+
|
||||
+ // Create the url
|
||||
+ URL url = new URL( BASE_URL + String.format( REPORT_URL, encode( "Waterfall" ) ) );
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
+
|
||||
+ // Connect to the website
|
||||
+ URLConnection connection;
|
||||
+
|
||||
+ connection = url.openConnection();
|
||||
+
|
||||
+ connection.setDoOutput( true );
|
||||
+ final BufferedReader reader;
|
||||
+ final String response;
|
||||
+ try ( OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() ) )
|
||||
+ {
|
||||
+ writer.write( data.toString() );
|
||||
+ writer.flush();
|
||||
+ reader = new BufferedReader( new InputStreamReader( connection.getInputStream() ) );
|
||||
+ response = reader.readLine();
|
||||
+ }
|
||||
+ reader.close();
|
||||
+
|
||||
+ if ( response == null || response.startsWith( "ERR" ) )
|
||||
+ {
|
||||
+ throw new IOException( response ); //Throw the exception
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * <p>
|
||||
+ * Encode a key/value data pair to be used in a HTTP post request. This
|
||||
+ * INCLUDES a & so the first key/value pair MUST be included manually,
|
||||
+ * e.g:</p>
|
||||
+ * <code>
|
||||
+ * StringBuffer data = new StringBuffer();
|
||||
+ * data.append(encode("guid")).append('=').append(encode(guid));
|
||||
+ * encodeDataPair(data, "version", description.getVersion());
|
||||
+ * </code>
|
||||
+ *
|
||||
+ * @param buffer the StringBuilder to append the data pair onto
|
||||
+ * @param key the key value
|
||||
+ * @param value the value
|
||||
+ */
|
||||
+ private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException
|
||||
+ {
|
||||
+ buffer.append( '&' ).append( encode( key ) ).append( '=' ).append( encode( value ) );
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Encode text as UTF-8
|
||||
+ *
|
||||
+ * @param text the text to encode
|
||||
+ * @return the encoded text, as UTF-8
|
||||
+ */
|
||||
+ private static String encode(final String text) throws UnsupportedEncodingException
|
||||
+ {
|
||||
+ return URLEncoder.encode( text, "UTF-8" );
|
||||
+ }
|
||||
+}
|
||||
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 03160da..1fa3ecd 100644
|
||||
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
@ -108,6 +205,141 @@ index 3dceb6e..3578aa4 100644
|
||||
}
|
||||
|
||||
public void startListeners()
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/Metrics.java b/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
||||
deleted file mode 100644
|
||||
index 9523987..0000000
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/Metrics.java
|
||||
+++ /dev/null
|
||||
@@ -1,129 +0,0 @@
|
||||
-package net.md_5.bungee;
|
||||
-
|
||||
-import java.io.BufferedReader;
|
||||
-import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
-import java.io.OutputStreamWriter;
|
||||
-import java.io.UnsupportedEncodingException;
|
||||
-import java.net.URL;
|
||||
-import java.net.URLConnection;
|
||||
-import java.net.URLEncoder;
|
||||
-import java.util.TimerTask;
|
||||
-import net.md_5.bungee.api.ProxyServer;
|
||||
-
|
||||
-public class Metrics extends TimerTask
|
||||
-{
|
||||
-
|
||||
- /**
|
||||
- * The current revision number
|
||||
- */
|
||||
- private final static int REVISION = 5;
|
||||
- /**
|
||||
- * The base url of the metrics domain
|
||||
- */
|
||||
- private static final String BASE_URL = "http://mcstats.org";
|
||||
- /**
|
||||
- * The url used to report a server's status
|
||||
- */
|
||||
- private static final String REPORT_URL = "/report/%s";
|
||||
- /**
|
||||
- * Interval of time to ping (in minutes)
|
||||
- */
|
||||
- final static int PING_INTERVAL = 10;
|
||||
- boolean firstPost = true;
|
||||
-
|
||||
- @Override
|
||||
- public void run()
|
||||
- {
|
||||
- try
|
||||
- {
|
||||
- // We use the inverse of firstPost because if it is the first time we are posting,
|
||||
- // it is not a interval ping, so it evaluates to FALSE
|
||||
- // Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
- postPlugin( !firstPost );
|
||||
-
|
||||
- // After the first post we set firstPost to false
|
||||
- // Each post thereafter will be a ping
|
||||
- firstPost = false;
|
||||
- } catch ( IOException ex )
|
||||
- {
|
||||
- // ProxyServer.getInstance().getLogger().info( "[Metrics] " + ex.getMessage() );
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * Generic method that posts a plugin to the metrics website
|
||||
- */
|
||||
- private void postPlugin(boolean isPing) throws IOException
|
||||
- {
|
||||
- // Construct the post data
|
||||
- final StringBuilder data = new StringBuilder();
|
||||
- data.append( encode( "guid" ) ).append( '=' ).append( encode( BungeeCord.getInstance().config.getUuid() ) );
|
||||
- encodeDataPair( data, "version", ProxyServer.getInstance().getVersion() );
|
||||
- encodeDataPair( data, "server", "0" );
|
||||
- encodeDataPair( data, "players", Integer.toString( ProxyServer.getInstance().getOnlineCount() ) );
|
||||
- encodeDataPair( data, "revision", String.valueOf( REVISION ) );
|
||||
-
|
||||
- // If we're pinging, append it
|
||||
- if ( isPing )
|
||||
- {
|
||||
- encodeDataPair( data, "ping", "true" );
|
||||
- }
|
||||
-
|
||||
- // Create the url
|
||||
- URL url = new URL( BASE_URL + String.format( REPORT_URL, encode( "BungeeCord" ) ) );
|
||||
-
|
||||
- // Connect to the website
|
||||
- URLConnection connection;
|
||||
-
|
||||
- connection = url.openConnection();
|
||||
-
|
||||
- connection.setDoOutput( true );
|
||||
- final BufferedReader reader;
|
||||
- final String response;
|
||||
- try ( OutputStreamWriter writer = new OutputStreamWriter( connection.getOutputStream() ) )
|
||||
- {
|
||||
- writer.write( data.toString() );
|
||||
- writer.flush();
|
||||
- reader = new BufferedReader( new InputStreamReader( connection.getInputStream() ) );
|
||||
- response = reader.readLine();
|
||||
- }
|
||||
- reader.close();
|
||||
-
|
||||
- if ( response == null || response.startsWith( "ERR" ) )
|
||||
- {
|
||||
- throw new IOException( response ); //Throw the exception
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * <p>
|
||||
- * Encode a key/value data pair to be used in a HTTP post request. This
|
||||
- * INCLUDES a & so the first key/value pair MUST be included manually,
|
||||
- * e.g:</p>
|
||||
- * <code>
|
||||
- * StringBuffer data = new StringBuffer();
|
||||
- * data.append(encode("guid")).append('=').append(encode(guid));
|
||||
- * encodeDataPair(data, "version", description.getVersion());
|
||||
- * </code>
|
||||
- *
|
||||
- * @param buffer the StringBuilder to append the data pair onto
|
||||
- * @param key the key value
|
||||
- * @param value the value
|
||||
- */
|
||||
- private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException
|
||||
- {
|
||||
- buffer.append( '&' ).append( encode( key ) ).append( '=' ).append( encode( value ) );
|
||||
- }
|
||||
-
|
||||
- /**
|
||||
- * Encode text as UTF-8
|
||||
- *
|
||||
- * @param text the text to encode
|
||||
- * @return the encoded text, as UTF-8
|
||||
- */
|
||||
- private static String encode(final String text) throws UnsupportedEncodingException
|
||||
- {
|
||||
- return URLEncoder.encode( text, "UTF-8" );
|
||||
- }
|
||||
-}
|
||||
--
|
||||
2.9.0
|
||||
2.8.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 19e1b3c08e0437f39228722b7d3ecd2da2199dca Mon Sep 17 00:00:00 2001
|
||||
From 8813a403a604019b8b96d5ca248e7c178b87a418 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.
|
||||
@ -85,7 +85,7 @@ index 2fcc7db..fa57f28 100644
|
||||
}
|
||||
}
|
||||
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 dab6ef2..c2348eb 100644
|
||||
index 3fe1d23..501d5ba 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
|
||||
@@ -277,19 +277,22 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@ -112,7 +112,7 @@ index dab6ef2..c2348eb 100644
|
||||
thisState = State.USERNAME;
|
||||
ch.setProtocol( Protocol.LOGIN );
|
||||
|
||||
@@ -609,7 +612,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -615,7 +618,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@ -134,5 +134,5 @@ index 28791a6..a96e793 100644
|
||||
}
|
||||
}
|
||||
--
|
||||
2.8.3
|
||||
2.8.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From d473177e5c6407f0f0c362bad49da0fbc7a45f19 Mon Sep 17 00:00:00 2001
|
||||
From 5bb1ba3fe06286ebef3e708cf720ee9cc84fcfb4 Mon Sep 17 00:00:00 2001
|
||||
From: kamcio96 <k.nadworski@icloud.com>
|
||||
Date: Mon, 14 Mar 2016 15:59:52 -0700
|
||||
Subject: [PATCH] Improve connection closing, fixing the kick delay.
|
||||
@ -49,7 +49,7 @@ index c88ab49..9a13f5c 100644
|
||||
if ( server != null )
|
||||
{
|
||||
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 d841090..8c19974 100644
|
||||
index d3635cd..378231c 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
|
||||
@@ -8,6 +8,7 @@ import java.net.URLEncoder;
|
||||
@ -105,7 +105,7 @@ index d841090..8c19974 100644
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -535,27 +532,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -541,27 +538,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@Override
|
||||
public void disconnect(final BaseComponent... reason)
|
||||
{
|
||||
@ -223,5 +223,5 @@ index 06d19c3..76bdff2 100644
|
||||
{
|
||||
Preconditions.checkState( ch.eventLoop().inEventLoop(), "cannot add handler outside of event loop" );
|
||||
--
|
||||
2.8.3
|
||||
2.8.2
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 96bf7a93e9168180264c32a1b046794707ca7d26 Mon Sep 17 00:00:00 2001
|
||||
From fe96d6163b2fcbceb6ea28617a8a871983232136 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@techcable.net>
|
||||
Date: Mon, 6 Jun 2016 13:36:10 -0600
|
||||
Subject: [PATCH] Don't send KICK packets while in HANDSHAKE state
|
||||
@ -6,10 +6,10 @@ Subject: [PATCH] Don't send KICK packets while in HANDSHAKE state
|
||||
Use a switch statement for checking the state (best practice when you have lots of cases)
|
||||
|
||||
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 8c19974..8bafc6b 100644
|
||||
index 378231c..132b73d 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
|
||||
@@ -534,10 +534,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -540,10 +540,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
{
|
||||
if ( !ch.isClosed() && disconnecting.compareAndSet(false, true) )
|
||||
{
|
||||
@ -30,5 +30,5 @@ index 8c19974..8bafc6b 100644
|
||||
}
|
||||
}
|
||||
--
|
||||
2.8.3
|
||||
2.8.2
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user