Renamed DNS to INS
This commit is contained in:
@@ -4,7 +4,7 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.packets.Packet;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseCode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
@@ -25,7 +25,7 @@ public abstract class OACPacket extends Packet {
|
||||
/**
|
||||
* The response code for the packet, defaulting to RESPONSE_NOT_REQUIRED.
|
||||
*/
|
||||
private DNSResponseCode responseCode = DNSResponseCode.RESPONSE_NOT_REQUIRED;
|
||||
private INSResponseCode responseCode = INSResponseCode.RESPONSE_NOT_REQUIRED;
|
||||
|
||||
/**
|
||||
* Constructor for OACPacket.
|
||||
@@ -41,18 +41,18 @@ public abstract class OACPacket extends Packet {
|
||||
/**
|
||||
* Gets the response code for the packet.
|
||||
*
|
||||
* @return The DNSResponseCode associated with the packet.
|
||||
* @return The INSResponseCode associated with the packet.
|
||||
*/
|
||||
protected final DNSResponseCode getResponseCode() {
|
||||
protected final INSResponseCode getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the response code for the packet.
|
||||
*
|
||||
* @param responseCode The DNSResponseCode to set for the packet.
|
||||
* @param responseCode The INSResponseCode to set for the packet.
|
||||
*/
|
||||
protected final void setResponseCode(DNSResponseCode responseCode) {
|
||||
protected final void setResponseCode(INSResponseCode responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ public abstract class OACPacket extends Packet {
|
||||
|
||||
// Read the response code if the protocol version is not classic
|
||||
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC)
|
||||
responseCode = (DNSResponseCode) objectInputStream.readObject();
|
||||
else responseCode = DNSResponseCode.RESPONSE_NOT_REQUIRED;
|
||||
responseCode = (INSResponseCode) objectInputStream.readObject();
|
||||
else responseCode = INSResponseCode.RESPONSE_NOT_REQUIRED;
|
||||
|
||||
// Call the response code read handler
|
||||
onResponseCodeRead(packetHandler, objectInputStream);
|
||||
|
||||
@@ -6,12 +6,12 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.NetworkUtils;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.side.client.events.ConnectedToProtocolDNSServerEvent;
|
||||
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.dns.events.ConnectedProtocolClientEvent;
|
||||
import org.openautonomousconnection.protocol.side.client.events.ConnectedToProtocolINSServerEvent;
|
||||
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.ins.events.ConnectedProtocolClientEvent;
|
||||
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseCode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -33,7 +33,7 @@ public final class AuthPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsDNSServer()) {
|
||||
if (protocolBridge.isRunningAsINSServer()) {
|
||||
objectOutputStream.writeObject(protocolBridge.getProtocolVersion());
|
||||
|
||||
// Read ca files
|
||||
@@ -41,22 +41,22 @@ public final class AuthPacket extends OACPacket {
|
||||
String caPem = "N/A";
|
||||
String caSrl = "N/A";
|
||||
try {
|
||||
objectOutputStream.writeUTF(protocolBridge.getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress());
|
||||
objectOutputStream.writeUTF(protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress());
|
||||
|
||||
caKey = FileUtils.readFileFull(new File(
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().privateCAFolder,
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".key"));
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().privateCAFolder,
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".key"));
|
||||
|
||||
caPem = FileUtils.readFileFull(new File(
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().publicCAFolder,
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".pem"));
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().publicCAFolder,
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".pem"));
|
||||
|
||||
caSrl = FileUtils.readFileFull(new File(
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().publicCAFolder,
|
||||
protocolBridge.getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".srl"));
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().publicCAFolder,
|
||||
protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".srl"));
|
||||
} catch (Exception exception) {
|
||||
protocolBridge.getLogger().exception("Failed to read ca-files", exception);
|
||||
setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
}
|
||||
|
||||
// Send ca data
|
||||
@@ -64,27 +64,27 @@ public final class AuthPacket extends OACPacket {
|
||||
objectOutputStream.writeUTF(caPem);
|
||||
objectOutputStream.writeUTF(caSrl);
|
||||
} else if (protocolBridge.isRunningAsClient()) {
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientDNSConnection().getClientID());
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
|
||||
objectOutputStream.writeObject(protocolBridge.getProtocolVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsDNSServer() || protocolBridge.isRunningAsWebServer()) {
|
||||
if (protocolBridge.isRunningAsINSServer() || protocolBridge.isRunningAsWebServer()) {
|
||||
int clientID = objectInputStream.readInt();
|
||||
ProtocolVersion clientVersion = (ProtocolVersion) objectInputStream.readObject();
|
||||
ConnectionHandler connectionHandler = protocolBridge.getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID);
|
||||
ConnectionHandler connectionHandler = protocolBridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID);
|
||||
|
||||
if (!protocolBridge.isVersionSupported(clientVersion)) {
|
||||
setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
connectionHandler.disconnect();
|
||||
return;
|
||||
} else setResponseCode(DNSResponseCode.RESPONSE_AUTH_SUCCESS);
|
||||
} else setResponseCode(INSResponseCode.RESPONSE_AUTH_SUCCESS);
|
||||
|
||||
|
||||
if (protocolBridge.isRunningAsDNSServer()) {
|
||||
ConnectedProtocolClient client = protocolBridge.getProtocolDNSServer().getClientByID(clientID);
|
||||
if (protocolBridge.isRunningAsINSServer()) {
|
||||
ConnectedProtocolClient client = protocolBridge.getProtocolINSServer().getClientByID(clientID);
|
||||
client.setClientVersion(clientVersion);
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedProtocolClientEvent(client));
|
||||
} else {
|
||||
@@ -95,10 +95,10 @@ public final class AuthPacket extends OACPacket {
|
||||
ProtocolVersion serverVersion = (ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
if (!protocolBridge.isVersionSupported(serverVersion)) {
|
||||
setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
protocolBridge.getProtocolClient().getClientDNSConnection().disconnect();
|
||||
setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
} else setResponseCode(DNSResponseCode.RESPONSE_AUTH_SUCCESS);
|
||||
} else setResponseCode(INSResponseCode.RESPONSE_AUTH_SUCCESS);
|
||||
|
||||
String caPrefix = objectInputStream.readUTF();
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class AuthPacket extends OACPacket {
|
||||
String caSrl = objectInputStream.readUTF();
|
||||
|
||||
if (caKey.equalsIgnoreCase("N/A") || caPem.equalsIgnoreCase("N/A") || caSrl.equalsIgnoreCase("N/A"))
|
||||
setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
else {
|
||||
|
||||
File caPemFile = new File(protocolBridge.getProtocolClient().getFolderStructure().publicCAFolder, caPrefix + ".pem");
|
||||
@@ -124,12 +124,12 @@ public final class AuthPacket extends OACPacket {
|
||||
FileUtils.writeFile(caKeyFile, caSrl);
|
||||
} catch (Exception exception) {
|
||||
protocolBridge.getLogger().exception("Failed to create/save ca-files", exception);
|
||||
setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
protocolBridge.getProtocolClient().setServerVersion(serverVersion);
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolDNSServerEvent());
|
||||
protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolINSServerEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,31 +4,31 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public final class GetDestinationPacket extends OACPacket {
|
||||
private Domain domain;
|
||||
private InfoName infoName;
|
||||
private int clientID;
|
||||
private DNSResponseCode validationResponse;
|
||||
private INSResponseCode validationResponse;
|
||||
private String destination;
|
||||
|
||||
// DNS-Server Constructor
|
||||
public GetDestinationPacket(Domain domain, DNSResponseCode validationResponse, String destination) {
|
||||
// INS-Server Constructor
|
||||
public GetDestinationPacket(InfoName infoName, INSResponseCode validationResponse, String destination) {
|
||||
this();
|
||||
this.domain = domain;
|
||||
this.infoName = infoName;
|
||||
this.validationResponse = validationResponse;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
// Client Constructor
|
||||
public GetDestinationPacket(Domain domain, DNSResponseCode validationResponse) {
|
||||
public GetDestinationPacket(InfoName infoName, INSResponseCode validationResponse) {
|
||||
this();
|
||||
this.domain = domain;
|
||||
this.infoName = infoName;
|
||||
this.validationResponse = validationResponse;
|
||||
this.destination = destination;
|
||||
}
|
||||
@@ -41,13 +41,13 @@ public final class GetDestinationPacket extends OACPacket {
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
if (validationResponse != DNSResponseCode.RESPONSE_DOMAIN_FULLY_EXIST) return;
|
||||
if (validationResponse != INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST) return;
|
||||
|
||||
objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID());
|
||||
objectOutputStream.writeObject(domain);
|
||||
objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getClientID());
|
||||
objectOutputStream.writeObject(infoName);
|
||||
objectOutputStream.writeObject(validationResponse);
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
objectOutputStream.writeObject(domain);
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
objectOutputStream.writeObject(infoName);
|
||||
objectOutputStream.writeObject(validationResponse);
|
||||
objectOutputStream.writeUTF(destination);
|
||||
}
|
||||
@@ -55,16 +55,16 @@ public final class GetDestinationPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
domain = (Domain) objectInputStream.readObject();
|
||||
validationResponse = (DNSResponseCode) objectInputStream.readObject();
|
||||
infoName = (InfoName) objectInputStream.readObject();
|
||||
validationResponse = (INSResponseCode) objectInputStream.readObject();
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
domain = (Domain) objectInputStream.readObject();
|
||||
validationResponse = (DNSResponseCode) objectInputStream.readObject();
|
||||
infoName = (InfoName) objectInputStream.readObject();
|
||||
validationResponse = (INSResponseCode) objectInputStream.readObject();
|
||||
destination = objectInputStream.readUTF();
|
||||
|
||||
ProtocolBridge.getInstance().getProtocolClient().getDestinationCompleted(domain, destination, validationResponse);
|
||||
ProtocolBridge.getInstance().getProtocolClient().getDestinationCompleted(infoName, destination, validationResponse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ public final class GetDestinationPacket extends OACPacket {
|
||||
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
|
||||
super.onResponseCodeRead(packetHandler, objectInputStream);
|
||||
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (validationResponse != DNSResponseCode.RESPONSE_DOMAIN_FULLY_EXIST) return;
|
||||
destination = domain.getDestination();
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
if (validationResponse != INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST) return;
|
||||
destination = infoName.getDestination();
|
||||
|
||||
try {
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new GetDestinationPacket(domain, validationResponse, destination));
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new GetDestinationPacket(infoName, validationResponse, destination));
|
||||
} catch (IOException | ClassNotFoundException exception) {
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().domainDestinationPacketFailedSend(ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), domain, validationResponse, exception);
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().infoNameDestinationPacketFailedSend(ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID), infoName, validationResponse, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseCode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
@@ -29,18 +29,18 @@ public final class UnsupportedClassicPacket extends OACPacket {
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsClient())
|
||||
objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID());
|
||||
objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getClientID());
|
||||
|
||||
objectOutputStream.writeUTF(unsupportedClassicPacket.getName());
|
||||
objectOutputStream.writeInt(content.length);
|
||||
for (Object o : content) objectOutputStream.writeObject(o);
|
||||
setResponseCode(DNSResponseCode.RESPONSE_NOT_REQUIRED);
|
||||
setResponseCode(INSResponseCode.RESPONSE_NOT_REQUIRED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
int clientID = 0;
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) clientID = objectInputStream.readInt();
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) clientID = objectInputStream.readInt();
|
||||
String className = objectInputStream.readUTF();
|
||||
int size = objectInputStream.readInt();
|
||||
content = new Object[size];
|
||||
@@ -49,12 +49,12 @@ public final class UnsupportedClassicPacket extends OACPacket {
|
||||
content[i] = objectInputStream.readObject();
|
||||
}
|
||||
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer())
|
||||
ProtocolBridge.getInstance().getClassicHandlerDNSServer().unsupportedClassicPacket(className, content, ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID));
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer())
|
||||
ProtocolBridge.getInstance().getClassicHandlerINSServer().unsupportedClassicPacket(className, content, ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID));
|
||||
else if (ProtocolBridge.getInstance().isRunningAsClient())
|
||||
ProtocolBridge.getInstance().getClassicHandlerClient().unsupportedClassicPacket(className, content);
|
||||
else if (ProtocolBridge.getInstance().isRunningAsWebServer())
|
||||
ProtocolBridge.getInstance().getClassicHandlerWebServer().unsupportedClassicPacket(className, content, ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID));
|
||||
ProtocolBridge.getInstance().getClassicHandlerWebServer().unsupportedClassicPacket(className, content, ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,55 +4,55 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public final class ValidateDomainPacket extends OACPacket {
|
||||
private Domain domain;
|
||||
public final class ValidateInfoNamePacket extends OACPacket {
|
||||
private InfoName infoName;
|
||||
private int clientID;
|
||||
private ProtocolBridge protocolBridge;
|
||||
|
||||
public ValidateDomainPacket(Domain domain, ProtocolBridge protocolBridge) {
|
||||
public ValidateInfoNamePacket(InfoName infoName, ProtocolBridge protocolBridge) {
|
||||
this();
|
||||
this.domain = domain;
|
||||
this.infoName = infoName;
|
||||
this.protocolBridge = protocolBridge;
|
||||
}
|
||||
|
||||
public ValidateDomainPacket() {
|
||||
public ValidateInfoNamePacket() {
|
||||
super(6, ProtocolVersion.PV_1_0_0_BETA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsClient())
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientDNSConnection().getClientID());
|
||||
else if (protocolBridge.isRunningAsDNSServer())
|
||||
setResponseCode(protocolBridge.getProtocolDNSServer().validateDomain(domain));
|
||||
objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
|
||||
else if (protocolBridge.isRunningAsINSServer())
|
||||
setResponseCode(protocolBridge.getProtocolINSServer().validateInfoName(infoName));
|
||||
|
||||
objectOutputStream.writeObject(domain);
|
||||
objectOutputStream.writeObject(infoName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (protocolBridge.isRunningAsDNSServer()) clientID = objectInputStream.readInt();
|
||||
domain = (Domain) objectInputStream.readObject();
|
||||
if (protocolBridge.isRunningAsINSServer()) clientID = objectInputStream.readInt();
|
||||
infoName = (InfoName) objectInputStream.readObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
|
||||
super.onResponseCodeRead(packetHandler, objectInputStream);
|
||||
|
||||
if (protocolBridge.isRunningAsDNSServer()) {
|
||||
if (protocolBridge.isRunningAsINSServer()) {
|
||||
try {
|
||||
protocolBridge.getProtocolDNSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new ValidateDomainPacket(domain, protocolBridge));
|
||||
protocolBridge.getProtocolINSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new ValidateInfoNamePacket(infoName, protocolBridge));
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
protocolBridge.getProtocolDNSServer().validationPacketSendFailed(domain, protocolBridge.getProtocolDNSServer().getClientByID(clientID), e);
|
||||
protocolBridge.getProtocolINSServer().validationPacketSendFailed(infoName, protocolBridge.getProtocolINSServer().getClientByID(clientID), e);
|
||||
}
|
||||
|
||||
} else if (protocolBridge.isRunningAsClient())
|
||||
protocolBridge.getProtocolClient().validationCompleted(domain, getResponseCode());
|
||||
protocolBridge.getProtocolClient().validationCompleted(infoName, getResponseCode());
|
||||
}
|
||||
}
|
||||
@@ -35,12 +35,12 @@ public final class Classic_DomainPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
objectOutputStream.writeObject(domain);
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
}
|
||||
@@ -50,30 +50,30 @@ public final class Classic_DomainPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
try {
|
||||
domain = ProtocolBridge.getInstance().getClassicHandlerDNSServer().getDomain(requestDomain);
|
||||
domain = ProtocolBridge.getInstance().getClassicHandlerINSServer().getDomain(requestDomain);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
|
||||
if (ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID).supportClientClassic())
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_DomainPacket(clientID, requestDomain, domain));
|
||||
if (ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID).supportClientClassic())
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_DomainPacket(clientID, requestDomain, domain));
|
||||
else
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}));
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}));
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
domain = (Classic_Domain) objectInputStream.readObject();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsWebServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
|
||||
@@ -27,10 +27,10 @@ public final class Classic_MessagePacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer())
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer() || ProtocolBridge.getInstance().isRunningAsWebServer())
|
||||
objectOutputStream.writeInt(clientID);
|
||||
else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ public final class Classic_MessagePacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
String message = objectInputStream.readUTF();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
ProtocolBridge.getInstance().getClassicHandlerDNSServer().handleMessage(ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), message, protocolVersion);
|
||||
ProtocolBridge.getInstance().getClassicHandlerINSServer().handleMessage(ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID), message, protocolVersion);
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
String message = objectInputStream.readUTF();
|
||||
@@ -57,7 +57,7 @@ public final class Classic_MessagePacket extends OACPacket {
|
||||
String message = objectInputStream.readUTF();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
ProtocolBridge.getInstance().getClassicHandlerWebServer().handleMessage(ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), message, protocolVersion);
|
||||
ProtocolBridge.getInstance().getClassicHandlerWebServer().handleMessage(ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID), message, protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseCode;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_PingPacketReceivedEvent;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
|
||||
@@ -38,13 +38,13 @@ public final class Classic_PingPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
objectOutputStream.writeObject(domain);
|
||||
objectOutputStream.writeBoolean(reachable);
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
|
||||
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getClientID();
|
||||
objectOutputStream.writeInt(clientID);
|
||||
objectOutputStream.writeObject(requestDomain);
|
||||
}
|
||||
@@ -54,23 +54,23 @@ public final class Classic_PingPacket extends OACPacket {
|
||||
|
||||
@Override
|
||||
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
|
||||
if (ProtocolBridge.getInstance().isRunningAsINSServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
try {
|
||||
domain = ProtocolBridge.getInstance().getClassicHandlerDNSServer().ping(requestDomain);
|
||||
domain = ProtocolBridge.getInstance().getClassicHandlerINSServer().ping(requestDomain);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
reachable = domain != null;
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
if (ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID).supportClientClassic())
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_PingPacket(requestDomain, domain, reachable));
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
if (ProtocolBridge.getInstance().getProtocolINSServer().getClientByID(clientID).supportClientClassic())
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_PingPacket(requestDomain, domain, reachable));
|
||||
else
|
||||
ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain, domain, reachable}));
|
||||
ProtocolBridge.getInstance().getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain, domain, reachable}));
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsClient()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
@@ -78,8 +78,8 @@ public final class Classic_PingPacket extends OACPacket {
|
||||
boolean reachable = objectInputStream.readBoolean();
|
||||
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
|
||||
|
||||
ProtocolBridge.getInstance().getProtocolClient().validationCompleted(domain.getDomain(), reachable ? DNSResponseCode.RESPONSE_DOMAIN_FULLY_EXIST : DNSResponseCode.RESPONSE_DOMAIN_FULLY_NOT_EXIST);
|
||||
ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
ProtocolBridge.getInstance().getProtocolClient().validationCompleted(domain.getInfoName(), reachable ? INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST : INSResponseCode.RESPONSE_INFONAME_FULLY_NOT_EXIST);
|
||||
ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
|
||||
} else if (ProtocolBridge.getInstance().isRunningAsWebServer()) {
|
||||
clientID = objectInputStream.readInt();
|
||||
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
|
||||
|
||||
Reference in New Issue
Block a user