Skip to content

Commit

Permalink
seecret.txt
Browse files Browse the repository at this point in the history
VanillaCord will no longer autofill your forwarding password into this file.

This also means you won't have to delete it when changing the password through replacing the jar.
  • Loading branch information
ME1312 committed May 31, 2021
1 parent c8feb9b commit ea6eb56
Showing 1 changed file with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,11 @@ public static void completeTransaction(Object networkManager, Object loginManage
mac.update(raw);
byte[] calculated = mac.doFinal();
if (!Arrays.equals(calculated, received)) {
StringBuilder s1 = new StringBuilder();
for (int i=0; i < calculated.length; i++) {
s1.append(Integer.toString((calculated[i] & 0xff) + 0x100, 16).substring(1));
}
StringBuilder s2 = new StringBuilder();
for (int i=0; i < received.length; i++) {
s2.append(Integer.toString((received[i] & 0xff) + 0x100, 16).substring(1));
}

throw QuietException.notify("Received invalid IP forwarding data: " + s1 + " != " + s2);
throw QuietException.notify("Received invalid IP forwarding data. Did you use the right forwarding secret?");
}
}

// Compare versioning information
int version = readVarInt(data); /*
if (version != 1) {
throw QuietException.notify("Received incompatible IP forwarding data")
} */
readVarInt(data); // we don't do anything with the protocol version at this time

// Retrieve IP forwarding data
NetworkManager.socket.set(networkManager, new InetSocketAddress(readString(data), ((InetSocketAddress) NetworkManager.socket.get(networkManager)).getPort()));
Expand Down Expand Up @@ -132,17 +119,20 @@ private static byte[] getSecret(String def) throws IOException {
Properties properties = new Properties();
try (FileInputStream reader = new FileInputStream(config)) {
properties.load(reader);
seecret = properties.getProperty("modern-forwarding-secret", def).getBytes(UTF_8);

String secret = properties.getProperty("modern-forwarding-secret");
if (secret == null || secret.length() == 0) secret = def;
seecret = secret.getBytes(UTF_8);
}
} else {
seecret = def.getBytes(UTF_8);
PrintWriter writer = new PrintWriter(config, UTF_8.name());
writer.println("# Hey, there. We know you already patched in a default secret key for VanillaCord to use,");
writer.println("# Hey, there. We know you already gave VanillaCord a default secret key to use,");
writer.println("# but if you ever need to change it, you can do so here without re-installing the patches.");
writer.println("# ");
writer.println("# This file is automatically generated by VanillaCord once a player attempts to join the server.");
writer.println();
writer.println("modern-forwarding-secret=" + def);
writer.println("modern-forwarding-secret=");
writer.close();
}
}
Expand Down

0 comments on commit ea6eb56

Please sign in to comment.