Compare commits

..

23 Commits

Author SHA1 Message Date
Tinglyyy
dae382d07d Added ProtocolInfoProcessing and its components 2025-09-29 18:27:03 +02:00
Tinglyyy
846fa167bc Revert "Revert "- Maked classes final""
This reverts commit 742059ff67.
2025-09-29 18:22:08 +02:00
Tinglyyy
1d2c94678e Revert "Revert "- Added comments""
This reverts commit 44ef52dba4.
2025-09-29 18:22:04 +02:00
Tinglyyy
8afab87f59 Revert "Revert "- Started with WebServer""
This reverts commit d14f2ec6f8.
2025-09-29 18:21:59 +02:00
Tinglyyy
bb5f312d63 Revert "Revert "- Code cleanup""
This reverts commit 95ac2b988b.
2025-09-29 18:21:54 +02:00
Tinglyyy
4b0009aff0 Revert "Revert "- Started with Web Protocol""
This reverts commit 944d0a71bc.
2025-09-29 18:21:50 +02:00
Tinglyyy
f0468c6f91 Revert "Revert "- Updated to new repo""
This reverts commit b88bae9f5e.
2025-09-29 18:21:45 +02:00
Tinglyyy
509d54c537 Revert "Revert "- Updated to new repo""
This reverts commit 257af4af91.
2025-09-29 18:21:41 +02:00
Tinglyyy
300615427c Revert "Revert "- Updated to new repo""
This reverts commit 06c5724803.
2025-09-29 18:21:37 +02:00
Tinglyyy
54e6c4163d Revert "Revert "- Updated to new repo""
This reverts commit 6c7a0728ee.
2025-09-29 18:21:32 +02:00
Tinglyyy
8a4c898bdf Revert "Revert "Update README.MD""
This reverts commit d2f6132ff0.
2025-09-29 18:21:28 +02:00
Tinglyyy
36493c4b5f Revert "Revert "Update README.MD""
This reverts commit 6e77d4dd8c.
2025-09-29 18:21:26 +02:00
Tinglyyy
6e77d4dd8c Revert "Update README.MD"
This reverts commit f0d7f89d2c.
2025-09-29 18:20:55 +02:00
Tinglyyy
d2f6132ff0 Revert "Update README.MD"
This reverts commit 1556896a5a.
2025-09-29 18:20:52 +02:00
Tinglyyy
6c7a0728ee Revert "- Updated to new repo"
This reverts commit d090b1067c.
2025-09-29 18:20:47 +02:00
Tinglyyy
06c5724803 Revert "- Updated to new repo"
This reverts commit 13953b94b0.
2025-09-29 18:20:41 +02:00
Tinglyyy
257af4af91 Revert "- Updated to new repo"
This reverts commit 4eb46ed50d.
2025-09-29 18:20:36 +02:00
Tinglyyy
b88bae9f5e Revert "- Updated to new repo"
This reverts commit f30a2a1046.
2025-09-29 18:20:33 +02:00
Tinglyyy
944d0a71bc Revert "- Started with Web Protocol"
This reverts commit 1dbfad7947.
2025-09-29 18:20:28 +02:00
Tinglyyy
95ac2b988b Revert "- Code cleanup"
This reverts commit f44ac49988.
2025-09-29 18:20:23 +02:00
Tinglyyy
d14f2ec6f8 Revert "- Started with WebServer"
This reverts commit fddf9d81ad.
2025-09-29 18:20:19 +02:00
Tinglyyy
44ef52dba4 Revert "- Added comments"
This reverts commit 1fe77f6076.
2025-09-29 18:20:16 +02:00
Tinglyyy
742059ff67 Revert "- Maked classes final"
This reverts commit f787463efc.
2025-09-29 18:20:02 +02:00
34 changed files with 176 additions and 349 deletions

