mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-12-01 14:44:11 +01:00
Make Log-Creator
a per-host option
This commit is contained in:
parent
eb70ebaeea
commit
4792e5f8b1
@ -1,5 +1,6 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host.External;
|
package net.ME1312.SubServers.Bungee.Host.External;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubRemoveServerEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubRemoveServerEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Host.Host;
|
import net.ME1312.SubServers.Bungee.Host.Host;
|
||||||
@ -32,7 +33,6 @@ public class ExternalHost extends Host implements ClientHandler {
|
|||||||
private InetAddress address;
|
private InetAddress address;
|
||||||
private SubCreator creator;
|
private SubCreator creator;
|
||||||
private String directory;
|
private String directory;
|
||||||
protected NamedContainer<Integer, Integer> range;
|
|
||||||
protected NamedContainer<Boolean, Client> client;
|
protected NamedContainer<Boolean, Client> client;
|
||||||
private LinkedList<PacketOut> queue;
|
private LinkedList<PacketOut> queue;
|
||||||
private boolean clean;
|
private boolean clean;
|
||||||
@ -41,24 +41,24 @@ public class ExternalHost extends Host implements ClientHandler {
|
|||||||
/**
|
/**
|
||||||
* Creates an External Host
|
* Creates an External Host
|
||||||
*
|
*
|
||||||
* @param plugin Plugin
|
* @param plugin SubServers Internals
|
||||||
* @param name Name
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory
|
* @param enabled If your host is Enabled
|
||||||
* @param gitBash Git Bash Location
|
* @param address The address of your Host
|
||||||
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
*/
|
*/
|
||||||
public ExternalHost(SubPlugin plugin, String name, Boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) {
|
public ExternalHost(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
|
||||||
super(plugin, name, enabled, address, directory, range, gitBash);
|
super(plugin, name, enabled, ports, log, address, directory, gitBash);
|
||||||
if (Util.isNull(plugin, name, enabled, address, directory, gitBash)) throw new NullPointerException();
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.client = new NamedContainer<Boolean, Client>(false, null);
|
this.client = new NamedContainer<Boolean, Client>(false, null);
|
||||||
this.creator = new ExternalSubCreator(this, gitBash);
|
this.creator = new ExternalSubCreator(this, ports, log, gitBash);
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
this.range = range;
|
|
||||||
this.queue = new LinkedList<PacketOut>();
|
this.queue = new LinkedList<PacketOut>();
|
||||||
this.clean = false;
|
this.clean = false;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host.External;
|
package net.ME1312.SubServers.Bungee.Host.External;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Host.*;
|
import net.ME1312.SubServers.Bungee.Host.*;
|
||||||
import net.ME1312.SubServers.Bungee.Host.Internal.InternalSubCreator;
|
import net.ME1312.SubServers.Bungee.Host.Internal.InternalSubCreator;
|
||||||
import net.ME1312.SubServers.Bungee.Library.*;
|
import net.ME1312.SubServers.Bungee.Library.*;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLConfig;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLConfig;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||||
|
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidHostException;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExConfigureHost;
|
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExConfigureHost;
|
||||||
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCreateServer;
|
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCreateServer;
|
||||||
@ -23,6 +25,8 @@ import java.util.*;
|
|||||||
public class ExternalSubCreator extends SubCreator {
|
public class ExternalSubCreator extends SubCreator {
|
||||||
private HashMap<String, ServerTemplate> templates = new HashMap<String, ServerTemplate>();
|
private HashMap<String, ServerTemplate> templates = new HashMap<String, ServerTemplate>();
|
||||||
private ExternalHost host;
|
private ExternalHost host;
|
||||||
|
private Range<Integer> ports;
|
||||||
|
private Container<Boolean> log;
|
||||||
private String gitBash;
|
private String gitBash;
|
||||||
private TreeMap<String, NamedContainer<Integer, ExternalSubLogger>> thread;
|
private TreeMap<String, NamedContainer<Integer, ExternalSubLogger>> thread;
|
||||||
|
|
||||||
@ -30,11 +34,16 @@ public class ExternalSubCreator extends SubCreator {
|
|||||||
* Creates an External SubCreator
|
* Creates an External SubCreator
|
||||||
*
|
*
|
||||||
* @param host Host
|
* @param host Host
|
||||||
* @param gitBash Git Bash
|
* @param ports The range of ports to auto-select from
|
||||||
|
* @param log Whether SubCreator should log to console
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
*/
|
*/
|
||||||
public ExternalSubCreator(ExternalHost host, String gitBash) {
|
public ExternalSubCreator(ExternalHost host, Range<Integer> ports, boolean log, String gitBash) {
|
||||||
if (Util.isNull(host, gitBash)) throw new NullPointerException();
|
if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
|
||||||
|
if (Util.isNull(host, ports, log, gitBash)) throw new NullPointerException();
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
this.ports = ports;
|
||||||
|
this.log = new Container<Boolean>(log);
|
||||||
this.gitBash = gitBash;
|
this.gitBash = gitBash;
|
||||||
this.thread = new TreeMap<String, NamedContainer<Integer, ExternalSubLogger>>();
|
this.thread = new TreeMap<String, NamedContainer<Integer, ExternalSubLogger>>();
|
||||||
reload();
|
reload();
|
||||||
@ -66,14 +75,16 @@ public class ExternalSubCreator extends SubCreator {
|
|||||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||||
|
|
||||||
if (port == null) {
|
if (port == null) {
|
||||||
Container<Integer> i = new Container<Integer>(host.range.name() - 1);
|
Container<Integer> i = new Container<Integer>(ports.lowerEndpoint() - 1);
|
||||||
port = Util.getNew(getAllReservedAddresses(), () -> {
|
port = Util.getNew(getAllReservedAddresses(), () -> {
|
||||||
|
do {
|
||||||
i.set(i.get() + 1);
|
i.set(i.get() + 1);
|
||||||
if (i.get() > host.range.get()) throw new IllegalStateException("There are no more ports available between " + host.range.name() + " and " + host.range.get());
|
if (i.get() > ports.upperEndpoint()) throw new IllegalStateException("There are no more ports available in range: " + ports.toString());
|
||||||
|
} while (!ports.contains(i.get()));
|
||||||
return new InetSocketAddress(host.getAddress(), i.get());
|
return new InetSocketAddress(host.getAddress(), i.get());
|
||||||
}).getPort();
|
}).getPort();
|
||||||
}
|
}
|
||||||
ExternalSubLogger logger = new ExternalSubLogger(this, name + File.separator + "Creator", new Container<Boolean>(host.plugin.config.get().getSection("Settings").getBoolean("Log-Creator")), null);
|
ExternalSubLogger logger = new ExternalSubLogger(this, name + File.separator + "Creator", log, null);
|
||||||
thread.put(name.toLowerCase(), new NamedContainer<>(port, logger));
|
thread.put(name.toLowerCase(), new NamedContainer<>(port, logger));
|
||||||
|
|
||||||
final int fport = port;
|
final int fport = port;
|
||||||
@ -206,6 +217,17 @@ public class ExternalSubCreator extends SubCreator {
|
|||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Range getPortRange() {
|
||||||
|
return ports;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPortRange(Range<Integer> value) {
|
||||||
|
if (!value.hasLowerBound() || !value.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
|
||||||
|
ports = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBashDirectory() {
|
public String getBashDirectory() {
|
||||||
return gitBash;
|
return gitBash;
|
||||||
@ -227,6 +249,17 @@ public class ExternalSubCreator extends SubCreator {
|
|||||||
return this.thread.get(name.toLowerCase()).get();
|
return this.thread.get(name.toLowerCase()).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogging() {
|
||||||
|
return log.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogging(boolean value) {
|
||||||
|
if (Util.isNull(value)) throw new NullPointerException();
|
||||||
|
log.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getReservedNames() {
|
public List<String> getReservedNames() {
|
||||||
return new ArrayList<String>(thread.keySet());
|
return new ArrayList<String>(thread.keySet());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host;
|
package net.ME1312.SubServers.Bungee.Host;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLValue;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLValue;
|
||||||
@ -29,14 +30,17 @@ public abstract class Host implements ExtraDataHandler {
|
|||||||
*
|
*
|
||||||
* @param plugin SubServers Internals
|
* @param plugin SubServers Internals
|
||||||
* @param name The Name of your Host
|
* @param name The Name of your Host
|
||||||
|
* @param ports The range of ports to auto-select from
|
||||||
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param enabled If your host is Enabled
|
* @param enabled If your host is Enabled
|
||||||
* @param address The address of your Host
|
* @param address The address of your Host
|
||||||
* @param directory The runtime directory of your Host
|
* @param directory The runtime directory of your Host
|
||||||
* @param range The range of ports to auto-select from
|
|
||||||
* @param gitBash The Git Bash directory
|
* @param gitBash The Git Bash directory
|
||||||
*/
|
*/
|
||||||
public Host(SubPlugin plugin, String name, Boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) {
|
public Host(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
|
||||||
if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name);
|
if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name);
|
||||||
|
if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new InvalidHostException("Port range is not bound");
|
||||||
|
if (Util.isNull(plugin, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
|
||||||
signature = plugin.api.signAnonymousObject();
|
signature = plugin.api.signAnonymousObject();
|
||||||
SubDataServer.allowConnection(address.getHostAddress());
|
SubDataServer.allowConnection(address.getHostAddress());
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host.Internal;
|
package net.ME1312.SubServers.Bungee.Host.Internal;
|
||||||
|
|
||||||
import com.dosse.upnp.UPnP;
|
import com.dosse.upnp.UPnP;
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubRemoveServerEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubRemoveServerEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||||
@ -8,7 +9,6 @@ import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
|
|||||||
import net.ME1312.SubServers.Bungee.Host.Host;
|
import net.ME1312.SubServers.Bungee.Host.Host;
|
||||||
import net.ME1312.SubServers.Bungee.Host.SubCreator;
|
import net.ME1312.SubServers.Bungee.Host.SubCreator;
|
||||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
||||||
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
|
|
||||||
import net.ME1312.SubServers.Bungee.Library.UniversalFile;
|
import net.ME1312.SubServers.Bungee.Library.UniversalFile;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||||
import net.ME1312.SubServers.Bungee.SubPlugin;
|
import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||||
@ -29,30 +29,29 @@ public class InternalHost extends Host {
|
|||||||
private InetAddress address;
|
private InetAddress address;
|
||||||
private SubCreator creator;
|
private SubCreator creator;
|
||||||
private String directory;
|
private String directory;
|
||||||
protected NamedContainer<Integer, Integer> range;
|
|
||||||
protected SubPlugin plugin;
|
protected SubPlugin plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an Internal Host
|
* Creates an Internal Host
|
||||||
*
|
*
|
||||||
* @param plugin Plugin
|
* @param plugin SubServers Internals
|
||||||
* @param name Name
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory
|
* @param enabled If your host is Enabled
|
||||||
* @param gitBash Git Bash Location
|
* @param address The address of your Host
|
||||||
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
*/
|
*/
|
||||||
public InternalHost(SubPlugin plugin, String name, Boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) {
|
public InternalHost(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
|
||||||
super(plugin, name, enabled, address, directory, range, gitBash);
|
super(plugin, name, enabled, ports, log, address, directory, gitBash);
|
||||||
if (!DRM_ALLOW) throw new IllegalStateException("SubServers' hosting capabilities have been disabled by your provider");
|
if (!DRM_ALLOW) throw new IllegalStateException("SubServers' hosting capabilities have been disabled by your provider");
|
||||||
if (Util.isNull(plugin, name, enabled, address, directory, gitBash)) throw new NullPointerException();
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.creator = new InternalSubCreator(this, gitBash);
|
this.creator = new InternalSubCreator(this, ports, log, gitBash);
|
||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
this.range = range;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host.Internal;
|
package net.ME1312.SubServers.Bungee.Host.Internal;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Host.*;
|
import net.ME1312.SubServers.Bungee.Host.*;
|
||||||
@ -32,6 +33,8 @@ import java.util.regex.Pattern;
|
|||||||
public class InternalSubCreator extends SubCreator {
|
public class InternalSubCreator extends SubCreator {
|
||||||
private HashMap<String, ServerTemplate> templates = new HashMap<String, ServerTemplate>();
|
private HashMap<String, ServerTemplate> templates = new HashMap<String, ServerTemplate>();
|
||||||
private InternalHost host;
|
private InternalHost host;
|
||||||
|
private Range<Integer> ports;
|
||||||
|
private Container<Boolean> log;
|
||||||
private String gitBash;
|
private String gitBash;
|
||||||
private TreeMap<String, CreatorTask> thread;
|
private TreeMap<String, CreatorTask> thread;
|
||||||
|
|
||||||
@ -51,7 +54,7 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
this.template = template;
|
this.template = template;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.log = new InternalSubLogger(null, this, name + File.separator + "Creator", new Container<Boolean>(false), null);
|
this.log = new InternalSubLogger(null, this, name + File.separator + "Creator", InternalSubCreator.this.log, null);
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +147,7 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
try {
|
try {
|
||||||
System.out.println(name + File.separator + "Creator > Launching " + template.getBuildOptions().getRawString("Shell-Location"));
|
System.out.println(name + File.separator + "Creator > Launching " + template.getBuildOptions().getRawString("Shell-Location"));
|
||||||
process = Runtime.getRuntime().exec(Executable.parse(gitBash, command), null, dir);
|
process = Runtime.getRuntime().exec(Executable.parse(gitBash, command), null, dir);
|
||||||
log.log.set(host.plugin.config.get().getSection("Settings").getBoolean("Log-Creator"));
|
log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString() + ".log");
|
||||||
log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString().replace(" ", "@") + ".log");
|
|
||||||
log.process = process;
|
log.process = process;
|
||||||
log.start();
|
log.start();
|
||||||
|
|
||||||
@ -267,11 +269,16 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
* Creates an Internal SubCreator
|
* Creates an Internal SubCreator
|
||||||
*
|
*
|
||||||
* @param host Host
|
* @param host Host
|
||||||
* @param gitBash Git Bash
|
* @param ports The range of ports to auto-select from
|
||||||
|
* @param log Whether SubCreator should log to console
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
*/
|
*/
|
||||||
public InternalSubCreator(InternalHost host, String gitBash) {
|
public InternalSubCreator(InternalHost host, Range<Integer> ports, boolean log, String gitBash) {
|
||||||
if (Util.isNull(host, gitBash)) throw new NullPointerException();
|
if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
|
||||||
|
if (Util.isNull(host, ports, log, gitBash)) throw new NullPointerException();
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
this.ports = ports;
|
||||||
|
this.log = new Container<Boolean>(log);
|
||||||
this.gitBash = (System.getenv("ProgramFiles(x86)") == null)?Pattern.compile("%(ProgramFiles)\\(x86\\)%", Pattern.CASE_INSENSITIVE).matcher(gitBash).replaceAll("%$1%"):gitBash;
|
this.gitBash = (System.getenv("ProgramFiles(x86)") == null)?Pattern.compile("%(ProgramFiles)\\(x86\\)%", Pattern.CASE_INSENSITIVE).matcher(gitBash).replaceAll("%$1%"):gitBash;
|
||||||
if (this.gitBash.endsWith(File.pathSeparator)) this.gitBash = this.gitBash.substring(0, this.gitBash.length() - 1);
|
if (this.gitBash.endsWith(File.pathSeparator)) this.gitBash = this.gitBash.substring(0, this.gitBash.length() - 1);
|
||||||
this.thread = new TreeMap<String, CreatorTask>();
|
this.thread = new TreeMap<String, CreatorTask>();
|
||||||
@ -305,10 +312,12 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||||
|
|
||||||
if (port == null) {
|
if (port == null) {
|
||||||
Container<Integer> i = new Container<Integer>(host.range.name() - 1);
|
Container<Integer> i = new Container<Integer>(ports.lowerEndpoint() - 1);
|
||||||
port = Util.getNew(getAllReservedAddresses(), () -> {
|
port = Util.getNew(getAllReservedAddresses(), () -> {
|
||||||
|
do {
|
||||||
i.set(i.get() + 1);
|
i.set(i.get() + 1);
|
||||||
if (i.get() > host.range.get()) throw new IllegalStateException("There are no more ports available between " + host.range.name() + " and " + host.range.get());
|
if (i.get() > ports.upperEndpoint()) throw new IllegalStateException("There are no more ports available in range: " + ports.toString());
|
||||||
|
} while (!ports.contains(i.get()));
|
||||||
return new InetSocketAddress(host.getAddress(), i.get());
|
return new InetSocketAddress(host.getAddress(), i.get());
|
||||||
}).getPort();
|
}).getPort();
|
||||||
}
|
}
|
||||||
@ -388,6 +397,17 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Range getPortRange() {
|
||||||
|
return ports;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPortRange(Range<Integer> value) {
|
||||||
|
if (!value.hasLowerBound() || !value.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
|
||||||
|
ports = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBashDirectory() {
|
public String getBashDirectory() {
|
||||||
return gitBash;
|
return gitBash;
|
||||||
@ -409,6 +429,17 @@ public class InternalSubCreator extends SubCreator {
|
|||||||
return this.thread.get(name.toLowerCase()).log;
|
return this.thread.get(name.toLowerCase()).log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogging() {
|
||||||
|
return log.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLogging(boolean value) {
|
||||||
|
if (Util.isNull(value)) throw new NullPointerException();
|
||||||
|
log.set(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getReservedNames() {
|
public List<String> getReservedNames() {
|
||||||
return new ArrayList<String>(thread.keySet());
|
return new ArrayList<String>(thread.keySet());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.ME1312.SubServers.Bungee.Host;
|
package net.ME1312.SubServers.Bungee.Host;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Callback;
|
import net.ME1312.SubServers.Bungee.Library.Callback;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||||
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidTemplateException;
|
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidTemplateException;
|
||||||
@ -259,6 +260,20 @@ public abstract class SubCreator {
|
|||||||
*/
|
*/
|
||||||
public abstract Host getHost();
|
public abstract Host getHost();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the range of available port numbers
|
||||||
|
*
|
||||||
|
* @return Port Range
|
||||||
|
*/
|
||||||
|
public abstract Range getPortRange();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the range of available port numbers
|
||||||
|
*
|
||||||
|
* @param value Value
|
||||||
|
*/
|
||||||
|
public abstract void setPortRange(Range<Integer> value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Git Bash install directory
|
* Gets the Git Bash install directory
|
||||||
*
|
*
|
||||||
@ -281,6 +296,20 @@ public abstract class SubCreator {
|
|||||||
*/
|
*/
|
||||||
public abstract SubLogger getLogger(String thread);
|
public abstract SubLogger getLogger(String thread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the Creator is Logging to console
|
||||||
|
*
|
||||||
|
* @return Logging Status
|
||||||
|
*/
|
||||||
|
public abstract boolean isLogging();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the Creator is Logging
|
||||||
|
*
|
||||||
|
* @param value Value
|
||||||
|
*/
|
||||||
|
public abstract void setLogging(boolean value);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of currently reserved Server names
|
* Get a list of currently reserved Server names
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
Settings:
|
Settings:
|
||||||
Version: '2.11.2a+'
|
Version: '2.11.2a+'
|
||||||
Log-Creator: true
|
|
||||||
Override-Bungee-Commands: true
|
Override-Bungee-Commands: true
|
||||||
UPnP:
|
UPnP:
|
||||||
Forward-Proxy: true
|
Forward-Proxy: true
|
||||||
@ -21,6 +20,7 @@ Hosts:
|
|||||||
Port-Range: '25500-25559'
|
Port-Range: '25500-25559'
|
||||||
Directory: './SubServers/Servers'
|
Directory: './SubServers/Servers'
|
||||||
Git-Bash: '%ProgramFiles%\Git'
|
Git-Bash: '%ProgramFiles%\Git'
|
||||||
|
Log-Creator: true
|
||||||
|
|
||||||
Servers:
|
Servers:
|
||||||
'Example':
|
'Example':
|
||||||
|
@ -66,6 +66,25 @@ public class Client {
|
|||||||
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.getInputStream());
|
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.getInputStream());
|
||||||
Value input;
|
Value input;
|
||||||
while ((input = in.unpackValue()) != null) {
|
while ((input = in.unpackValue()) != null) {
|
||||||
|
recievePacket(input);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
subdata.removeClient(Client.this);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
||||||
|
try {
|
||||||
|
subdata.removeClient(Client.this);
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recievePacket(Value input) {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = subdata.getCipher().decrypt(subdata.plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
YAMLSection data = subdata.getCipher().decrypt(subdata.plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
||||||
for (PacketIn packet : SubDataServer.decodePacket(this, data)) {
|
for (PacketIn packet : SubDataServer.decodePacket(this, data)) {
|
||||||
@ -106,32 +125,6 @@ public class Client {
|
|||||||
new InvocationTargetException(e, getAddress().toString() + ": Exception while decoding packet").printStackTrace();
|
new InvocationTargetException(e, getAddress().toString() + ": Exception while decoding packet").printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
subdata.removeClient(Client.this);
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
|
||||||
try {
|
|
||||||
subdata.removeClient(Client.this);
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Authorize Connection
|
|
||||||
*/
|
|
||||||
public void authorize() {
|
|
||||||
if (authorized != null) {
|
|
||||||
authorized.cancel();
|
|
||||||
System.out.println("SubData > " + socket.getRemoteSocketAddress().toString() + " logged in");
|
|
||||||
}
|
|
||||||
authorized = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send Packet to Client
|
* Send Packet to Client
|
||||||
@ -148,6 +141,17 @@ public class Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authorize Connection
|
||||||
|
*/
|
||||||
|
public void authorize() {
|
||||||
|
if (authorized != null) {
|
||||||
|
authorized.cancel();
|
||||||
|
System.out.println("SubData > " + socket.getRemoteSocketAddress().toString() + " logged in");
|
||||||
|
}
|
||||||
|
authorized = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Raw Connection
|
* Get Raw Connection
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.ME1312.SubServers.Bungee;
|
package net.ME1312.SubServers.Bungee;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubAddHostEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubAddHostEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubRemoveHostEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubRemoveHostEvent;
|
||||||
@ -133,20 +134,21 @@ public final class SubAPI {
|
|||||||
* Add a Host to the Network
|
* Add a Host to the Network
|
||||||
*
|
*
|
||||||
* @param driver Driver to initiate
|
* @param driver Driver to initiate
|
||||||
* @param name Name of the Host
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address of the Host
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory of the Host
|
* @param enabled If your host is Enabled
|
||||||
* @param range The range of ports to auto-select from
|
* @param address The address of your Host
|
||||||
* @param gitBash Git Bash Directory
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
* @return The Host
|
* @return The Host
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws InvocationTargetException
|
* @throws InvocationTargetException
|
||||||
* @throws InstantiationException
|
* @throws InstantiationException
|
||||||
*/
|
*/
|
||||||
public Host addHost(String driver, String name, boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
public Host addHost(String driver, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
return addHost(null, driver, name, enabled, address, directory, range, gitBash);
|
return addHost(null, driver, name, enabled, ports, log, address, directory, gitBash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,42 +156,44 @@ public final class SubAPI {
|
|||||||
*
|
*
|
||||||
* @param player Player who added
|
* @param player Player who added
|
||||||
* @param driver Driver to initiate
|
* @param driver Driver to initiate
|
||||||
* @param name Name of the Host
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address of the Host
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory of the Host
|
* @param enabled If your host is Enabled
|
||||||
* @param range The range of ports to auto-select from
|
* @param address The address of your Host
|
||||||
* @param gitBash Git Bash Directory
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
* @return The Host
|
* @return The Host
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws InvocationTargetException
|
* @throws InvocationTargetException
|
||||||
* @throws InstantiationException
|
* @throws InstantiationException
|
||||||
*/
|
*/
|
||||||
public Host addHost(UUID player, String driver, String name, boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
public Host addHost(UUID player, String driver, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
if (Util.isNull(driver, name, enabled, address, directory, range, gitBash)) throw new NullPointerException();
|
if (Util.isNull(driver, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
|
||||||
if (!getHostDrivers().contains(driver.toUpperCase().replace('-', '_').replace(' ', '_'))) throw new InvalidHostException("Invalid Driver for host: " + name);
|
if (!getHostDrivers().contains(driver.toUpperCase().replace('-', '_').replace(' ', '_'))) throw new InvalidHostException("Invalid Driver for host: " + name);
|
||||||
return addHost(player, plugin.hostDrivers.get(driver.toUpperCase().replace('-', '_').replace(' ', '_')), name, enabled, address, directory, range, gitBash);
|
return addHost(player, plugin.hostDrivers.get(driver.toUpperCase().replace('-', '_').replace(' ', '_')), name, enabled, ports, log, address, directory, gitBash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a Host with a potentially unregistered driver to the Network
|
* Add a Host with a potentially unregistered driver to the Network
|
||||||
*
|
*
|
||||||
* @param driver Driver to initiate
|
* @param driver Driver to initiate
|
||||||
* @param name Name of the Host
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address of the Host
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory of the Host
|
* @param enabled If your host is Enabled
|
||||||
* @param range The range of ports to auto-select from
|
* @param address The address of your Host
|
||||||
* @param gitBash Git Bash Directory
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
* @return The Host
|
* @return The Host
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws InvocationTargetException
|
* @throws InvocationTargetException
|
||||||
* @throws InstantiationException
|
* @throws InstantiationException
|
||||||
*/
|
*/
|
||||||
public Host addHost(Class<? extends Host> driver, String name, boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
public Host addHost(Class<? extends Host> driver, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
return addHost(null, driver, name, enabled, address, directory, range, gitBash);
|
return addHost(null, driver, name, enabled, ports, log, address, directory, gitBash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,21 +201,22 @@ public final class SubAPI {
|
|||||||
*
|
*
|
||||||
* @param player Player who added
|
* @param player Player who added
|
||||||
* @param driver Driver to initiate
|
* @param driver Driver to initiate
|
||||||
* @param name Name of the Host
|
* @param name The Name of your Host
|
||||||
* @param enabled Enabled Status
|
* @param ports The range of ports to auto-select from
|
||||||
* @param address Address of the Host
|
* @param log Whether apps like SubCreator should log to console (does not apply to servers)
|
||||||
* @param directory Directory of the Host
|
* @param enabled If your host is Enabled
|
||||||
* @param range The range of ports to auto-select from
|
* @param address The address of your Host
|
||||||
* @param gitBash Git Bash Directory
|
* @param directory The runtime directory of your Host
|
||||||
|
* @param gitBash The Git Bash directory
|
||||||
* @return The Host
|
* @return The Host
|
||||||
* @throws NoSuchMethodException
|
* @throws NoSuchMethodException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws InvocationTargetException
|
* @throws InvocationTargetException
|
||||||
* @throws InstantiationException
|
* @throws InstantiationException
|
||||||
*/
|
*/
|
||||||
public Host addHost(UUID player, Class<? extends Host> driver, String name, boolean enabled, InetAddress address, String directory, NamedContainer<Integer, Integer> range, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
public Host addHost(UUID player, Class<? extends Host> driver, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
if (Util.isNull(driver, name, enabled, address, directory, range, gitBash)) throw new NullPointerException();
|
if (Util.isNull(driver, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
|
||||||
Host host = driver.getConstructor(SubPlugin.class, String.class, Boolean.class, InetAddress.class, String.class, NamedContainer.class, String.class).newInstance(plugin, name, (Boolean) enabled, address, directory, range, gitBash);
|
Host host = driver.getConstructor(SubPlugin.class, String.class, boolean.class, Range.class, boolean.class, InetAddress.class, String.class, String.class).newInstance(plugin, name, enabled, ports, log, address, directory, gitBash);
|
||||||
return addHost(player, host)?host:null;
|
return addHost(player, host)?host:null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.ME1312.SubServers.Bungee;
|
package net.ME1312.SubServers.Bungee;
|
||||||
|
|
||||||
import com.dosse.upnp.UPnP;
|
import com.dosse.upnp.UPnP;
|
||||||
|
import com.google.common.collect.Range;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubAddProxyEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubAddProxyEvent;
|
||||||
import net.ME1312.SubServers.Bungee.Event.SubRemoveProxyEvent;
|
import net.ME1312.SubServers.Bungee.Event.SubRemoveProxyEvent;
|
||||||
@ -316,15 +317,20 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
|||||||
!hostDrivers.get(config.get().getSection("Hosts").getSection(name).getRawString("Driver").toUpperCase().replace('-', '_').replace(' ', '_')).equals(host.getClass()) ||
|
!hostDrivers.get(config.get().getSection("Hosts").getSection(name).getRawString("Driver").toUpperCase().replace('-', '_').replace(' ', '_')).equals(host.getClass()) ||
|
||||||
!config.get().getSection("Hosts").getSection(name).getRawString("Address").equals(host.getAddress().getHostAddress()) ||
|
!config.get().getSection("Hosts").getSection(name).getRawString("Address").equals(host.getAddress().getHostAddress()) ||
|
||||||
!config.get().getSection("Hosts").getSection(name).getRawString("Directory").equals(host.getPath()) ||
|
!config.get().getSection("Hosts").getSection(name).getRawString("Directory").equals(host.getPath()) ||
|
||||||
!config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").equals(prevconfig.getSection("Hosts", new YAMLSection()).getSection(name, new YAMLSection()).getRawString("Port-Range", "25500-25559")) ||
|
|
||||||
!config.get().getSection("Hosts").getSection(name).getRawString("Git-Bash").equals(host.getCreator().getBashDirectory())
|
!config.get().getSection("Hosts").getSection(name).getRawString("Git-Bash").equals(host.getCreator().getBashDirectory())
|
||||||
) {
|
) {
|
||||||
if (host != null) api.forceRemoveHost(name);
|
if (host != null) api.forceRemoveHost(name);
|
||||||
host = api.addHost(config.get().getSection("Hosts").getSection(name).getRawString("Driver").toLowerCase(), name, config.get().getSection("Hosts").getSection(name).getBoolean("Enabled"), InetAddress.getByName(config.get().getSection("Hosts").getSection(name).getRawString("Address")), config.get().getSection("Hosts").getSection(name).getRawString("Directory"),
|
host = api.addHost(config.get().getSection("Hosts").getSection(name).getRawString("Driver").toLowerCase(), name, config.get().getSection("Hosts").getSection(name).getBoolean("Enabled"),
|
||||||
new NamedContainer<>(Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[0]), Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[1])), config.get().getSection("Hosts").getSection(name).getRawString("Git-Bash"));
|
Range.closed(Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[0]), Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[1])),
|
||||||
|
config.get().getSection("Hosts").getSection(name).getBoolean("Log-Creator", true), InetAddress.getByName(config.get().getSection("Hosts").getSection(name).getRawString("Address")),
|
||||||
|
config.get().getSection("Hosts").getSection(name).getRawString("Directory"), config.get().getSection("Hosts").getSection(name).getRawString("Git-Bash"));
|
||||||
} else { // Host wasn't reset, so check for these changes
|
} else { // Host wasn't reset, so check for these changes
|
||||||
if (config.get().getSection("Hosts").getSection(name).getBoolean("Enabled") != host.isEnabled())
|
if (config.get().getSection("Hosts").getSection(name).getBoolean("Enabled") != host.isEnabled())
|
||||||
host.setEnabled(config.get().getSection("Hosts").getSection(name).getBoolean("Enabled"));
|
host.setEnabled(config.get().getSection("Hosts").getSection(name).getBoolean("Enabled"));
|
||||||
|
if (!config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").equals(prevconfig.getSection("Hosts", new YAMLSection()).getSection(name, new YAMLSection()).getRawString("Port-Range", "25500-25559")))
|
||||||
|
host.getCreator().setPortRange(Range.closed(Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[0]), Integer.parseInt(config.get().getSection("Hosts").getSection(name).getRawString("Port-Range", "25500-25559").split("-")[1])));
|
||||||
|
if (config.get().getSection("Hosts").getSection(name).getBoolean("Log-Creator", true) != host.getCreator().isLogging())
|
||||||
|
host.getCreator().setLogging(config.get().getSection("Hosts").getSection(name).getBoolean("Log-Creator", true));
|
||||||
} // Check for other changes
|
} // Check for other changes
|
||||||
if (config.get().getSection("Hosts").getSection(name).getKeys().contains("Display") && ((config.get().getSection("Hosts").getSection(name).getString("Display").length() == 0 && !host.getDisplayName().equals(host.getName())) || !config.get().getSection("Hosts").getSection(name).getString("Display").equals(host.getDisplayName())))
|
if (config.get().getSection("Hosts").getSection(name).getKeys().contains("Display") && ((config.get().getSection("Hosts").getSection(name).getString("Display").length() == 0 && !host.getDisplayName().equals(host.getName())) || !config.get().getSection("Hosts").getSection(name).getString("Display").equals(host.getDisplayName())))
|
||||||
host.setDisplayName(config.get().getSection("Hosts").getSection(name).getString("Display"));
|
host.setDisplayName(config.get().getSection("Hosts").getSection(name).getString("Display"));
|
||||||
|
@ -138,6 +138,25 @@ public final class SubDataClient {
|
|||||||
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
||||||
Value input;
|
Value input;
|
||||||
while ((input = in.unpackValue()) != null) {
|
while ((input = in.unpackValue()) != null) {
|
||||||
|
recieve(input);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recieve(Value input) {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = cipher.decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
YAMLSection data = cipher.decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
@ -157,21 +176,6 @@ public final class SubDataClient {
|
|||||||
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Assigned Server Name
|
* Gets the Assigned Server Name
|
||||||
|
@ -142,6 +142,25 @@ public final class SubDataClient {
|
|||||||
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
||||||
Value input;
|
Value input;
|
||||||
while ((input = in.unpackValue()) != null) {
|
while ((input = in.unpackValue()) != null) {
|
||||||
|
recieve(input);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).submit(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recieve(Value input) {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = getCipher().decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
YAMLSection data = getCipher().decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
@ -161,21 +180,6 @@ public final class SubDataClient {
|
|||||||
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).submit(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Assigned Server Name
|
* Gets the Assigned Server Name
|
||||||
|
@ -162,6 +162,25 @@ public final class SubDataClient {
|
|||||||
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
||||||
Value input;
|
Value input;
|
||||||
while ((input = in.unpackValue()) != null) {
|
while ((input = in.unpackValue()) != null) {
|
||||||
|
recieve(input);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
destroy(host.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
log.error.println(e1);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) log.error.println(e);
|
||||||
|
try {
|
||||||
|
destroy(host.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
log.error.println(e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recieve(Value input) {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = cipher.decrypt(host.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
YAMLSection data = cipher.decrypt(host.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
@ -179,21 +198,6 @@ public final class SubDataClient {
|
|||||||
log.error.println(new InvocationTargetException(e, "Exception while decoding packet"));
|
log.error.println(new InvocationTargetException(e, "Exception while decoding packet"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
destroy(host.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
log.error.println(e1);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) log.error.println(e);
|
|
||||||
try {
|
|
||||||
destroy(host.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
log.error.println(e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Assigned Host Name
|
* Gets the Assigned Host Name
|
||||||
|
@ -174,6 +174,25 @@ public final class SubDataClient {
|
|||||||
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
MessageUnpacker in = MessagePack.newDefaultUnpacker(socket.get().getInputStream());
|
||||||
Value input;
|
Value input;
|
||||||
while ((input = in.unpackValue()) != null) {
|
while ((input = in.unpackValue()) != null) {
|
||||||
|
recieve(input);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
||||||
|
try {
|
||||||
|
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recieve(Value input) {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = cipher.decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
YAMLSection data = cipher.decrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
@ -191,21 +210,6 @@ public final class SubDataClient {
|
|||||||
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
new InvocationTargetException(e, "Exception while decoding packet").printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!(e instanceof SocketException || e instanceof MessageInsufficientBufferException)) e.printStackTrace();
|
|
||||||
try {
|
|
||||||
destroy(plugin.config.get().getSection("Settings").getSection("SubData").getInt("Reconnect", 30));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Assigned Proxy Name
|
* Gets the Assigned Proxy Name
|
||||||
|
Loading…
Reference in New Issue
Block a user