diff --git a/README.MD b/README.MD
index c082761..b405884 100644
--- a/README.MD
+++ b/README.MD
@@ -85,7 +85,7 @@ public class Server extends ProtocolServer {
import me.openautonomousconnection.protocol.ProtocolBridge;
import me.openautonomousconnection.protocol.ProtocolSettings;
import me.openautonomousconnection.protocol.ProtocolVersion;
-import me.openautonomousconnection.protocol.domain.Domain;
+import me.openautonomousconnection.protocol.infoName.Domain;
import me.openautonomousconnection.protocol.side.ProtocolClient;
import me.openautonomousconnection.protocol.utils.SiteType;
@@ -103,7 +103,7 @@ public class Client extends ProtocolClient {
}
@Override
- public void handleHTMLContent(SiteType siteType, Domain domain, String htmlContent) {
+ public void handleHTMLContent(SiteType siteType, Domain infoName, String htmlContent) {
System.out.println("Website html content received. This site is " + siteType.name);
System.out.println(htmlContent); // Render content in a webview for example
}
diff --git a/pom.xml b/pom.xml
index f217227..5831d6b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.openautonomousconnection
protocol
- 1.0.0-BETA.6
+ 1.0.0-BETA.7
Open Autonomous Connection
https://open-autonomous-connection.org/
@@ -87,7 +87,7 @@
dev.unlegitdqrk
unlegitlibrary
- 1.6.5
+ 1.6.6
org.projectlombok
diff --git a/src/main/java/org/openautonomousconnection/protocol/ProtocolBridge.java b/src/main/java/org/openautonomousconnection/protocol/ProtocolBridge.java
index 143f824..d5377ab 100644
--- a/src/main/java/org/openautonomousconnection/protocol/ProtocolBridge.java
+++ b/src/main/java/org/openautonomousconnection/protocol/ProtocolBridge.java
@@ -5,20 +5,22 @@ 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.packets.v1_0_0.classic.Classic_MessagePacket;
+import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_PingPacket;
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;
@@ -31,13 +33,6 @@ import java.net.Proxy;
* It manages the protocol settings, version, and side instances.
*/
public final class ProtocolBridge {
-
- /**
- * The singleton instance of the ProtocolBridge class
- */
- @Getter
- private static ProtocolBridge instance;
-
/**
* The protocol settings for the current connection
*/
@@ -60,7 +55,7 @@ public final class ProtocolBridge {
* The protocol side instances
*/
@Getter
- private ProtocolDNSServer protocolDNSServer;
+ private ProtocolINSServer protocolINSServer;
/**
* The protocol side instances
@@ -75,11 +70,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
@@ -103,18 +98,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.protocolINSServer = protocolINSServer;
+ this.protocolINSServer.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -125,9 +121,6 @@ public final class ProtocolBridge {
// Register the appropriate listeners and packets
registerListeners();
registerPackets();
-
- // Set the static instance to this instance
- instance = this;
}
/**
@@ -143,6 +136,7 @@ public final class ProtocolBridge {
public ProtocolBridge(ProtocolWebServer protocolWebServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolWebServer = protocolWebServer;
+ this.protocolWebServer.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -153,9 +147,6 @@ public final class ProtocolBridge {
// Register the appropriate listeners and packets
registerListeners();
registerPackets();
-
- // Set the static instance to this instance
- instance = this;
}
/**
@@ -171,6 +162,7 @@ public final class ProtocolBridge {
public ProtocolBridge(ProtocolClient protocolClient, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolClient = protocolClient;
+ this.protocolClient.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -181,9 +173,6 @@ public final class ProtocolBridge {
// Register the appropriate listeners and packets
registerListeners();
registerPackets();
-
- // Set the static instance to this instance
- instance = this;
}
/**
@@ -192,8 +181,8 @@ public final class ProtocolBridge {
private void registerPackets() {
// Classic packets
Classic_DomainPacket cDomainPacket = new Classic_DomainPacket();
- Classic_DomainPacket cMessagePacket = new Classic_DomainPacket();
- Classic_DomainPacket cPingPacket = new Classic_DomainPacket();
+ Classic_MessagePacket cMessagePacket = new Classic_MessagePacket();
+ Classic_PingPacket cPingPacket = new Classic_PingPacket();
if (isPacketSupported(cDomainPacket)) protocolSettings.packetHandler.registerPacket(cDomainPacket);
if (isPacketSupported(cMessagePacket)) protocolSettings.packetHandler.registerPacket(cMessagePacket);
@@ -202,14 +191,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);
}
@@ -221,27 +210,37 @@ public final class ProtocolBridge {
*/
private void registerListeners() throws Exception {
// Classic listeners
- if (isClassicSupported()) protocolSettings.eventManager.registerListener(Classic_ClientListener.class);
+ if (isClassicSupported()) {
+ Classic_ClientListener classicListener = new Classic_ClientListener();
+ classicListener.setProtocolBridge(this);
+ protocolSettings.eventManager.registerListener(classicListener.getClass());
+ }
else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
- // DNS Listeners
- if (isRunningAsDNSServer()) {
- protocolSettings.eventManager.registerListener(DNSServerListener.class);
+ // INS Listeners
+ if (isRunningAsINSServer()) {
+ INSServerListener serverListener = new INSServerListener();
+ serverListener.setINSServer(protocolINSServer);
+ protocolSettings.eventManager.registerListener(serverListener.getClass());
protocolSettings.eventManager.unregisterListener(WebServerListener.class);
protocolSettings.eventManager.unregisterListener(ClientListener.class);
}
// Web Listeners
if (isRunningAsWebServer()) {
- protocolSettings.eventManager.registerListener(WebServerListener.class);
- protocolSettings.eventManager.unregisterListener(DNSServerListener.class);
+ WebServerListener serverListener = new WebServerListener();
+ serverListener.setWebServer(protocolWebServer);
+ protocolSettings.eventManager.registerListener(serverListener.getClass());
+ protocolSettings.eventManager.unregisterListener(INSServerListener.class);
protocolSettings.eventManager.unregisterListener(ClientListener.class);
}
// Client Listeners
if (isRunningAsClient()) {
- protocolSettings.eventManager.registerListener(ClientListener.class);
- protocolSettings.eventManager.unregisterListener(DNSServerListener.class);
+ ClientListener clientListener = new ClientListener();
+ clientListener.setClient(protocolClient);
+ protocolSettings.eventManager.registerListener(clientListener.getClass());
+ protocolSettings.eventManager.unregisterListener(INSServerListener.class);
protocolSettings.eventManager.unregisterListener(WebServerListener.class);
}
}
@@ -346,27 +345,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;
}
/**
diff --git a/src/main/java/org/openautonomousconnection/protocol/listeners/ClientListener.java b/src/main/java/org/openautonomousconnection/protocol/listeners/ClientListener.java
index ee5cc99..a247c8b 100644
--- a/src/main/java/org/openautonomousconnection/protocol/listeners/ClientListener.java
+++ b/src/main/java/org/openautonomousconnection/protocol/listeners/ClientListener.java
@@ -4,9 +4,11 @@ import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientConnectedEvent;
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
+import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
+import org.openautonomousconnection.protocol.side.client.ProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import java.io.IOException;
@@ -17,6 +19,21 @@ import java.io.IOException;
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
public final class ClientListener extends EventListener {
+ /**
+ * The reference to the ProtocolClient object
+ */
+ @Getter
+ private ProtocolClient client;
+
+ /**
+ * Sets the client variable
+ * @param client The Instance of the ProtocolClient
+ */
+ public void setClient(ProtocolClient client) {
+ if (this.client != null) return;
+ this.client = client;
+ }
+
/**
* Handles the event when a client connects.
* Sends an authentication packet to the server.
@@ -26,9 +43,9 @@ public final class ClientListener extends EventListener {
@Listener
public void onConnect(ClientConnectedEvent event) {
try {
- event.getClient().sendPacket(new AuthPacket());
+ event.getClient().sendPacket(new AuthPacket(client.getProtocolBridge()));
} catch (IOException | ClassNotFoundException exception) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to send auth packet", exception);
+ event.getClient().getLogger().exception("Failed to send auth packet", exception);
event.getClient().disconnect();
}
}
@@ -41,7 +58,7 @@ public final class ClientListener extends EventListener {
*/
@Listener
public void onDisconnect(ClientDisconnectedEvent event) {
- ProtocolBridge.getInstance().getProtocolClient().onDNSDisconnect(event);
+ client.onINSDisconnect(event);
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/listeners/DNSServerListener.java b/src/main/java/org/openautonomousconnection/protocol/listeners/INSServerListener.java
similarity index 51%
rename from src/main/java/org/openautonomousconnection/protocol/listeners/DNSServerListener.java
rename to src/main/java/org/openautonomousconnection/protocol/listeners/INSServerListener.java
index 09cea1d..c3415e6 100644
--- a/src/main/java/org/openautonomousconnection/protocol/listeners/DNSServerListener.java
+++ b/src/main/java/org/openautonomousconnection/protocol/listeners/INSServerListener.java
@@ -4,38 +4,55 @@ import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
+import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
-import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
+import org.openautonomousconnection.protocol.side.client.ProtocolClient;
+import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
+import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
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.
+ * The reference to the INSServer object
+ */
+ @Getter
+ private ProtocolINSServer insServer;
+
+ /**
+ * Sets the insServer variable
+ * @param insServer The Instance of the INSServer
+ */
+ public void setINSServer(ProtocolINSServer insServer) {
+ if (this.insServer != null) return;
+ this.insServer = insServer;
+ }
+
+ /**
+ * 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()));
+ insServer.getClients().add(new ConnectedProtocolClient(event.getConnectionHandler(), insServer));
}
/**
- * 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 ->
- client.getConnectionHandler().getClientID() == -1);
+ insServer.getClients().removeIf(client -> client.getConnectionHandler().getClientID() == -1);
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/listeners/WebServerListener.java b/src/main/java/org/openautonomousconnection/protocol/listeners/WebServerListener.java
index 465dcf2..9f5000f 100644
--- a/src/main/java/org/openautonomousconnection/protocol/listeners/WebServerListener.java
+++ b/src/main/java/org/openautonomousconnection/protocol/listeners/WebServerListener.java
@@ -4,9 +4,12 @@ import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
+import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
+import org.openautonomousconnection.protocol.side.client.ProtocolClient;
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
+import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
@@ -15,6 +18,21 @@ import org.openautonomousconnection.protocol.versions.ProtocolVersion;
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.WEB)
public final class WebServerListener extends EventListener {
+ /**
+ * The reference to the ProtocolWebServer object
+ */
+ @Getter
+ private ProtocolWebServer webServer;
+
+ /**
+ * Sets the webServer variable
+ * @param webServer The Instance of the ProtocolWebServer
+ */
+ public void setWebServer(ProtocolWebServer webServer) {
+ if (this.webServer != null) return;
+ this.webServer = webServer;
+ }
+
/**
* Handles the event when a connection is established.
* Adds the connected client to the protocol web server's client list.
@@ -23,7 +41,7 @@ public final class WebServerListener extends EventListener {
*/
@Listener
public void onConnect(ConnectionHandlerConnectedEvent event) {
- ProtocolBridge.getInstance().getProtocolWebServer().getClients().add(new ConnectedWebClient(event.getConnectionHandler()));
+ webServer.getClients().add(new ConnectedWebClient(event.getConnectionHandler()));
}
/**
@@ -34,7 +52,7 @@ public final class WebServerListener extends EventListener {
*/
@Listener
public void onDisconnect(ConnectionHandlerDisconnectedEvent event) {
- ProtocolBridge.getInstance().getProtocolWebServer().getClients().removeIf(client -> client.getPipelineConnection().getClientID() == -1);
+ webServer.getClients().removeIf(client -> client.getPipelineConnection().getClientID() == -1);
}
}
\ No newline at end of file
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/OACPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/OACPacket.java
index a545be5..a9ea79c 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/OACPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/OACPacket.java
@@ -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);
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/AuthPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/AuthPacket.java
index 7abb8ab..7878995 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/AuthPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/AuthPacket.java
@@ -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;
@@ -20,13 +20,12 @@ import java.io.ObjectOutputStream;
public final class AuthPacket extends OACPacket {
- File certificatesFolder = new File("certificates");
- File publicFolder = new File(certificatesFolder, "public");
- File publicCAFolder = new File(publicFolder, "ca");
- File publicServerFolder = new File(publicFolder, "server");
- File privateFolder = new File(certificatesFolder, "private");
- File privateCAFolder = new File(privateFolder, "ca");
- File privateServerFolder = new File(privateFolder, "server");
+ private ProtocolBridge protocolBridge;
+
+ public AuthPacket(ProtocolBridge protocolBridge) {
+ this();
+ this.protocolBridge = protocolBridge;
+ }
public AuthPacket() {
super(4, ProtocolVersion.PV_1_0_0_BETA);
@@ -34,72 +33,72 @@ public final class AuthPacket extends OACPacket {
@Override
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
- objectOutputStream.writeObject(ProtocolBridge.getInstance().getProtocolVersion());
+ if (protocolBridge.isRunningAsINSServer()) {
+ objectOutputStream.writeObject(protocolBridge.getProtocolVersion());
// Read ca files
String caKey = "N/A";
String caPem = "N/A";
String caSrl = "N/A";
try {
- objectOutputStream.writeUTF(ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress());
+ objectOutputStream.writeUTF(protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress());
caKey = FileUtils.readFileFull(new File(
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().privateCAFolder,
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".key"));
+ protocolBridge.getProtocolINSServer().getFolderStructure().privateCAFolder,
+ protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".key"));
caPem = FileUtils.readFileFull(new File(
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().publicCAFolder,
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".pem"));
+ protocolBridge.getProtocolINSServer().getFolderStructure().publicCAFolder,
+ protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".pem"));
caSrl = FileUtils.readFileFull(new File(
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().publicCAFolder,
- ProtocolBridge.getInstance().getProtocolDNSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".srl"));
+ protocolBridge.getProtocolINSServer().getFolderStructure().publicCAFolder,
+ protocolBridge.getProtocolINSServer().getFolderStructure().caPrefix + NetworkUtils.getPublicIPAddress() + ".srl"));
} catch (Exception exception) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to read ca-files", exception);
- setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
+ protocolBridge.getLogger().exception("Failed to read ca-files", exception);
+ setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
}
// Send ca data
objectOutputStream.writeUTF(caKey);
objectOutputStream.writeUTF(caPem);
objectOutputStream.writeUTF(caSrl);
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
- objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID());
- objectOutputStream.writeObject(ProtocolBridge.getInstance().getProtocolVersion());
+ } else if (protocolBridge.isRunningAsClient()) {
+ objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
+ objectOutputStream.writeObject(protocolBridge.getProtocolVersion());
}
}
@Override
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer()) {
+ if (protocolBridge.isRunningAsINSServer() || protocolBridge.isRunningAsWebServer()) {
int clientID = objectInputStream.readInt();
ProtocolVersion clientVersion = (ProtocolVersion) objectInputStream.readObject();
- ConnectionHandler connectionHandler = ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID);
+ ConnectionHandler connectionHandler = protocolBridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID);
- if (!ProtocolBridge.getInstance().isVersionSupported(clientVersion)) {
- setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
+ if (!protocolBridge.isVersionSupported(clientVersion)) {
+ setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
connectionHandler.disconnect();
return;
- } else setResponseCode(DNSResponseCode.RESPONSE_AUTH_SUCCESS);
+ } else setResponseCode(INSResponseCode.RESPONSE_AUTH_SUCCESS);
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
- ConnectedProtocolClient client = ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID);
+ if (protocolBridge.isRunningAsINSServer()) {
+ ConnectedProtocolClient client = protocolBridge.getProtocolINSServer().getClientByID(clientID);
client.setClientVersion(clientVersion);
- ProtocolBridge.getInstance().getProtocolSettings().eventManager.executeEvent(new ConnectedProtocolClientEvent(client));
+ protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedProtocolClientEvent(client));
} else {
- ConnectedWebClient client = ProtocolBridge.getInstance().getProtocolWebServer().getClientByID(clientID);
+ ConnectedWebClient client = protocolBridge.getProtocolWebServer().getClientByID(clientID);
client.setClientVersion(clientVersion);
}
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
+ } else if (protocolBridge.isRunningAsClient()) {
ProtocolVersion serverVersion = (ProtocolVersion) objectInputStream.readObject();
- if (!ProtocolBridge.getInstance().isVersionSupported(serverVersion)) {
- setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
- ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().disconnect();
+ if (!protocolBridge.isVersionSupported(serverVersion)) {
+ 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();
@@ -108,12 +107,12 @@ 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.getInstance().getProtocolClient().getFolderStructure().publicCAFolder, caPrefix + ".pem");
- File caSrlFile = new File(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicCAFolder, caPrefix + ".srl");
- File caKeyFile = new File(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().privateCAFolder, caPrefix + ".key");
+ File caPemFile = new File(protocolBridge.getProtocolClient().getFolderStructure().publicCAFolder, caPrefix + ".pem");
+ File caSrlFile = new File(protocolBridge.getProtocolClient().getFolderStructure().publicCAFolder, caPrefix + ".srl");
+ File caKeyFile = new File(protocolBridge.getProtocolClient().getFolderStructure().privateCAFolder, caPrefix + ".key");
try {
if (!caPemFile.exists()) caPemFile.createNewFile();
@@ -124,13 +123,13 @@ public final class AuthPacket extends OACPacket {
FileUtils.writeFile(caSrlFile, caKey);
FileUtils.writeFile(caKeyFile, caSrl);
} catch (Exception exception) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to create/save ca-files", exception);
- setResponseCode(DNSResponseCode.RESPONSE_AUTH_FAILED);
+ protocolBridge.getLogger().exception("Failed to create/save ca-files", exception);
+ setResponseCode(INSResponseCode.RESPONSE_AUTH_FAILED);
}
}
- ProtocolBridge.getInstance().getProtocolClient().setServerVersion(serverVersion);
- ProtocolBridge.getInstance().getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolDNSServerEvent());
+ protocolBridge.getProtocolClient().setServerVersion(serverVersion);
+ protocolBridge.getProtocolSettings().eventManager.executeEvent(new ConnectedToProtocolINSServerEvent(protocolBridge.getProtocolClient()));
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/GetDestinationPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/GetDestinationPacket.java
index e87ba98..e3dac88 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/GetDestinationPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/GetDestinationPacket.java
@@ -4,33 +4,36 @@ 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;
+ private ProtocolBridge protocolBridge;
- // DNS-Server Constructor
- public GetDestinationPacket(Domain domain, DNSResponseCode validationResponse, String destination) {
+ // INS-Server Constructor
+ public GetDestinationPacket(InfoName infoName, INSResponseCode validationResponse, String destination, ProtocolBridge protocolBridge) {
this();
- this.domain = domain;
+ this.infoName = infoName;
this.validationResponse = validationResponse;
this.destination = destination;
+ this.protocolBridge = protocolBridge;
}
// Client Constructor
- public GetDestinationPacket(Domain domain, DNSResponseCode validationResponse) {
+ public GetDestinationPacket(InfoName infoName, INSResponseCode validationResponse, ProtocolBridge protocolBridge) {
this();
- this.domain = domain;
+ this.infoName = infoName;
this.validationResponse = validationResponse;
this.destination = destination;
+ this.protocolBridge = protocolBridge;
}
// Registration Constructor
@@ -40,14 +43,14 @@ 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 (protocolBridge.isRunningAsClient()) {
+ if (validationResponse != INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST) return;
- objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID());
- objectOutputStream.writeObject(domain);
+ objectOutputStream.writeInt(protocolBridge.getProtocolClient().getClientINSConnection().getClientID());
+ objectOutputStream.writeObject(infoName);
objectOutputStream.writeObject(validationResponse);
- } else if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
- objectOutputStream.writeObject(domain);
+ } else if (protocolBridge.isRunningAsINSServer()) {
+ objectOutputStream.writeObject(infoName);
objectOutputStream.writeObject(validationResponse);
objectOutputStream.writeUTF(destination);
}
@@ -55,16 +58,16 @@ public final class GetDestinationPacket extends OACPacket {
@Override
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (protocolBridge.isRunningAsINSServer()) {
clientID = objectInputStream.readInt();
- domain = (Domain) objectInputStream.readObject();
- validationResponse = (DNSResponseCode) objectInputStream.readObject();
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
- domain = (Domain) objectInputStream.readObject();
- validationResponse = (DNSResponseCode) objectInputStream.readObject();
+ infoName = (InfoName) objectInputStream.readObject();
+ validationResponse = (INSResponseCode) objectInputStream.readObject();
+ } else if (protocolBridge.isRunningAsClient()) {
+ infoName = (InfoName) objectInputStream.readObject();
+ validationResponse = (INSResponseCode) objectInputStream.readObject();
destination = objectInputStream.readUTF();
- ProtocolBridge.getInstance().getProtocolClient().getDestinationCompleted(domain, destination, validationResponse);
+ protocolBridge.getProtocolClient().getDestinationCompleted(infoName, destination, validationResponse);
}
}
@@ -72,14 +75,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.isRunningAsINSServer()) {
+ if (validationResponse != INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST) return;
+ destination = infoName.getDestination(protocolBridge);
try {
- ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new GetDestinationPacket(domain, validationResponse, destination));
+ protocolBridge.getProtocolINSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new GetDestinationPacket(infoName, validationResponse, destination, protocolBridge));
} catch (IOException | ClassNotFoundException exception) {
- ProtocolBridge.getInstance().getProtocolDNSServer().domainDestinationPacketFailedSend(ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), domain, validationResponse, exception);
+ protocolBridge.getProtocolINSServer().infoNameDestinationPacketFailedSend(protocolBridge.getProtocolINSServer().getClientByID(clientID), infoName, validationResponse, exception);
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/UnsupportedClassicPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/UnsupportedClassicPacket.java
index 63e27bc..ca4a928 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/UnsupportedClassicPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/UnsupportedClassicPacket.java
@@ -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;
@@ -13,12 +13,14 @@ import java.io.ObjectOutputStream;
public final class UnsupportedClassicPacket extends OACPacket {
private Class extends OACPacket> unsupportedClassicPacket;
private Object[] content;
+ private ProtocolBridge protocolBridge;
// Constructor with more information
- public UnsupportedClassicPacket(Class extends OACPacket> unsupportedClassicPacket, Object[] content) {
+ public UnsupportedClassicPacket(Class extends OACPacket> unsupportedClassicPacket, Object[] content, ProtocolBridge protocolBridge) {
this();
this.unsupportedClassicPacket = unsupportedClassicPacket;
this.content = content;
+ this.protocolBridge = protocolBridge;
}
// Registration Constructor
@@ -28,19 +30,19 @@ 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());
+ if (protocolBridge.isRunningAsClient())
+ objectOutputStream.writeInt(protocolBridge.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.isRunningAsINSServer()) clientID = objectInputStream.readInt();
String className = objectInputStream.readUTF();
int size = objectInputStream.readInt();
content = new Object[size];
@@ -49,12 +51,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));
- 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));
+ if (protocolBridge.isRunningAsINSServer())
+ protocolBridge.getClassicHandlerINSServer().unsupportedClassicPacket(className, content, protocolBridge.getProtocolINSServer().getClientByID(clientID));
+ else if (protocolBridge.isRunningAsClient())
+ protocolBridge.getClassicHandlerClient().unsupportedClassicPacket(className, content);
+ else if (protocolBridge.isRunningAsWebServer())
+ protocolBridge.getClassicHandlerWebServer().unsupportedClassicPacket(className, content, protocolBridge.getProtocolINSServer().getClientByID(clientID));
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateDomainPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateDomainPacket.java
deleted file mode 100644
index c6b6de5..0000000
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateDomainPacket.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
-
-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 java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-public final class ValidateDomainPacket extends OACPacket {
- private Domain domain;
- private int clientID;
-
- public ValidateDomainPacket(Domain domain) {
- this();
- this.domain = domain;
- }
-
- public ValidateDomainPacket() {
- super(6, ProtocolVersion.PV_1_0_0_BETA);
- }
-
- @Override
- public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsClient())
- objectOutputStream.writeInt(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID());
- else if (ProtocolBridge.getInstance().isRunningAsDNSServer())
- setResponseCode(ProtocolBridge.getInstance().getProtocolDNSServer().validateDomain(domain));
-
- objectOutputStream.writeObject(domain);
- }
-
- @Override
- public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) clientID = objectInputStream.readInt();
- domain = (Domain) objectInputStream.readObject();
- }
-
- @Override
- protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
- super.onResponseCodeRead(packetHandler, objectInputStream);
-
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
- try {
- ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new ValidateDomainPacket(domain));
- } catch (IOException | ClassNotFoundException e) {
- ProtocolBridge.getInstance().getProtocolDNSServer().validationPacketSendFailed(domain, ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), e);
- }
-
- } else if (ProtocolBridge.getInstance().isRunningAsClient())
- ProtocolBridge.getInstance().getProtocolClient().validationCompleted(domain, getResponseCode());
- }
-}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateInfoNamePacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateInfoNamePacket.java
new file mode 100644
index 0000000..98b9726
--- /dev/null
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/beta/ValidateInfoNamePacket.java
@@ -0,0 +1,58 @@
+package org.openautonomousconnection.protocol.packets.v1_0_0.beta;
+
+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.InfoName;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+public final class ValidateInfoNamePacket extends OACPacket {
+ private InfoName infoName;
+ private int clientID;
+ private ProtocolBridge protocolBridge;
+
+ public ValidateInfoNamePacket(InfoName infoName, ProtocolBridge protocolBridge) {
+ this();
+ this.infoName = infoName;
+ this.protocolBridge = protocolBridge;
+ }
+
+ 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().getClientINSConnection().getClientID());
+ else if (protocolBridge.isRunningAsINSServer())
+ setResponseCode(protocolBridge.getProtocolINSServer().validateInfoName(infoName));
+
+ objectOutputStream.writeObject(infoName);
+ }
+
+ @Override
+ public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
+ if (protocolBridge.isRunningAsINSServer()) clientID = objectInputStream.readInt();
+ infoName = (InfoName) objectInputStream.readObject();
+ }
+
+ @Override
+ protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {
+ super.onResponseCodeRead(packetHandler, objectInputStream);
+
+ if (protocolBridge.isRunningAsINSServer()) {
+ try {
+ protocolBridge.getProtocolINSServer().getClientByID(clientID).getConnectionHandler().sendPacket(new ValidateInfoNamePacket(infoName, protocolBridge));
+ } catch (IOException | ClassNotFoundException e) {
+ protocolBridge.getProtocolINSServer().validationPacketSendFailed(infoName, protocolBridge.getProtocolINSServer().getClientByID(clientID), e);
+ }
+
+ } else if (protocolBridge.isRunningAsClient())
+ protocolBridge.getProtocolClient().validationCompleted(infoName, getResponseCode());
+ }
+}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_DomainPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_DomainPacket.java
index ddcb726..c8c0a7a 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_DomainPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_DomainPacket.java
@@ -19,10 +19,12 @@ public final class Classic_DomainPacket extends OACPacket {
private Classic_RequestDomain requestDomain;
private Classic_Domain domain;
private int clientID;
+ private ProtocolBridge bridge;
- public Classic_DomainPacket(int toClient, Classic_RequestDomain requestDomain, Classic_Domain domain) {
+ public Classic_DomainPacket(int toClient, Classic_RequestDomain requestDomain, Classic_Domain domain, ProtocolBridge protocolBridge) {
this();
this.clientID = toClient;
+ this.bridge = protocolBridge;
this.requestDomain = requestDomain;
this.domain = domain;
@@ -35,12 +37,12 @@ public final class Classic_DomainPacket extends OACPacket {
@Override
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (bridge.isRunningAsINSServer()) {
objectOutputStream.writeInt(clientID);
objectOutputStream.writeObject(requestDomain);
objectOutputStream.writeObject(domain);
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
- clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
+ } else if (bridge.isRunningAsClient()) {
+ clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
objectOutputStream.writeInt(clientID);
objectOutputStream.writeObject(requestDomain);
}
@@ -50,36 +52,36 @@ public final class Classic_DomainPacket extends OACPacket {
@Override
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (bridge.isRunningAsINSServer()) {
clientID = objectInputStream.readInt();
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
try {
- domain = ProtocolBridge.getInstance().getClassicHandlerDNSServer().getDomain(requestDomain);
+ domain = bridge.getClassicHandlerINSServer().getDomain(requestDomain);
} catch (SQLException exception) {
exception.printStackTrace();
}
- ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
+ bridge.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 (bridge.getProtocolINSServer().getClientByID(clientID).supportClientClassic())
+ bridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_DomainPacket(clientID, requestDomain, domain, bridge));
else
- ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}));
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
+ bridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}, bridge));
+ } else if (bridge.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));
- } else if (ProtocolBridge.getInstance().isRunningAsWebServer()) {
+ bridge.getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_DomainPacketReceivedEvent(protocolVersion, domain, requestDomain, clientID));
+ } else if (bridge.isRunningAsWebServer()) {
clientID = objectInputStream.readInt();
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
- ProtocolBridge.getInstance().getProtocolWebServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}));
+ bridge.getProtocolWebServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{clientID, requestDomain, domain}, bridge));
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_MessagePacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_MessagePacket.java
index e1547c6..24cbc91 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_MessagePacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_MessagePacket.java
@@ -13,12 +13,14 @@ import java.io.ObjectOutputStream;
public final class Classic_MessagePacket extends OACPacket {
private String message;
private int clientID;
+ private ProtocolBridge bridge;
// Constructor with message and client id
- public Classic_MessagePacket(String message, int toClient) {
+ public Classic_MessagePacket(String message, int toClient, ProtocolBridge bridge) {
this();
this.message = message;
this.clientID = toClient;
+ this.bridge = bridge;
}
public Classic_MessagePacket() {
@@ -27,10 +29,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 (bridge.isRunningAsINSServer() || bridge.isRunningAsWebServer())
objectOutputStream.writeInt(clientID);
- else if (ProtocolBridge.getInstance().isRunningAsClient()) {
- clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
+ else if (bridge.isRunningAsClient()) {
+ clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
objectOutputStream.writeInt(clientID);
}
@@ -40,24 +42,24 @@ public final class Classic_MessagePacket extends OACPacket {
@Override
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (bridge.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);
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
+ bridge.getClassicHandlerINSServer().handleMessage(bridge.getProtocolINSServer().getClientByID(clientID), message, protocolVersion);
+ } else if (bridge.isRunningAsClient()) {
clientID = objectInputStream.readInt();
String message = objectInputStream.readUTF();
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
- ProtocolBridge.getInstance().getClassicHandlerClient().handleMessage(message, protocolVersion);
- } else if (ProtocolBridge.getInstance().isRunningAsWebServer()) {
+ bridge.getClassicHandlerClient().handleMessage(message, protocolVersion);
+ } else if (bridge.isRunningAsWebServer()) {
clientID = objectInputStream.readInt();
String message = objectInputStream.readUTF();
Classic_ProtocolVersion protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
- ProtocolBridge.getInstance().getClassicHandlerWebServer().handleMessage(ProtocolBridge.getInstance().getProtocolDNSServer().getClientByID(clientID), message, protocolVersion);
+ bridge.getClassicHandlerWebServer().handleMessage(bridge.getProtocolINSServer().getClientByID(clientID), message, protocolVersion);
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_PingPacket.java b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_PingPacket.java
index bdac3e7..4c873ee 100644
--- a/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_PingPacket.java
+++ b/src/main/java/org/openautonomousconnection/protocol/packets/v1_0_0/classic/Classic_PingPacket.java
@@ -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;
@@ -22,9 +22,11 @@ public final class Classic_PingPacket extends OACPacket {
private int clientID;
private boolean reachable;
private Classic_ProtocolVersion protocolVersion;
+ private ProtocolBridge bridge;
- public Classic_PingPacket(Classic_RequestDomain requestDomain, Classic_Domain domain, boolean reachable) {
+ public Classic_PingPacket(Classic_RequestDomain requestDomain, Classic_Domain domain, boolean reachable, ProtocolBridge bridge) {
this();
+ this.bridge = bridge;
this.requestDomain = requestDomain;
this.domain = domain;
@@ -38,13 +40,13 @@ public final class Classic_PingPacket extends OACPacket {
@Override
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (bridge.isRunningAsINSServer()) {
objectOutputStream.writeInt(clientID);
objectOutputStream.writeObject(requestDomain);
objectOutputStream.writeObject(domain);
objectOutputStream.writeBoolean(reachable);
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
- clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
+ } else if (bridge.isRunningAsClient()) {
+ clientID = bridge.getProtocolClient().getClientINSConnection().getClientID();
objectOutputStream.writeInt(clientID);
objectOutputStream.writeObject(requestDomain);
}
@@ -54,38 +56,38 @@ public final class Classic_PingPacket extends OACPacket {
@Override
public void onRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
- if (ProtocolBridge.getInstance().isRunningAsDNSServer()) {
+ if (bridge.isRunningAsINSServer()) {
clientID = objectInputStream.readInt();
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
try {
- domain = ProtocolBridge.getInstance().getClassicHandlerDNSServer().ping(requestDomain);
+ domain = bridge.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));
+ bridge.getProtocolINSServer().getNetworkServer().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
+ if (bridge.getProtocolINSServer().getClientByID(clientID).supportClientClassic())
+ bridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new Classic_PingPacket(requestDomain, domain, reachable, bridge));
else
- ProtocolBridge.getInstance().getProtocolDNSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain, domain, reachable}));
- } else if (ProtocolBridge.getInstance().isRunningAsClient()) {
+ bridge.getProtocolINSServer().getNetworkServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain, domain, reachable}, bridge));
+ } else if (bridge.isRunningAsClient()) {
clientID = objectInputStream.readInt();
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
domain = (Classic_Domain) objectInputStream.readObject();
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));
- } else if (ProtocolBridge.getInstance().isRunningAsWebServer()) {
+ bridge.getProtocolClient().validationCompleted(domain.getInfoName(), reachable ? INSResponseCode.RESPONSE_INFONAME_FULLY_EXIST : INSResponseCode.RESPONSE_INFONAME_FULLY_NOT_EXIST);
+ bridge.getProtocolClient().getClientINSConnection().getEventManager().executeEvent(new Classic_PingPacketReceivedEvent(protocolVersion, domain, requestDomain, reachable, clientID));
+ } else if (bridge.isRunningAsWebServer()) {
clientID = objectInputStream.readInt();
requestDomain = (Classic_RequestDomain) objectInputStream.readObject();
protocolVersion = (Classic_ProtocolVersion) objectInputStream.readObject();
- ProtocolBridge.getInstance().getProtocolWebServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain}));
+ bridge.getProtocolWebServer().getPipelineServer().getConnectionHandlerByID(clientID).sendPacket(new UnsupportedClassicPacket(Classic_PingPacket.class, new Object[]{requestDomain}, bridge));
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/client/ProtocolClient.java b/src/main/java/org/openautonomousconnection/protocol/side/client/ProtocolClient.java
index 87eb125..528f8f6 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/client/ProtocolClient.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/client/ProtocolClient.java
@@ -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.
@@ -51,7 +51,13 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
private ProtocolVersion serverVersion = null;
/**
- * Initializes the ProtocolClient, setting up certificate folders and the DNS client connection.
+ * The reference to the ProtocolBridge Object
+ */
+ @Getter
+ private ProtocolBridge protocolBridge;
+
+ /**
+ * 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.
@@ -60,34 +66,34 @@ 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.getInstance().getLogger()).setProxy(ProtocolBridge.getInstance().getProxy()).
- setHost(ProtocolBridge.getInstance().getProtocolSettings().host).setPort(ProtocolBridge.getInstance().getProtocolSettings().port).
- setPacketHandler(ProtocolBridge.getInstance().getProtocolSettings().packetHandler).setEventManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager).
+ // 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).
build();
}
/**
- * 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.getInstance().isProtocolSupported(ProtocolVersion.Protocol.OAC))
+ if (!protocolBridge.isProtocolSupported(ProtocolVersion.Protocol.OAC))
throw new UnsupportedProtocolException();
// Check if web client is already connected and close it
@@ -95,13 +101,13 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
try {
webClient.closeConnection();
} catch (IOException e) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to close connection to web server", e);
+ protocolBridge.getLogger().exception("Failed to close connection to web server", e);
return;
}
}
// Verify necessary certificate files exist
- webClient = new WebClient(domain, pipelinePort, webPort);
+ webClient = new WebClient(infoName, pipelinePort, webPort, this);
}
/**
@@ -127,8 +133,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
// Validate each file in the folder
for (File file : files) {
- if (!file.getName().startsWith(prefix) || !file.getName().endsWith(extension))
- throw new CertificateException(file.getAbsolutePath() + " is not valid");
+ if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
// Check for specific files
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
@@ -157,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
@@ -170,7 +175,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
try {
webClient.closeConnection();
} catch (IOException e) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to close connection to web server", e);
+ protocolBridge.getLogger().exception("Failed to close connection to web server", e);
}
}
}
@@ -297,54 +302,62 @@ 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.getInstance().isClassicSupported()) clientToDNS.sendPacket(cPingPacket);
+ Classic_PingPacket cPingPacket = new Classic_PingPacket(new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath(), protocolBridge), null, false, protocolBridge);
+ if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cPingPacket);
- // Send ValidateDomainPacket
- clientToDNS.sendPacket(new ValidateDomainPacket(domain));
+ // 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.getInstance().isClassicSupported()) clientToDNS.sendPacket(cDomainPacket);
+ Classic_DomainPacket cDomainPacket = new Classic_DomainPacket(0, new Classic_RequestDomain(infoName.getName(), infoName.getTopLevelName(), infoName.getPath(), protocolBridge), null, protocolBridge);
+ if (protocolBridge.isClassicSupported()) clientToINS.sendPacket(cDomainPacket);
// Send GetDestinationPacket
- clientToDNS.sendPacket(new GetDestinationPacket(domain, responseCode));
+ clientToINS.sendPacket(new GetDestinationPacket(infoName, responseCode, protocolBridge));
}
/**
- * Callback method invoked when domain validation is completed.
- *
- * @param domain the Domain that was validated.
- * @param responseCode the DNSResponseCode resulting from the validation.
+ * Set protocol bridge.
+ * @param protocolBridge The ProtocolBridge object.
*/
- public abstract void validationCompleted(Domain domain, DNSResponseCode responseCode);
+ public void setProtocolBridge(ProtocolBridge protocolBridge) {
+ if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
+ }
+
+ /**
+ * Callback method invoked when InfoName validation is completed.
+ *
+ * @param infoName the InfoName that was validated.
+ * @param responseCode the INSResponseCode resulting from the validation.
+ */
+ 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.
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/client/WebClient.java b/src/main/java/org/openautonomousconnection/protocol/side/client/WebClient.java
index 3fc6e8b..f6c5cef 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/client/WebClient.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/client/WebClient.java
@@ -1,10 +1,11 @@
package org.openautonomousconnection.protocol.side.client;
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
+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;
@@ -21,7 +22,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.
@@ -42,34 +43,43 @@ public final class WebClient {
*/
private ObjectInputStream inputStream;
+ /**
+ * The Protocol Client associated with this protocol client.
+ */
+ @Getter
+ private final ProtocolClient protocolClient;
+
/**
* 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) throws Exception {
+ public WebClient(InfoName infoName, int pipelinePort, int webPort, ProtocolClient protocolClient) throws Exception {
+ this.protocolClient = protocolClient;
+
// Initialize and connect the pipeline client
clientToWebPipeline = new NetworkClient.ClientBuilder().
// Set logger from ProtocolBridge
- setLogger(ProtocolBridge.getInstance().getLogger()).
+ setLogger(protocolClient.getProtocolBridge().getLogger()).
// Set the destination and port for the pipeline connection
- setHost(domain.getDestination()).setPort(pipelinePort).
+ setHost(infoName.getDestination(protocolClient.getProtocolBridge())).setPort(pipelinePort).
// Configure packet handler and event manager
- setPacketHandler(ProtocolBridge.getInstance().getProtocolSettings().packetHandler).
- setEventManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager).
+ setPacketHandler(protocolClient.getProtocolBridge().getProtocolSettings().packetHandler).
+ setEventManager(protocolClient.getProtocolBridge().getProtocolSettings().eventManager).
- // Set proxy and ssl parameters from DNS connection settings
- setProxy(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getProxy()).
- setSSLParameters(ProtocolBridge.getInstance().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(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicCAFolder).
- setClientCertificatesFolder(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicClientFolder,
- ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().privateClientFolder).
+ setRootCAFolder(protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().publicCAFolder).
+ setClientCertificatesFolder(protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().publicClientFolder,
+ protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().privateClientFolder).
// Finalize the client setup
@@ -83,9 +93,9 @@ public final class WebClient {
// Create SSL socket factory using client certificates
SSLSocketFactory sslSocketFactory = NetworkClient.ClientBuilder.
- createSSLSocketFactory(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicCAFolder,
- ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicClientFolder,
- ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().privateClientFolder);
+ createSSLSocketFactory(protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().publicCAFolder,
+ protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().publicClientFolder,
+ protocolClient.getProtocolBridge().getProtocolClient().getFolderStructure().privateClientFolder);
// Get proxy settings from the pipeline client
Proxy proxy = clientToWebPipeline.getProxy();
@@ -98,10 +108,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(protocolClient.getProtocolBridge()), webPort), 0);
+ tempSocket = (SSLSocket) sslSocketFactory.createSocket(rawSocket, infoName.getDestination(protocolClient.getProtocolBridge()), webPort, true);
} else {
- tempSocket = (SSLSocket) sslSocketFactory.createSocket(domain.getDestination(), webPort);
+ tempSocket = (SSLSocket) sslSocketFactory.createSocket(infoName.getDestination(protocolClient.getProtocolBridge()), webPort);
}
clientToWebServer = tempSocket;
@@ -166,7 +176,7 @@ public final class WebClient {
public boolean isConnected() {
return this.clientToWebServer != null && this.clientToWebServer.isConnected() && !this.clientToWebServer.isClosed()
&& this.receiveThread.isAlive() && !this.receiveThread.isInterrupted() &&
- ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().isConnected() && clientToWebPipeline.isConnected();
+ protocolClient.getProtocolBridge().getProtocolClient().getClientINSConnection().isConnected() && clientToWebPipeline.isConnected();
}
/**
@@ -183,7 +193,7 @@ public final class WebClient {
try {
this.closeConnection();
} catch (IOException exception) {
- ProtocolBridge.getInstance().getLogger().exception("Failed to close connection to web server", var2);
+ protocolClient.getProtocolBridge().getLogger().exception("Failed to close connection to web server", var2);
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolDNSServerEvent.java b/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolDNSServerEvent.java
deleted file mode 100644
index dc0c5ab..0000000
--- a/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolDNSServerEvent.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.openautonomousconnection.protocol.side.client.events;
-
-import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
-import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
-import org.openautonomousconnection.protocol.versions.ProtocolVersion;
-
-/**
- * Event triggered when a client successfully connects to a DNS protocol server.
- */
-@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
-public final class ConnectedToProtocolDNSServerEvent extends Event {
-}
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolINSServerEvent.java b/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolINSServerEvent.java
new file mode 100644
index 0000000..901e985
--- /dev/null
+++ b/src/main/java/org/openautonomousconnection/protocol/side/client/events/ConnectedToProtocolINSServerEvent.java
@@ -0,0 +1,25 @@
+package org.openautonomousconnection.protocol.side.client.events;
+
+import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
+import lombok.Getter;
+import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
+import org.openautonomousconnection.protocol.side.client.ProtocolClient;
+import org.openautonomousconnection.protocol.versions.ProtocolVersion;
+
+/**
+ * Event triggered when a client successfully connects to a INS protocol server.
+ */
+@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.INS)
+public final class ConnectedToProtocolINSServerEvent extends Event {
+
+ /**
+ * Reference to the ProtocolClient object.
+ */
+ @Getter
+ private final ProtocolClient client;
+
+ public ConnectedToProtocolINSServerEvent(ProtocolClient client) {
+ this.client = client;
+ }
+
+}
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/dns/ConnectedProtocolClient.java b/src/main/java/org/openautonomousconnection/protocol/side/ins/ConnectedProtocolClient.java
similarity index 93%
rename from src/main/java/org/openautonomousconnection/protocol/side/dns/ConnectedProtocolClient.java
rename to src/main/java/org/openautonomousconnection/protocol/side/ins/ConnectedProtocolClient.java
index 7f19fa5..1f66462 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/dns/ConnectedProtocolClient.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/ins/ConnectedProtocolClient.java
@@ -1,4 +1,4 @@
-package org.openautonomousconnection.protocol.side.dns;
+package org.openautonomousconnection.protocol.side.ins;
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
import lombok.Getter;
@@ -7,9 +7,9 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
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 {
/**
@@ -18,13 +18,20 @@ public final class ConnectedProtocolClient {
@Getter
private final ConnectionHandler connectionHandler;
+ /**
+ * The Protocol Server associated with this protocol client.
+ */
+ @Getter
+ private final ProtocolINSServer protocolINSServer;
+
/**
* The protocol version of the connected client.
*/
private ProtocolVersion clientVersion = null;
- public ConnectedProtocolClient(ConnectionHandler connectionHandler) {
+ public ConnectedProtocolClient(ConnectionHandler connectionHandler, ProtocolINSServer protocolINSServer) {
this.connectionHandler = connectionHandler;
+ this.protocolINSServer = protocolINSServer;
}
/**
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/dns/ProtocolDNSServer.java b/src/main/java/org/openautonomousconnection/protocol/side/ins/ProtocolINSServer.java
similarity index 72%
rename from src/main/java/org/openautonomousconnection/protocol/side/dns/ProtocolDNSServer.java
rename to src/main/java/org/openautonomousconnection/protocol/side/ins/ProtocolINSServer.java
index 7d34158..44b9d26 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/dns/ProtocolDNSServer.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/ins/ProtocolINSServer.java
@@ -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.
*/
@@ -47,13 +47,19 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
private ServerCertificateFolderStructure folderStructure;
/**
- * Constructs a ProtocolDNSServer with the specified configuration file.
+ * The reference to the ProtocolBridge Object
+ */
+ @Getter
+ private ProtocolBridge protocolBridge;
+
+ /**
+ * 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();
@@ -63,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();
}
@@ -88,7 +94,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
File keyFile = new File(folderStructure.privateServerFolder, folderStructure.certPrefix + NetworkUtils.getPublicIPAddress() + ".key");
// Initialize the protocol bridge and clients list
- ProtocolBridge protocolBridge = ProtocolBridge.getInstance();
this.clients = new ArrayList<>();
// Build the network server with the specified settings
@@ -126,8 +131,7 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
// Validate each file in the folder
for (File file : files) {
- if (!file.getName().startsWith(prefix) || !file.getName().endsWith(extension))
- throw new CertificateException(file.getAbsolutePath() + " is not valid");
+ if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
// Check if the file matches the expected naming convention
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
@@ -150,81 +154,87 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
}
/**
- * Gets the DNS information site URL from the configuration.
- *
- * @return The DNS information site URL.
+ * Set protocol bridge
+ * @param protocolBridge The ProtocolBridge object
*/
- public final String getDNSInfoSite() {
+ public void setProtocolBridge(ProtocolBridge protocolBridge) {
+ if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
+ }
+
+ /**
+ * Gets the INS information site URL from the configuration.
+ *
+ * @return The INS information site URL.
+ */
+ 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 getDomains();
+ public abstract List 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(ProtocolBridge)
+ * 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(ProtocolBridge)
+ * 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(ProtocolBridge)
+ * 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.
@@ -240,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");
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/dns/events/ConnectedProtocolClientEvent.java b/src/main/java/org/openautonomousconnection/protocol/side/ins/events/ConnectedProtocolClientEvent.java
similarity index 67%
rename from src/main/java/org/openautonomousconnection/protocol/side/dns/events/ConnectedProtocolClientEvent.java
rename to src/main/java/org/openautonomousconnection/protocol/side/ins/events/ConnectedProtocolClientEvent.java
index ef76840..6891621 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/dns/events/ConnectedProtocolClientEvent.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/ins/events/ConnectedProtocolClientEvent.java
@@ -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
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/web/ConnectedWebClient.java b/src/main/java/org/openautonomousconnection/protocol/side/web/ConnectedWebClient.java
index 8fd330c..5ab23d3 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/web/ConnectedWebClient.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/web/ConnectedWebClient.java
@@ -68,6 +68,12 @@ public final class ConnectedWebClient {
*/
private final Thread receiveThread = new Thread(this::receive);
+ /**
+ * The reference to the ProtocolWebServer Object
+ */
+ @Getter
+ private ProtocolWebServer protocolWebServer;
+
/**
* Sends an HTTP redirect response to the client.
*
@@ -629,7 +635,7 @@ public final class ConnectedWebClient {
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
path = normalizePath(path);
- File file = new File(ProtocolBridge.getInstance().getProtocolWebServer().getContentFolder(), path);
+ File file = new File(protocolWebServer.getProtocolBridge().getProtocolWebServer().getContentFolder(), path);
String sessionId = null;
if (headers.containsKey("cookie")) {
@@ -642,14 +648,14 @@ public final class ConnectedWebClient {
}
if (!file.exists() || !file.isFile()) {
- sendResponse(out, 404, new File(ProtocolBridge.getInstance().getProtocolWebServer().getErrorsFolder(), "404.html"));
+ sendResponse(out, 404, new File(protocolWebServer.getProtocolBridge().getProtocolWebServer().getErrorsFolder(), "404.html"));
return;
}
String clientIp = webSocket.getInetAddress().getHostAddress();
String userAgent = headers.getOrDefault("user-agent", null);
- boolean loggedIn = sessionId != null && SessionManager.isValid(sessionId, clientIp, userAgent);
+ boolean loggedIn = sessionId != null && SessionManager.isValid(sessionId, clientIp, userAgent, protocolWebServer);
if (path.equals("/403-login") && headers.getOrDefault("content-type", "").startsWith("application/x-www-form-urlencoded")) {
Map postParams = parsePostParams(in);
@@ -657,7 +663,7 @@ public final class ConnectedWebClient {
String password = postParams.get("password");
if (AuthManager.checkAuth(login, password)) {
- String newSessionId = SessionManager.create(login, clientIp, userAgent);
+ String newSessionId = SessionManager.create(login, clientIp, userAgent, protocolWebServer);
Map cookies = Map.of("Set-Cookie", "SESSIONID=" + newSessionId + "; HttpOnly; Path=/");
sendRedirect(out, "/main.html", cookies);
return;
@@ -668,18 +674,18 @@ public final class ConnectedWebClient {
}
if (isMultipart(headers)) {
- handleMultipart(in, headers, new File(ProtocolBridge.getInstance().getProtocolWebServer().getContentFolder(), "uploads"));
+ handleMultipart(in, headers, new File(protocolWebServer.getProtocolBridge().getProtocolWebServer().getContentFolder(), "uploads"));
}
if (RuleManager.requiresAuth(path) && !loggedIn) {
- PHPResponse phpResp = renderPHPWithCookies(new File(ProtocolBridge.getInstance().getProtocolWebServer().getContentFolder(), "403.php"));
+ PHPResponse phpResp = renderPHPWithCookies(new File(protocolWebServer.getProtocolBridge().getProtocolWebServer().getContentFolder(), "403.php"));
sendResponse(out, 200, phpResp.body.getBytes(StandardCharsets.UTF_8), "text/html", phpResp.cookies);
return;
}
if (RuleManager.isDenied(path) && !RuleManager.isAllowed(path)) {
- sendResponse(out, 403, new File(ProtocolBridge.getInstance().getProtocolWebServer().getErrorsFolder(), "403.php"));
+ sendResponse(out, 403, new File(protocolWebServer.getProtocolBridge().getProtocolWebServer().getErrorsFolder(), "403.php"));
return;
}
@@ -701,6 +707,14 @@ public final class ConnectedWebClient {
}
}
+ /**
+ * Set protocol bridge
+ * @param protocolWebServer The ProtocolWebServer object
+ */
+ public void setProtocolWebServer(ProtocolWebServer protocolWebServer) {
+ if (this.protocolWebServer == null) this.protocolWebServer = protocolWebServer;
+ }
+
/**
* Represents the response from a PHP script, including body and cookies.
*/
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/web/ProtocolWebServer.java b/src/main/java/org/openautonomousconnection/protocol/side/web/ProtocolWebServer.java
index 22b2239..349bb42 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/web/ProtocolWebServer.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/web/ProtocolWebServer.java
@@ -83,6 +83,12 @@ public final class ProtocolWebServer {
@Getter
private String uniqueSessionString;
+ /**
+ * The reference to the ProtocolBridge Object
+ */
+ @Getter
+ private ProtocolBridge protocolBridge;
+
/**
* Initializes the web server with the given configuration, authentication, and rules files.
*
@@ -159,8 +165,8 @@ public final class ProtocolWebServer {
// Initialize the pipeline server
pipelineServer = new NetworkServer.ServerBuilder().
setPort(configurationManager.getInt("port.pipeline")).setTimeout(0).
- setPacketHandler(ProtocolBridge.getInstance().getProtocolSettings().packetHandler).setEventManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager).
- setLogger(ProtocolBridge.getInstance().getLogger()).
+ setPacketHandler(protocolBridge.getProtocolSettings().packetHandler).setEventManager(protocolBridge.getProtocolSettings().eventManager).
+ setLogger(protocolBridge.getLogger()).
setServerCertificate(certFile, keyFile).setRootCAFolder(folderStructure.publicCAFolder).
build();
}
@@ -177,6 +183,14 @@ public final class ProtocolWebServer {
return null;
}
+ /**
+ * Set protocol bridge
+ * @param protocolBridge The ProtocolBridge object
+ */
+ public void setProtocolBridge(ProtocolBridge protocolBridge) {
+ if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
+ }
+
/**
* Starts the web server to accept and handle client connections.
*
@@ -228,6 +242,7 @@ public final class ProtocolWebServer {
if (connectedWebClient.getPipelineConnection().getClientID() != -1 && connectedWebClient.isClientVersionLoaded()) {
// Assign socket to an existing connected client
connectedWebClient.setWebSocket(client);
+ connectedWebClient.setProtocolWebServer(this);
}
}
} catch (IOException e) {
@@ -255,7 +270,7 @@ public final class ProtocolWebServer {
* @throws CertificateException If a required certificate file is missing or invalid.
* @throws IOException If an I/O error occurs while checking the files.
*/
- private void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
+ private final void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
boolean found = false;
// Ensure the folder exists
@@ -268,8 +283,7 @@ public final class ProtocolWebServer {
// Check for the required certificate file
for (File file : files) {
- if (!file.getName().startsWith(prefix) || !file.getName().endsWith(extension))
- throw new CertificateException(file.getAbsolutePath() + " is not valid");
+ if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
// Check for file matching the public IP address
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
diff --git a/src/main/java/org/openautonomousconnection/protocol/side/web/managers/SessionManager.java b/src/main/java/org/openautonomousconnection/protocol/side/web/managers/SessionManager.java
index 0903ba8..300581c 100644
--- a/src/main/java/org/openautonomousconnection/protocol/side/web/managers/SessionManager.java
+++ b/src/main/java/org/openautonomousconnection/protocol/side/web/managers/SessionManager.java
@@ -3,6 +3,7 @@ package org.openautonomousconnection.protocol.side.web.managers;
import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
+import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import java.io.IOException;
@@ -34,19 +35,20 @@ public final class SessionManager {
* @param login The username associated with the session.
* @param ip The IP address of the client.
* @param userAgent The User-Agent string of the client.
+ * @param protocolWebServer The Protocol WebServer for the unique Session
* @return The generated session ID.
* @throws IOException If an I/O error occurs.
*/
- public static String create(String login, String ip, String userAgent) throws IOException {
+ public static String create(String login, String ip, String userAgent, ProtocolWebServer protocolWebServer) throws IOException {
// Generate a secure random session ID
byte[] bytes = new byte[32];
secureRandom.nextBytes(bytes);
// Encode the bytes to a URL-safe Base64 string
- String sessionId = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes) + ProtocolBridge.getInstance().getProtocolWebServer().getUniqueSessionString();
+ String sessionId = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes) + protocolWebServer.getUniqueSessionString();
// Create and store the new session
- sessions.put(sessionId, new Session(login, ip, userAgent));
+ sessions.put(sessionId, new Session(login, ip, userAgent, protocolWebServer));
return sessionId;
}
@@ -56,10 +58,11 @@ public final class SessionManager {
* @param sessionId The session ID to validate.
* @param ip The IP address of the client.
* @param userAgent The User-Agent string of the client.
+ * @param protocolWebServer The Protocol WebServer to get the config for refreshing
* @return True if the session is valid, false otherwise.
* @throws IOException If an I/O error occurs.
*/
- public static boolean isValid(String sessionId, String ip, String userAgent) throws IOException {
+ public static boolean isValid(String sessionId, String ip, String userAgent, ProtocolWebServer protocolWebServer) throws IOException {
// Retrieve the session associated with the session ID
Session session = sessions.get(sessionId);
@@ -70,7 +73,7 @@ public final class SessionManager {
}
// Refresh the session expiration time
- session.refresh();
+ session.refresh(protocolWebServer);
return true;
}
@@ -122,11 +125,11 @@ public final class SessionManager {
String userAgent;
long expiresAt;
- Session(String login, String ip, String userAgent) throws IOException {
+ Session(String login, String ip, String userAgent, ProtocolWebServer protocolWebServer) throws IOException {
this.login = login;
this.ip = ip;
this.userAgent = userAgent;
- this.expiresAt = System.currentTimeMillis() + (long) ProtocolBridge.getInstance().getProtocolWebServer().getConfigurationManager().getInt("sessionexpireminutes") * 60 * 1000;
+ this.expiresAt = System.currentTimeMillis() + (long) protocolWebServer.getConfigurationManager().getInt("sessionexpireminutes") * 60 * 1000;
}
/**
@@ -151,11 +154,11 @@ public final class SessionManager {
/**
* Refreshes the session's expiration time.
- *
+ * @param protocolWebServer The Protocol WebServer to get the Config setting
* @throws IOException If an I/O error occurs.
*/
- void refresh() throws IOException {
- this.expiresAt = System.currentTimeMillis() + (long) ProtocolBridge.getInstance().getProtocolWebServer().getConfigurationManager().getInt("sessionexpireminutes") * 60 * 1000;
+ void refresh(ProtocolWebServer protocolWebServer) throws IOException {
+ this.expiresAt = System.currentTimeMillis() + (long) protocolWebServer.getConfigurationManager().getInt("sessionexpireminutes") * 60 * 1000;
}
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/ProtocolVersion.java b/src/main/java/org/openautonomousconnection/protocol/versions/ProtocolVersion.java
index 64ffe95..b2e30a4 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/ProtocolVersion.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/ProtocolVersion.java
@@ -14,7 +14,7 @@ public enum ProtocolVersion implements Serializable {
/**
* Support for old OAC-Project => *_old
*/
- 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
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/DNSResponseCode.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/DNSResponseCode.java
deleted file mode 100644
index 71524e3..0000000
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/DNSResponseCode.java
+++ /dev/null
@@ -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 + "}";
- }
-}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/Domain.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/Domain.java
deleted file mode 100644
index abd0c83..0000000
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/Domain.java
+++ /dev/null
@@ -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 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 + "/");
- }
- }
-
-}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/INSResponseCode.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/INSResponseCode.java
new file mode 100644
index 0000000..ce84668
--- /dev/null
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/INSResponseCode.java
@@ -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 + "}";
+ }
+}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/InfoName.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/InfoName.java
new file mode 100644
index 0000000..8366865
--- /dev/null
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/beta/InfoName.java
@@ -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 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(ProtocolBridge protocolBridge) {
+ // If running as client or web server, return invalid request
+ if (protocolBridge.isRunningAsClient() || protocolBridge.isRunningAsWebServer())
+ return INSResponseCode.RESPONSE_INVALID_REQUEST.toString();
+
+ // Handle special default InfoNames
+ if (this.equals(DefaultInfoNames.INS_INFO_SITE))
+ return protocolBridge.getProtocolINSServer().getINSInfoSite();
+ if (this.equals(DefaultInfoNames.INS_REGISTER_SITE))
+ return protocolBridge.getProtocolINSServer().getINSRegisterSite();
+ if (this.equals(DefaultInfoNames.TLN_INFO_SITE(topLevelName)))
+ return protocolBridge.getProtocolINSServer().getTLNInfoSite(topLevelName);
+
+ // Return destination based on whether subname exists
+ return !hasSubname() ? protocolBridge.getProtocolINSServer().getInfoNameDestination(this) : protocolBridge.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 + "/");
+ }
+ }
+
+}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_DomainPacketReceivedEvent.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_DomainPacketReceivedEvent.java
index a64dd31..504ff03 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_DomainPacketReceivedEvent.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_DomainPacketReceivedEvent.java
@@ -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
*/
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_PingPacketReceivedEvent.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_PingPacketReceivedEvent.java
index bba9656..34fec21 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_PingPacketReceivedEvent.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/events/Classic_PingPacketReceivedEvent.java
@@ -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
*/
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerClient.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerClient.java
index 4e420cc..9551fd8 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerClient.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerClient.java
@@ -1,8 +1,10 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
+import lombok.Getter;
import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_MessagePacket;
+import org.openautonomousconnection.protocol.side.client.ProtocolClient;
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.site.Classic_SiteType;
@@ -16,6 +18,21 @@ import java.io.IOException;
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
public abstract class ClassicHandlerClient {
+ /**
+ * Reference to the ProtocolClient
+ */
+ @Getter
+ private final ProtocolClient client;
+
+ /**
+ * Sets the client variable
+ *
+ * @param client The ProtocolClient Object
+ */
+ public ClassicHandlerClient(ProtocolClient client) {
+ this.client = client;
+ }
+
public abstract void unsupportedClassicPacket(String classicPacketClassName, Object[] content);
public abstract void handleHTMLContent(Classic_SiteType siteType, Classic_Domain domain, String html);
@@ -23,6 +40,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));
+ client.getClientINSConnection().sendPacket(new Classic_MessagePacket(message, 0, client.getProtocolBridge()));
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerDNSServer.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerINSServer.java
similarity index 81%
rename from src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerDNSServer.java
rename to src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerINSServer.java
index 4c1ca62..074a0d8 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerDNSServer.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerINSServer.java
@@ -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;
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerWebServer.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerWebServer.java
index 4457047..2a261df 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerWebServer.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/handlers/ClassicHandlerWebServer.java
@@ -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;
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_Domain.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_Domain.java
index acfe6dd..0e6177d 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_Domain.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_Domain.java
@@ -1,14 +1,15 @@
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.ProtocolBridge;
+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,45 +17,52 @@ 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 ProtocolBridge reference.
+ */
+ @Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
+ private final ProtocolBridge protocolBridge;
+
/**
* 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();
+ public Classic_Domain(String name, String topLevelDomain, String destination, String path, ProtocolBridge bridge) {
+ this.protocolBridge = bridge;
+ this.infoName = new InfoName(name + "." + topLevelDomain + "/" + (path.startsWith("/") ? path : "/" + path));
+ this.name = infoName.getName();
+ this.topLevelDomain = infoName.getTopLevelName();
+ this.destination = infoName.getDestination(bridge);
+ this.path = infoName.getPath();
}
@Override
protected final Object clone() throws CloneNotSupportedException {
- return new Classic_Domain(name, topLevelDomain, destination, path);
+ return new Classic_Domain(name, topLevelDomain, destination, path, protocolBridge);
}
@Override
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_LocalDomain.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_LocalDomain.java
index bdf6bbe..8b2c9c8 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_LocalDomain.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_LocalDomain.java
@@ -1,12 +1,14 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects;
+import org.openautonomousconnection.protocol.ProtocolBridge;
+
/**
* Class representing a local domain in the Classic protocol.
* This class extends Classic_Domain and is used for local domain representation.
*/
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final class Classic_LocalDomain extends Classic_Domain {
- public Classic_LocalDomain(String name, String endName, String path) {
- super(name, endName, null, path);
+ public Classic_LocalDomain(String name, String endName, String path, ProtocolBridge protocolBridge) {
+ super(name, endName, null, path, protocolBridge);
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_RequestDomain.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_RequestDomain.java
index c6d184b..408d520 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_RequestDomain.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/objects/Classic_RequestDomain.java
@@ -1,5 +1,7 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects;
+import org.openautonomousconnection.protocol.ProtocolBridge;
+
import java.io.Serializable;
/**
@@ -9,7 +11,7 @@ import java.io.Serializable;
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public final class Classic_RequestDomain extends Classic_Domain implements Serializable {
- public Classic_RequestDomain(String name, String topLevelDomain, String path) {
- super(name, topLevelDomain, null, path);
+ public Classic_RequestDomain(String name, String topLevelDomain, String path, ProtocolBridge protocolBridge) {
+ super(name, topLevelDomain, null, path, protocolBridge);
}
}
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_SiteType.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_SiteType.java
index 78c4547..0a82c04 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_SiteType.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_SiteType.java
@@ -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) {
diff --git a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_WebsitesContent.java b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_WebsitesContent.java
index 70941c0..66d5996 100644
--- a/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_WebsitesContent.java
+++ b/src/main/java/org/openautonomousconnection/protocol/versions/v1_0_0/classic/site/Classic_WebsitesContent.java
@@ -17,7 +17,7 @@ public final class Classic_WebsitesContent extends DefaultMethodsOverrider {
- 404 - This domain was not found
+ 404 - This infoName was not found