Move encryption keys to a variable
This commit is contained in:
parent
6debb5b605
commit
2c41c40213
|
@ -86,7 +86,7 @@ public class Client {
|
||||||
|
|
||||||
private void recievePacket(Value input) {
|
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.password, input);
|
||||||
for (PacketIn packet : SubDataServer.decodePacket(this, data)) {
|
for (PacketIn packet : SubDataServer.decodePacket(this, data)) {
|
||||||
boolean auth = authorized == null;
|
boolean auth = authorized == null;
|
||||||
if (auth || packet instanceof PacketAuthorization) {
|
if (auth || packet instanceof PacketAuthorization) {
|
||||||
|
@ -134,7 +134,7 @@ public class Client {
|
||||||
public void sendPacket(PacketOut packet) {
|
public void sendPacket(PacketOut packet) {
|
||||||
if (Util.isNull(packet)) throw new NullPointerException();
|
if (Util.isNull(packet)) throw new NullPointerException();
|
||||||
if (!isClosed()) try {
|
if (!isClosed()) try {
|
||||||
out.packValue(subdata.getCipher().encrypt(subdata.plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), SubDataServer.encodePacket(this, packet)));
|
out.packValue(subdata.getCipher().encrypt(subdata.password, SubDataServer.encodePacket(this, packet)));
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||||
import net.ME1312.SubServers.Bungee.Network.Client;
|
import net.ME1312.SubServers.Bungee.Network.Client;
|
||||||
import net.ME1312.SubServers.Bungee.Network.PacketIn;
|
import net.ME1312.SubServers.Bungee.Network.PacketIn;
|
||||||
import net.ME1312.SubServers.Bungee.Network.PacketOut;
|
import net.ME1312.SubServers.Bungee.Network.PacketOut;
|
||||||
|
import net.ME1312.SubServers.Bungee.Network.SubDataServer;
|
||||||
import net.ME1312.SubServers.Bungee.SubPlugin;
|
import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +50,7 @@ public final class PacketAuthorization implements PacketIn, PacketOut {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Client client, YAMLSection data) {
|
public void execute(Client client, YAMLSection data) {
|
||||||
try {
|
try {
|
||||||
if (data.getRawString("password").equals(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"))) {
|
if (data.getRawString("password").equals(Util.reflect(SubDataServer.class.getDeclaredField("password"), plugin.subdata))) {
|
||||||
client.authorize();
|
client.authorize();
|
||||||
client.sendPacket(new PacketAuthorization(0, "Successfully Logged in"));
|
client.sendPacket(new PacketAuthorization(0, "Successfully Logged in"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,6 +34,7 @@ public final class SubDataServer {
|
||||||
private ServerSocket server;
|
private ServerSocket server;
|
||||||
private Cipher cipher;
|
private Cipher cipher;
|
||||||
protected SubPlugin plugin;
|
protected SubPlugin plugin;
|
||||||
|
String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SubData Server Instance
|
* SubData Server Instance
|
||||||
|
@ -55,6 +56,7 @@ public final class SubDataServer {
|
||||||
}
|
}
|
||||||
if (UPnP.isUPnPAvailable() && plugin.config.get().getSection("Settings").getSection("UPnP", new YAMLSection()).getBoolean("Forward-SubData", false)) UPnP.openPortTCP(port);
|
if (UPnP.isUPnPAvailable() && plugin.config.get().getSection("Settings").getSection("UPnP", new YAMLSection()).getBoolean("Forward-SubData", false)) UPnP.openPortTCP(port);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.password = plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password");
|
||||||
this.cipher = (cipher != null)?cipher:new Cipher() {
|
this.cipher = (cipher != null)?cipher:new Cipher() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
@ -15,16 +15,18 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
public final class PacketAuthorization implements PacketIn, PacketOut {
|
public final class PacketAuthorization implements PacketIn, PacketOut {
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
|
private String password;
|
||||||
|
|
||||||
public PacketAuthorization(SubPlugin plugin) {
|
public PacketAuthorization(SubPlugin plugin, String password) {
|
||||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YAMLSection generate() {
|
public YAMLSection generate() {
|
||||||
YAMLSection json = new YAMLSection();
|
YAMLSection json = new YAMLSection();
|
||||||
json.set("password", plugin.config.get().getSection("Settings").getSection("SubData").getString("Password"));
|
json.set("password", password);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ public final class SubDataClient {
|
||||||
private NamedContainer<Boolean, Socket> socket;
|
private NamedContainer<Boolean, Socket> socket;
|
||||||
private String name;
|
private String name;
|
||||||
private Cipher cipher;
|
private Cipher cipher;
|
||||||
|
private String password;
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ public final class SubDataClient {
|
||||||
this.name = (name == null || name.length() > 0)?name:null;
|
this.name = (name == null || name.length() > 0)?name:null;
|
||||||
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
||||||
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
||||||
|
this.password = plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password");
|
||||||
this.cipher = (cipher != null)?cipher:new Cipher() {
|
this.cipher = (cipher != null)?cipher:new Cipher() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -77,7 +79,7 @@ public final class SubDataClient {
|
||||||
if (!defaults) loadDefaults();
|
if (!defaults) loadDefaults();
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin)));
|
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin, password)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
@ -98,7 +100,7 @@ public final class SubDataClient {
|
||||||
} private void loadDefaults() {
|
} private void loadDefaults() {
|
||||||
defaults = true;
|
defaults = true;
|
||||||
|
|
||||||
registerPacket(new PacketAuthorization(plugin), "SubData", "Authorization");
|
registerPacket(new PacketAuthorization(plugin, null), "SubData", "Authorization");
|
||||||
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
||||||
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
||||||
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
||||||
|
@ -160,7 +162,7 @@ public final class SubDataClient {
|
||||||
|
|
||||||
private void recieve(Value input) {
|
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(password, input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
if (plugin.isEnabled()) Bukkit.getScheduler().runTask(plugin, () -> {
|
if (plugin.isEnabled()) Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
try {
|
try {
|
||||||
|
@ -332,7 +334,7 @@ public final class SubDataClient {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = encodePacket(packet.get());
|
YAMLSection data = encodePacket(packet.get());
|
||||||
if (packet.name() != null) data.set("f", packet.name());
|
if (packet.name() != null) data.set("f", packet.name());
|
||||||
out.packValue(getCipher().encrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), data));
|
out.packValue(getCipher().encrypt(password, data));
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -17,17 +17,18 @@ import java.lang.reflect.Method;
|
||||||
public final class PacketAuthorization implements PacketIn, PacketOut {
|
public final class PacketAuthorization implements PacketIn, PacketOut {
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
private Logger log = null;
|
private Logger log = null;
|
||||||
|
private String password;
|
||||||
|
|
||||||
public PacketAuthorization(SubPlugin plugin) {
|
public PacketAuthorization(SubPlugin plugin, String password) {
|
||||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
Util.isException(() -> this.log = Util.reflect(SubDataClient.class.getDeclaredField("log"), null));
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YAMLSection generate() {
|
public YAMLSection generate() {
|
||||||
YAMLSection json = new YAMLSection();
|
YAMLSection json = new YAMLSection();
|
||||||
json.set("password", plugin.config.get().getSection("Settings").getSection("SubData").getString("Password"));
|
json.set("password", password);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public final class SubDataClient {
|
||||||
private NamedContainer<Boolean, Socket> socket;
|
private NamedContainer<Boolean, Socket> socket;
|
||||||
private String name;
|
private String name;
|
||||||
private Cipher cipher;
|
private Cipher cipher;
|
||||||
|
private String password;
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ public final class SubDataClient {
|
||||||
this.name = (name == null || name.length() > 0)?name:null;
|
this.name = (name == null || name.length() > 0)?name:null;
|
||||||
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
||||||
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
||||||
|
this.password = plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password");
|
||||||
this.cipher = (cipher != null)?cipher:new Cipher() {
|
this.cipher = (cipher != null)?cipher:new Cipher() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -80,7 +82,7 @@ public final class SubDataClient {
|
||||||
if (!defaults) loadDefaults();
|
if (!defaults) loadDefaults();
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin)));
|
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin, password)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
@ -102,7 +104,7 @@ public final class SubDataClient {
|
||||||
defaults = true;
|
defaults = true;
|
||||||
log = LoggerFactory.getLogger("SubData");
|
log = LoggerFactory.getLogger("SubData");
|
||||||
|
|
||||||
registerPacket(new PacketAuthorization(plugin), "SubData", "Authorization");
|
registerPacket(new PacketAuthorization(plugin, null), "SubData", "Authorization");
|
||||||
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
||||||
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
||||||
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
||||||
|
@ -164,7 +166,7 @@ public final class SubDataClient {
|
||||||
|
|
||||||
private void recieve(Value input) {
|
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(password, input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
Sponge.getScheduler().createTaskBuilder().execute(() -> {
|
Sponge.getScheduler().createTaskBuilder().execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -336,7 +338,7 @@ public final class SubDataClient {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = encodePacket(packet.get());
|
YAMLSection data = encodePacket(packet.get());
|
||||||
if (packet.name() != null) data.set("f", packet.name());
|
if (packet.name() != null) data.set("f", packet.name());
|
||||||
out.packValue(getCipher().encrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), data));
|
out.packValue(getCipher().encrypt(password, data));
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -20,22 +20,18 @@ import java.lang.reflect.Method;
|
||||||
public final class PacketAuthorization implements PacketIn, PacketOut {
|
public final class PacketAuthorization implements PacketIn, PacketOut {
|
||||||
private ExHost host;
|
private ExHost host;
|
||||||
private Logger log = null;
|
private Logger log = null;
|
||||||
|
private String password;
|
||||||
|
|
||||||
/**
|
public PacketAuthorization(ExHost host, String password) {
|
||||||
* New PacketAuthorization
|
|
||||||
*
|
|
||||||
* @param host SubServers.Host
|
|
||||||
*/
|
|
||||||
public PacketAuthorization(ExHost host) {
|
|
||||||
if (Util.isNull(host)) throw new NullPointerException();
|
if (Util.isNull(host)) throw new NullPointerException();
|
||||||
this.host = host;
|
this.host = host;
|
||||||
Util.isException(() -> this.log = Util.reflect(SubDataClient.class.getDeclaredField("log"), null));
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YAMLSection generate() {
|
public YAMLSection generate() {
|
||||||
YAMLSection json = new YAMLSection();
|
YAMLSection json = new YAMLSection();
|
||||||
json.set("password", host.config.get().getSection("Settings").getSection("SubData").getString("Password"));
|
json.set("password", password);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ public final class SubDataClient {
|
||||||
private NamedContainer<Boolean, Socket> socket;
|
private NamedContainer<Boolean, Socket> socket;
|
||||||
private String name;
|
private String name;
|
||||||
private Cipher cipher;
|
private Cipher cipher;
|
||||||
|
private String password;
|
||||||
private ExHost host;
|
private ExHost host;
|
||||||
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ public final class SubDataClient {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
||||||
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
this.queue = new LinkedList<NamedContainer<String, PacketOut>>();
|
||||||
|
this.password = host.config.get().getSection("Settings").getSection("SubData").getRawString("Password");
|
||||||
this.cipher = (cipher != null)?cipher:new Cipher() {
|
this.cipher = (cipher != null)?cipher:new Cipher() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -83,7 +85,7 @@ public final class SubDataClient {
|
||||||
if (!defaults) loadDefaults();
|
if (!defaults) loadDefaults();
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
sendPacket(new NamedContainer<>(null, new PacketAuthorization(host)));
|
sendPacket(new NamedContainer<>(null, new PacketAuthorization(host, password)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
@ -107,7 +109,7 @@ public final class SubDataClient {
|
||||||
defaults = true;
|
defaults = true;
|
||||||
log = new Logger("SubData");
|
log = new Logger("SubData");
|
||||||
|
|
||||||
registerPacket(new PacketAuthorization(host), "SubData", "Authorization");
|
registerPacket(new PacketAuthorization(host, null), "SubData", "Authorization");
|
||||||
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
||||||
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
||||||
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
||||||
|
@ -184,7 +186,7 @@ public final class SubDataClient {
|
||||||
|
|
||||||
private void recieve(Value input) {
|
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(password, input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
try {
|
try {
|
||||||
packet.execute((data.contains("c"))?data.getSection("c"):null);
|
packet.execute((data.contains("c"))?data.getSection("c"):null);
|
||||||
|
@ -354,7 +356,7 @@ public final class SubDataClient {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = encodePacket(packet.get());
|
YAMLSection data = encodePacket(packet.get());
|
||||||
if (packet.name() != null) data.set("f", packet.name());
|
if (packet.name() != null) data.set("f", packet.name());
|
||||||
out.packValue(getCipher().encrypt(host.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), data));
|
out.packValue(getCipher().encrypt(password, data));
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error.println(e);
|
log.error.println(e);
|
||||||
|
|
|
@ -13,17 +13,19 @@ import java.lang.reflect.Method;
|
||||||
|
|
||||||
public final class PacketAuthorization implements PacketIn, PacketOut {
|
public final class PacketAuthorization implements PacketIn, PacketOut {
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
|
private String password;
|
||||||
|
|
||||||
public PacketAuthorization(SubPlugin plugin) {
|
public PacketAuthorization(SubPlugin plugin, String password) {
|
||||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YAMLSection generate() {
|
public YAMLSection generate() {
|
||||||
YAMLSection data = new YAMLSection();
|
YAMLSection json = new YAMLSection();
|
||||||
data.set("password", plugin.config.get().getSection("Settings").getSection("SubData").getString("Password"));
|
json.set("password", password);
|
||||||
return data;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,6 +47,7 @@ public final class SubDataClient {
|
||||||
private NamedContainer<Boolean, Socket> socket;
|
private NamedContainer<Boolean, Socket> socket;
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private Cipher cipher;
|
private Cipher cipher;
|
||||||
|
private String password;
|
||||||
private SubPlugin plugin;
|
private SubPlugin plugin;
|
||||||
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
private LinkedList<NamedContainer<String, PacketOut>> queue;
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ public final class SubDataClient {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = (name == null || name.length() > 0)?name:null;
|
this.name = (name == null || name.length() > 0)?name:null;
|
||||||
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
this.out = MessagePack.newDefaultPacker(socket.get().getOutputStream());
|
||||||
|
this.password = plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password");
|
||||||
this.cipher = (cipher != null)?cipher:new Cipher() {
|
this.cipher = (cipher != null)?cipher:new Cipher() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -85,7 +87,7 @@ public final class SubDataClient {
|
||||||
if (!defaults) loadDefaults();
|
if (!defaults) loadDefaults();
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin)));
|
sendPacket(new NamedContainer<>(null, new PacketAuthorization(plugin, password)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
@ -131,7 +133,7 @@ public final class SubDataClient {
|
||||||
} private void loadDefaults() {
|
} private void loadDefaults() {
|
||||||
defaults = true;
|
defaults = true;
|
||||||
|
|
||||||
registerPacket(new PacketAuthorization(plugin), "SubData", "Authorization");
|
registerPacket(new PacketAuthorization(plugin, null), "SubData", "Authorization");
|
||||||
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
registerPacket(new PacketCommandServer(), "SubServers", "CommandServer");
|
||||||
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
registerPacket(new PacketCreateServer(), "SubServers", "CreateServer");
|
||||||
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
registerPacket(new PacketDownloadGroupInfo(), "SubServers", "DownloadGroupInfo");
|
||||||
|
@ -193,7 +195,7 @@ public final class SubDataClient {
|
||||||
|
|
||||||
private void recieve(Value input) {
|
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(password, input);
|
||||||
for (PacketIn packet : decodePacket(data)) {
|
for (PacketIn packet : decodePacket(data)) {
|
||||||
try {
|
try {
|
||||||
packet.execute((data.contains("c")) ? data.getSection("c") : null);
|
packet.execute((data.contains("c")) ? data.getSection("c") : null);
|
||||||
|
@ -374,7 +376,7 @@ public final class SubDataClient {
|
||||||
try {
|
try {
|
||||||
YAMLSection data = encodePacket(packet.get());
|
YAMLSection data = encodePacket(packet.get());
|
||||||
if (packet.name() != null) data.set("f", packet.name());
|
if (packet.name() != null) data.set("f", packet.name());
|
||||||
out.packValue(getCipher().encrypt(plugin.config.get().getSection("Settings").getSection("SubData").getRawString("Password"), data));
|
out.packValue(getCipher().encrypt(password, data));
|
||||||
out.flush();
|
out.flush();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue