Renamed DNS to INS

This commit is contained in:
Finn
2025-12-08 09:59:58 +01:00
parent f5afd9c3e7
commit 2ea23885fd
34 changed files with 573 additions and 574 deletions

View File

@@ -5,20 +5,20 @@ import lombok.Getter;
import lombok.Setter;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.listeners.ClientListener;
import org.openautonomousconnection.protocol.listeners.DNSServerListener;
import org.openautonomousconnection.protocol.listeners.INSServerListener;
import org.openautonomousconnection.protocol.listeners.WebServerListener;
import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.GetDestinationPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateDomainPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateInfoNamePacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_DomainPacket;
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
import org.openautonomousconnection.protocol.side.dns.ProtocolDNSServer;
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerINSServer;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ClientListener;
@@ -53,7 +53,7 @@ public final class ProtocolBridge {
* The protocol side instances
*/
@Getter
private ProtocolDNSServer protocolDNSServer;
private ProtocolINSServer protocolINSServer;
/**
* The protocol side instances
@@ -68,11 +68,11 @@ public final class ProtocolBridge {
private ProtocolWebServer protocolWebServer;
/**
* The classic protocol handlers for dns server side
* The classic protocol handlers for INS server side
*/
@Getter
@Setter
private ClassicHandlerDNSServer classicHandlerDNSServer;
private ClassicHandlerINSServer classicHandlerINSServer;
/**
* The classic protocol handlers for web server side
@@ -96,19 +96,19 @@ public final class ProtocolBridge {
private Proxy proxy;
/**
* Initialize the ProtocolBridge instance for the DNS server side
* Initialize the ProtocolBridge instance for the INS server side
*
* @param protocolDNSServer The ProtocolDNSServer instance
* @param protocolINSServer The ProtocolINSServer instance
* @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public ProtocolBridge(ProtocolDNSServer protocolDNSServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public ProtocolBridge(ProtocolINSServer protocolINSServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolDNSServer = protocolDNSServer;
this.protocolDNSServer.setProtocolBridge(this);
this.protocolINSServer = protocolINSServer;
this.protocolINSServer.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -189,14 +189,14 @@ public final class ProtocolBridge {
// 1.0.0-BETA packets
AuthPacket v100bAuthPath = new AuthPacket();
UnsupportedClassicPacket v100bUnsupportedClassicPacket = new UnsupportedClassicPacket();
ValidateDomainPacket v100bValidateDomainPacket = new ValidateDomainPacket();
ValidateInfoNamePacket v100BValidateInfoNamePacket = new ValidateInfoNamePacket();
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(v100BValidateInfoNamePacket))
protocolSettings.packetHandler.registerPacket(v100BValidateInfoNamePacket);
if (isPacketSupported(v100bGetDestinationPacket))
protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
}
@@ -211,9 +211,9 @@ public final class ProtocolBridge {
if (isClassicSupported()) protocolSettings.eventManager.registerListener(Classic_ClientListener.class);
else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
// DNS Listeners
if (isRunningAsDNSServer()) {
protocolSettings.eventManager.registerListener(DNSServerListener.class);
// INS Listeners
if (isRunningAsINSServer()) {
protocolSettings.eventManager.registerListener(INSServerListener.class);
protocolSettings.eventManager.unregisterListener(WebServerListener.class);
protocolSettings.eventManager.unregisterListener(ClientListener.class);
}
@@ -221,14 +221,14 @@ public final class ProtocolBridge {
// Web Listeners
if (isRunningAsWebServer()) {
protocolSettings.eventManager.registerListener(WebServerListener.class);
protocolSettings.eventManager.unregisterListener(DNSServerListener.class);
protocolSettings.eventManager.unregisterListener(INSServerListener.class);
protocolSettings.eventManager.unregisterListener(ClientListener.class);
}
// Client Listeners
if (isRunningAsClient()) {
protocolSettings.eventManager.registerListener(ClientListener.class);
protocolSettings.eventManager.unregisterListener(DNSServerListener.class);
protocolSettings.eventManager.unregisterListener(INSServerListener.class);
protocolSettings.eventManager.unregisterListener(WebServerListener.class);
}
}
@@ -333,27 +333,27 @@ public final class ProtocolBridge {
return
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT) ||
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_WEB) ||
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_DNS) ||
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_INS) ||
(isRunningAsClient() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_WEB) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_DNS) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_INS) ||
(isRunningAsWebServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL) ||
(isRunningAsDNSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.DNS) ||
(isRunningAsDNSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_DNS) ||
(isRunningAsDNSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_DNS) ||
(isRunningAsDNSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL);
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.WEB_INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.CLIENT_INS) ||
(isRunningAsINSServer() && protocolVersion.getProtocolSide() == ProtocolVersion.ProtocolSide.ALL);
}
/**
* Check if the current instance is running as a DNS server
* Check if the current instance is running as a INS server
*
* @return true if the current instance is running as a DNS server, false otherwise
* @return true if the current instance is running as a INS server, false otherwise
*/
public boolean isRunningAsDNSServer() {
return protocolDNSServer != null;
public boolean isRunningAsINSServer() {
return protocolINSServer != null;
}
/**

View File

@@ -41,7 +41,7 @@ public final class ClientListener extends EventListener {
*/
@Listener
public void onDisconnect(ClientDisconnectedEvent event) {
ProtocolBridge.getInstance().getProtocolClient().onDNSDisconnect(event);
ProtocolBridge.getInstance().getProtocolClient().onINSDisconnect(event);
}
}

View File

@@ -6,35 +6,35 @@ import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHan
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
* Listener for DNS server connection events.
* Listener for INS server connection events.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public final class DNSServerListener extends EventListener {
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class INSServerListener extends EventListener {
/**
* Handles the event when a connection handler connects to the DNS server.
* Adds the connected client to the ProtocolBridge's DNS server client list.
* Handles the event when a connection handler connects to the INS server.
* Adds the connected client to the ProtocolBridge's INS server client list.
*
* @param event The connection handler connected event.
*/
@Listener
public void onConnect(ConnectionHandlerConnectedEvent event) {
ProtocolBridge.getInstance().getProtocolDNSServer().getClients().add(new ConnectedProtocolClient(event.getConnectionHandler()));
ProtocolBridge.getInstance().getProtocolINSServer().getClients().add(new ConnectedProtocolClient(event.getConnectionHandler()));
}
/**
* Handles the event when a connection handler disconnects from the DNS server.
* Removes the disconnected client from the ProtocolBridge's DNS server client list.
* Handles the event when a connection handler disconnects from the INS server.
* Removes the disconnected client from the ProtocolBridge's INS server client list.
*
* @param event The connection handler disconnected event.
*/
@Listener
public void onDisconnect(ConnectionHandlerDisconnectedEvent event) {
ProtocolBridge.getInstance().getProtocolDNSServer().getClients().removeIf(client ->
ProtocolBridge.getInstance().getProtocolINSServer().getClients().removeIf(client ->
client.getConnectionHandler().getClientID() == -1);
}

View File

@@ -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);

View File

@@ -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());
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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));
}
}

