Renamed DNS to INS

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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