Skip to content

Commit

Permalink
Update SubData
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Sep 24, 2019
1 parent 17b63c1 commit 27806b9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 17 deletions.
6 changes: 3 additions & 3 deletions SubServers.Bungee/pom.xml
Expand Up @@ -30,20 +30,20 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Server</artifactId>
<version>19w26a</version>
<version>19w39a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
Expand Up @@ -10,8 +10,12 @@
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* SubServers Configuration Updater
Expand Down Expand Up @@ -68,14 +72,50 @@ public static void updateConfig(File file) throws IOException {

existing = updated.clone();
i++;
} if (was.compareTo(new Version("19w35b")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).contains("Allowed-Connections"))
updated.getMap("Settings").getMap("SubData").safeSet("Whitelist", existing.getMap("Settings").getMap("SubData").getRawStringList("Allowed-Connections"));
} if (was.compareTo(new Version("19w35c")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).contains("SubData")) {
LinkedList<String> whitelist = new LinkedList<>();
LinkedList<String> newWhitelist = new LinkedList<>();
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Allowed-Connections", Collections.emptyList()));
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Whitelist", Collections.emptyList()));

boolean warnPls = false;
for (String address : whitelist) {
Matcher regAddress = Pattern.compile("^(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)$").matcher(address);
if (regAddress.find()) {
StringBuilder newAddress = new StringBuilder();
int subnet = -1;
boolean warn = false;
for (int o = 1; o <= 4; o++) {
if (o > 1) newAddress.append('.');
if (subnet == -1) {
if (!regAddress.group(o).equals("%")) {
newAddress.append(regAddress.group(o));
} else {
subnet = 8 * (o - 1);
newAddress.append('0');
}
} else {
if (!regAddress.group(o).equals("%")) warn = warnPls = true;
newAddress.append('0');
}
}
if (subnet < 0) subnet = 32;
if (warn) Logger.get("SubServers").warning("Updating non-standard mask: " + address);
newAddress.append('/');
newAddress.append(subnet);
newWhitelist.add(newAddress.toString());
}
}
updated.getMap("Settings").getMap("SubData").set("Whitelist", newWhitelist);
if (warnPls) Logger.get("SubServers").warning("Non-standard masks have been updated. This may expose SubData to unintended networks!");
}

existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// existing = updated.clone();
// i++
//}

Expand Down Expand Up @@ -250,7 +290,7 @@ public static void updateLang(File file) throws IOException {
lang.set("Bungee.Feature.Smart-Fallback.Result", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Feature.Smart-Fallback.Result", "&6You are now on $str$."));
lang.set("Bungee.Ping.Offline", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Ping.Offline", "&6&l[&e&lWarning&6&l] &7Backend server(s) are not running"));
lang.set("Bungee.Server.Current", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Current", "&6You are currently connected to $str$"));
lang.set("Bungee.Server.Available", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Available", "&6You may connect to the following servers at this tRime:"));
lang.set("Bungee.Server.Available", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Available", "&6You may connect to the following servers at this time:"));
lang.set("Bungee.Server.List", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.List", "&6$str$"));
lang.set("Bungee.Server.Hover", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Hover", "$int$ player(s)\n&oClick to connect to the server"));
lang.set("Bungee.Server.Divider", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Divider", "&6, "));
Expand Down
4 changes: 2 additions & 2 deletions SubServers.Client/Bukkit/pom.xml
Expand Up @@ -48,14 +48,14 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w26a</version>
<version>19w39a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions SubServers.Client/Sponge/pom.xml
Expand Up @@ -30,14 +30,14 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w26a</version>
<version>19w39a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
Expand Up @@ -132,7 +132,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
}
break;
case KeyEvent.VK_F:
if (kpressed[KeyEvent.VK_SHIFT] == Boolean.TRUE) {
if ((event.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK && kpressed[KeyEvent.VK_SHIFT] == Boolean.TRUE) {
boolean open = false;
if (ifocus) {
findT.setText(input.getSelectedText());
Expand Down
4 changes: 2 additions & 2 deletions SubServers.Host/pom.xml
Expand Up @@ -20,14 +20,14 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w26a</version>
<version>19w39a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions SubServers.Sync/pom.xml
Expand Up @@ -30,20 +30,20 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w28a</version>
<version>19w39b</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w26a</version>
<version>19w39a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Expand Down

0 comments on commit 27806b9

Please sign in to comment.