View File

@@ -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());
}
}

View File

@@ -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();

View File

@@ -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);
}
}
}

View File

@@ -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();

View File

@@ -10,12 +10,12 @@ import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.exceptions.UnsupportedProtocolException;
import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.GetDestinationPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateDomainPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.ValidateInfoNamePacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_DomainPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_PingPacket;
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 org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import java.io.File;
@@ -24,14 +24,14 @@ import java.io.IOException;
import java.security.cert.CertificateException;
/**
* Abstract class defining the client-side protocol operations and interactions with DNS and web servers.
* Abstract class defining the client-side protocol operations and interactions with INS and web servers.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public abstract class ProtocolClient extends DefaultMethodsOverrider {
/**
* Handles everything with DNS-Connection.
* Handles everything with INS-Connection.
*/
private final NetworkClient clientToDNS;
private final NetworkClient clientToINS;
/**
* Manages the folder structure for client certificates.
@@ -57,7 +57,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
private ProtocolBridge protocolBridge;
/**
* Initializes the ProtocolClient, setting up certificate folders and the DNS client connection.
* Initializes the ProtocolClient, setting up certificate folders and the INS client connection.
*
* @throws CertificateException if there are issues with the certificates.
* @throws IOException if there are I/O issues during initialization.
@@ -66,8 +66,8 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
// Initialize and verify certificate folders and files
folderStructure = new ClientCertificateFolderStructure();
// Initialize connection to DNS server
clientToDNS = new NetworkClient.ClientBuilder().setLogger(protocolBridge.getLogger()).setProxy(protocolBridge.getProxy()).
// Initialize connection to INS server
clientToINS = new NetworkClient.ClientBuilder().setLogger(protocolBridge.getLogger()).setProxy(protocolBridge.getProxy()).
setHost(protocolBridge.getProtocolSettings().host).setPort(protocolBridge.getProtocolSettings().port).
setPacketHandler(protocolBridge.getProtocolSettings().packetHandler).setEventManager(protocolBridge.getProtocolSettings().eventManager).
setRootCAFolder(folderStructure.publicCAFolder).setClientCertificatesFolder(folderStructure.publicClientFolder, folderStructure.privateClientFolder).
@@ -75,23 +75,23 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
}
/**
* Gets the DNS connection client.
* Gets the INS connection client.
*
* @return the NetworkClient handling the DNS connection.
* @return the NetworkClient handling the INS connection.
*/
public final NetworkClient getClientDNSConnection() {
return clientToDNS;
public final NetworkClient getClientINSConnection() {
return clientToINS;
}
/**
* Creates a web connection to the specified domain and ports.
* Creates a web connection to the specified InfoName and ports.
*
* @param domain the target domain for the web connection.
* @param infoName the target InfoName for the web connection.
* @param pipelinePort the port used for the pipeline connection.
* @param webPort the port used for the web connection.
* @throws Exception if there are issues creating the web connection or if the protocol is unsupported.
*/
public final void createWebConnection(Domain domain, int pipelinePort, int webPort) throws Exception {
public final void createWebConnection(InfoName infoName, int pipelinePort, int webPort) throws Exception {
// Ensure the protocol supports web connections
if (!protocolBridge.isProtocolSupported(ProtocolVersion.Protocol.OAC))
throw new UnsupportedProtocolException();
@@ -107,7 +107,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
}
// Verify necessary certificate files exist
webClient = new WebClient(domain, pipelinePort, webPort, this);
webClient = new WebClient(infoName, pipelinePort, webPort, this);
}
/**
@@ -162,12 +162,12 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
}
/**
* Handles DNS disconnection events, resetting the server version and closing the web client connection if necessary.
* Handles INS disconnection events, resetting the server version and closing the web client connection if necessary.
*
* @param event the ClientDisconnectedEvent triggered on DNS disconnection.
* @param event the ClientDisconnectedEvent triggered on INS disconnection.
*/
public final void onDNSDisconnect(ClientDisconnectedEvent event) {
// Reset server version on DNS disconnect
public final void onINSDisconnect(ClientDisconnectedEvent event) {
// Reset server version on INS disconnect
serverVersion = null;
// Close web client connection if it exists
@@ -302,36 +302,36 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
}
/**
* Validates the specified domain by sending a validation request to the DNS server.
* Validates the specified InfoName by sending a validation request to the INS server.
*
* @param domain the Domain to validate.
* @param infoName the InfoName to validate.
* @throws IOException if there are I/O issues during the validation process.
* @throws ClassNotFoundException if there are issues with class loading during packet handling.
*/
public final void validateDomain(Domain domain) throws IOException, ClassNotFoundException {
public final void validateInfoName(InfoName infoName) throws IOException, ClassNotFoundException {
// Send Classic_PingPacket if classic protocol is supported
Classic_PingPacket cPingPacket = new Classic_PingPacket(new Classic_RequestDomain(domain.getName(), domain.getTopLevelName(), domain.getPath()), null, false);
if (protocolBridge.isClassicSupported()) clientToDNS.sendPacket(cPingPacket);
Classic_PingPacket cPingPacket = new Classic_PingPacket(new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath()), null, false);
if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cPingPacket);
// Send ValidateDomainPacket
clientToDNS.sendPacket(new ValidateDomainPacket(domain, protocolBridge));
// Send ValidateInfoNamePacket
clientToINS.sendPacket(new ValidateInfoNamePacket(infoName, protocolBridge));
}
/**
* Requests the destination for the specified domain from the DNS server.
* Requests the destination for the specified InfoName from the INS server.
*
* @param domain the Domain for which to request the destination.
* @param responseCode the expected DNSResponseCode for the request.
* @param infoName the InfoName for which to request the destination.
* @param responseCode the expected INSResponseCode for the request.
* @throws IOException if there are I/O issues during the request process.
* @throws ClassNotFoundException if there are issues with class loading during packet handling.
*/
public final void requestDestination(Domain domain, DNSResponseCode responseCode) throws IOException, ClassNotFoundException {
public final void requestInfoName(InfoName infoName, INSResponseCode responseCode) throws IOException, ClassNotFoundException {
// Send Classic_DomainPacket if classic protocol is supported
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket(0, new Classic_RequestDomain(domain.getName(), domain.getTopLevelName(), domain.getPath()), null);
if (protocolBridge.isClassicSupported()) clientToDNS.sendPacket(cDomainPacket);
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket(0, new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath()), null);
if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cDomainPacket);
// Send GetDestinationPacket
clientToDNS.sendPacket(new GetDestinationPacket(domain, responseCode));
clientToINS.sendPacket(new GetDestinationPacket(infoName, responseCode));
}
/**
@@ -343,21 +343,21 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
}
/**
* Callback method invoked when domain validation is completed.
* Callback method invoked when InfoName validation is completed.
*
* @param domain the Domain that was validated.
* @param responseCode the DNSResponseCode resulting from the validation.
* @param infoName the InfoName that was validated.
* @param responseCode the INSResponseCode resulting from the validation.
*/
public abstract void validationCompleted(Domain domain, DNSResponseCode responseCode);
public abstract void validationCompleted(InfoName infoName, INSResponseCode responseCode);
/**
* Callback method invoked when the destination retrieval is completed.
*
* @param domain the Domain for which the destination was requested.
* @param infoName the InfoName for which the destination was requested.
* @param destination the retrieved destination as a string.
* @param validationResponse the DNSResponseCode resulting from the destination retrieval.
* @param validationResponse the INSResponseCode resulting from the destination retrieval.
*/
public abstract void getDestinationCompleted(Domain domain, String destination, DNSResponseCode validationResponse);
public abstract void getDestinationCompleted(InfoName infoName, String destination, INSResponseCode validationResponse);
/**
* Manages the folder structure for client certificates.

View File

@@ -1,12 +1,10 @@
package org.openautonomousconnection.protocol.side.client;
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
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 javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
@@ -23,7 +21,7 @@ import java.net.Socket;
* WebClient handles secure connections to web servers through a pipeline connection.
* It manages SSL/TLS handshakes and data transmission over the established connection.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class WebClient {
/**
* NetworkClient instance for managing the pipeline connection to the web server.
@@ -53,13 +51,13 @@ public final class WebClient {
/**
* Constructs a WebClient instance and establishes a secure connection to the web server.
*
* @param domain The domain information for the web server.
* @param infoName The InfoName information for the web server.
* @param pipelinePort The port for the pipeline connection.
* @param webPort The port for the web server connection.
* @param protocolClient The Protocol Client associated with this protocol client.
* @throws Exception If an error occurs during connection setup.
*/
public WebClient(Domain domain, int pipelinePort, int webPort, ProtocolClient protocolClient) throws Exception {
public WebClient(InfoName infoName, int pipelinePort, int webPort, ProtocolClient protocolClient) throws Exception {
this.protocolClient = protocolClient;
// Initialize and connect the pipeline client
@@ -67,15 +65,15 @@ public final class WebClient {
// Set logger from ProtocolBridge
setLogger(protocolClient.getProtocolBridge().getLogger()).
// Set the destination and port for the pipeline connection
setHost(domain.getDestination()).setPort(pipelinePort).
setHost(infoName.getDestination()).setPort(pipelinePort).
// Configure packet handler and event manager
setPacketHandler(protocolClient.getProtocolBridge().getProtocolSettings().packetHandler).
setEventManager(protocolClient.getProtocolBridge().getProtocolSettings().eventManager).
// Set proxy and ssl parameters from DNS connection settings
setProxy(protocolClient.getProtocolBridge().getProtocolClient().getClientDNSConnection().getProxy()).
setSSLParameters(protocolClient.getProtocolBridge().getProtocolClient().getClientDNSConnection().getSocket().getSSLParameters()).
// Set proxy and ssl parameters from INS connection settings
setProxy(protocolClient.getProtocolBridge().getProtocolClient().getClientINSConnection().getProxy()).
setSSLParameters(protocolClient.getProtocolBridge().getProtocolClient().getClientINSConnection().getSocket().getSSLParameters()).
// Set certificates and folders for SSL
setRootCAFolder(protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().publicCAFolder).
@@ -109,10 +107,10 @@ public final class WebClient {
// Create raw socket and wrap it in SSL socket
if (proxy != null) {
Socket rawSocket = new Socket(proxy);
rawSocket.connect(new InetSocketAddress(domain.getDestination(), webPort), 0);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(rawSocket, domain.getDestination(), webPort, true);
rawSocket.connect(new InetSocketAddress(infoName.getDestination(), webPort), 0);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(rawSocket, infoName.getDestination(), webPort, true);
} else {
tempSocket = (SSLSocket) sslSocketFactory.createSocket(domain.getDestination(), webPort);
tempSocket = (SSLSocket) sslSocketFactory.createSocket(infoName.getDestination(), webPort);
}
clientToWebServer = tempSocket;
@@ -177,7 +175,7 @@ public final class WebClient {
public boolean isConnected() {
return this.clientToWebServer != null && this.clientToWebServer.isConnected() && !this.clientToWebServer.isClosed()
&& this.receiveThread.isAlive() && !this.receiveThread.isInterrupted() &&
protocolClient.getProtocolBridge().getProtocolClient().getClientDNSConnection().isConnected() && clientToWebPipeline.isConnected();
protocolClient.getProtocolBridge().getProtocolClient().getClientINSConnection().isConnected() && clientToWebPipeline.isConnected();
}
/**

View File

@@ -5,8 +5,8 @@ import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
* Event triggered when a client successfully connects to a DNS protocol server.
* Event triggered when a client successfully connects to a INS protocol server.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public final class ConnectedToProtocolDNSServerEvent extends Event {
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class ConnectedToProtocolINSServerEvent extends Event {
}

View File

@@ -1,16 +1,15 @@
package org.openautonomousconnection.protocol.side.dns;
package org.openautonomousconnection.protocol.side.ins;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
import lombok.Getter;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
* Represents a connected protocol client on the DNS server side.
* Represents a connected protocol client on the INS server side.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class ConnectedProtocolClient {
/**
@@ -23,16 +22,16 @@ public final class ConnectedProtocolClient {
* The Protocol Server associated with this protocol client.
*/
@Getter
private final ProtocolDNSServer protocolDNSServer;
private final ProtocolINSServer protocolINSServer;
/**
* The protocol version of the connected client.
*/
private ProtocolVersion clientVersion = null;
public ConnectedProtocolClient(ConnectionHandler connectionHandler, ProtocolDNSServer protocolDNSServer) {
public ConnectedProtocolClient(ConnectionHandler connectionHandler, ProtocolINSServer protocolINSServer) {
this.connectionHandler = connectionHandler;
this.protocolDNSServer = protocolDNSServer;
this.protocolINSServer = protocolINSServer;
}
/**

View File

@@ -1,4 +1,4 @@
package org.openautonomousconnection.protocol.side.dns;
package org.openautonomousconnection.protocol.side.ins;
import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.NetworkServer;
@@ -8,8 +8,8 @@ import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
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.File;
import java.io.FileNotFoundException;
@@ -19,10 +19,10 @@ import java.util.ArrayList;
import java.util.List;
/**
* Abstract class representing a DNS server in the protocol.
* Abstract class representing a INS server in the protocol.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
/**
* The network server instance.
*/
@@ -53,13 +53,13 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
private ProtocolBridge protocolBridge;
/**
* Constructs a ProtocolDNSServer with the specified configuration file.
* Constructs a ProtocolINSServer with the specified configuration file.
*
* @param configFile The configuration file for the DNS server.
* @param configFile The configuration file for the INS server.
* @throws IOException If an I/O error occurs.
* @throws CertificateException If a certificate error occurs.
*/
public ProtocolDNSServer(File configFile) throws IOException, CertificateException {
public ProtocolINSServer(File configFile) throws IOException, CertificateException {
// Ensure the configuration file exists
if (!configFile.exists()) configFile.createNewFile();
@@ -69,12 +69,12 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
// Set default values for configuration properties if not already set
if (!configurationManager.isSet("server.site.info")) {
configurationManager.set("server.site.info", "DNS-SERVER INFO SITE IP");
configurationManager.set("server.site.info", "INS-SERVER INFO SITE IP");
configurationManager.saveProperties();
}
if (!configurationManager.isSet("server.site.register")) {
configurationManager.set("server.site.register", "SERVER IP TO DNS-FRONTENT WEBSITE");
configurationManager.set("server.site.register", "SERVER IP TO INS-FRONTEND WEBSITE");
configurationManager.saveProperties();
}
@@ -162,79 +162,79 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
}
/**
* Gets the DNS information site URL from the configuration.
* Gets the INS information site URL from the configuration.
*
* @return The DNS information site URL.
* @return The INS information site URL.
*/
public final String getDNSInfoSite() {
public final String getINSInfoSite() {
return configurationManager.getString("server.site.info");
}
/**
* Gets the DNS registration site URL from the configuration.
* Gets the INS registration site URL from the configuration.
*
* @return The DNS registration site URL.
* @return The INS registration site URL.
*/
public final String getDNSRegisterSite() {
public final String getINSRegisterSite() {
return configurationManager.getString("server.site.register");
}
/**
* Abstract method to retrieve the list of domains managed by the DNS server.
* Abstract method to retrieve the list of InfoNames managed by the INS server.
*
* @return A list of Domain objects.
* @return A list of InfoName objects.
*/
public abstract List<Domain> getDomains();
public abstract List<InfoName> getInfoNames();
/**
* @param domain The domain to look up.
* @return The destination associated with the domain.
* @see Domain#getDestination()
* Abstract method to get the destination for a given domain.
* @param infoName The InfoName to look up.
* @return The destination associated with the InfoName.
* @see InfoName#getDestination()
* Abstract method to get the destination for a given InfoName.
*/
public abstract String getDomainDestination(Domain domain);
public abstract String getInfoNameDestination(InfoName infoName);
/**
* @param domain The parent domain.
* @param infoName The parent InfoName.
* @param subname The subname to look up.
* @return The destination associated with the subname.
* @see Domain#getDestination()
* Abstract method to get the destination for a given subname under a specific domain.
* @see InfoName#getDestination()
* Abstract method to get the destination for a given subname under a specific InfoName.
*/
public abstract String getSubnameDestination(Domain domain, String subname);
public abstract String getSubnameDestination(InfoName infoName, String subname);
/**
* @param topLevelName The top-level domain name.
* @return The information site URL for the specified top-level domain.
* @see Domain#getDestination()
* Abstract method to get the top-level domain information site URL.
* @param topLevelName The top-level name.
* @return The information site URL for the specified top-level name.
* @see InfoName#getDestination()
* Abstract method to get the top-level name information site URL.
*/
public abstract String getTLNInfoSite(String topLevelName);
/**
* Abstract method to validate a requested domain.
* Abstract method to validate a requested InfoName.
*
* @param requestedDomain The domain to validate.
* @return A DNSResponseCode indicating the result of the validation.
* @param requestedInfoName The InfoName to validate.
* @return A INSResponseCode indicating the result of the validation.
*/
public abstract DNSResponseCode validateDomain(Domain requestedDomain);
public abstract INSResponseCode validateInfoName(InfoName requestedInfoName);
/**
* Abstract method called when a validation packet fails to send.
* @param domain The domain associated with the validation.
* @param infoName The InfoName associated with the validation.
* @param client The connected protocol client.
* @param exception The exception that occurred during sending.
*/
public abstract void validationPacketSendFailed(Domain domain, ConnectedProtocolClient client, Exception exception);
public abstract void validationPacketSendFailed(InfoName infoName, ConnectedProtocolClient client, Exception exception);
/**
* Abstract method called when a domain destination packet fails to send.
* Abstract method called when a InfoName destination packet fails to send.
* @param client The connected protocol client.
* @param domain The domain associated with the packet.
* @param validationResponse The DNS response code from validation.
* @param infoName The InfoName associated with the packet.
* @param validationResponse The INS response code from validation.
* @param exception The exception that occurred during sending.
*/
public abstract void domainDestinationPacketFailedSend(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception);
public abstract void infoNameDestinationPacketFailedSend(ConnectedProtocolClient client, InfoName infoName, INSResponseCode validationResponse, Exception exception);
/**
* Class representing the folder structure for server certificates.
@@ -250,8 +250,8 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
public final File publicCAFolder;
public final File publicServerFolder;
public final String caPrefix = "ca_dns_";
public final String certPrefix = "cert_dns_";
public final String caPrefix = "ca_ins_";
public final String certPrefix = "cert_ins_";
public ServerCertificateFolderStructure() {
certificatesFolder = new File("certificates");

View File

@@ -1,15 +1,15 @@
package org.openautonomousconnection.protocol.side.dns.events;
package org.openautonomousconnection.protocol.side.ins.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
import lombok.Getter;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
* Event triggered when a protocol client connects to the DNS server.
* Event triggered when a protocol client connects to the INS server.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public final class ConnectedProtocolClientEvent extends Event {
@Getter

View File

@@ -14,7 +14,7 @@ public enum ProtocolVersion implements Serializable {
/**
* Support for old OAC-Project => <a href="https://repo.open-autonomous-connection.org/Open-Autonomous-Connection/">*_old</a>
*/
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.WEB_DNS, List.of(Protocol.HTTP)),
PV_1_0_0_CLASSIC("1.0.0", ProtocolType.CLASSIC, ProtocolSide.WEB_INS, List.of(Protocol.HTTP)),
/**
* First Beta Version of OAC-Protocol
@@ -153,12 +153,12 @@ public enum ProtocolVersion implements Serializable {
/**
* Client Side only
*/
CLIENT, // Protocol version can only used on Client
CLIENT,
/**
* DNS Server Side only
* INS Server Side only
*/
DNS,
INS,
/**
* Web Server Side only
@@ -166,14 +166,14 @@ public enum ProtocolVersion implements Serializable {
WEB,
/**
* Both DNS and Web Server Side
* Both INS and Web Server Side
*/
WEB_DNS,
WEB_INS,
/**
* Both Client and DNS Server Side
* Both Client and INS Server Side
*/
CLIENT_DNS,
CLIENT_INS,
/**
* Both Client and Web Server Side

View File

@@ -1,85 +0,0 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.beta;
import lombok.Getter;
import java.io.Serializable;
/**
* Enum representing various DNS response codes and their descriptions.
*/
public enum DNSResponseCode implements Serializable {
/**
* General Responses
*/
RESPONSE_NOT_REQUIRED(0, "Response code not required"),
RESPONSE_INVALID_REQUEST(1, "Invalid request"),
/**
* Authentication Responses
*/
RESPONSE_AUTH_SUCCESS(4, "Auth success"),
RESPONSE_AUTH_FAILED(5, "Auth failed"),
/**
* Domain Responses
*/
RESPONSE_DOMAIN_NAME_EXIST(100, "Domainname exist"),
RESPONSE_DOMAIN_NAME_NOT_EXIST(101, "Domainname does not exist"),
RESPONSE_DOMAIN_NAME_CREATED(105, "Domainname created"),
RESPONSE_DOMAIN_NAME_DELETED(106, "Domainname deleted"),
/**
* Top Level Name Responses
*/
RESPONSE_DOMAIN_TLN_EXIST(110, "TopLevelName exist"),
RESPONSE_DOMAIN_TLN_NOT_EXIST(111, "TopLevelName does not exist"),
RESPONSE_DOMAIN_TLN_CREATED(115, "TopLevelName created"),
RESPONSE_DOMAIN_TLN_DELETED(116, "TopLevelName deleted"),
/**
* Subname Responses
*/
RESPONSE_DOMAIN_SUBNAME_EXIST(120, "Subname exist"),
RESPONSE_DOMAIN_SUBNAME_NOT_EXIST(121, "Subname does not exist"),
RESPONSE_DOMAIN_SUBNAME_CREATED(125, "Subname created"),
RESPONSE_DOMAIN_SUBNAME_DELETED(126, "Subname deleted"),
/**
* Full Domain Responses
*/
RESPONSE_DOMAIN_FULLY_EXIST(130, "Full domain exist"),
RESPONSE_DOMAIN_FULLY_NOT_EXIST(131, "Full domain does not exist");
/**
* The numeric code representing the DNS response.
*/
@Getter
private final int code;
/**
* A brief description of the DNS response code.
*/
@Getter
private final String description;
/**
* Constructor for DNSResponseCode enum.
*
* @param code The numeric code of the response.
* @param description A brief description of the response.
*/
DNSResponseCode(int code, String description) {
this.code = code;
this.description = description;
}
/**
* Returns a string representation of the DNS response code, including its code and description.
*
* @return a string representation of the DNS response code.
*/
@Override
public String toString() {
return "{code=" + code + ";description=" + description + "}";
}
}

View File

@@ -1,172 +0,0 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.beta;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
/**
* Class representing a domain with its components such as subname, name, top-level name, path, query, fragment, and protocol.
*/
public final class Domain implements Serializable {
/**
* The subname of the domain (e.g., "sub" in "sub.example.com").
*/
@Getter
private final String subname;
/**
* The main name of the domain (e.g., "example" in "sub.example.com").
*/
@Getter
private final String name;
/**
* The top-level name of the domain (e.g., "com" in "sub.example.com").
*/
@Getter
private final String topLevelName;
/**
* The path component of the domain (e.g., "path/to/resource" in "example.com/path/to/resource").
*/
@Getter
private String path;
/**
* The query component of the domain (e.g., "key=value" in "example.com/path?key=value").
*/
@Getter
private String query;
/**
* The fragment component of the domain (e.g., "section1" in "example.com/path#section1").
*/
@Getter
private String fragment;
/**
* The protocol of the domain (e.g., "oac" in "oac://example.com").
*/
@Getter
private String protocol;
/**
* Constructs a Domain object by parsing the provided full domain string.
*
* @param fullDomain The full domain string to parse.
* @throws IllegalArgumentException if the domain is invalid.
*/
public Domain(String fullDomain) {
// Remove protocol
String domainWithPath = fullDomain.contains("://") ? fullDomain.split("://", 2)[1] : fullDomain;
this.protocol = fullDomain.contains("://") ? fullDomain.split("://", 2)[0] : "";
if (this.protocol.endsWith("://"))
this.protocol = this.protocol.substring(0, this.protocol.length() - "://".length());
// Cut path
String[] domainPartsAndPath = domainWithPath.split("/", 2);
// Get host and full path
String host = domainPartsAndPath[0];
String fullPath = domainPartsAndPath.length > 1 ? "/" + domainPartsAndPath[1] : "";
// Split domain in labels
List<String> labels = Arrays.asList(host.split("\\."));
if (labels.size() < 2) throw new IllegalArgumentException("Invalid domain: " + host);
// Get subname, name and top-level name
this.topLevelName = labels.getLast();
this.name = labels.get(labels.size() - 2);
this.subname = labels.size() > 2 ? String.join(".", labels.subList(0, labels.size() - 2)) : null;
// Split fragment
if (fullPath.contains("#")) {
this.fragment = "#" + Arrays.stream(fullPath.split("#")).toList().getLast();
fullPath = fullPath.substring(0, fullPath.length() - ("#" + fragment).length());
} else this.fragment = "";
// Split path and query
if (fullPath.contains("?")) {
String[] parts = fullPath.split("\\?", 2);
this.path = parts[0];
this.query = parts[1];
} else {
this.path = fullPath;
this.query = "";
}
// Clean up path, query and fragment
if (this.path.startsWith("/")) this.path = this.path.substring(1);
if (this.path.endsWith("/")) this.path = this.path.substring(0, this.path.length() - 1);
if (this.query.startsWith("?")) this.query = this.query.substring(1);
if (this.fragment.startsWith("#")) this.fragment = this.fragment.substring(1);
}
/**
* Checks if the domain has a subname.
*
* @return true if the domain has a subname, false otherwise.
*/
public boolean hasSubname() {
return subname != null;
}
/**
* Checks if this domain is equal to another object.
* Two domains are considered equal if their subname, name, top-level name, and protocol are equal (case-insensitive).
*
* @return true if the domains are equal, false otherwise.
*/
@Override
public boolean equals(Object obj) {
// Check if the object is an instance of Domain
if (!(obj instanceof Domain domain)) return false;
// Compare subname, name, top-level name, and protocol (case-insensitive)
return domain.getSubname().equalsIgnoreCase(this.subname) && domain.getName().equalsIgnoreCase(this.name) &&
domain.getTopLevelName().equalsIgnoreCase(this.topLevelName) && domain.getProtocol().equalsIgnoreCase(this.protocol);
}
/**
* Returns the destination associated with this domain.
* The destination is determined based on the domain's components and the current protocol context.
*
* @return the destination as a string.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public String getDestination() {
// If running as client or web server, return invalid request
if (ProtocolBridge.getInstance().isRunningAsClient() || ProtocolBridge.getInstance().isRunningAsWebServer())
return DNSResponseCode.RESPONSE_INVALID_REQUEST.toString();
// Handle special default domains
if (this.equals(DefaultDomains.DNS_INFO_SITE))
return ProtocolBridge.getInstance().getProtocolDNSServer().getDNSInfoSite();
if (this.equals(DefaultDomains.DNS_REGISTER_SITE))
return ProtocolBridge.getInstance().getProtocolDNSServer().getDNSRegisterSite();
if (this.name.equalsIgnoreCase("about") && this.protocol.equalsIgnoreCase("oac"))
return ProtocolBridge.getInstance().getProtocolDNSServer().getTLNInfoSite(topLevelName);
// Return destination based on whether subname exists
return !hasSubname() ? ProtocolBridge.getInstance().getProtocolDNSServer().getDomainDestination(this) : ProtocolBridge.getInstance().getProtocolDNSServer().getSubnameDestination(this, subname);
}
/**
* Returns a string representation of the domain, including its protocol, subname, name, top-level name, path, query, and fragment.
*/
public static class DefaultDomains {
public static final Domain DNS_INFO_SITE = new Domain("oac://about.oac/");
public static final Domain DNS_REGISTER_SITE = new Domain("oac://register.oac/");
public static Domain TLN_INFO_SITE(String topLevelName) {
return new Domain("oac://about." + topLevelName + "/");
}
}
}

View File

@@ -0,0 +1,85 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.beta;
import lombok.Getter;
import java.io.Serializable;
/**
* Enum representing various INS response codes and their descriptions.
*/
public enum INSResponseCode implements Serializable {
/**
* General Responses
*/
RESPONSE_NOT_REQUIRED(0, "Response code not required"),
RESPONSE_INVALID_REQUEST(1, "Invalid request"),
/**
* Authentication Responses
*/
RESPONSE_AUTH_SUCCESS(4, "Auth success"),
RESPONSE_AUTH_FAILED(5, "Auth failed"),
/**
* InfoName Responses
*/
RESPONSE_INFONAME_NAME_EXIST(100, "Infoname exist"),
RESPONSE_INFONAME_NAME_NOT_EXIST(101, "Infoname does not exist"),
RESPONSE_INFONAME_NAME_CREATED(105, "Infoname created"),
RESPONSE_INFONAME_NAME_DELETED(106, "Infoname deleted"),
/**
* Top Level Name Responses
*/
RESPONSE_INFONAME_TLN_EXIST(110, "TopLevelName exist"),
RESPONSE_INFONAME_TLN_NOT_EXIST(111, "TopLevelName does not exist"),
RESPONSE_INFONAME_TLN_CREATED(115, "TopLevelName created"),
RESPONSE_INFONAME_TLN_DELETED(116, "TopLevelName deleted"),
/**
* Subname Responses
*/
RESPONSE_INFONAME_SUBNAME_EXIST(120, "Subname exist"),
RESPONSE_INFONAME_SUBNAME_NOT_EXIST(121, "Subname does not exist"),
RESPONSE_INFONAME_SUBNAME_CREATED(125, "Subname created"),
RESPONSE_INFONAME_SUBNAME_DELETED(126, "Subname deleted"),
/**
* Full InfoName Responses
*/
RESPONSE_INFONAME_FULLY_EXIST(130, "Full Infoname exist"),
RESPONSE_INFONAME_FULLY_NOT_EXIST(131, "Full Infoname does not exist");
/**
* The numeric code representing the INS response.
*/
@Getter
private final int code;
/**
* A brief description of the INS response code.
*/
@Getter
private final String description;
/**
* Constructor for INSResponseCode enum.
*
* @param code The numeric code of the response.
* @param description A brief description of the response.
*/
INSResponseCode(int code, String description) {
this.code = code;
this.description = description;
}
/**
* Returns a string representation of the INS response code, including its code and description.
*
* @return a string representation of the INS response code.
*/
@Override
public String toString() {
return "{code=" + code + ";description=" + description + "}";
}
}

View File

@@ -0,0 +1,172 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.beta;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
/**
* Class representing a InfoName with its components such as subname, name, top-level name, path, query, fragment, and protocol.
*/
public final class InfoName implements Serializable {
/**
* The subname of the InfoName (e.g., "sub" in "sub.example.com").
*/
@Getter
private final String subname;
/**
* The main name of the InfoName (e.g., "example" in "sub.example.com").
*/
@Getter
private final String name;
/**
* The top-level name of the InfoName (e.g., "com" in "sub.example.com").
*/
@Getter
private final String topLevelName;
/**
* The path component of the InfoName (e.g., "path/to/resource" in "example.com/path/to/resource").
*/
@Getter
private String path;
/**
* The query component of the InfoName (e.g., "key=value" in "example.com/path?key=value").
*/
@Getter
private String query;
/**
* The fragment component of the InfoName (e.g., "section1" in "example.com/path#section1").
*/
@Getter
private String fragment;
/**
* The protocol of the InfoName (e.g., "oac" in "oac://example.com").
*/
@Getter
private String protocol;
/**
* Constructs a InfoName object by parsing the provided full InfoName string.
*
* @param fullInfoName The full InfoName string to parse.
* @throws IllegalArgumentException if the InfoName is invalid.
*/
public InfoName(String fullInfoName) {
// Remove protocol
String infoNameWithPath = fullInfoName.contains("://") ? fullInfoName.split("://", 2)[1] : fullInfoName;
this.protocol = fullInfoName.contains("://") ? fullInfoName.split("://", 2)[0] : "";
if (this.protocol.endsWith("://"))
this.protocol = this.protocol.substring(0, this.protocol.length() - "://".length());
// Cut path
String[] infoNamePartsAndPath = infoNameWithPath.split("/", 2);
// Get host and full path
String host = infoNamePartsAndPath[0];
String fullPath = infoNamePartsAndPath.length > 1 ? "/" + infoNamePartsAndPath[1] : "";
// Split InfoName in labels
List<String> labels = Arrays.asList(host.split("\\."));
if (labels.size() < 2) throw new IllegalArgumentException("Invalid InfoName: " + host);
// Get subname, name and top-level name
this.topLevelName = labels.getLast();
this.name = labels.get(labels.size() - 2);
this.subname = labels.size() > 2 ? String.join(".", labels.subList(0, labels.size() - 2)) : null;
// Split fragment
if (fullPath.contains("#")) {
this.fragment = "#" + Arrays.stream(fullPath.split("#")).toList().getLast();
fullPath = fullPath.substring(0, fullPath.length() - ("#" + fragment).length());
} else this.fragment = "";
// Split path and query
if (fullPath.contains("?")) {
String[] parts = fullPath.split("\\?", 2);
this.path = parts[0];
this.query = parts[1];
} else {
this.path = fullPath;
this.query = "";
}
// Clean up path, query and fragment
if (this.path.startsWith("/")) this.path = this.path.substring(1);
if (this.path.endsWith("/")) this.path = this.path.substring(0, this.path.length() - 1);
if (this.query.startsWith("?")) this.query = this.query.substring(1);
if (this.fragment.startsWith("#")) this.fragment = this.fragment.substring(1);
}
/**
* Checks if the InfoName has a subname.
*
* @return true if the InfoName has a subname, false otherwise.
*/
public boolean hasSubname() {
return subname != null;
}
/**
* Checks if this InfoName is equal to another object.
* Two InfoNames are considered equal if their subname, name, top-level name, and protocol are equal (case-insensitive).
*
* @return true if the InfoNames are equal, false otherwise.
*/
@Override
public boolean equals(Object obj) {
// Check if the object is an instance of InfoName
if (!(obj instanceof InfoName infoName)) return false;
// Compare subname, name, top-level name, and protocol (case-insensitive)
return infoName.getSubname().equalsIgnoreCase(this.subname) && infoName.getName().equalsIgnoreCase(this.name) &&
infoName.getTopLevelName().equalsIgnoreCase(this.topLevelName) && infoName.getProtocol().equalsIgnoreCase(this.protocol);
}
/**
* Returns the destination associated with this InfoName.
* The destination is determined based on the InfoName's components and the current protocol context.
*
* @return the destination as a string.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public String getDestination() {
// If running as client or web server, return invalid request
if (ProtocolBridge.getInstance().isRunningAsClient() || ProtocolBridge.getInstance().isRunningAsWebServer())
return INSResponseCode.RESPONSE_INVALID_REQUEST.toString();
// Handle special default InfoNames
if (this.equals(DefaultInfoNames.INS_INFO_SITE))
return ProtocolBridge.getInstance().getProtocolINSServer().getINSInfoSite();
if (this.equals(DefaultInfoNames.INS_REGISTER_SITE))
return ProtocolBridge.getInstance().getProtocolINSServer().getINSRegisterSite();
if (this.equals(DefaultInfoNames.TLN_INFO_SITE(topLevelName)))
return ProtocolBridge.getInstance().getProtocolINSServer().getTLNInfoSite(topLevelName);
// Return destination based on whether subname exists
return !hasSubname() ? ProtocolBridge.getInstance().getProtocolINSServer().getInfoNameDestination(this) : ProtocolBridge.getInstance().getProtocolINSServer().getSubnameDestination(this, subname);
}
/**
* Returns a string representation of the InfoName, including its protocol, subname, name, top-level name, path, query, and fragment.
*/
public static class DefaultInfoNames {
public static final InfoName INS_INFO_SITE = new InfoName("oac://info.oac/");
public static final InfoName INS_REGISTER_SITE = new InfoName("oac://register.oac/");
public static InfoName TLN_INFO_SITE(String topLevelName) {
return new InfoName("oac://about." + topLevelName + "/");
}
}
}

View File

@@ -1,6 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerINSServer;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
@@ -9,7 +10,7 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Class
* This event is fired when a classic domain packet is received.
* This event is deprecated and will be marked for removal in future versions.
*
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer
* @see ClassicHandlerINSServer
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer
*/

View File

@@ -1,6 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerINSServer;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
@@ -9,7 +10,7 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Class
* This event is fired when a classic ping packet is received.
* This event is deprecated and will be marked for removal in future versions.
*
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer
* @see ClassicHandlerINSServer
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer
*/

View File

@@ -23,6 +23,6 @@ public abstract class ClassicHandlerClient {
public abstract void handleMessage(String message, Classic_ProtocolVersion protocolVersion);
public final void sendMessage(String message) throws IOException, ClassNotFoundException {
ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().sendPacket(new Classic_MessagePacket(message, 0));
ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().sendPacket(new Classic_MessagePacket(message, 0));
}
}

View File

@@ -1,7 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
@@ -10,10 +10,10 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Class
import java.sql.SQLException;
/**
* Abstract class defining the DNS server-side handler for Classic protocol operations.
* Abstract class defining the INS server-side handler for Classic protocol operations.
*/
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public abstract class ClassicHandlerDNSServer {
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
public abstract class ClassicHandlerINSServer {
public abstract void handleMessage(ConnectedProtocolClient client, String message, Classic_ProtocolVersion protocolVersion);
public abstract Classic_Domain getDomain(Classic_RequestDomain requestDomain) throws SQLException;

View File

@@ -1,7 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;

View File

@@ -1,14 +1,14 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects;
import lombok.Getter;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
import java.io.Serializable;
/**
* Classic_Domain is an old representation of a domain, maintained for backward compatibility.
* It encapsulates the domain's name, top-level domain, path, and destination.
* This class is deprecated and users are encouraged to use the Domain class instead.
* Classic_Domain is an old representation of a InfoName, maintained for backward compatibility.
* It encapsulates the InfoName's name, top-level name, path, and destination.
* This class is deprecated and users are encouraged to use the InfoName class instead.
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public class Classic_Domain implements Serializable {
@@ -16,40 +16,40 @@ public class Classic_Domain implements Serializable {
/**
* The name of the domain (e.g., "example" in "example.com").
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3 | Will be replaced with a getter")
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final String name;
/**
* The top-level domain (e.g., "com" in "example.com").
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3 | Will be replaced with a getter")
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final String topLevelDomain;
/**
* The path component of the domain (e.g., "/path/to/resource" in "example.com/path/to/resource").
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3 | Will be replaced with a getter")
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final String path;
/**
* The destination of the domain, typically the full URL or address.
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3 | Will be replaced with a getter")
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
private final String destination;
/**
* The encapsulated Domain object for modern usage.
*/
@Getter
private final Domain domain;
private final InfoName infoName;
public Classic_Domain(String name, String topLevelDomain, String destination, String path) {
this.domain = new Domain(name + "." + topLevelDomain + "/" + (path.startsWith("/") ? path : "/" + path));
this.name = domain.getName();
this.topLevelDomain = domain.getTopLevelName();
this.destination = domain.getDestination();
this.path = domain.getPath();
this.infoName = new InfoName(name + "." + topLevelDomain + "/" + (path.startsWith("/") ? path : "/" + path));
this.name = infoName.getName();
this.topLevelDomain = infoName.getTopLevelName();
this.destination = infoName.getDestination();
this.path = infoName.getPath();
}
@Override

View File

@@ -18,7 +18,7 @@ public enum Classic_SiteType implements Serializable {
SERVER("oac-server"),
/**
* DNS server site type.
* INS server site type.
*/
PUBLIC("oac"),
@@ -35,7 +35,7 @@ public enum Classic_SiteType implements Serializable {
/**
* The name of the site type.
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3 | Will be replaced with a getter")
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final String name;
Classic_SiteType(String name) {

View File

@@ -17,7 +17,7 @@ public final class Classic_WebsitesContent extends DefaultMethodsOverrider {
<meta content="Domain not found" name="description"/>
</head>
<body>
<h1>404 - This domain was not found</h1>
<h1>404 - This infoName was not found</h1>
</body>
</html>
""";
@@ -61,7 +61,7 @@ public final class Classic_WebsitesContent extends DefaultMethodsOverrider {
<meta content="Site not reached" name="description"/>
</head>
<body>
<h1>500 - Error occured while resolving domain!</h1>
<h1>500 - Error occured while resolving infoName!</h1>
<h4>Details:</h2>
<h5>""" + errorDetails + "</h5>" + """
</body>

View File

@@ -1,7 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils;
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 org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain;
/**
@@ -10,25 +10,25 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Cla
public final class ClassicConverter {
/**
* Converts a Classic_Domain object to a Domain object.
* Converts a Classic_Domain object to a InfoName object.
*
* @param classicDomain the Classic_Domain object to convert
* @return the converted Domain object
* @return the converted InfoName object
*/
@SuppressWarnings(value = "deprecation")
public static Domain classicDomainToNewDomain(Classic_Domain classicDomain) {
return new Domain(classicDomain.name + "." + classicDomain.topLevelDomain + (classicDomain.path.startsWith("/") ? classicDomain.path : "/" + classicDomain.path));
public static InfoName classicDomainToInfoName(Classic_Domain classicDomain) {
return new InfoName(classicDomain.name + "." + classicDomain.topLevelDomain + (classicDomain.path.startsWith("/") ? classicDomain.path : "/" + classicDomain.path));
}
/**
* Converts a Domain object to a Classic_Domain object.
* Converts a InfoName object to a Classic_Domain object.
*
* @param newDomain the Domain object to convert
* @param newInfoName the InfoName object to convert
* @return the converted Classic_Domain object
*/
@SuppressWarnings(value = "deprecation")
public static Classic_Domain newDomainToClassicDomain(Domain newDomain) {
return new Classic_Domain(newDomain.getName(), newDomain.getTopLevelName(), newDomain.getDestination(), newDomain.getPath());
public static Classic_Domain infoNameToClassicDomain(InfoName newInfoName) {
return new Classic_Domain(newInfoName.getName(), newInfoName.getTopLevelName(), newInfoName.getDestination(), newInfoName.getPath());
}
/**

View File

@@ -18,7 +18,7 @@ import java.net.URL;
/**
* This class listens for events related to Classic protocol operations on the client side.
* It handles domain resolution and ping responses, facilitating communication with the DNS server
* It handles domain resolution and ping responses, facilitating communication with the INS server
* and web content retrieval.
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
@@ -26,7 +26,7 @@ public final class Classic_ClientListener extends EventListener {
/**
* Handles the event when a domain packet is received.
* It checks if the domain exists and sends a ping request to the DNS server.
* It checks if the domain exists and sends a ping request to the INS server.
* If the domain does not exist, it handles the error accordingly.
*
* @param event The event containing domain information.
@@ -38,8 +38,8 @@ public final class Classic_ClientListener extends EventListener {
if (exists) {
try {
// Send a ping request to the DNS server
if (!ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().sendPacket(new Classic_PingPacket(event.requestDomain, event.domain, false))) {
// Send a ping request to the INS server
if (!ProtocolBridge.getInstance().getProtocolClient().getClientINSConnection().sendPacket(new Classic_PingPacket(event.requestDomain, event.domain, false))) {
// If sending the packet fails, handle the error
ProtocolBridge.getInstance().getClassicHandlerClient().handleHTMLContent(Classic_SiteType.PROTOCOL, new Classic_LocalDomain("error-occurred", "html", ""),
Classic_WebsitesContent.ERROR_OCCURRED(event.domain + "/" + event.domain.path));
@@ -65,7 +65,7 @@ public final class Classic_ClientListener extends EventListener {
public void onPing(Classic_PingPacketReceivedEvent event) {
// If the domain is reachable, fetch the HTML content
if (event.reachable) {
String destination = event.domain.getDomain().getDestination();
String destination = event.domain.getInfoName().getDestination();
try {
// Create a URL object
@@ -85,7 +85,7 @@ public final class Classic_ClientListener extends EventListener {
} catch (IOException exception) {
// Handle any exceptions that occur during the process
ProtocolBridge.getInstance().getClassicHandlerClient().handleHTMLContent(Classic_SiteType.PROTOCOL, new Classic_LocalDomain("error-occurred", "html", ""),
Classic_WebsitesContent.ERROR_OCCURRED(exception.getMessage().replace(event.domain.getDomain().getDestination(), event.domain + "/" + event.domain.path)));
Classic_WebsitesContent.ERROR_OCCURRED(exception.getMessage().replace(event.domain.getInfoName().getDestination(), event.domain + "/" + event.domain.path)));
}
} else
// If the domain is not reachable, handle the error