33
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>org.openautonomousconnection</groupId> <groupId>org.openautonomousconnection</groupId>
<artifactId>protocol</artifactId> <artifactId>protocol</artifactId>
<version>1.0.0-BETA.5</version> <version>1.0.0-BETA.3</version>
<organization> <organization>
<name>Open Autonomous Connection</name> <name>Open Autonomous Connection</name>
<url>https://open-autonomous-connection.org/</url> <url>https://open-autonomous-connection.org/</url>
@@ -138,35 +138,4 @@
<version>LATEST</version> <version>LATEST</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@@ -4,6 +4,7 @@ import dev.unlegitdqrk.unlegitlibrary.utils.Logger;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo; import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.annotations.processing.ProtocolInfoProcessing;
import org.openautonomousconnection.protocol.listeners.ClientListener; import org.openautonomousconnection.protocol.listeners.ClientListener;
import org.openautonomousconnection.protocol.listeners.DNSServerListener; import org.openautonomousconnection.protocol.listeners.DNSServerListener;
import org.openautonomousconnection.protocol.listeners.WebServerListener; import org.openautonomousconnection.protocol.listeners.WebServerListener;
@@ -24,6 +25,7 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Class
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
/** /**
* The main bridge class for the protocol connection. * The main bridge class for the protocol connection.
@@ -94,13 +96,14 @@ public final class ProtocolBridge {
@Setter @Setter
private ClassicHandlerClient classicHandlerClient; private ClassicHandlerClient classicHandlerClient;
private final ProtocolInfoProcessing protocolInfoProcessing;
/** /**
* Initialize the ProtocolBridge instance for the DNS server side * Initialize the ProtocolBridge instance for the DNS server side
*
* @param protocolDNSServer The ProtocolDNSServer instance * @param protocolDNSServer The ProtocolDNSServer instance
* @param protocolSettings The ProtocolSettings instance * @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance * @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files * @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge * @throws Exception if an error occurs while initializing the ProtocolBridge
*/ */
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS) @ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
@@ -120,15 +123,16 @@ public final class ProtocolBridge {
// Set the static instance to this instance // Set the static instance to this instance
instance = this; instance = this;
this.protocolInfoProcessing = new ProtocolInfoProcessing();
} }
/** /**
* Initialize the ProtocolBridge instance for the web server side * Initialize the ProtocolBridge instance for the web server side
*
* @param protocolWebServer The ProtocolWebServer instance * @param protocolWebServer The ProtocolWebServer instance
* @param protocolSettings The ProtocolSettings instance * @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance * @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files * @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge * @throws Exception if an error occurs while initializing the ProtocolBridge
*/ */
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.WEB) @ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.WEB)
@@ -148,15 +152,16 @@ public final class ProtocolBridge {
// Set the static instance to this instance // Set the static instance to this instance
instance = this; instance = this;
this.protocolInfoProcessing = new ProtocolInfoProcessing();
} }
/** /**
* Initialize the ProtocolBridge instance for the client side * Initialize the ProtocolBridge instance for the client side
* * @param protocolClient The ProtocolClient instance
* @param protocolClient The ProtocolClient instance
* @param protocolSettings The ProtocolSettings instance * @param protocolSettings The ProtocolSettings instance
* @param protocolVersion The ProtocolVersion instance * @param protocolVersion The ProtocolVersion instance
* @param logFolder The folder to store the log files * @param logFolder The folder to store the log files
* @throws Exception if an error occurs while initializing the ProtocolBridge * @throws Exception if an error occurs while initializing the ProtocolBridge
*/ */
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT) @ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
@@ -176,6 +181,8 @@ public final class ProtocolBridge {
// Set the static instance to this instance // Set the static instance to this instance
instance = this; instance = this;
this.protocolInfoProcessing = new ProtocolInfoProcessing();
} }
/** /**
@@ -198,17 +205,13 @@ public final class ProtocolBridge {
GetDestinationPacket v100bGetDestinationPacket = new GetDestinationPacket(); GetDestinationPacket v100bGetDestinationPacket = new GetDestinationPacket();
if (isPacketSupported(v100bAuthPath)) protocolSettings.packetHandler.registerPacket(v100bAuthPath); if (isPacketSupported(v100bAuthPath)) protocolSettings.packetHandler.registerPacket(v100bAuthPath);
if (isPacketSupported(v100bUnsupportedClassicPacket)) if (isPacketSupported(v100bUnsupportedClassicPacket)) protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket);
protocolSettings.packetHandler.registerPacket(v100bUnsupportedClassicPacket); if (isPacketSupported(v100bValidateDomainPacket)) protocolSettings.packetHandler.registerPacket(v100bValidateDomainPacket);
if (isPacketSupported(v100bValidateDomainPacket)) if (isPacketSupported(v100bGetDestinationPacket)) protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
protocolSettings.packetHandler.registerPacket(v100bValidateDomainPacket);
if (isPacketSupported(v100bGetDestinationPacket))
protocolSettings.packetHandler.registerPacket(v100bGetDestinationPacket);
} }
/** /**
* Register the appropriate listeners based on the current side * Register the appropriate listeners based on the current side
*
* @throws Exception if an error occurs while registering the listeners * @throws Exception if an error occurs while registering the listeners
*/ */
private void registerListeners() throws Exception { private void registerListeners() throws Exception {
@@ -240,7 +243,6 @@ public final class ProtocolBridge {
/** /**
* Initialize the logger instance * Initialize the logger instance
*
* @param logFolder The folder to store the log files * @param logFolder The folder to store the log files
*/ */
private void initializeLogger(File logFolder) { private void initializeLogger(File logFolder) {
@@ -275,10 +277,9 @@ public final class ProtocolBridge {
/** /**
* Check if the classic protocol is supported by the current protocol version * Check if the classic protocol is supported by the current protocol version
*
* @return true if the classic protocol is supported, false otherwise * @return true if the classic protocol is supported, false otherwise
*/ */
public boolean isClassicSupported() { public final boolean isClassicSupported() {
boolean yes = false; boolean yes = false;
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) { for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
// Check if the compatible version is classic // Check if the compatible version is classic
@@ -292,11 +293,10 @@ public final class ProtocolBridge {
/** /**
* Check if the target protocol is supported by the current protocol version * Check if the target protocol is supported by the current protocol version
*
* @param protocol The target protocol to check * @param protocol The target protocol to check
* @return true If the target protocol is supported, false otherwise * @return true If the target protocol is supported, false otherwise
*/ */
public boolean isProtocolSupported(ProtocolVersion.Protocol protocol) { public final boolean isProtocolSupported(ProtocolVersion.Protocol protocol) {
boolean yes = false; boolean yes = false;
for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) { for (ProtocolVersion compatibleVersion : protocolVersion.getCompatibleVersions()) {
// Check if the compatible version supports the target protocol // Check if the compatible version supports the target protocol
@@ -310,28 +310,25 @@ public final class ProtocolBridge {
/** /**
* Check if the target packet is supported by the current protocol version * Check if the target packet is supported by the current protocol version
*
* @param packet The target packet to check * @param packet The target packet to check
* @return true if the target packet is supported, false otherwise * @return true if the target packet is supported, false otherwise
*/ */
public boolean isPacketSupported(OACPacket packet) { public final boolean isPacketSupported(OACPacket packet) {
return isVersionSupported(packet.getProtocolVersion()); return isVersionSupported(packet.getProtocolVersion());
} }
/** /**
* Check if the target protocol version is supported by the current protocol version * Check if the target protocol version is supported by the current protocol version
*
* @param targetVersion The target protocol version to check * @param targetVersion The target protocol version to check
* @return true if the target protocol version is supported, false otherwise * @return true if the target protocol version is supported, false otherwise
*/ */
public boolean isVersionSupported(ProtocolVersion targetVersion) { public final boolean isVersionSupported(ProtocolVersion targetVersion) {
// Check if the target protocol version is the same as the current protocol version or if it is in the list of compatible versions // Check if the target protocol version is the same as the current protocol version or if it is in the list of compatible versions
return protocolVersion == targetVersion || protocolVersion.getCompatibleVersions().contains(targetVersion); return protocolVersion == targetVersion || protocolVersion.getCompatibleVersions().contains(targetVersion);
} }
/** /**
* Validate if the protocol version is valid for the current side * Validate if the protocol version is valid for the current side
*
* @return true if the protocol version is valid for the current side, false otherwise * @return true if the protocol version is valid for the current side, false otherwise
*/ */
private boolean validateProtocolSide() { private boolean validateProtocolSide() {
@@ -354,28 +351,25 @@ public final class ProtocolBridge {
/** /**
* Check if the current instance is running as a DNS server * Check if the current instance is running as a DNS 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 DNS server, false otherwise
*/ */
public boolean isRunningAsDNSServer() { public final boolean isRunningAsDNSServer() {
return protocolDNSServer != null; return protocolDNSServer != null;
} }
/** /**
* Check if the current instance is running as a client * Check if the current instance is running as a client
*
* @return true if the current instance is running as a client, false otherwise * @return true if the current instance is running as a client, false otherwise
*/ */
public boolean isRunningAsClient() { public final boolean isRunningAsClient() {
return protocolClient != null; return protocolClient != null;
} }
/** /**
* Check if the current instance is running as a web server * Check if the current instance is running as a web server
*
* @return true if the current instance is running as a web server, false otherwise * @return true if the current instance is running as a web server, false otherwise
*/ */
public boolean isRunningAsWebServer() { public final boolean isRunningAsWebServer() {
return protocolWebServer != null; return protocolWebServer != null;
} }
} }

View File

@@ -2,19 +2,14 @@ package org.openautonomousconnection.protocol.annotations;
import org.openautonomousconnection.protocol.versions.ProtocolVersion; import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/** /**
* Annotation to provide metadata about protocol handlers or classes. * Annotation to provide metadata about protocol handlers or classes.
*/ */
@Retention(RetentionPolicy.RUNTIME)
public @interface ProtocolInfo { public @interface ProtocolInfo {
/** /**
* Specifies the side of the protocol that the annotated class or method is associated with. * Specifies the side of the protocol that the annotated class or method is associated with.
* Default is ALL, indicating that it can be used on any side. * Default is ALL, indicating that it can be used on any side.
*
* @return The protocol side. * @return The protocol side.
*/ */
ProtocolVersion.ProtocolSide protocolSide() default ProtocolVersion.ProtocolSide.ALL; ProtocolVersion.ProtocolSide protocolSide() default ProtocolVersion.ProtocolSide.ALL;

View File

@@ -36,16 +36,21 @@ public class CallTracker<A extends Annotation> extends GenericReflectClass<A> {
} }
public abstract static class CallInterceptor { public abstract static class CallInterceptor {
private static final Set<CallInterceptor> interceptors = new HashSet<>(); private static Set<CallInterceptor> interceptors = new HashSet<>();
public CallInterceptor() { public CallInterceptor() {
interceptors.add(this); interceptors.add(this);
} }
/**
* Code executed on any method call
*/
public abstract void onCall(Method method, @Nullable StackTraceElement callerMethod);
@Advice.OnMethodEnter @Advice.OnMethodEnter
static void intercept(@Advice.Origin Method method) { static void intercept(@Advice.Origin Method method) {
for (CallInterceptor interceptor : interceptors) { for(CallInterceptor interceptor : interceptors) {
StackTraceElement[] stack = Thread.currentThread().getStackTrace(); StackTraceElement[] stack = Thread.currentThread().getStackTrace();
if (stack.length <= 3) if (stack.length <= 3)
@@ -74,10 +79,5 @@ public class CallTracker<A extends Annotation> extends GenericReflectClass<A> {
// //
// } // }
} }
/**
* Code executed on any method call
*/
public abstract void onCall(Method method, @Nullable StackTraceElement callerMethod);
} }
} }

View File

@@ -5,7 +5,7 @@ package org.openautonomousconnection.protocol.annotations.processing;
import dev.unlegitdqrk.unlegitlibrary.reflections.annotation.processing.AnnotationProcessor; import dev.unlegitdqrk.unlegitlibrary.reflections.annotation.processing.AnnotationProcessor;
import org.openautonomousconnection.protocol.annotations.ProtocolInfo; import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.exceptions.IncompatibleProtocolSideException; import org.openautonomousconnection.protocol.exceptions.IncompatibleProtocolException;
import org.openautonomousconnection.protocol.versions.ProtocolVersion; import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -41,25 +41,26 @@ public class ProtocolInfoProcessing extends AnnotationProcessor<ProtocolInfo> {
Object o; Object o;
if ((o = methodGetByName(callerMethod.getMethodName())) != null) if((o = methodGetByName(callerMethod.getMethodName())) != null)
callerSide = ((Method) o).getAnnotation(ProtocolInfo.class).protocolSide(); callerSide = ((Method) o).getAnnotation(ProtocolInfo.class).protocolSide();
else if ((o = typeHasAnnotation(callerMethod.getClassName())) != null) else if((o = typeHasAnnotation(callerMethod.getClassName())) != null)
callerSide = ((Class<?>) o).getAnnotation(ProtocolInfo.class).protocolSide(); callerSide = ((Class<?>) o).getAnnotation(ProtocolInfo.class).protocolSide();
else else
return; return;
if (methodReferences.get().contains(method)) if(methodReferences.get().contains(method))
side = method.getAnnotation(ProtocolInfo.class).protocolSide(); side = method.getAnnotation(ProtocolInfo.class).protocolSide();
else if (typeReferences.get().contains(method.getDeclaringClass())) else if(typeReferences.get().contains(method.getDeclaringClass()))
side = method.getDeclaringClass().getAnnotation(ProtocolInfo.class).protocolSide(); side = method.getDeclaringClass().getAnnotation(ProtocolInfo.class).protocolSide();
else else
return; return;
if (callerSide.equals(ProtocolVersion.ProtocolSide.CLIENT) && if(callerSide.equals(ProtocolVersion.ProtocolSide.CLIENT) &&
!side.equals(callerSide)) !side.equals(callerSide))
throw new IncompatibleProtocolSideException(callerSide, side); throw new IncompatibleProtocolException(callerSide, side);
} }
@@ -67,15 +68,15 @@ public class ProtocolInfoProcessing extends AnnotationProcessor<ProtocolInfo> {
} }
private Method methodGetByName(String methodName) { private Method methodGetByName(String methodName) {
for (Method method : this.annotatedMethods) for(Method method : this.annotatedMethods)
if (method.getName().equals(methodName)) if(method.getName().equals(methodName))
return method; return method;
return null; return null;
} }
private Class<?> typeHasAnnotation(String typeName) { private Class<?> typeHasAnnotation(String typeName) {
for (Class<?> type : this.annotatedTypes) for(Class<?> type : this.annotatedTypes)
if (type.getName().equals(typeName)) if(type.getName().equals(typeName))
return type; return type;
return null; return null;
} }

View File

@@ -0,0 +1,9 @@
package org.openautonomousconnection.protocol.exceptions;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
public class IncompatibleProtocolException extends RuntimeException {
public IncompatibleProtocolException(ProtocolVersion.ProtocolSide callerSide, ProtocolVersion.ProtocolSide side) {
super(callerSide.name() + " is incompatible with called method of ProtocolSide " + side.name());
}
}

View File

@@ -1,12 +0,0 @@
package org.openautonomousconnection.protocol.exceptions;
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
/**
* Exception thrown when an unsupported protocol side method is called.
*/
public class IncompatibleProtocolSideException extends RuntimeException {
public IncompatibleProtocolSideException(ProtocolVersion.ProtocolSide callerSide, ProtocolVersion.ProtocolSide side) {
super(callerSide.name() + " is incompatible with called method of ProtocolSide " + side.name());
}
}

View File

@@ -20,7 +20,6 @@ public final class ClientListener extends EventListener {
/** /**
* Handles the event when a client connects. * Handles the event when a client connects.
* Sends an authentication packet to the server. * Sends an authentication packet to the server.
*
* @param event The client connected event. * @param event The client connected event.
*/ */
@Listener @Listener
@@ -36,7 +35,6 @@ public final class ClientListener extends EventListener {
/** /**
* Handles the event when a client disconnects. * Handles the event when a client disconnects.
* Notifies the protocol client of the disconnection. * Notifies the protocol client of the disconnection.
*
* @param event The client disconnected event. * @param event The client disconnected event.
*/ */
@Listener @Listener

View File

@@ -18,7 +18,6 @@ public final class DNSServerListener extends EventListener {
/** /**
* Handles the event when a connection handler connects to the DNS server. * Handles the event when a connection handler connects to the DNS server.
* Adds the connected client to the ProtocolBridge's DNS server client list. * Adds the connected client to the ProtocolBridge's DNS server client list.
*
* @param event The connection handler connected event. * @param event The connection handler connected event.
*/ */
@Listener @Listener
@@ -29,7 +28,6 @@ public final class DNSServerListener extends EventListener {
/** /**
* Handles the event when a connection handler disconnects from the DNS server. * Handles the event when a connection handler disconnects from the DNS server.
* Removes the disconnected client from the ProtocolBridge's DNS server client list. * Removes the disconnected client from the ProtocolBridge's DNS server client list.
*
* @param event The connection handler disconnected event. * @param event The connection handler disconnected event.
*/ */
@Listener @Listener

View File

@@ -18,7 +18,6 @@ public final class WebServerListener extends EventListener {
/** /**
* Handles the event when a connection is established. * Handles the event when a connection is established.
* Adds the connected client to the protocol web server's client list. * Adds the connected client to the protocol web server's client list.
*
* @param event The connection handler connected event. * @param event The connection handler connected event.
*/ */
@Listener @Listener
@@ -29,7 +28,6 @@ public final class WebServerListener extends EventListener {
/** /**
* Handles the event when a connection is disconnected. * Handles the event when a connection is disconnected.
* Removes the disconnected client from the protocol web server's client list. * Removes the disconnected client from the protocol web server's client list.
*
* @param event The connection handler disconnected event. * @param event The connection handler disconnected event.
*/ */
@Listener @Listener

View File

@@ -29,7 +29,6 @@ public abstract class OACPacket extends Packet {
/** /**
* Constructor for OACPacket. * Constructor for OACPacket.
*
* @param id The unique identifier for the packet. * @param id The unique identifier for the packet.
* @param protocolVersion The protocol version associated with this packet. * @param protocolVersion The protocol version associated with this packet.
*/ */
@@ -40,7 +39,6 @@ public abstract class OACPacket extends Packet {
/** /**
* Gets the response code for the packet. * Gets the response code for the packet.
*
* @return The DNSResponseCode associated with the packet. * @return The DNSResponseCode associated with the packet.
*/ */
protected final DNSResponseCode getResponseCode() { protected final DNSResponseCode getResponseCode() {
@@ -49,7 +47,6 @@ public abstract class OACPacket extends Packet {
/** /**
* Sets the response code for the packet. * Sets the response code for the packet.
*
* @param responseCode The DNSResponseCode to set for the packet. * @param responseCode The DNSResponseCode to set for the packet.
*/ */
protected final void setResponseCode(DNSResponseCode responseCode) { protected final void setResponseCode(DNSResponseCode responseCode) {
@@ -58,7 +55,6 @@ public abstract class OACPacket extends Packet {
/** /**
* Writes the packet data to the output stream. * Writes the packet data to the output stream.
*
* @param packetHandler The packet handler managing the packet. * @param packetHandler The packet handler managing the packet.
* @param objectOutputStream The output stream to write the packet data to. * @param objectOutputStream The output stream to write the packet data to.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -79,8 +75,7 @@ public abstract class OACPacket extends Packet {
onRead(packetHandler, objectInputStream); onRead(packetHandler, objectInputStream);
// Read the response code if the protocol version is not classic // Read the response code if the protocol version is not classic
if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) if (protocolVersion != ProtocolVersion.PV_1_0_0_CLASSIC) responseCode = (DNSResponseCode) objectInputStream.readObject();
responseCode = (DNSResponseCode) objectInputStream.readObject();
else responseCode = DNSResponseCode.RESPONSE_NOT_REQUIRED; else responseCode = DNSResponseCode.RESPONSE_NOT_REQUIRED;
// Call the response code read handler // Call the response code read handler
@@ -89,7 +84,6 @@ public abstract class OACPacket extends Packet {
/** /**
* Abstract method to be implemented by subclasses for writing specific packet data. * Abstract method to be implemented by subclasses for writing specific packet data.
*
* @param packetHandler The packet handler managing the packet. * @param packetHandler The packet handler managing the packet.
* @param objectOutputStream The output stream to write the packet data to. * @param objectOutputStream The output stream to write the packet data to.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -99,9 +93,8 @@ public abstract class OACPacket extends Packet {
/** /**
* Abstract method to be implemented by subclasses for reading specific packet data. * Abstract method to be implemented by subclasses for reading specific packet data.
* * @param packetHandler The packet handler managing the packet.
* @param packetHandler The packet handler managing the packet. * @param objectInputStream The input stream to read the packet data from.
* @param objectInputStream The input stream to read the packet data from.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws ClassNotFoundException If a class cannot be found during deserialization. * @throws ClassNotFoundException If a class cannot be found during deserialization.
*/ */
@@ -110,10 +103,8 @@ public abstract class OACPacket extends Packet {
/** /**
* Method called after the response code has been read from the input stream. * Method called after the response code has been read from the input stream.
* Subclasses can override this method to handle any additional logic based on the response code. * Subclasses can override this method to handle any additional logic based on the response code.
* * @param packetHandler The packet handler managing the packet.
* @param packetHandler The packet handler managing the packet. * @param objectInputStream The input stream from which the response code was read.
* @param objectInputStream The input stream from which the response code was read.
*/ */
protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) { protected void onResponseCodeRead(PacketHandler packetHandler, ObjectInputStream objectInputStream) {}
}
} }

View File

@@ -27,7 +27,7 @@ public final class AuthPacket extends OACPacket {
File privateFolder = new File(certificatesFolder, "private"); File privateFolder = new File(certificatesFolder, "private");
File privateCAFolder = new File(privateFolder, "ca"); File privateCAFolder = new File(privateFolder, "ca");
File privateServerFolder = new File(privateFolder, "server"); File privateServerFolder = new File(privateFolder, "server");
// Registration Constructor
public AuthPacket() { public AuthPacket() {
super(4, ProtocolVersion.PV_1_0_0_BETA); super(4, ProtocolVersion.PV_1_0_0_BETA);
} }

View File

@@ -5,10 +5,10 @@ import org.openautonomousconnection.protocol.ProtocolBridge;
import org.openautonomousconnection.protocol.packets.OACPacket; import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket; import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
import org.openautonomousconnection.protocol.versions.ProtocolVersion; import org.openautonomousconnection.protocol.versions.ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_DomainPacketReceivedEvent;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain; 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.events.Classic_DomainPacketReceivedEvent;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;

View File

@@ -27,8 +27,7 @@ public final class Classic_MessagePacket extends OACPacket {
@Override @Override
public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException { public void onWrite(PacketHandler packetHandler, ObjectOutputStream objectOutputStream) throws IOException, ClassNotFoundException {
if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer()) if (ProtocolBridge.getInstance().isRunningAsDNSServer() || ProtocolBridge.getInstance().isRunningAsWebServer()) objectOutputStream.writeInt(clientID);
objectOutputStream.writeInt(clientID);
else if (ProtocolBridge.getInstance().isRunningAsClient()) { else if (ProtocolBridge.getInstance().isRunningAsClient()) {
clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID(); clientID = ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getClientID();
objectOutputStream.writeInt(clientID); objectOutputStream.writeInt(clientID);

View File

@@ -6,10 +6,10 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket; import org.openautonomousconnection.protocol.packets.v1_0_0.beta.UnsupportedClassicPacket;
import org.openautonomousconnection.protocol.versions.ProtocolVersion; 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.DNSResponseCode;
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_Domain;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.events.Classic_PingPacketReceivedEvent;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;

View File

@@ -52,7 +52,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Initializes the ProtocolClient, setting up certificate folders and the DNS client connection. * Initializes the ProtocolClient, setting up certificate folders and the DNS client connection.
*
* @throws CertificateException if there are issues with the certificates. * @throws CertificateException if there are issues with the certificates.
* @throws IOException if there are I/O issues during initialization. * @throws IOException if there are I/O issues during initialization.
*/ */
@@ -70,7 +69,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Gets the DNS connection client. * Gets the DNS connection client.
*
* @return the NetworkClient handling the DNS connection. * @return the NetworkClient handling the DNS connection.
*/ */
public final NetworkClient getClientDNSConnection() { public final NetworkClient getClientDNSConnection() {
@@ -79,10 +77,9 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Creates a web connection to the specified domain and ports. * Creates a web connection to the specified domain and ports.
* * @param domain the target domain for the web connection.
* @param domain the target domain for the web connection.
* @param pipelinePort the port used for the pipeline connection. * @param pipelinePort the port used for the pipeline connection.
* @param webPort the port used for the web 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. * @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(Domain domain, int pipelinePort, int webPort) throws Exception {
@@ -106,7 +103,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the required certificate files exist in the specified folder. * Checks if the required certificate files exist in the specified folder.
*
* @param folder the folder to check for certificate files. * @param folder the folder to check for certificate files.
* @param prefix the prefix of the certificate files. * @param prefix the prefix of the certificate files.
* @param extension the extension of the certificate files. * @param extension the extension of the certificate files.
@@ -140,7 +136,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Gets the protocol version of the connected server. * Gets the protocol version of the connected server.
*
* @return the ProtocolVersion of the server, or PV_1_0_0_CLASSIC if not set. * @return the ProtocolVersion of the server, or PV_1_0_0_CLASSIC if not set.
*/ */
public final ProtocolVersion getServerVersion() { public final ProtocolVersion getServerVersion() {
@@ -149,7 +144,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Sets the protocol version of the connected server. * Sets the protocol version of the connected server.
*
* @param serverVersion the ProtocolVersion to set for the server. * @param serverVersion the ProtocolVersion to set for the server.
*/ */
public final void setServerVersion(ProtocolVersion serverVersion) { public final void setServerVersion(ProtocolVersion serverVersion) {
@@ -158,7 +152,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Handles DNS disconnection events, resetting the server version and closing the web client connection if necessary. * Handles DNS 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 DNS disconnection.
*/ */
public final void onDNSDisconnect(ClientDisconnectedEvent event) { public final void onDNSDisconnect(ClientDisconnectedEvent event) {
@@ -177,7 +170,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server is a stable server. * Checks if the connected server is a stable server.
*
* @return true if the server is stable, false otherwise. * @return true if the server is stable, false otherwise.
*/ */
public final boolean isStableServer() { public final boolean isStableServer() {
@@ -187,7 +179,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server or its compatible versions support stable protocol. * Checks if the connected server or its compatible versions support stable protocol.
*
* @return true if stable protocol is supported, false otherwise. * @return true if stable protocol is supported, false otherwise.
*/ */
public final boolean supportServerStable() { public final boolean supportServerStable() {
@@ -204,7 +195,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server is a beta server. * Checks if the connected server is a beta server.
*
* @return true if the server is beta, false otherwise. * @return true if the server is beta, false otherwise.
*/ */
public final boolean isBetaServer() { public final boolean isBetaServer() {
@@ -214,7 +204,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server or its compatible versions support beta protocol. * Checks if the connected server or its compatible versions support beta protocol.
*
* @return true if beta protocol is supported, false otherwise. * @return true if beta protocol is supported, false otherwise.
*/ */
public final boolean supportServerBeta() { public final boolean supportServerBeta() {
@@ -231,7 +220,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server is a classic server. * Checks if the connected server is a classic server.
*
* @return true if the server is classic, false otherwise. * @return true if the server is classic, false otherwise.
*/ */
public final boolean isClassicServer() { public final boolean isClassicServer() {
@@ -241,7 +229,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server or its compatible versions support classic protocol. * Checks if the connected server or its compatible versions support classic protocol.
*
* @return true if classic protocol is supported, false otherwise. * @return true if classic protocol is supported, false otherwise.
*/ */
public final boolean supportServerClassic() { public final boolean supportServerClassic() {
@@ -258,7 +245,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server supports the protocol version of the given packet. * Checks if the connected server supports the protocol version of the given packet.
*
* @param packet the OACPacket to check against the server's supported protocol version. * @param packet the OACPacket to check against the server's supported protocol version.
* @return true if the server supports the packet's protocol version, false otherwise. * @return true if the server supports the packet's protocol version, false otherwise.
*/ */
@@ -269,7 +255,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server or its compatible versions support the specified protocol version. * Checks if the connected server or its compatible versions support the specified protocol version.
*
* @param targetVersion the ProtocolVersion to check for support. * @param targetVersion the ProtocolVersion to check for support.
* @return true if the server or its compatible versions support the target version, false otherwise. * @return true if the server or its compatible versions support the target version, false otherwise.
*/ */
@@ -280,7 +265,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Checks if the connected server or its compatible versions support the specified protocol. * Checks if the connected server or its compatible versions support the specified protocol.
*
* @param protocol the Protocol to check for support. * @param protocol the Protocol to check for support.
* @return true if the server or its compatible versions support the protocol, false otherwise. * @return true if the server or its compatible versions support the protocol, false otherwise.
*/ */
@@ -298,7 +282,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Validates the specified domain by sending a validation request to the DNS server. * Validates the specified domain by sending a validation request to the DNS server.
*
* @param domain the Domain to validate. * @param domain the Domain to validate.
* @throws IOException if there are I/O issues during the validation process. * @throws IOException if there are I/O issues during the validation process.
* @throws ClassNotFoundException if there are issues with class loading during packet handling. * @throws ClassNotFoundException if there are issues with class loading during packet handling.
@@ -314,7 +297,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Requests the destination for the specified domain from the DNS server. * Requests the destination for the specified domain from the DNS server.
*
* @param domain the Domain for which to request the destination. * @param domain the Domain for which to request the destination.
* @param responseCode the expected DNSResponseCode for the request. * @param responseCode the expected DNSResponseCode for the request.
* @throws IOException if there are I/O issues during the request process. * @throws IOException if there are I/O issues during the request process.
@@ -331,7 +313,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Callback method invoked when domain validation is completed. * Callback method invoked when domain validation is completed.
*
* @param domain the Domain that was validated. * @param domain the Domain that was validated.
* @param responseCode the DNSResponseCode resulting from the validation. * @param responseCode the DNSResponseCode resulting from the validation.
*/ */
@@ -339,7 +320,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
/** /**
* Callback method invoked when the destination retrieval is completed. * Callback method invoked when the destination retrieval is completed.
*
* @param domain the Domain for which the destination was requested. * @param domain the Domain for which the destination was requested.
* @param destination the retrieved destination as a string. * @param destination the retrieved destination as a string.
* @param validationResponse the DNSResponseCode resulting from the destination retrieval. * @param validationResponse the DNSResponseCode resulting from the destination retrieval.

View File

@@ -42,9 +42,13 @@ public final class WebClient {
*/ */
private ObjectInputStream inputStream; private ObjectInputStream inputStream;
/**
* Thread for receiving data from the web server.
*/
private final Thread receiveThread = new Thread(this::receive);
/** /**
* Constructs a WebClient instance and establishes a secure connection to the web server. * Constructs a WebClient instance and establishes a secure connection to the web server.
*
* @param domain The domain information for the web server. * @param domain The domain information for the web server.
* @param pipelinePort The port for the pipeline connection. * @param pipelinePort The port for the pipeline connection.
* @param webPort The port for the web server connection. * @param webPort The port for the web server connection.
@@ -54,26 +58,26 @@ public final class WebClient {
// Initialize and connect the pipeline client // Initialize and connect the pipeline client
clientToWebPipeline = new NetworkClient.ClientBuilder(). clientToWebPipeline = new NetworkClient.ClientBuilder().
// Set logger from ProtocolBridge // Set logger from ProtocolBridge
setLogger(ProtocolBridge.getInstance().getLogger()). setLogger(ProtocolBridge.getInstance().getLogger()).
// Set the destination and port for the pipeline connection // Set the destination and port for the pipeline connection
setHost(domain.getDestination()).setPort(pipelinePort). setHost(domain.getDestination()).setPort(pipelinePort).
// Configure packet handler and event manager // Configure packet handler and event manager
setPacketHandler(ProtocolBridge.getInstance().getProtocolSettings().packetHandler). setPacketHandler(ProtocolBridge.getInstance().getProtocolSettings().packetHandler).
setEventManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager). setEventManager(ProtocolBridge.getInstance().getProtocolSettings().eventManager).
// Set proxy and ssl parameters from DNS connection settings // Set proxy and ssl parameters from DNS connection settings
setProxy(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getProxy()). setProxy(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getProxy()).
setSSLParameters(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getSocket().getSSLParameters()). setSSLParameters(ProtocolBridge.getInstance().getProtocolClient().getClientDNSConnection().getSocket().getSSLParameters()).
// Set certificates and folders for SSL // Set certificates and folders for SSL
setRootCAFolder(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicCAFolder). setRootCAFolder(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicCAFolder).
setClientCertificatesFolder(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicClientFolder, setClientCertificatesFolder(ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().publicClientFolder,
ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().privateClientFolder). ProtocolBridge.getInstance().getProtocolClient().getFolderStructure().privateClientFolder).
// Finalize the client setup // Finalize the client setup
build(); build();
// Connect to the pipeline // Connect to the pipeline
clientToWebPipeline.connect(); clientToWebPipeline.connect();
@@ -135,14 +139,10 @@ public final class WebClient {
// Start the receive thread // Start the receive thread
this.receiveThread.start(); this.receiveThread.start();
} }
} /** }
* Thread for receiving data from the web server.
*/
private final Thread receiveThread = new Thread(this::receive);
/** /**
* Gets the NetworkClient used for the pipeline connection to the web server. * Gets the NetworkClient used for the pipeline connection to the web server.
*
* @return The NetworkClient connected to the web server pipeline. * @return The NetworkClient connected to the web server pipeline.
*/ */
public NetworkClient getClientPipelineConnection() { public NetworkClient getClientPipelineConnection() {
@@ -151,7 +151,6 @@ public final class WebClient {
/** /**
* Gets the SSLSocket used for communication with the web server. * Gets the SSLSocket used for communication with the web server.
*
* @return The SSLSocket connected to the web server. * @return The SSLSocket connected to the web server.
*/ */
public SSLSocket getClientWebConnection() { public SSLSocket getClientWebConnection() {
@@ -160,7 +159,6 @@ public final class WebClient {
/** /**
* Checks if the WebClient is currently connected to the web server. * Checks if the WebClient is currently connected to the web server.
*
* @return true if connected, false otherwise. * @return true if connected, false otherwise.
*/ */
public boolean isConnected() { public boolean isConnected() {
@@ -190,7 +188,6 @@ public final class WebClient {
/** /**
* Closes the connection to the web server and releases resources. * Closes the connection to the web server and releases resources.
*
* @return true if the connection was successfully closed, false if it was already closed. * @return true if the connection was successfully closed, false if it was already closed.
* @throws IOException If an I/O error occurs during closure. * @throws IOException If an I/O error occurs during closure.
*/ */
@@ -228,6 +225,4 @@ public final class WebClient {
} }
} }

View File

@@ -30,7 +30,6 @@ public final class ConnectedProtocolClient {
/** /**
* Gets the protocol version of the connected client. * Gets the protocol version of the connected client.
* Defaults to PV_1_0_0_CLASSIC if not set. * Defaults to PV_1_0_0_CLASSIC if not set.
*
* @return The protocol version of the client. * @return The protocol version of the client.
*/ */
public ProtocolVersion getClientVersion() { public ProtocolVersion getClientVersion() {
@@ -39,7 +38,6 @@ public final class ConnectedProtocolClient {
/** /**
* Sets the protocol version of the connected client. * Sets the protocol version of the connected client.
*
* @param clientVersion The protocol version to set. * @param clientVersion The protocol version to set.
*/ */
public void setClientVersion(ProtocolVersion clientVersion) { public void setClientVersion(ProtocolVersion clientVersion) {
@@ -48,7 +46,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client is a stable client. * Checks if the connected client is a stable client.
*
* @return True if the client is stable, false otherwise. * @return True if the client is stable, false otherwise.
*/ */
public boolean isStableClient() { public boolean isStableClient() {
@@ -58,7 +55,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports stable protocol versions. * Checks if the connected client supports stable protocol versions.
*
* @return True if the client supports stable versions, false otherwise. * @return True if the client supports stable versions, false otherwise.
*/ */
public boolean supportClientStable() { public boolean supportClientStable() {
@@ -75,7 +71,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client is a beta client. * Checks if the connected client is a beta client.
*
* @return True if the client is beta, false otherwise. * @return True if the client is beta, false otherwise.
*/ */
public boolean isBetaClient() { public boolean isBetaClient() {
@@ -85,7 +80,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports beta protocol versions. * Checks if the connected client supports beta protocol versions.
*
* @return True if the client supports beta versions, false otherwise. * @return True if the client supports beta versions, false otherwise.
*/ */
public boolean supportClientBeta() { public boolean supportClientBeta() {
@@ -102,7 +96,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client is a classic client. * Checks if the connected client is a classic client.
*
* @return True if the client is classic, false otherwise. * @return True if the client is classic, false otherwise.
*/ */
public boolean isClassicClient() { public boolean isClassicClient() {
@@ -113,7 +106,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports classic protocol versions. * Checks if the connected client supports classic protocol versions.
*
* @return True if the client supports classic versions, false otherwise. * @return True if the client supports classic versions, false otherwise.
*/ */
public boolean supportClientClassic() { public boolean supportClientClassic() {
@@ -130,7 +122,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports the given packet's protocol version. * Checks if the connected client supports the given packet's protocol version.
*
* @param packet The packet to check. * @param packet The packet to check.
* @return True if the client supports the packet's protocol version, false otherwise. * @return True if the client supports the packet's protocol version, false otherwise.
*/ */
@@ -140,7 +131,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports the given protocol version. * Checks if the connected client supports the given protocol version.
*
* @param targetVersion The protocol version to check. * @param targetVersion The protocol version to check.
* @return True if the client supports the target version, false otherwise. * @return True if the client supports the target version, false otherwise.
*/ */
@@ -151,7 +141,6 @@ public final class ConnectedProtocolClient {
/** /**
* Checks if the connected client supports the given protocol. * Checks if the connected client supports the given protocol.
*
* @param protocol The protocol to check. * @param protocol The protocol to check.
* @return True if the client supports the protocol, false otherwise. * @return True if the client supports the protocol, false otherwise.
*/ */

View File

@@ -104,7 +104,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Checks if the required certificate files exist in the specified folder. * Checks if the required certificate files exist in the specified folder.
*
* @param folder The folder to check for certificate files. * @param folder The folder to check for certificate files.
* @param prefix The prefix of the certificate files. * @param prefix The prefix of the certificate files.
* @param extension The extension of the certificate files. * @param extension The extension of the certificate files.
@@ -139,7 +138,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Retrieves a connected protocol client by its client ID. * Retrieves a connected protocol client by its client ID.
*
* @param clientID The ID of the client to retrieve. * @param clientID The ID of the client to retrieve.
* @return The ConnectedProtocolClient with the specified ID, or null if not found. * @return The ConnectedProtocolClient with the specified ID, or null if not found.
*/ */
@@ -151,7 +149,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Gets the DNS information site URL from the configuration. * Gets the DNS information site URL from the configuration.
*
* @return The DNS information site URL. * @return The DNS information site URL.
*/ */
public final String getDNSInfoSite() { public final String getDNSInfoSite() {
@@ -160,7 +157,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Gets the DNS registration site URL from the configuration. * Gets the DNS registration site URL from the configuration.
*
* @return The DNS registration site URL. * @return The DNS registration site URL.
*/ */
public final String getDNSRegisterSite() { public final String getDNSRegisterSite() {
@@ -169,39 +165,37 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Abstract method to retrieve the list of domains managed by the DNS server. * Abstract method to retrieve the list of domains managed by the DNS server.
*
* @return A list of Domain objects. * @return A list of Domain objects.
*/ */
public abstract List<Domain> getDomains(); public abstract List<Domain> getDomains();
/** /**
* @param domain The domain to look up.
* @return The destination associated with the domain.
* @see Domain#getDestination() * @see Domain#getDestination()
* Abstract method to get the destination for a given domain. * Abstract method to get the destination for a given domain.
* @param domain The domain to look up.
* @return The destination associated with the domain.
*/ */
public abstract String getDomainDestination(Domain domain); public abstract String getDomainDestination(Domain domain);
/** /**
* @param domain The parent domain.
* @param subname The subname to look up.
* @return The destination associated with the subname.
* @see Domain#getDestination() * @see Domain#getDestination()
* Abstract method to get the destination for a given subname under a specific domain. * Abstract method to get the destination for a given subname under a specific domain.
* @param domain The parent domain.
* @param subname The subname to look up.
* @return The destination associated with the subname.
*/ */
public abstract String getSubnameDestination(Domain domain, String subname); public abstract String getSubnameDestination(Domain domain, String subname);
/** /**
* @param topLevelName The top-level domain name.
* @return The information site URL for the specified top-level domain.
* @see Domain#getDestination() * @see Domain#getDestination()
* Abstract method to get the top-level domain information site URL. * Abstract method to get the top-level domain information site URL.
* @param topLevelName The top-level domain name.
* @return The information site URL for the specified top-level domain.
*/ */
public abstract String getTLNInfoSite(String topLevelName); public abstract String getTLNInfoSite(String topLevelName);
/** /**
* Abstract method to validate a requested domain. * Abstract method to validate a requested domain.
*
* @param requestedDomain The domain to validate. * @param requestedDomain The domain to validate.
* @return A DNSResponseCode indicating the result of the validation. * @return A DNSResponseCode indicating the result of the validation.
*/ */
@@ -209,20 +203,18 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
/** /**
* Abstract method called when a validation packet fails to send. * Abstract method called when a validation packet fails to send.
* * @param domain The domain associated with the validation.
* @param domain The domain associated with the validation. * @param client The connected protocol client.
* @param client The connected protocol client.
* @param exception The exception that occurred during sending. * @param exception The exception that occurred during sending.
*/ */
public abstract void validationPacketSendFailed(Domain domain, ConnectedProtocolClient client, Exception exception); public abstract void validationPacketSendFailed(Domain domain, ConnectedProtocolClient client, Exception exception);
/** /**
* Abstract method called when a domain destination packet fails to send. * Abstract method called when a domain destination packet fails to send.
* * @param client The connected protocol client.
* @param client The connected protocol client. * @param domain The domain associated with the packet.
* @param domain The domain associated with the packet.
* @param validationResponse The DNS response code from validation. * @param validationResponse The DNS response code from validation.
* @param exception The exception that occurred during sending. * @param exception The exception that occurred during sending.
*/ */
public abstract void domainDestinationPacketFailedSend(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception); public abstract void domainDestinationPacketFailedSend(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception);
@@ -242,7 +234,6 @@ public abstract class ProtocolDNSServer extends DefaultMethodsOverrider {
public final File publicServerFolder; public final File publicServerFolder;
public final String caPrefix = "ca_dns_"; public final String caPrefix = "ca_dns_";
public final String certPrefix = "cert_dns_"; public final String certPrefix = "cert_dns_";
public ServerCertificateFolderStructure() { public ServerCertificateFolderStructure() {
certificatesFolder = new File("certificates"); certificatesFolder = new File("certificates");

View File

@@ -51,18 +51,20 @@ public final class ConnectedWebClient {
* The protocol version of the connected client. * The protocol version of the connected client.
*/ */
private ProtocolVersion clientVersion = null; private ProtocolVersion clientVersion = null;
/** /**
* Indicates if the client version has been loaded.
*/
@Getter
private boolean clientVersionLoaded = false; /**
* Thread for receiving data from the client. * Thread for receiving data from the client.
*/ */
private final Thread receiveThread = new Thread(this::receive); private final Thread receiveThread = new Thread(this::receive);
/**
* Indicates if the client version has been loaded.
*/
@Getter
private boolean clientVersionLoaded = false;
/** /**
* Constructs a ConnectedWebClient with the given connection handler. * Constructs a ConnectedWebClient with the given connection handler.
*
* @param pipelineConnection The connection handler for the web client. * @param pipelineConnection The connection handler for the web client.
*/ */
public ConnectedWebClient(ConnectionHandler pipelineConnection) { public ConnectedWebClient(ConnectionHandler pipelineConnection) {
@@ -71,10 +73,9 @@ public final class ConnectedWebClient {
/** /**
* Sends an HTTP redirect response to the client. * Sends an HTTP redirect response to the client.
* * @param out The output stream to send the response to.
* @param out The output stream to send the response to.
* @param location The URL to redirect to. * @param location The URL to redirect to.
* @param cookies Optional cookies to set in the response. * @param cookies Optional cookies to set in the response.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
private static void sendRedirect(OutputStream out, String location, Map<String, String> cookies) throws IOException { private static void sendRedirect(OutputStream out, String location, Map<String, String> cookies) throws IOException {
@@ -96,7 +97,6 @@ public final class ConnectedWebClient {
/** /**
* Parses POST parameters from the input stream. * Parses POST parameters from the input stream.
*
* @param in The input stream to read from. * @param in The input stream to read from.
* @return A map of POST parameter names to values. * @return A map of POST parameter names to values.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -124,7 +124,6 @@ public final class ConnectedWebClient {
/** /**
* Normalizes a file path to prevent directory traversal attacks. * Normalizes a file path to prevent directory traversal attacks.
*
* @param path The raw file path. * @param path The raw file path.
* @return The normalized file path. * @return The normalized file path.
*/ */
@@ -142,7 +141,6 @@ public final class ConnectedWebClient {
/** /**
* Parses query parameters from a raw URL path. * Parses query parameters from a raw URL path.
*
* @param rawPath The raw URL path containing query parameters. * @param rawPath The raw URL path containing query parameters.
* @return A map of query parameter names to values. * @return A map of query parameter names to values.
*/ */
@@ -163,7 +161,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the request is a multipart/form-data request. * Checks if the request is a multipart/form-data request.
*
* @param headers The HTTP headers of the request. * @param headers The HTTP headers of the request.
* @return True if the request is multipart/form-data, false otherwise. * @return True if the request is multipart/form-data, false otherwise.
*/ */
@@ -174,9 +171,8 @@ public final class ConnectedWebClient {
/** /**
* Handles a multipart/form-data request, saving uploaded files to the specified directory. * Handles a multipart/form-data request, saving uploaded files to the specified directory.
* * @param in The input stream to read the request body from.
* @param in The input stream to read the request body from. * @param headers The HTTP headers of the request.
* @param headers The HTTP headers of the request.
* @param uploadDir The directory to save uploaded files to. * @param uploadDir The directory to save uploaded files to.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@@ -236,7 +232,6 @@ public final class ConnectedWebClient {
/** /**
* Sends an response to the client. * Sends an response to the client.
*
* @param out * @param out
* @param code * @param code
* @param file * @param file
@@ -250,8 +245,7 @@ public final class ConnectedWebClient {
/** /**
* Sends an response to the client. * Sends an response to the client.
* * @param out The output stream to send the response to.
* @param out The output stream to send the response to.
* @param code The HTTP status code. * @param code The HTTP status code.
* @param file The file to read the response body from. * @param file The file to read the response body from.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -262,10 +256,9 @@ public final class ConnectedWebClient {
/** /**
* Sends an response to the client. * Sends an response to the client.
* * @param out The output stream to send the response to.
* @param out The output stream to send the response to. * @param code The HTTP status code.
* @param code The HTTP status code. * @param body The response body as a string.
* @param body The response body as a string.
* @param contentType The content type of the response. * @param contentType The content type of the response.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@@ -275,10 +268,9 @@ public final class ConnectedWebClient {
/** /**
* Sends an response to the client. * Sends an response to the client.
* * @param out The output stream to send the response to.
* @param out The output stream to send the response to. * @param code The HTTP status code.
* @param code The HTTP status code. * @param file The file to read the response body from.
* @param file The file to read the response body from.
* @param contentType The content type of the response. * @param contentType The content type of the response.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
@@ -289,12 +281,11 @@ public final class ConnectedWebClient {
/** /**
* Sends an response to the client. * Sends an response to the client.
* * @param out The output stream to send the response to.
* @param out The output stream to send the response to. * @param code The HTTP status code.
* @param code The HTTP status code. * @param body The response body as a byte array.
* @param body The response body as a byte array.
* @param contentType The content type of the response. * @param contentType The content type of the response.
* @param headers Additional headers to include in the response. * @param headers Additional headers to include in the response.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
private static void sendResponse(OutputStream out, int code, byte[] body, String contentType, Map<String, String> headers) throws IOException { private static void sendResponse(OutputStream out, int code, byte[] body, String contentType, Map<String, String> headers) throws IOException {
@@ -319,7 +310,6 @@ public final class ConnectedWebClient {
/** /**
* Returns the standard status text for a given status code. * Returns the standard status text for a given status code.
*
* @param code The status code. * @param code The status code.
* @return The corresponding status text. * @return The corresponding status text.
*/ */
@@ -339,7 +329,6 @@ public final class ConnectedWebClient {
/** /**
* Returns the content type based on the file extension. * Returns the content type based on the file extension.
*
* @param name The file name. * @param name The file name.
* @return The corresponding content type. * @return The corresponding content type.
*/ */
@@ -361,10 +350,9 @@ public final class ConnectedWebClient {
/** /**
* Renders a PHP file by executing it with the PHP interpreter and captures cookies. * Renders a PHP file by executing it with the PHP interpreter and captures cookies.
*
* @param file The PHP file to render. * @param file The PHP file to render.
* @return A PHPResponse containing the output and cookies. * @return A PHPResponse containing the output and cookies.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
* @throws InterruptedException If the process is interrupted. * @throws InterruptedException If the process is interrupted.
*/ */
private static PHPResponse renderPHPWithCookies(File file) throws IOException, InterruptedException { private static PHPResponse renderPHPWithCookies(File file) throws IOException, InterruptedException {
@@ -414,7 +402,6 @@ public final class ConnectedWebClient {
/** /**
* Sets the SSL socket for the web client and starts the receive thread. * Sets the SSL socket for the web client and starts the receive thread.
*
* @param webSocket The SSL socket to set. * @param webSocket The SSL socket to set.
*/ */
public void setWebSocket(SSLSocket webSocket) { public void setWebSocket(SSLSocket webSocket) {
@@ -424,7 +411,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the web client is currently connected. * Checks if the web client is currently connected.
*
* @return True if connected, false otherwise. * @return True if connected, false otherwise.
*/ */
public boolean isConnected() { public boolean isConnected() {
@@ -433,7 +419,6 @@ public final class ConnectedWebClient {
/** /**
* Disconnects the web client, closing streams and the socket. * Disconnects the web client, closing streams and the socket.
*
* @return True if disconnection was successful, false if already disconnected. * @return True if disconnection was successful, false if already disconnected.
*/ */
public synchronized boolean disconnect() { public synchronized boolean disconnect() {
@@ -467,7 +452,6 @@ public final class ConnectedWebClient {
/** /**
* Gets the protocol version of the connected client. * Gets the protocol version of the connected client.
*
* @return The protocol version of the client, defaults to PV_1_0_0_CLASSIC if not set. * @return The protocol version of the client, defaults to PV_1_0_0_CLASSIC if not set.
*/ */
public ProtocolVersion getClientVersion() { public ProtocolVersion getClientVersion() {
@@ -476,7 +460,6 @@ public final class ConnectedWebClient {
/** /**
* Sets the protocol version of the connected client. * Sets the protocol version of the connected client.
*
* @param clientVersion The protocol version to set. * @param clientVersion The protocol version to set.
*/ */
public void setClientVersion(ProtocolVersion clientVersion) { public void setClientVersion(ProtocolVersion clientVersion) {
@@ -486,7 +469,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client is a stable client. * Checks if the connected client is a stable client.
*
* @return True if the client is stable, false otherwise. * @return True if the client is stable, false otherwise.
*/ */
public boolean isStableClient() { public boolean isStableClient() {
@@ -496,7 +478,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports stable protocol versions. * Checks if the connected client supports stable protocol versions.
*
* @return True if the client supports stable versions, false otherwise. * @return True if the client supports stable versions, false otherwise.
*/ */
public boolean supportClientStable() { public boolean supportClientStable() {
@@ -513,7 +494,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client is a beta client. * Checks if the connected client is a beta client.
*
* @return True if the client is beta, false otherwise. * @return True if the client is beta, false otherwise.
*/ */
public boolean isBetaClient() { public boolean isBetaClient() {
@@ -523,7 +503,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports beta protocol versions. * Checks if the connected client supports beta protocol versions.
*
* @return True if the client supports beta versions, false otherwise. * @return True if the client supports beta versions, false otherwise.
*/ */
public boolean supportClientBeta() { public boolean supportClientBeta() {
@@ -540,7 +519,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client is a classic client. * Checks if the connected client is a classic client.
*
* @return True if the client is classic, false otherwise. * @return True if the client is classic, false otherwise.
*/ */
public boolean isClassicClient() { public boolean isClassicClient() {
@@ -549,7 +527,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports classic protocol versions. * Checks if the connected client supports classic protocol versions.
*
* @return True if the client supports classic versions, false otherwise. * @return True if the client supports classic versions, false otherwise.
*/ */
public boolean supportClientClassic() { public boolean supportClientClassic() {
@@ -566,7 +543,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports the protocol version of the given packet. * Checks if the connected client supports the protocol version of the given packet.
*
* @param packet The packet to check support for. * @param packet The packet to check support for.
* @return True if the client supports the packet's protocol version, false otherwise. * @return True if the client supports the packet's protocol version, false otherwise.
*/ */
@@ -576,7 +552,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports the given protocol version. * Checks if the connected client supports the given protocol version.
*
* @param targetVersion The protocol version to check support for. * @param targetVersion The protocol version to check support for.
* @return True if the client supports the target version, false otherwise. * @return True if the client supports the target version, false otherwise.
*/ */
@@ -587,7 +562,6 @@ public final class ConnectedWebClient {
/** /**
* Checks if the connected client supports the given protocol. * Checks if the connected client supports the given protocol.
*
* @param protocol The protocol to check support for. * @param protocol The protocol to check support for.
* @return True if the client supports the protocol, false otherwise. * @return True if the client supports the protocol, false otherwise.
*/ */
@@ -715,6 +689,4 @@ public final class ConnectedWebClient {
} }
} }
} }

View File

@@ -58,25 +58,31 @@ public final class ProtocolWebServer {
* Certificate files for SSL. * Certificate files for SSL.
*/ */
private final File keyFile; private final File keyFile;
/**
* The configuration file for the web server.
*/
private final File configFile;
/** /**
* The network server handling pipeline connections. * The network server handling pipeline connections.
*/ */
@Getter @Getter
private NetworkServer pipelineServer; private NetworkServer pipelineServer;
/** /**
* The SSL server socket for web connections. * The SSL server socket for web connections.
*/ */
@Getter @Getter
private SSLServerSocket webServer; private SSLServerSocket webServer;
/** /**
* List of connected web clients. * List of connected web clients.
*/ */
@Getter @Getter
private List<ConnectedWebClient> clients; private List<ConnectedWebClient> clients;
/**
* The configuration file for the web server.
*/
private final File configFile;
/** /**
* A unique secret for session management. * A unique secret for session management.
*/ */
@@ -85,10 +91,9 @@ public final class ProtocolWebServer {
/** /**
* Initializes the web server with the given configuration, authentication, and rules files. * Initializes the web server with the given configuration, authentication, and rules files.
*
* @param configFile The configuration file. * @param configFile The configuration file.
* @param authFile The authentication file. * @param authFile The authentication file.
* @param rulesFile The rules file. * @param rulesFile The rules file.
* @throws Exception If an error occurs during initialization. * @throws Exception If an error occurs during initialization.
*/ */
public ProtocolWebServer(File configFile, File authFile, File rulesFile) throws Exception { public ProtocolWebServer(File configFile, File authFile, File rulesFile) throws Exception {
@@ -167,11 +172,10 @@ public final class ProtocolWebServer {
/** /**
* Retrieves a connected web client by its client ID. * Retrieves a connected web client by its client ID.
*
* @param clientID The client ID to search for. * @param clientID The client ID to search for.
* @return The connected web client with the specified ID, or null if not found. * @return The connected web client with the specified ID, or null if not found.
*/ */
public ConnectedWebClient getClientByID(int clientID) { public final ConnectedWebClient getClientByID(int clientID) {
for (ConnectedWebClient client : clients) for (ConnectedWebClient client : clients)
if (client.getPipelineConnection().getClientID() == clientID) return client; if (client.getPipelineConnection().getClientID() == clientID) return client;
return null; return null;
@@ -179,10 +183,9 @@ public final class ProtocolWebServer {
/** /**
* Starts the web server to accept and handle client connections. * Starts the web server to accept and handle client connections.
*
* @throws Exception If an error occurs while starting the server. * @throws Exception If an error occurs while starting the server.
*/ */
public void startWebServer() throws Exception { public final void startWebServer() throws Exception {
// Start the pipeline server // Start the pipeline server
pipelineServer.start(); pipelineServer.start();
@@ -212,8 +215,7 @@ public final class ProtocolWebServer {
try { try {
// Sleep for a while before checking again // Sleep for a while before checking again
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {}
}
} }
}).start(); }).start();
@@ -239,7 +241,6 @@ public final class ProtocolWebServer {
/** /**
* Handles the shutdown of the web server when the pipeline server stops. * Handles the shutdown of the web server when the pipeline server stops.
*
* @throws IOException If an I/O error occurs while closing the web server. * @throws IOException If an I/O error occurs while closing the web server.
*/ */
private void onPipelineStop() throws IOException { private void onPipelineStop() throws IOException {
@@ -248,12 +249,11 @@ public final class ProtocolWebServer {
/** /**
* Checks if the required certificate files exist in the specified folder. * Checks if the required certificate files exist in the specified folder.
* * @param folder The folder to check for certificate files.
* @param folder The folder to check for certificate files. * @param prefix The prefix of the certificate files.
* @param prefix The prefix of the certificate files.
* @param extension The extension of the certificate files. * @param extension The extension of the certificate files.
* @throws CertificateException If a required certificate file is missing or invalid. * @throws CertificateException If a required certificate file is missing or invalid.
* @throws IOException If an I/O error occurs while checking the files. * @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 void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
boolean found = false; boolean found = false;
@@ -281,17 +281,15 @@ public final class ProtocolWebServer {
/** /**
* Retrieves the configuration manager for the web server. * Retrieves the configuration manager for the web server.
*
* @return The configuration manager. * @return The configuration manager.
* @throws IOException If an I/O error occurs while loading or saving the configuration. * @throws IOException If an I/O error occurs while loading or saving the configuration.
*/ */
public ConfigurationManager getConfigurationManager() throws IOException { public final ConfigurationManager getConfigurationManager() throws IOException {
return getConfigurationManager(configFile); return getConfigurationManager(configFile);
} }
/** /**
* Loads and initializes the configuration manager with default settings if necessary. * Loads and initializes the configuration manager with default settings if necessary.
*
* @param configFile The configuration file to load. * @param configFile The configuration file to load.
* @return The initialized configuration manager. * @return The initialized configuration manager.
* @throws IOException If an I/O error occurs while loading or saving the configuration. * @throws IOException If an I/O error occurs while loading or saving the configuration.
@@ -341,7 +339,6 @@ public final class ProtocolWebServer {
public final File publicServerFolder; public final File publicServerFolder;
public final String caPrefix = "ca_server_"; public final String caPrefix = "ca_server_";
public final String certPrefix = "cert_server_"; public final String certPrefix = "cert_server_";
public ServerCertificateFolderStructure() { public ServerCertificateFolderStructure() {
certificatesFolder = new File("certificates"); certificatesFolder = new File("certificates");

View File

@@ -27,7 +27,6 @@ public final class AuthManager {
* Loads the authentication file and populates the users map. * Loads the authentication file and populates the users map.
* The file should contain lines in the format: username:hashed_password * The file should contain lines in the format: username:hashed_password
* Lines starting with '#' are treated as comments and ignored. * Lines starting with '#' are treated as comments and ignored.
*
* @param authFile The authentication file to load. * @param authFile The authentication file to load.
* @throws IOException If an I/O error occurs reading from the file. * @throws IOException If an I/O error occurs reading from the file.
*/ */
@@ -49,8 +48,7 @@ public final class AuthManager {
/** /**
* Checks if the provided login and password are valid. * Checks if the provided login and password are valid.
* * @param login The username to check.
* @param login The username to check.
* @param password The password to verify. * @param password The password to verify.
* @return True if the credentials are valid, false otherwise. * @return True if the credentials are valid, false otherwise.
*/ */
@@ -66,7 +64,6 @@ public final class AuthManager {
/** /**
* Computes the SHA-256 hash of the given input string. * Computes the SHA-256 hash of the given input string.
*
* @param input The input string to hash. * @param input The input string to hash.
* @return The hexadecimal representation of the SHA-256 hash. * @return The hexadecimal representation of the SHA-256 hash.
*/ */

View File

@@ -35,19 +35,17 @@ public final class RuleManager {
* Loads rules from a JSON file. * Loads rules from a JSON file.
* The JSON should have the structure: * The JSON should have the structure:
* { * {
* "allow": ["pattern1", "pattern2", ...], * "allow": ["pattern1", "pattern2", ...],
* "deny": ["pattern1", "pattern2", ...], * "deny": ["pattern1", "pattern2", ...],
* "auth": ["pattern1", "pattern2", ...] * "auth": ["pattern1", "pattern2", ...]
* } * }
*
* @param rulesFile The JSON file containing the rules. * @param rulesFile The JSON file containing the rules.
* @throws Exception If an error occurs reading the file or parsing JSON. * @throws Exception If an error occurs reading the file or parsing JSON.
*/ */
public static void loadRules(File rulesFile) throws Exception { public static void loadRules(File rulesFile) throws Exception {
// Load and parse the JSON file // Load and parse the JSON file
String json = new String(Files.readAllBytes(rulesFile.toPath())); String json = new String(Files.readAllBytes(rulesFile.toPath()));
Map<String, List<String>> map = new Gson().fromJson(json, new TypeToken<Map<String, List<String>>>() { Map<String, List<String>> map = new Gson().fromJson(json, new TypeToken<Map<String, List<String>>>() {}.getType());
}.getType());
// Default to empty lists if keys are missing // Default to empty lists if keys are missing
allow = map.getOrDefault("allow", List.of()); allow = map.getOrDefault("allow", List.of());
@@ -55,9 +53,7 @@ public final class RuleManager {
auth = map.getOrDefault("auth", List.of()); auth = map.getOrDefault("auth", List.of());
} }
/** /** Checks if the given path is allowed based on the allow rules.
* Checks if the given path is allowed based on the allow rules.
*
* @param path The path to check. * @param path The path to check.
* @return True if the path is allowed, false otherwise. * @return True if the path is allowed, false otherwise.
*/ */
@@ -65,9 +61,7 @@ public final class RuleManager {
return allow.stream().anyMatch(p -> pathMatches(path, p)); return allow.stream().anyMatch(p -> pathMatches(path, p));
} }
/** /** Checks if the given path is denied based on the deny rules.
* Checks if the given path is denied based on the deny rules.
*
* @param path The path to check. * @param path The path to check.
* @return True if the path is denied, false otherwise. * @return True if the path is denied, false otherwise.
*/ */
@@ -75,9 +69,7 @@ public final class RuleManager {
return deny.stream().anyMatch(p -> pathMatches(path, p)); return deny.stream().anyMatch(p -> pathMatches(path, p));
} }
/** /** Checks if the given path requires authentication based on the auth rules.
* Checks if the given path requires authentication based on the auth rules.
*
* @param path The path to check. * @param path The path to check.
* @return True if the path requires authentication, false otherwise. * @return True if the path requires authentication, false otherwise.
*/ */
@@ -85,11 +77,9 @@ public final class RuleManager {
return auth.stream().anyMatch(p -> pathMatches(path, p)); return auth.stream().anyMatch(p -> pathMatches(path, p));
} }
/** /** Helper method to check if a path matches a pattern.
* Helper method to check if a path matches a pattern.
* Patterns can include '*' as a wildcard. * Patterns can include '*' as a wildcard.
* * @param path The path to check.
* @param path The path to check.
* @param pattern The pattern to match against. * @param pattern The pattern to match against.
* @return True if the path matches the pattern, false otherwise. * @return True if the path matches the pattern, false otherwise.
*/ */

View File

@@ -30,9 +30,8 @@ public final class SessionManager {
/** /**
* Creates a new session for the given user. * Creates a new session for the given user.
* * @param login The username associated with the session.
* @param login The username associated with the session. * @param ip The IP address of the client.
* @param ip The IP address of the client.
* @param userAgent The User-Agent string of the client. * @param userAgent The User-Agent string of the client.
* @return The generated session ID. * @return The generated session ID.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -52,9 +51,8 @@ public final class SessionManager {
/** /**
* Validates a session ID against the provided IP and User-Agent. * Validates a session ID against the provided IP and User-Agent.
*
* @param sessionId The session ID to validate. * @param sessionId The session ID to validate.
* @param ip The IP address of the client. * @param ip The IP address of the client.
* @param userAgent The User-Agent string of the client. * @param userAgent The User-Agent string of the client.
* @return True if the session is valid, false otherwise. * @return True if the session is valid, false otherwise.
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
@@ -76,7 +74,6 @@ public final class SessionManager {
/** /**
* Invalidates a session, removing it from the active sessions. * Invalidates a session, removing it from the active sessions.
*
* @param sessionId The session ID to invalidate. * @param sessionId The session ID to invalidate.
*/ */
public static void invalidate(String sessionId) { public static void invalidate(String sessionId) {
@@ -85,7 +82,6 @@ public final class SessionManager {
/** /**
* Retrieves the username associated with a valid session ID. * Retrieves the username associated with a valid session ID.
*
* @param sessionId The session ID to look up. * @param sessionId The session ID to look up.
* @return The username if the session is valid, null otherwise. * @return The username if the session is valid, null otherwise.
*/ */
@@ -131,7 +127,6 @@ public final class SessionManager {
/** /**
* Checks if the session has expired. * Checks if the session has expired.
*
* @return True if the session is expired, false otherwise. * @return True if the session is expired, false otherwise.
*/ */
boolean isExpired() { boolean isExpired() {
@@ -140,8 +135,7 @@ public final class SessionManager {
/** /**
* Checks if the session matches the given IP and User-Agent. * Checks if the session matches the given IP and User-Agent.
* * @param ip The IP address to check.
* @param ip The IP address to check.
* @param userAgent The User-Agent string to check. * @param userAgent The User-Agent string to check.
* @return True if both match, false otherwise. * @return True if both match, false otherwise.
*/ */
@@ -151,7 +145,6 @@ public final class SessionManager {
/** /**
* Refreshes the session's expiration time. * Refreshes the session's expiration time.
*
* @throws IOException If an I/O error occurs. * @throws IOException If an I/O error occurs.
*/ */
void refresh() throws IOException { void refresh() throws IOException {

View File

@@ -71,7 +71,6 @@ public enum ProtocolVersion implements Serializable {
/** /**
* Returns a string representation of the protocol version, including its version, type, side, supported protocols, and compatible versions. * Returns a string representation of the protocol version, including its version, type, side, supported protocols, and compatible versions.
*
* @return a string representation of the protocol version. * @return a string representation of the protocol version.
*/ */
@Override @Override
@@ -90,7 +89,6 @@ public enum ProtocolVersion implements Serializable {
/** /**
* Builds a name for the protocol version combining its version and type. * Builds a name for the protocol version combining its version and type.
*
* @return a string representing the name of the protocol version. * @return a string representing the name of the protocol version.
*/ */
public final String buildName() { public final String buildName() {
@@ -107,7 +105,6 @@ public enum ProtocolVersion implements Serializable {
/** /**
* Returns the name of the protocol in uppercase. * Returns the name of the protocol in uppercase.
*
* @return the name of the protocol in uppercase. * @return the name of the protocol in uppercase.
*/ */
@Override @Override
@@ -137,7 +134,6 @@ public enum ProtocolVersion implements Serializable {
/** /**
* Returns the name of the protocol in uppercase. * Returns the name of the protocol in uppercase.
*
* @return the name of the protocol in uppercase. * @return the name of the protocol in uppercase.
*/ */
@Override @Override
@@ -183,11 +179,11 @@ public enum ProtocolVersion implements Serializable {
/** /**
* All Sides * All Sides
*/ */
ALL; ALL
;
/** /**
* Returns the name of the protocol in uppercase. * Returns the name of the protocol in uppercase.
*
* @return the name of the protocol in uppercase. * @return the name of the protocol in uppercase.
*/ */
@Override @Override

View File

@@ -75,7 +75,6 @@ public enum DNSResponseCode implements Serializable {
/** /**
* Returns a string representation of the DNS response code, including its code and description. * Returns a string representation of the DNS response code, including its code and description.
*
* @return a string representation of the DNS response code. * @return a string representation of the DNS response code.
*/ */
@Override @Override

View File

@@ -110,21 +110,19 @@ public final class Domain implements Serializable {
/** /**
* Checks if the domain has a subname. * Checks if the domain has a subname.
*
* @return true if the domain has a subname, false otherwise. * @return true if the domain has a subname, false otherwise.
*/ */
public boolean hasSubname() { public final boolean hasSubname() {
return subname != null; return subname != null;
} }
/** /**
* Checks if this domain is equal to another object. * 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). * 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. * @return true if the domains are equal, false otherwise.
*/ */
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
// Check if the object is an instance of Domain // Check if the object is an instance of Domain
if (!(obj instanceof Domain domain)) return false; if (!(obj instanceof Domain domain)) return false;
@@ -136,11 +134,10 @@ public final class Domain implements Serializable {
/** /**
* Returns the destination associated with this domain. * Returns the destination associated with this domain.
* The destination is determined based on the domain's components and the current protocol context. * The destination is determined based on the domain's components and the current protocol context.
*
* @return the destination as a string. * @return the destination as a string.
*/ */
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS) @ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.DNS)
public String getDestination() { public final String getDestination() {
// If running as client or web server, return invalid request // If running as client or web server, return invalid request
if (ProtocolBridge.getInstance().isRunningAsClient() || ProtocolBridge.getInstance().isRunningAsWebServer()) if (ProtocolBridge.getInstance().isRunningAsClient() || ProtocolBridge.getInstance().isRunningAsWebServer())
return DNSResponseCode.RESPONSE_INVALID_REQUEST.toString(); return DNSResponseCode.RESPONSE_INVALID_REQUEST.toString();
@@ -159,6 +156,7 @@ public final class Domain implements Serializable {
/** /**
* Returns a string representation of the domain, including its protocol, subname, name, top-level name, path, query, and fragment. * Returns a string representation of the domain, including its protocol, subname, name, top-level name, path, query, and fragment.
* @return a string representation of the domain.
*/ */
public static class DefaultDomains { public static class DefaultDomains {
public static final Domain DNS_INFO_SITE = new Domain("oac://about.oac/"); public static final Domain DNS_INFO_SITE = new Domain("oac://about.oac/");

View File

@@ -1,14 +1,14 @@
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.events; package org.openautonomousconnection.protocol.versions.v1_0_0.classic.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
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_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; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
/** /**
* This event is fired when a classic domain packet is received. * This event is fired when a classic domain packet is received.
* This event is deprecated and will be marked for removal in future versions. * 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 org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient * @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer * @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer
@@ -29,22 +29,22 @@ public final class Classic_DomainPacketReceivedEvent extends Event {
} }
@Override @Override
protected Object clone() throws CloneNotSupportedException { protected final Object clone() throws CloneNotSupportedException {
return super.clone(); return super.clone();
} }
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
return super.equals(obj); return super.equals(obj);
} }
@Override @Override
public String toString() { public final String toString() {
return super.toString(); return super.toString();
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return super.hashCode(); return super.hashCode();
} }
} }

View File

@@ -2,13 +2,12 @@ package org.openautonomousconnection.protocol.versions.v1_0_0.classic.events;
import dev.unlegitdqrk.unlegitlibrary.event.impl.Event; import dev.unlegitdqrk.unlegitlibrary.event.impl.Event;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_Domain; 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; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
/** /**
* This event is fired when a classic ping packet is received. * This event is fired when a classic ping packet is received.
* This event is deprecated and will be marked for removal in future versions. * 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 org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerDNSServer
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient * @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerClient
* @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer * @see org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers.ClassicHandlerWebServer
@@ -30,22 +29,22 @@ public final class Classic_PingPacketReceivedEvent extends Event {
} }
@Override @Override
protected Object clone() throws CloneNotSupportedException { protected final Object clone() throws CloneNotSupportedException {
return super.clone(); return super.clone();
} }
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
return super.equals(obj); return super.equals(obj);
} }
@Override @Override
public String toString() { public final String toString() {
return super.toString(); return super.toString();
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return super.hashCode(); return super.hashCode();
} }
} }

View File

@@ -4,8 +4,8 @@ import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient; import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
import org.openautonomousconnection.protocol.versions.ProtocolVersion; 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_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; import org.openautonomousconnection.protocol.versions.v1_0_0.classic.utils.Classic_ProtocolVersion;
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.objects.Classic_RequestDomain;
import java.sql.SQLException; import java.sql.SQLException;

View File

@@ -11,7 +11,7 @@ import java.io.Serializable;
* This class is deprecated and users are encouraged to use the Domain class instead. * This class is deprecated and users are encouraged to use the Domain class instead.
*/ */
@Deprecated(forRemoval = false, since = "1.0.0-BETA.3") @Deprecated(forRemoval = false, since = "1.0.0-BETA.3")
public class Classic_Domain implements Serializable { public final class Classic_Domain implements Serializable {
/** /**
* The name of the domain (e.g., "example" in "example.com"). * The name of the domain (e.g., "example" in "example.com").

View File

@@ -11,7 +11,6 @@ public final class ClassicConverter {
/** /**
* Converts a Classic_Domain object to a Domain object. * Converts a Classic_Domain object to a Domain object.
*
* @param classicDomain the Classic_Domain object to convert * @param classicDomain the Classic_Domain object to convert
* @return the converted Domain object * @return the converted Domain object
*/ */
@@ -22,7 +21,6 @@ public final class ClassicConverter {
/** /**
* Converts a Domain object to a Classic_Domain object. * Converts a Domain object to a Classic_Domain object.
*
* @param newDomain the Domain object to convert * @param newDomain the Domain object to convert
* @return the converted Classic_Domain object * @return the converted Classic_Domain object
*/ */
@@ -33,7 +31,6 @@ public final class ClassicConverter {
/** /**
* Converts a Classic_ProtocolVersion to a ProtocolVersion. * Converts a Classic_ProtocolVersion to a ProtocolVersion.
*
* @param classicProtocolVersion the Classic_ProtocolVersion to convert * @param classicProtocolVersion the Classic_ProtocolVersion to convert
* @return the converted ProtocolVersion * @return the converted ProtocolVersion
*/ */
@@ -45,7 +42,6 @@ public final class ClassicConverter {
/** /**
* Converts a ProtocolVersion to a Classic_ProtocolVersion. * Converts a ProtocolVersion to a Classic_ProtocolVersion.
*
* @param newProtocolVersion the ProtocolVersion to convert * @param newProtocolVersion the ProtocolVersion to convert
* @return the converted Classic_ProtocolVersion * @return the converted Classic_ProtocolVersion
*/ */

View File

@@ -28,7 +28,6 @@ public final class Classic_ClientListener extends EventListener {
* Handles the event when a domain packet is received. * 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 DNS server.
* If the domain does not exist, it handles the error accordingly. * If the domain does not exist, it handles the error accordingly.
*
* @param event The event containing domain information. * @param event The event containing domain information.
*/ */
@Listener @Listener
@@ -58,7 +57,6 @@ public final class Classic_ClientListener extends EventListener {
* Handles the event when a ping packet is received. * Handles the event when a ping packet is received.
* If the domain is reachable, it fetches the HTML content from the domain. * If the domain is reachable, it fetches the HTML content from the domain.
* If not reachable, it handles the error accordingly. * If not reachable, it handles the error accordingly.
*
* @param event The event containing ping response information. * @param event The event containing ping response information.
*/ */
@Listener @Listener
@@ -93,22 +91,22 @@ public final class Classic_ClientListener extends EventListener {
} }
@Override @Override
protected Object clone() throws CloneNotSupportedException { protected final Object clone() throws CloneNotSupportedException {
return super.clone(); return super.clone();
} }
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
return super.equals(obj); return super.equals(obj);
} }
@Override @Override
public String toString() { public final String toString() {
return super.toString(); return super.toString();
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return super.hashCode(); return super.hashCode();
} }
} }

View File

@@ -16,7 +16,6 @@ class Classic_DomainUtils extends DefaultMethodsOverrider {
/** /**
* Extracts the top-level domain (TLD) from a given URL. * Extracts the top-level domain (TLD) from a given URL.
*
* @param url The URL from which to extract the TLD. * @param url The URL from which to extract the TLD.
* @return The top-level domain as a string. * @return The top-level domain as a string.
* @throws MalformedURLException If the URL is malformed. * @throws MalformedURLException If the URL is malformed.
@@ -47,10 +46,9 @@ class Classic_DomainUtils extends DefaultMethodsOverrider {
/** /**
* Extracts the domain name (excluding the TLD) from a given URL. * Extracts the domain name (excluding the TLD) from a given URL.
*
* @param url The URL from which to extract the domain name. * @param url The URL from which to extract the domain name.
* @return The domain name as a string. * @return The domain name as a string.
* @throws URISyntaxException If the URL syntax is incorrect. * @throws URISyntaxException If the URL syntax is incorrect.
* @throws MalformedURLException If the URL is malformed. * @throws MalformedURLException If the URL is malformed.
*/ */
public static String getDomainName(String url) throws URISyntaxException, MalformedURLException { public static String getDomainName(String url) throws URISyntaxException, MalformedURLException {
@@ -73,7 +71,6 @@ class Classic_DomainUtils extends DefaultMethodsOverrider {
/** /**
* Extracts the path component from a given URL. * Extracts the path component from a given URL.
*
* @param url The URL from which to extract the path. * @param url The URL from which to extract the path.
* @return The path as a string. * @return The path as a string.
*/ */