Refactored using IntelliJ
This commit is contained in:
95
README.MD
95
README.MD
@@ -7,20 +7,31 @@ Feel free to join our Discord.
|
|||||||
|
|
||||||
## License Notice
|
## License Notice
|
||||||
|
|
||||||
This project (OAC) is licensed under the [Open Autonomous Public License (OAPL)](https://repo.open-autonomous-connection.org/open-autonomous-connection/OAPL/).
|
This project (OAC) is licensed under
|
||||||
|
the [Open Autonomous Public License (OAPL)](https://repo.open-autonomous-connection.org/open-autonomous-connection/OAPL/).
|
||||||
|
|
||||||
**Third-party components:**
|
**Third-party components:**
|
||||||
|
|
||||||
- *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement:
|
- *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement:
|
||||||
While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE),
|
While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under
|
||||||
|
the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE),
|
||||||
it is additionally licensed under OAPL **exclusively for the OAC project**.
|
it is additionally licensed under OAPL **exclusively for the OAC project**.
|
||||||
Therefore, within OAC, the OAPL terms apply to UnlegitLibrary as well.
|
Therefore, within OAC, the OAPL terms apply to UnlegitLibrary as well.
|
||||||
|
|
||||||
# Bugs/Problems
|
# Bugs/Problems
|
||||||
|
- Project not tested yet
|
||||||
# In progress
|
# In progress
|
||||||
|
- WebServer
|
||||||
# TODO
|
# TODO
|
||||||
|
- Finishing WebServer
|
||||||
|
- Writing INS Backend and Frontend
|
||||||
|
- Writing WebClient
|
||||||
|
- Writing WebServer
|
||||||
|
- Documentation / Wiki
|
||||||
# Maven
|
# Maven
|
||||||
|
|
||||||
### pom.xml
|
### pom.xml
|
||||||
|
|
||||||
```
|
```
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openautonomousconnection</groupId>
|
<groupId>org.openautonomousconnection</groupId>
|
||||||
@@ -30,6 +41,7 @@ This project (OAC) is licensed under the [Open Autonomous Public License (OAPL)]
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Repository:
|
### Repository:
|
||||||
|
|
||||||
```
|
```
|
||||||
<repository>
|
<repository>
|
||||||
<id>oac</id>
|
<id>oac</id>
|
||||||
@@ -38,79 +50,4 @@ This project (OAC) is licensed under the [Open Autonomous Public License (OAPL)]
|
|||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
```
|
```
|
||||||
|
|
||||||
# Examples
|
|
||||||
#### Note: These examples are very basic
|
|
||||||
### Server
|
|
||||||
|
|
||||||
```java
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolSettings;
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolVersion;
|
|
||||||
import me.openautonomousconnection.protocol.side.ProtocolServer;
|
|
||||||
|
|
||||||
public class Server extends ProtocolServer {
|
|
||||||
|
|
||||||
public Server() throws IOException, InterruptedException {
|
|
||||||
super(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
ProtocolBridge protocolBridge = new ProtocolBridge(ProtocolVersion.PV_1_0_0, new ProtocolSettings(), new Server());
|
|
||||||
protocolBridge.getProtocolServer().setProtocolBridge(protocolBridge);
|
|
||||||
protocolBridge.getProtocolServer().startServer();
|
|
||||||
} catch (IOException | InterruptedException | InvocationTargetException | InstantiationException |
|
|
||||||
IllegalAccessException | NoSuchMethodException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Domain> getDomains() throws SQLException {
|
|
||||||
return List.of(); // Your method here to get all registered domains
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(ConnectionHandler connectionHandler, String message) {
|
|
||||||
System.out.println("Received message: " + message + " from client: " + connectionHandler.getClientID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
### Client
|
|
||||||
|
|
||||||
```java
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolSettings;
|
|
||||||
import me.openautonomousconnection.protocol.ProtocolVersion;
|
|
||||||
import me.openautonomousconnection.protocol.infoName.Domain;
|
|
||||||
import me.openautonomousconnection.protocol.side.ProtocolClient;
|
|
||||||
import me.openautonomousconnection.protocol.utils.SiteType;
|
|
||||||
|
|
||||||
public class Client extends ProtocolClient {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
ProtocolBridge protocolBridge = new ProtocolBridge(ProtocolVersion.PV_1_0_0, new ProtocolSettings(), new Client());
|
|
||||||
protocolBridge.getProtocolClient().setProtocolBridge(protocolBridge);
|
|
||||||
protocolBridge.getProtocolServer().startClient();
|
|
||||||
} catch (IOException | InterruptedException | InvocationTargetException | InstantiationException |
|
|
||||||
IllegalAccessException | NoSuchMethodException exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleHTMLContent(SiteType siteType, Domain infoName, String htmlContent) {
|
|
||||||
System.out.println("Website html content received. This site is " + siteType.name);
|
|
||||||
System.out.println(htmlContent); // Render content in a webview for example
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(String message) {
|
|
||||||
System.out.println("Received message: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
4
pom.xml
4
pom.xml
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -211,11 +211,10 @@ public final class ProtocolBridge {
|
|||||||
private void registerListeners() throws Exception {
|
private void registerListeners() throws Exception {
|
||||||
// Classic listeners
|
// Classic listeners
|
||||||
if (isClassicSupported()) {
|
if (isClassicSupported()) {
|
||||||
Classic_ClientListener classicListener = new Classic_ClientListener();
|
Classic_ClientListener classicListener = new Classic_ClientListener();
|
||||||
classicListener.setProtocolBridge(this);
|
classicListener.setProtocolBridge(this);
|
||||||
protocolSettings.eventManager.registerListener(classicListener.getClass());
|
protocolSettings.eventManager.registerListener(classicListener.getClass());
|
||||||
}
|
} else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
|
||||||
else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
|
|
||||||
|
|
||||||
// INS Listeners
|
// INS Listeners
|
||||||
if (isRunningAsINSServer()) {
|
if (isRunningAsINSServer()) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
|||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientConnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientConnectedEvent;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
||||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||||
@@ -27,6 +26,7 @@ public final class ClientListener extends EventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the client variable
|
* Sets the client variable
|
||||||
|
*
|
||||||
* @param client The Instance of the ProtocolClient
|
* @param client The Instance of the ProtocolClient
|
||||||
*/
|
*/
|
||||||
public void setClient(ProtocolClient client) {
|
public void setClient(ProtocolClient client) {
|
||||||
@@ -58,7 +58,7 @@ public final class ClientListener extends EventListener {
|
|||||||
*/
|
*/
|
||||||
@Listener
|
@Listener
|
||||||
public void onDisconnect(ClientDisconnectedEvent event) {
|
public void onDisconnect(ClientDisconnectedEvent event) {
|
||||||
client.onINSDisconnect(event);
|
client.onINSDisconnect(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
|||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
|
||||||
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
|
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
|
||||||
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
@@ -26,6 +24,7 @@ public final class INSServerListener extends EventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the insServer variable
|
* Sets the insServer variable
|
||||||
|
*
|
||||||
* @param insServer The Instance of the INSServer
|
* @param insServer The Instance of the INSServer
|
||||||
*/
|
*/
|
||||||
public void setINSServer(ProtocolINSServer insServer) {
|
public void setINSServer(ProtocolINSServer insServer) {
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
|||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
|
||||||
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
|
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
|
||||||
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
@@ -26,6 +24,7 @@ public final class WebServerListener extends EventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the webServer variable
|
* Sets the webServer variable
|
||||||
|
*
|
||||||
* @param webServer The Instance of the ProtocolWebServer
|
* @param webServer The Instance of the ProtocolWebServer
|
||||||
*/
|
*/
|
||||||
public void setWebServer(ProtocolWebServer webServer) {
|
public void setWebServer(ProtocolWebServer webServer) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
/**
|
/**
|
||||||
* Creates a web connection to the specified InfoName and ports.
|
* Creates a web connection to the specified InfoName and ports.
|
||||||
*
|
*
|
||||||
* @param infoName the target InfoName for the web connection.
|
* @param infoName the target InfoName 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.
|
||||||
@@ -133,7 +133,8 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
// Validate each file in the folder
|
// Validate each file in the folder
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
if (!file.getName().startsWith(prefix))
|
||||||
|
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||||
|
|
||||||
// Check for specific files
|
// Check for specific files
|
||||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||||
@@ -320,8 +321,8 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
/**
|
/**
|
||||||
* Requests the destination for the specified InfoName from the INS server.
|
* Requests the destination for the specified InfoName from the INS server.
|
||||||
*
|
*
|
||||||
* @param infoName the InfoName for which to request the destination.
|
* @param infoName the InfoName for which to request the destination.
|
||||||
* @param responseCode the expected INSResponseCode for the request.
|
* @param responseCode the expected INSResponseCode 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.
|
||||||
* @throws ClassNotFoundException if there are issues with class loading during packet handling.
|
* @throws ClassNotFoundException if there are issues with class loading during packet handling.
|
||||||
*/
|
*/
|
||||||
@@ -336,6 +337,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set protocol bridge.
|
* Set protocol bridge.
|
||||||
|
*
|
||||||
* @param protocolBridge The ProtocolBridge object.
|
* @param protocolBridge The ProtocolBridge object.
|
||||||
*/
|
*/
|
||||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||||
@@ -345,7 +347,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
|||||||
/**
|
/**
|
||||||
* Callback method invoked when InfoName validation is completed.
|
* Callback method invoked when InfoName validation is completed.
|
||||||
*
|
*
|
||||||
* @param infoName the InfoName that was validated.
|
* @param infoName the InfoName that was validated.
|
||||||
* @param responseCode the INSResponseCode resulting from the validation.
|
* @param responseCode the INSResponseCode resulting from the validation.
|
||||||
*/
|
*/
|
||||||
public abstract void validationCompleted(InfoName infoName, INSResponseCode responseCode);
|
public abstract void validationCompleted(InfoName infoName, INSResponseCode responseCode);
|
||||||
@@ -353,7 +355,7 @@ 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 infoName the InfoName for which the destination was requested.
|
* @param infoName the InfoName for which the destination was requested.
|
||||||
* @param destination the retrieved destination as a string.
|
* @param destination the retrieved destination as a string.
|
||||||
* @param validationResponse the INSResponseCode resulting from the destination retrieval.
|
* @param validationResponse the INSResponseCode resulting from the destination retrieval.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.openautonomousconnection.protocol.side.client;
|
|||||||
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
|
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
|
||||||
@@ -28,12 +27,15 @@ public final class WebClient {
|
|||||||
* NetworkClient instance for managing the pipeline connection to the web server.
|
* NetworkClient instance for managing the pipeline connection to the web server.
|
||||||
*/
|
*/
|
||||||
private final NetworkClient clientToWebPipeline;
|
private final NetworkClient clientToWebPipeline;
|
||||||
|
/**
|
||||||
|
* The Protocol Client associated with this protocol client.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final ProtocolClient protocolClient;
|
||||||
/**
|
/**
|
||||||
* SSLSocket for secure communication with the web server.
|
* SSLSocket for secure communication with the web server.
|
||||||
*/
|
*/
|
||||||
private SSLSocket clientToWebServer;
|
private SSLSocket clientToWebServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Streams for object serialization over the SSL connection.
|
* Streams for object serialization over the SSL connection.
|
||||||
*/
|
*/
|
||||||
@@ -43,18 +45,12 @@ public final class WebClient {
|
|||||||
*/
|
*/
|
||||||
private ObjectInputStream inputStream;
|
private ObjectInputStream inputStream;
|
||||||
|
|
||||||
/**
|
|
||||||
* The Protocol Client associated with this protocol client.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final ProtocolClient protocolClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a WebClient instance and establishes a secure connection to the web server.
|
* Constructs a WebClient instance and establishes a secure connection to the web server.
|
||||||
*
|
*
|
||||||
* @param infoName The InfoName information for the web server.
|
* @param infoName The InfoName 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.
|
||||||
* @param protocolClient The Protocol Client associated with this protocol client.
|
* @param protocolClient The Protocol Client associated with this protocol client.
|
||||||
* @throws Exception If an error occurs during connection setup.
|
* @throws Exception If an error occurs during connection setup.
|
||||||
*/
|
*/
|
||||||
@@ -154,10 +150,7 @@ public final class WebClient {
|
|||||||
*/
|
*/
|
||||||
public NetworkClient getClientPipelineConnection() {
|
public NetworkClient getClientPipelineConnection() {
|
||||||
return clientToWebPipeline;
|
return clientToWebPipeline;
|
||||||
} /**
|
}
|
||||||
* Thread for receiving data from the web server.
|
|
||||||
*/
|
|
||||||
private final Thread receiveThread = new Thread(this::receive);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the SSLSocket used for communication with the web server.
|
* Gets the SSLSocket used for communication with the web server.
|
||||||
@@ -166,7 +159,10 @@ public final class WebClient {
|
|||||||
*/
|
*/
|
||||||
public SSLSocket getClientWebConnection() {
|
public SSLSocket getClientWebConnection() {
|
||||||
return clientToWebServer;
|
return clientToWebServer;
|
||||||
}
|
} /**
|
||||||
|
* Thread for receiving data from the web server.
|
||||||
|
*/
|
||||||
|
private final Thread receiveThread = new Thread(this::receive);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the WebClient is currently connected to the web server.
|
* Checks if the WebClient is currently connected to the web server.
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
// Validate each file in the folder
|
// Validate each file in the folder
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
if (!file.getName().startsWith(prefix))
|
||||||
|
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||||
|
|
||||||
// Check if the file matches the expected naming convention
|
// Check if the file matches the expected naming convention
|
||||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||||
@@ -155,6 +156,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set protocol bridge
|
* Set protocol bridge
|
||||||
|
*
|
||||||
* @param protocolBridge The ProtocolBridge object
|
* @param protocolBridge The ProtocolBridge object
|
||||||
*/
|
*/
|
||||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||||
@@ -195,8 +197,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
|||||||
public abstract String getInfoNameDestination(InfoName infoName);
|
public abstract String getInfoNameDestination(InfoName infoName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param infoName The parent InfoName.
|
* @param infoName The parent InfoName.
|
||||||
* @param subname The subname to look up.
|
* @param subname The subname to look up.
|
||||||
* @return The destination associated with the subname.
|
* @return The destination associated with the subname.
|
||||||
* @see InfoName#getDestination(ProtocolBridge)
|
* @see InfoName#getDestination(ProtocolBridge)
|
||||||
* Abstract method to get the destination for a given subname under a specific InfoName.
|
* Abstract method to get the destination for a given subname under a specific InfoName.
|
||||||
@@ -221,7 +223,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract method called when a validation packet fails to send.
|
* Abstract method called when a validation packet fails to send.
|
||||||
* @param infoName The InfoName associated with the validation.
|
*
|
||||||
|
* @param infoName The InfoName 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.
|
||||||
*/
|
*/
|
||||||
@@ -229,8 +232,9 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract method called when a InfoName destination packet fails to send.
|
* Abstract method called when a InfoName destination packet fails to send.
|
||||||
|
*
|
||||||
* @param client The connected protocol client.
|
* @param client The connected protocol client.
|
||||||
* @param infoName The InfoName associated with the packet.
|
* @param infoName The InfoName associated with the packet.
|
||||||
* @param validationResponse The INS response code from validation.
|
* @param validationResponse The INS response code from validation.
|
||||||
* @param exception The exception that occurred during sending.
|
* @param exception The exception that occurred during sending.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.openautonomousconnection.protocol.side.web;
|
|||||||
|
|
||||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||||
import org.openautonomousconnection.protocol.side.web.managers.AuthManager;
|
import org.openautonomousconnection.protocol.side.web.managers.AuthManager;
|
||||||
@@ -56,6 +55,12 @@ public final class ConnectedWebClient {
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private boolean clientVersionLoaded = false;
|
private boolean clientVersionLoaded = false;
|
||||||
|
/**
|
||||||
|
* The reference to the ProtocolWebServer Object
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private ProtocolWebServer protocolWebServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a ConnectedWebClient with the given connection handler.
|
* Constructs a ConnectedWebClient with the given connection handler.
|
||||||
*
|
*
|
||||||
@@ -68,12 +73,6 @@ public final class ConnectedWebClient {
|
|||||||
*/
|
*/
|
||||||
private final Thread receiveThread = new Thread(this::receive);
|
private final Thread receiveThread = new Thread(this::receive);
|
||||||
|
|
||||||
/**
|
|
||||||
* The reference to the ProtocolWebServer Object
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private ProtocolWebServer protocolWebServer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an HTTP redirect response to the client.
|
* Sends an HTTP redirect response to the client.
|
||||||
*
|
*
|
||||||
@@ -709,6 +708,7 @@ public final class ConnectedWebClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set protocol bridge
|
* Set protocol bridge
|
||||||
|
*
|
||||||
* @param protocolWebServer The ProtocolWebServer object
|
* @param protocolWebServer The ProtocolWebServer object
|
||||||
*/
|
*/
|
||||||
public void setProtocolWebServer(ProtocolWebServer protocolWebServer) {
|
public void setProtocolWebServer(ProtocolWebServer protocolWebServer) {
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ public final class ProtocolWebServer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set protocol bridge
|
* Set protocol bridge
|
||||||
|
*
|
||||||
* @param protocolBridge The ProtocolBridge object
|
* @param protocolBridge The ProtocolBridge object
|
||||||
*/
|
*/
|
||||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||||
@@ -270,7 +271,7 @@ public final class ProtocolWebServer {
|
|||||||
* @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 final 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;
|
||||||
|
|
||||||
// Ensure the folder exists
|
// Ensure the folder exists
|
||||||
@@ -283,7 +284,8 @@ public final class ProtocolWebServer {
|
|||||||
|
|
||||||
// Check for the required certificate file
|
// Check for the required certificate file
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
if (!file.getName().startsWith(prefix))
|
||||||
|
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||||
|
|
||||||
// Check for file matching the public IP address
|
// Check for file matching the public IP address
|
||||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.openautonomousconnection.protocol.side.web.managers;
|
package org.openautonomousconnection.protocol.side.web.managers;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||||
@@ -32,9 +31,9 @@ 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.
|
||||||
* @param protocolWebServer The Protocol WebServer for the unique Session
|
* @param protocolWebServer The Protocol WebServer for the unique Session
|
||||||
* @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.
|
||||||
@@ -55,9 +54,9 @@ 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.
|
||||||
* @param protocolWebServer The Protocol WebServer to get the config for refreshing
|
* @param protocolWebServer The Protocol WebServer to get the config for refreshing
|
||||||
* @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.
|
||||||
@@ -154,6 +153,7 @@ public final class SessionManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the session's expiration time.
|
* Refreshes the session's expiration time.
|
||||||
|
*
|
||||||
* @param protocolWebServer The Protocol WebServer to get the Config setting
|
* @param protocolWebServer The Protocol WebServer to get the Config setting
|
||||||
* @throws IOException If an I/O error occurs.
|
* @throws IOException If an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
|
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
|
||||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||||
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_MessagePacket;
|
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_MessagePacket;
|
||||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public final class ClassicConverter {
|
|||||||
/**
|
/**
|
||||||
* Converts a InfoName object to a Classic_Domain object.
|
* Converts a InfoName object to a Classic_Domain object.
|
||||||
*
|
*
|
||||||
* @param newInfoName the InfoName object to convert
|
* @param newInfoName the InfoName object to convert
|
||||||
* @param protocolBridge The reference to the ProtocolBridge object.
|
* @param protocolBridge The reference to the ProtocolBridge object.
|
||||||
* @return the converted Classic_Domain object
|
* @return the converted Classic_Domain object
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public final class Classic_ClientListener extends EventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set protocol bridge
|
* Set protocol bridge
|
||||||
|
*
|
||||||
* @param protocolBridge The ProtocolBridge object
|
* @param protocolBridge The ProtocolBridge object
|
||||||
*/
|
*/
|
||||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||||
|
|||||||
Reference in New Issue
Block a user