- Finished with Domain resolving
This commit is contained in:
@@ -3,7 +3,13 @@ package github.openautonomousconnection.protocol;
|
|||||||
import github.openautonomousconnection.protocol.listeners.ClientListener;
|
import github.openautonomousconnection.protocol.listeners.ClientListener;
|
||||||
import github.openautonomousconnection.protocol.listeners.ServerListener;
|
import github.openautonomousconnection.protocol.listeners.ServerListener;
|
||||||
import github.openautonomousconnection.protocol.packets.OACPacket;
|
import github.openautonomousconnection.protocol.packets.OACPacket;
|
||||||
|
import github.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
||||||
|
import github.openautonomousconnection.protocol.packets.v1_0_0.beta.GetDestinationPacket;
|
||||||
|
import github.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
|
||||||
|
import github.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateDomainPacket;
|
||||||
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||||
import github.openautonomousconnection.protocol.versions.v1_0_0.classic.ClassicHandlerClient;
|
import github.openautonomousconnection.protocol.versions.v1_0_0.classic.ClassicHandlerClient;
|
||||||
import github.openautonomousconnection.protocol.versions.v1_0_0.classic.ClassicHandlerServer;
|
import github.openautonomousconnection.protocol.versions.v1_0_0.classic.ClassicHandlerServer;
|
||||||
import github.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_DomainPacket;
|
import github.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_DomainPacket;
|
||||||
@@ -66,17 +72,8 @@ public class ProtocolBridge {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isClassicSupported()) {
|
if (isClassicSupported()) protocolSettings.eventManager.unregisterListener(new Classic_ClientListener());
|
||||||
protocolSettings.eventManager.unregisterListener(new Classic_ClientListener());
|
registerPackets();
|
||||||
|
|
||||||
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket();
|
|
||||||
Classic_DomainPacket cMessagePacket = new Classic_DomainPacket();
|
|
||||||
Classic_DomainPacket cPingPacket = new Classic_DomainPacket();
|
|
||||||
|
|
||||||
if (isPacketSupported(cDomainPacket)) protocolSettings.packetHandler.registerPacket(cDomainPacket);
|
|
||||||
if (isPacketSupported(cMessagePacket)) protocolSettings.packetHandler.registerPacket(cMessagePacket);
|
|
||||||
if (isPacketSupported(cPingPacket)) protocolSettings.packetHandler.registerPacket(cPingPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
@@ -104,21 +101,34 @@ public class ProtocolBridge {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isClassicSupported()) {
|
if (isClassicSupported()) protocolSettings.eventManager.registerListener(new Classic_ClientListener());
|
||||||
protocolSettings.eventManager.registerListener(new Classic_ClientListener());
|
registerPackets();
|
||||||
|
|
||||||
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket();
|
|
||||||
Classic_DomainPacket cMessagePacket = new Classic_DomainPacket();
|
|
||||||
Classic_DomainPacket cPingPacket = new Classic_DomainPacket();
|
|
||||||
|
|
||||||
if (isPacketSupported(cDomainPacket)) protocolSettings.packetHandler.registerPacket(cDomainPacket);
|
|
||||||
if (isPacketSupported(cMessagePacket)) protocolSettings.packetHandler.registerPacket(cMessagePacket);
|
|
||||||
if (isPacketSupported(cPingPacket)) protocolSettings.packetHandler.registerPacket(cPingPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerPackets() {
|
||||||
|
// Classic packets
|
||||||
|
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket();
|
||||||
|
Classic_DomainPacket cMessagePacket = new Classic_DomainPacket();
|
||||||
|
Classic_DomainPacket cPingPacket = new Classic_DomainPacket();
|
||||||
|
|
||||||
|
if (isPacketSupported(cDomainPacket)) protocolSettings.packetHandler.registerPacket(cDomainPacket);
|
||||||
|
if (isPacketSupported(cMessagePacket)) protocolSettings.packetHandler.registerPacket(cMessagePacket);
|
||||||
|
if (isPacketSupported(cPingPacket)) protocolSettings.packetHandler.registerPacket(cPingPacket);
|
||||||
|
|
||||||
|
// 1.0.0-BETA packets
|
||||||
|
AuthPacket v100bAuthPath = new AuthPacket();
|
||||||
|
UnsupportedClassicPacket v100bUnsupportedClassicPacket = new UnsupportedClassicPacket();
|
||||||
|
ValidateDomainPacket v100bValidateDomainPacket = new ValidateDomainPacket();
|
||||||
|
GetDestinationPacket v100bGetDestinationPacket = new GetDestinationPacket();
|
||||||
|
|
||||||
|
if (isPacketSupported(v100bAuthPath)) protocolSettings.packetHandler.registerPacket(v100bAuthPath);
|
||||||
|
if (isPacketSupported(v100bUnsupportedClassicPacket)) protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket);
|
||||||
|
if (isPacketSupported(v100bValidateDomainPacket)) protocolSettings.packetHandler.registerPacket(v100bValidateDomainPacket);
|
||||||
|
if (isPacketSupported(v100bGetDestinationPacket)) protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPacketSupported(OACPacket packet) {
|
public boolean isPacketSupported(OACPacket packet) {
|
||||||
return isVersionSupported(packet.getProtocolVersion());
|
return isVersionSupported(packet.getProtocolVersion());
|
||||||
}
|
}
|
||||||
|
@@ -39,9 +39,13 @@ public abstract class OACPacket extends Packet {
|
|||||||
@Override
|
@Override
|
||||||
public final void read(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
public final void read(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||||
onRead(packetHandler, objectInputStream);
|
onRead(packetHandler, objectInputStream);
|
||||||
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) responseCode = (DNSResponseCode) objectInputStream.readObject();
|
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) {
|
||||||
|
responseCode = (DNSResponseCode) objectInputStream.readObject();
|
||||||
|
onResponseCodeRead(packetHandler, objectInputStream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException;
|
public abstract void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException;
|
||||||
public abstract void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException;
|
public abstract void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException;
|
||||||
|
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,76 @@
|
|||||||
|
package github.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||||
|
|
||||||
|
import github.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
|
import github.openautonomousconnection.protocol.packets.OACPacket;
|
||||||
|
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||||
|
import me.finn.unlegitlibrary.network.system.packets.PacketHandler;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.function.DoubleBinaryOperator;
|
||||||
|
|
||||||
|
public class GetDestinationPacket extends OACPacket {
|
||||||
|
private Domain domain;
|
||||||
|
private int clientID;
|
||||||
|
private DNSResponseCode validationResponse;
|
||||||
|
private String destination;
|
||||||
|
|
||||||
|
public GetDestinationPacket(Domain domain, DNSResponseCode validationResponse, String destination) {
|
||||||
|
this();
|
||||||
|
this.domain = domain;
|
||||||
|
this.validationResponse = validationResponse;
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetDestinationPacket() {
|
||||||
|
super(6, ProtocolVersion.PV_1_0_0_BETA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||||
|
if (validationResponse != DNSResponseCode.RESPONSE_DOMAIN_FULLY_EXIST) return;
|
||||||
|
|
||||||
|
objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getNetworkClient().getClientID());
|
||||||
|
objectOutputStream.writeObject(domain);
|
||||||
|
objectOutputStream.writeObject(validationResponse);
|
||||||
|
} else {
|
||||||
|
objectOutputStream.writeObject(domain);
|
||||||
|
objectOutputStream.writeObject(validationResponse);
|
||||||
|
objectOutputStream.writeUTF(destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsServer()) {
|
||||||
|
clientID = objectInputStream.readInt();
|
||||||
|
domain = (Domain) objectInputStream.readObject();
|
||||||
|
validationResponse = (DNSResponseCode) objectInputStream.readObject();
|
||||||
|
} else {
|
||||||
|
domain = (Domain) objectInputStream.readObject();
|
||||||
|
validationResponse = (DNSResponseCode) objectInputStream.readObject();
|
||||||
|
destination = objectInputStream.readUTF();
|
||||||
|
|
||||||
|
ProtocolBridge.getInstance().getProtocolClient().getDestinationCompleted(domain, destination, validationResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
|
||||||
|
super.onResponseCodeRead(packetHandler, objectInputStream);
|
||||||
|
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsServer()) {
|
||||||
|
if (validationResponse != DNSResponseCode.RESPONSE_DOMAIN_FULLY_EXIST) return;
|
||||||
|
destination = domain.getDestination();
|
||||||
|
try {
|
||||||
|
ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID).getConnectionHandler().sendPacket(new GetDestinationPacket(domain, validationResponse, destination));
|
||||||
|
} catch (IOException | ClassNotFoundException exception) {
|
||||||
|
ProtocolBridge.getInstance().getProtocolServer().getDomainDestinationFailed(ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID), domain, validationResponse, exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -27,6 +27,7 @@ public class UnsupportedClassicPacket extends OACPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsClient()) objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getNetworkClient().getClientID());
|
||||||
objectOutputStream.writeUTF(unsupportedClassicPacket.getName());
|
objectOutputStream.writeUTF(unsupportedClassicPacket.getName());
|
||||||
objectOutputStream.writeInt(content.length);
|
objectOutputStream.writeInt(content.length);
|
||||||
for (Object o : content) objectOutputStream.writeObject(o);
|
for (Object o : content) objectOutputStream.writeObject(o);
|
||||||
@@ -35,6 +36,8 @@ public class UnsupportedClassicPacket extends OACPacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||||
|
int clientID = 0;
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsServer()) clientID = objectInputStream.readInt();
|
||||||
String className = objectInputStream.readUTF();
|
String className = objectInputStream.readUTF();
|
||||||
int size = objectInputStream.readInt();
|
int size = objectInputStream.readInt();
|
||||||
content = new Object[size];
|
content = new Object[size];
|
||||||
@@ -43,6 +46,7 @@ public class UnsupportedClassicPacket extends OACPacket {
|
|||||||
content[i] = objectInputStream.readObject();
|
content[i] = objectInputStream.readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtocolBridge.getInstance().getClassicHandlerClient().unsupportedClassicPacket(className, content);
|
if (ProtocolBridge.getInstance().isRunningAsServer()) ProtocolBridge.getInstance().getClassicHandlerServer().unsupportedClassicPacket(className, content, ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID));
|
||||||
|
else ProtocolBridge.getInstance().getClassicHandlerClient().unsupportedClassicPacket(className, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,56 @@
|
|||||||
|
package github.openautonomousconnection.protocol.packets.v1_0_0.beta;
|
||||||
|
|
||||||
|
import github.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
|
import github.openautonomousconnection.protocol.packets.OACPacket;
|
||||||
|
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||||
|
import me.finn.unlegitlibrary.network.system.packets.PacketHandler;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
public class ValidateDomainPacket extends OACPacket {
|
||||||
|
private Domain domain;
|
||||||
|
private int clientID;
|
||||||
|
|
||||||
|
public ValidateDomainPacket(Domain domain) {
|
||||||
|
this();
|
||||||
|
this.domain = domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidateDomainPacket() {
|
||||||
|
super(6, ProtocolVersion.PV_1_0_0_BETA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsClient()) objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getNetworkClient().getClientID());
|
||||||
|
else setResponseCode(ProtocolBridge.getInstance().getProtocolServer().validateDomain(domain));
|
||||||
|
|
||||||
|
objectOutputStream.writeObject(domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsServer()) clientID = objectInputStream.readInt();
|
||||||
|
domain = (Domain) objectInputStream.readObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
|
||||||
|
super.onResponseCodeRead(packetHandler, objectInputStream);
|
||||||
|
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsServer()) {
|
||||||
|
try {
|
||||||
|
ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID).getConnectionHandler().sendPacket(new ValidateDomainPacket(domain));
|
||||||
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
|
ProtocolBridge.getInstance().getProtocolServer().validationFailed(domain, ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolBridge.getInstance().getProtocolClient().validationCompleted(domain, getResponseCode());
|
||||||
|
}
|
||||||
|
}
|
@@ -44,7 +44,7 @@ public class Classic_MessagePacket extends OACPacket {
|
|||||||
String message = objectInputStream.readUTF();
|
String message = objectInputStream.readUTF();
|
||||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||||
|
|
||||||
ProtocolBridge.getInstance().getClassicHandlerServer().handleMessage(ProtocolBridge.getInstance().getProtocolServer().getNetworkServer().getConnectionHandlerByID(clientID), message, protocolVersion);
|
ProtocolBridge.getInstance().getClassicHandlerServer().handleMessage(ProtocolBridge.getInstance().getProtocolServer().getClientByID(clientID), message, protocolVersion);
|
||||||
} else {
|
} else {
|
||||||
clientID = objectInputStream.readInt();
|
clientID = objectInputStream.readInt();
|
||||||
String message = objectInputStream.readUTF();
|
String message = objectInputStream.readUTF();
|
||||||
|
@@ -2,15 +2,19 @@ package github.openautonomousconnection.protocol.side.client;
|
|||||||
|
|
||||||
import github.openautonomousconnection.protocol.ProtocolBridge;
|
import github.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
import github.openautonomousconnection.protocol.packets.OACPacket;
|
import github.openautonomousconnection.protocol.packets.OACPacket;
|
||||||
|
import github.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateDomainPacket;
|
||||||
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import github.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.finn.unlegitlibrary.network.system.client.NetworkClient;
|
import me.finn.unlegitlibrary.network.system.client.NetworkClient;
|
||||||
import me.finn.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
|
import me.finn.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
|
||||||
import me.finn.unlegitlibrary.utils.DefaultMethodsOverrider;
|
import me.finn.unlegitlibrary.utils.DefaultMethodsOverrider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ProtocolClient extends DefaultMethodsOverrider {
|
public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||||
private ProtocolVersion serverVersion = null;
|
private ProtocolVersion serverVersion = null;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -78,6 +82,10 @@ public class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
return getServerVersion() == targetVersion || getServerVersion().getCompatibleVersions().contains(targetVersion);
|
return getServerVersion() == targetVersion || getServerVersion().getCompatibleVersions().contains(targetVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void validateDomain(Domain domain) throws IOException, ClassNotFoundException {
|
||||||
|
networkClient.sendPacket(new ValidateDomainPacket(domain));
|
||||||
|
}
|
||||||
|
|
||||||
public ProtocolClient(File caFolder, File certificatesClientFolder, File certificatesKeyFolder) {
|
public ProtocolClient(File caFolder, File certificatesClientFolder, File certificatesKeyFolder) {
|
||||||
if (!caFolder.exists()) caFolder.mkdirs();
|
if (!caFolder.exists()) caFolder.mkdirs();
|
||||||
if (!certificatesClientFolder.exists()) certificatesClientFolder.mkdirs();
|
if (!certificatesClientFolder.exists()) certificatesClientFolder.mkdirs();
|
||||||
@@ -89,4 +97,7 @@ public class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
setRootCAFolder(caFolder).setClientCertificatesFolder(certificatesClientFolder, certificatesKeyFolder).
|
setRootCAFolder(caFolder).setClientCertificatesFolder(certificatesClientFolder, certificatesKeyFolder).
|
||||||
build();
|
build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void validationCompleted(Domain domain, DNSResponseCode responseCode);
|
||||||
|
public abstract void getDestinationCompleted(Domain domain, String destination, DNSResponseCode validationResponse);
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
package github.openautonomousconnection.protocol.side.server;
|
package github.openautonomousconnection.protocol.side.server;
|
||||||
|
|
||||||
import github.openautonomousconnection.protocol.ProtocolBridge;
|
import github.openautonomousconnection.protocol.ProtocolBridge;
|
||||||
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||||
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
import github.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.finn.unlegitlibrary.file.ConfigurationManager;
|
import me.finn.unlegitlibrary.file.ConfigurationManager;
|
||||||
|
import me.finn.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||||
import me.finn.unlegitlibrary.network.system.server.NetworkServer;
|
import me.finn.unlegitlibrary.network.system.server.NetworkServer;
|
||||||
import me.finn.unlegitlibrary.utils.DefaultMethodsOverrider;
|
import me.finn.unlegitlibrary.utils.DefaultMethodsOverrider;
|
||||||
|
|
||||||
@@ -60,4 +62,7 @@ public abstract class ProtocolServer extends DefaultMethodsOverrider {
|
|||||||
public abstract String getDomainDestination(Domain domain);
|
public abstract String getDomainDestination(Domain domain);
|
||||||
public abstract String getSubnameDestination(Domain domain, String subname);
|
public abstract String getSubnameDestination(Domain domain, String subname);
|
||||||
public abstract String getTLNInfoSite(String topLevelName);
|
public abstract String getTLNInfoSite(String topLevelName);
|
||||||
|
public abstract DNSResponseCode validateDomain(Domain requestedDomain);
|
||||||
|
public abstract void validationFailed(Domain domain, ConnectedProtocolClient client, Exception exception);
|
||||||
|
public abstract void getDomainDestinationFailed(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception);
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,19 @@ package github.openautonomousconnection.protocol.versions.v1_0_0.beta;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum DNSResponseCode {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public enum DNSResponseCode implements Serializable {
|
||||||
RESPONSE_NOT_REQUIRED(0, "Response code not required"),
|
RESPONSE_NOT_REQUIRED(0, "Response code not required"),
|
||||||
|
RESPONSE_INVALID_REQUEST(1, "Invalid request"),
|
||||||
|
|
||||||
RESPONSE_AUTH_SUCCESS(1, "Auth success"),
|
RESPONSE_AUTH_SUCCESS(4, "Auth success"),
|
||||||
RESPONSE_AUTH_FAILED(2, "Auth failed"),
|
RESPONSE_AUTH_FAILED(5, "Auth failed"),
|
||||||
|
|
||||||
RESPONSE_DOMAIN_EXIST(100, "Domain exist"),
|
RESPONSE_DOMAIN_NAME_EXIST(100, "Domainname exist"),
|
||||||
RESPONSE_DOMAIN_NOT_EXIST(101, "Domain does not exist"),
|
RESPONSE_DOMAIN_NAME_NOT_EXIST(101, "Domainname does not exist"),
|
||||||
RESPONSE_DOMAIN_CREATED(105, "Domain created"),
|
RESPONSE_DOMAIN_NAME_CREATED(105, "Domainname created"),
|
||||||
RESPONSE_DOMAIN_DELETED(106, "Domain deleted"),
|
RESPONSE_DOMAIN_NAME_DELETED(106, "Domainname deleted"),
|
||||||
|
|
||||||
RESPONSE_DOMAIN_TLN_EXIST(110, "TopLevelName exist"),
|
RESPONSE_DOMAIN_TLN_EXIST(110, "TopLevelName exist"),
|
||||||
RESPONSE_DOMAIN_TLN_NOT_EXIST(111, "TopLevelName does not exist"),
|
RESPONSE_DOMAIN_TLN_NOT_EXIST(111, "TopLevelName does not exist"),
|
||||||
@@ -22,6 +25,9 @@ public enum DNSResponseCode {
|
|||||||
RESPONSE_DOMAIN_SUBNAME_NOT_EXIST(121, "Subname does not exist"),
|
RESPONSE_DOMAIN_SUBNAME_NOT_EXIST(121, "Subname does not exist"),
|
||||||
RESPONSE_DOMAIN_SUBNAME_CREATED(125, "Subname created"),
|
RESPONSE_DOMAIN_SUBNAME_CREATED(125, "Subname created"),
|
||||||
RESPONSE_DOMAIN_SUBNAME_DELETED(126, "Subname deleted"),
|
RESPONSE_DOMAIN_SUBNAME_DELETED(126, "Subname deleted"),
|
||||||
|
|
||||||
|
RESPONSE_DOMAIN_FULLY_EXIST(130, "Full domain exist"),
|
||||||
|
RESPONSE_DOMAIN_FULLY_NOT_EXIST(131, "Full domain does not exist")
|
||||||
;
|
;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@@ -85,7 +85,10 @@ public class Domain implements Serializable {
|
|||||||
domain.getTopLevelName().equalsIgnoreCase(this.topLevelName) && domain.getProtocol().equalsIgnoreCase(this.protocol);
|
domain.getTopLevelName().equalsIgnoreCase(this.topLevelName) && domain.getProtocol().equalsIgnoreCase(this.protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final String getDestination() {
|
public final String getDestination() {
|
||||||
|
if (ProtocolBridge.getInstance().isRunningAsClient()) return DNSResponseCode.RESPONSE_INVALID_REQUEST.toString();
|
||||||
|
|
||||||
if (this.equals(DefaultDomains.DNS_INFO_SITE)) return ProtocolBridge.getInstance().getProtocolServer().getDNSInfoSite();
|
if (this.equals(DefaultDomains.DNS_INFO_SITE)) return ProtocolBridge.getInstance().getProtocolServer().getDNSInfoSite();
|
||||||
if (this.equals(DefaultDomains.DNS_REGISTER_SITE)) return ProtocolBridge.getInstance().getProtocolServer().getDNSRegisterSite();
|
if (this.equals(DefaultDomains.DNS_REGISTER_SITE)) return ProtocolBridge.getInstance().getProtocolServer().getDNSRegisterSite();
|
||||||
if (this.name.equalsIgnoreCase("about") && this.protocol.equalsIgnoreCase("oac")) return ProtocolBridge.getInstance().getProtocolServer().getTLNInfoSite(topLevelName);
|
if (this.name.equalsIgnoreCase("about") && this.protocol.equalsIgnoreCase("oac")) return ProtocolBridge.getInstance().getProtocolServer().getTLNInfoSite(topLevelName);
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
package github.openautonomousconnection.protocol.versions.v1_0_0.classic;
|
package github.openautonomousconnection.protocol.versions.v1_0_0.classic;
|
||||||
|
|
||||||
|
import github.openautonomousconnection.protocol.side.server.ConnectedProtocolClient;
|
||||||
import me.finn.unlegitlibrary.network.system.server.ConnectionHandler;
|
import me.finn.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public abstract class ClassicHandlerServer {
|
public abstract class ClassicHandlerServer {
|
||||||
public abstract void handleMessage(ConnectionHandler connectionHandler, String message, Classic_ProtocolVersion protocolVersion);
|
public abstract void handleMessage(ConnectedProtocolClient client, String message, Classic_ProtocolVersion protocolVersion);
|
||||||
public abstract Classic_Domain getDomain(Classic_RequestDomain requestDomain) throws SQLException;
|
public abstract Classic_Domain getDomain(Classic_RequestDomain requestDomain) throws SQLException;
|
||||||
public abstract Classic_Domain ping(Classic_RequestDomain requestDomain) throws SQLException;
|
public abstract Classic_Domain ping(Classic_RequestDomain requestDomain) throws SQLException;
|
||||||
|
public abstract void unsupportedClassicPacket(String className, Object[] content, ConnectedProtocolClient client);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user