@@ -90,7 +90,12 @@ private static BungeeCordHandshake decodeAndVerify0(String handshake, TokenStore
9090 readIndex = 1 ;
9191 }
9292 String socketAddressHostname = split [readIndex ++];
93- UUID uniqueId = UUID .fromString (split [readIndex ++].replaceFirst ("(\\ w{8})(\\ w{4})(\\ w{4})(\\ w{4})(\\ w{12})" , "$1-$2-$3-$4-$5" ));
93+ UUID uniqueId ;
94+ try {
95+ uniqueId = UUID .fromString (split [readIndex ++].replaceFirst ("(\\ w{8})(\\ w{4})(\\ w{4})(\\ w{4})(\\ w{12})" , "$1-$2-$3-$4-$5" ));
96+ } catch (NumberFormatException e ) {
97+ return new Fail (Fail .Reason .INVALID_UNIQUE_ID , encodeBase64 (handshake ));
98+ }
9499
95100 String connectionDescription = uniqueId + " @ " + encodeBase64 (socketAddressHostname );
96101
@@ -108,7 +113,7 @@ private static BungeeCordHandshake decodeAndVerify0(String handshake, TokenStore
108113 JsonObject property = iterator .next ();
109114 if (property .get (PROPERTY_NAME_KEY ).getAsString ().equals (BUNGEEGUARD_TOKEN_NAME )) {
110115 if (bungeeGuardToken != null ) {
111- return new Fail (Fail .Reason .INCORRECT_TOKEN , connectionDescription + " - more than one token" );
116+ return new Fail (Fail .Reason .DUPLICATED_TOKEN , connectionDescription );
112117 }
113118
114119 bungeeGuardToken = property .get (PROPERTY_VALUE_KEY ).getAsString ();
@@ -195,8 +200,7 @@ public String describeConnection() {
195200 }
196201
197202 public enum Reason {
198- INVALID_HANDSHAKE , NO_TOKEN , INCORRECT_TOKEN
203+ INVALID_HANDSHAKE , INVALID_UNIQUE_ID , NO_TOKEN , DUPLICATED_TOKEN , INCORRECT_TOKEN
199204 }
200205 }
201-
202206}
0 commit comments