Reformatted using IntelliJ
This commit is contained in:
@@ -72,10 +72,10 @@ public final class ProtocolBridge {
|
||||
/**
|
||||
* Initialize the ProtocolBridge instance for the client side
|
||||
*
|
||||
* @param protocolServer The ProtocolCustomServer instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @param protocolServer The ProtocolCustomServer instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @throws Exception if an error occurs while initializing the ProtocolBridge
|
||||
*/
|
||||
public ProtocolBridge(ProtocolCustomServer protocolServer, ProtocolValues protocolValues, ProtocolVersion protocolVersion, File logFolder) throws Exception {
|
||||
@@ -101,10 +101,10 @@ public final class ProtocolBridge {
|
||||
/**
|
||||
* Initialize the ProtocolBridge instance for the client side
|
||||
*
|
||||
* @param protocolClient The ProtocolClient instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @param protocolClient The ProtocolClient instance
|
||||
* @param protocolValues The ProtocolSettings instance
|
||||
* @param protocolVersion The ProtocolVersion instance
|
||||
* @param logFolder The folder to store the log files
|
||||
* @throws Exception if an error occurs while initializing the ProtocolBridge
|
||||
*/
|
||||
@ProtocolInfo(protocolSide = ProtocolVersion.ProtocolSide.CLIENT)
|
||||
@@ -130,14 +130,21 @@ public final class ProtocolBridge {
|
||||
*/
|
||||
private void registerPackets() {
|
||||
// 1.0.0-BETA packets
|
||||
if (isPacketSupported(new AuthPacket(this))) protocolValues.packetHandler.registerPacket(() -> new AuthPacket(this));
|
||||
if (isPacketSupported(new AuthPacket(this)))
|
||||
protocolValues.packetHandler.registerPacket(() -> new AuthPacket(this));
|
||||
if (isPacketSupported(new INSQueryPacket())) protocolValues.packetHandler.registerPacket(INSQueryPacket::new);
|
||||
if (isPacketSupported(new INSResponsePacket(this))) protocolValues.packetHandler.registerPacket(() -> new INSResponsePacket(this));
|
||||
if (isPacketSupported(new WebRequestPacket())) protocolValues.packetHandler.registerPacket(WebRequestPacket::new);
|
||||
if (isPacketSupported(new WebResponsePacket())) protocolValues.packetHandler.registerPacket(WebResponsePacket::new);
|
||||
if (isPacketSupported(new WebStreamChunkPacket())) protocolValues.packetHandler.registerPacket(WebStreamChunkPacket::new);
|
||||
if (isPacketSupported(new WebStreamStartPacket())) protocolValues.packetHandler.registerPacket(WebStreamStartPacket::new);
|
||||
if (isPacketSupported(new WebStreamEndPacket())) protocolValues.packetHandler.registerPacket(WebStreamEndPacket::new);
|
||||
if (isPacketSupported(new INSResponsePacket(this)))
|
||||
protocolValues.packetHandler.registerPacket(() -> new INSResponsePacket(this));
|
||||
if (isPacketSupported(new WebRequestPacket()))
|
||||
protocolValues.packetHandler.registerPacket(WebRequestPacket::new);
|
||||
if (isPacketSupported(new WebResponsePacket()))
|
||||
protocolValues.packetHandler.registerPacket(WebResponsePacket::new);
|
||||
if (isPacketSupported(new WebStreamChunkPacket()))
|
||||
protocolValues.packetHandler.registerPacket(WebStreamChunkPacket::new);
|
||||
if (isPacketSupported(new WebStreamStartPacket()))
|
||||
protocolValues.packetHandler.registerPacket(WebStreamStartPacket::new);
|
||||
if (isPacketSupported(new WebStreamEndPacket()))
|
||||
protocolValues.packetHandler.registerPacket(WebStreamEndPacket::new);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Listener for client-side events such as connection and disconnection.
|
||||
*/
|
||||
@@ -44,7 +42,7 @@ public final class ClientListener extends EventListener {
|
||||
try {
|
||||
event.getClient().sendPacket(new AuthPacket(client.getProtocolBridge()), TransportProtocol.TCP);
|
||||
} catch (Exception exception) {
|
||||
client.getProtocolBridge().getLogger().exception("Failed to send auth packet", exception);
|
||||
client.getProtocolBridge().getLogger().exception("Failed to send auth packet", exception);
|
||||
event.getClient().disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.openautonomousconnection.protocol.listeners;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.client.S_ClientConnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.client.S_ClientDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.packets.S_PacketReadEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.TransportProtocol;
|
||||
import lombok.Getter;
|
||||
@@ -17,7 +16,6 @@ import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecord;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -19,19 +21,12 @@ public abstract class OACPacket extends Packet {
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolVersion protocolVersion;
|
||||
|
||||
private final int id;
|
||||
/**
|
||||
* The response code for the packet, defaulting to RESPONSE_NOT_REQUIRED.
|
||||
*/
|
||||
private INSResponseStatus responseCode = INSResponseStatus.RESPONSE_NOT_REQUIRED;
|
||||
|
||||
private final int id;
|
||||
|
||||
@Override
|
||||
public int getPacketID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for OACPacket.
|
||||
*
|
||||
@@ -43,6 +38,11 @@ public abstract class OACPacket extends Packet {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the response code for the packet.
|
||||
*
|
||||
@@ -65,7 +65,7 @@ public abstract class OACPacket extends Packet {
|
||||
* Writes the packet data to the output stream.
|
||||
*
|
||||
* @param outputStream 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.
|
||||
*/
|
||||
@Override
|
||||
public final void write(DataOutputStream outputStream) throws IOException {
|
||||
@@ -94,7 +94,7 @@ public abstract class OACPacket extends Packet {
|
||||
* Abstract method to be implemented by subclasses for writing specific packet data.
|
||||
*
|
||||
* @param outputStream 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.
|
||||
*/
|
||||
public abstract void onWrite(DataOutputStream outputStream) throws IOException;
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class OACPacket extends Packet {
|
||||
* Abstract method to be implemented by subclasses for reading specific packet data.
|
||||
*
|
||||
* @param inputStream 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.
|
||||
*/
|
||||
public abstract void onRead(DataInputStream inputStream, UUID clientID) throws IOException;
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.TOFUFeedback;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -179,7 +182,10 @@ public final class AuthPacket extends OACPacket {
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
}
|
||||
if (feedback == TOFUFeedback.TRUST) { FileUtils.writeFile(fpFile, fp + System.lineSeparator()); allowWritePem = true; }
|
||||
if (feedback == TOFUFeedback.TRUST) {
|
||||
FileUtils.writeFile(fpFile, fp + System.lineSeparator());
|
||||
allowWritePem = true;
|
||||
}
|
||||
} else {
|
||||
TOFUFeedback feedback = protocolBridge.getProtocolClient().trustINS(fp);
|
||||
if (feedback == TOFUFeedback.DISCONNECT) {
|
||||
@@ -187,11 +193,15 @@ public final class AuthPacket extends OACPacket {
|
||||
protocolBridge.getProtocolClient().getClientINSConnection().disconnect();
|
||||
return;
|
||||
}
|
||||
if (feedback == TOFUFeedback.TRUST) { FileUtils.writeFile(fpFile, fp + System.lineSeparator()); allowWritePem = true; }
|
||||
if (feedback == TOFUFeedback.TRUST) {
|
||||
FileUtils.writeFile(fpFile, fp + System.lineSeparator());
|
||||
allowWritePem = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowWritePem) {
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED); return;
|
||||
setResponseCode(INSResponseStatus.RESPONSE_AUTH_FAILED);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecordType;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecord;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSResponseStatus;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.WebRequestMethod;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WebStreamChunkPacket extends OACPacket {
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class WebStreamEndPacket extends OACPacket {
|
||||
|
||||
@@ -4,7 +4,9 @@ import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.state.ClientDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.TransportProtocol;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.NetworkUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.PemUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.utils.DefaultMethodsOverrider;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
@@ -23,7 +21,8 @@ import org.openautonomousconnection.protocol.versions.v1_0_0.beta.TOFUFeedback;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.security.*;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.HashMap;
|
||||
@@ -147,7 +146,6 @@ public abstract class ProtocolClient extends EventListener {
|
||||
}
|
||||
|
||||
private void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
|
||||
boolean found = false;
|
||||
if (folder == null) throw new FileNotFoundException("Folder does not exist");
|
||||
|
||||
File[] files = folder.listFiles();
|
||||
@@ -158,11 +156,7 @@ public abstract class ProtocolClient extends EventListener {
|
||||
for (File file : files) {
|
||||
if (!file.getName().startsWith(prefix))
|
||||
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
|
||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||
}
|
||||
|
||||
if (!found) throw new CertificateException("Missing " + prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||
}
|
||||
|
||||
public final ProtocolVersion getServerVersion() {
|
||||
@@ -332,6 +326,7 @@ public abstract class ProtocolClient extends EventListener {
|
||||
}
|
||||
|
||||
public abstract TOFUFeedback trustINS(String caFingerprint);
|
||||
|
||||
public abstract TOFUFeedback insFingerprintChanged(String oldCAFingerprint, String newCAFingerprint);
|
||||
|
||||
public static final class ClientCertificateFolderStructure {
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
package org.openautonomousconnection.protocol.side.ins;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager;
|
||||
import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.NetworkServer;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientAuthMode;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.utils.NetworkUtils;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.side.server.ProtocolCustomServer;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecord;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecordType;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -32,25 +26,17 @@ public abstract class ProtocolINSServer extends ProtocolCustomServer {
|
||||
* @return The INS information site URL.
|
||||
*/
|
||||
private final String insInfoSite;
|
||||
public final String getInsInfoSite() {
|
||||
return insInfoSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the INS registration site URL from the configuration.
|
||||
*
|
||||
* @return The INS registration site URL.
|
||||
*/
|
||||
private String insFrontendSite;
|
||||
|
||||
public final String getInsFrontendSite() {
|
||||
return insFrontendSite;
|
||||
}
|
||||
private final String insFrontendSite;
|
||||
|
||||
/**
|
||||
* Constructs a ProtocolINSServer with the specified configuration file.
|
||||
*
|
||||
* @param insInfoSite The INS-InfoSize (IP:PORT)
|
||||
* @param insInfoSite The INS-InfoSize (IP:PORT)
|
||||
* @param insFrontendSite The INS-InfoSize (IP:PORT)
|
||||
* @throws IOException If an I/O error occurs.
|
||||
* @throws CertificateException If a certificate error occurs.
|
||||
@@ -61,6 +47,14 @@ public abstract class ProtocolINSServer extends ProtocolCustomServer {
|
||||
this.insFrontendSite = insFrontendSite;
|
||||
}
|
||||
|
||||
public final String getInsInfoSite() {
|
||||
return insInfoSite;
|
||||
}
|
||||
|
||||
public final String getInsFrontendSite() {
|
||||
return insFrontendSite;
|
||||
}
|
||||
|
||||
public void start(int tcpPort) throws IOException, InterruptedException, NoSuchAlgorithmException {
|
||||
getNetwork().start(tcpPort, -1);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.openautonomousconnection.protocol.side.server;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.EventManager;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.EventPriority;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectedClient;
|
||||
|
||||
@@ -4,7 +4,6 @@ import dev.unlegitdqrk.unlegitlibrary.event.EventListener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.EventPriority;
|
||||
import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.state.ClientDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.NetworkServer;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.client.S_ClientDisconnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.state.ServerStoppedEvent;
|
||||
@@ -14,10 +13,7 @@ import dev.unlegitdqrk.unlegitlibrary.network.utils.PemUtils;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.side.server.events.S_CustomClientDisconnectedEvent;
|
||||
import org.openautonomousconnection.protocol.side.web.managers.AuthManager;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -33,11 +29,6 @@ public abstract class ProtocolCustomServer extends EventListener {
|
||||
* Structure for server.
|
||||
*/
|
||||
private final ServerCertificateFolderStructure folderStructure;
|
||||
|
||||
public final ServerCertificateFolderStructure getFolderStructure() {
|
||||
return folderStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Certificate files for SSL.
|
||||
*/
|
||||
@@ -46,38 +37,19 @@ public abstract class ProtocolCustomServer extends EventListener {
|
||||
* Certificate files for SSL.
|
||||
*/
|
||||
private final File keyFile;
|
||||
|
||||
/**
|
||||
* The reference to the ProtocolBridge Object
|
||||
*/
|
||||
private ProtocolBridge protocolBridge;
|
||||
|
||||
public final ProtocolBridge getProtocolBridge() {
|
||||
return protocolBridge;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of connected web clients.
|
||||
*/
|
||||
private final List<CustomConnectedClient> clients;
|
||||
|
||||
public final List<CustomConnectedClient> getClients() {
|
||||
return clients;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference to the ProtocolBridge Object
|
||||
*/
|
||||
private ProtocolBridge protocolBridge;
|
||||
/**
|
||||
* The network server handling pipeline connections.
|
||||
*/
|
||||
private NetworkServer network;
|
||||
|
||||
public final NetworkServer getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
protected final void setNetwork(NetworkServer network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the web server with the given configuration, authentication, and rules files.
|
||||
*
|
||||
@@ -99,6 +71,26 @@ public abstract class ProtocolCustomServer extends EventListener {
|
||||
this.keyFile = new File(folderStructure.privateServerFolder, folderStructure.certPrefix + NetworkUtils.getPublicIPAddress() + ".key");
|
||||
}
|
||||
|
||||
public final ServerCertificateFolderStructure getFolderStructure() {
|
||||
return folderStructure;
|
||||
}
|
||||
|
||||
public final ProtocolBridge getProtocolBridge() {
|
||||
return protocolBridge;
|
||||
}
|
||||
|
||||
public final List<CustomConnectedClient> getClients() {
|
||||
return clients;
|
||||
}
|
||||
|
||||
public final NetworkServer getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
protected final void setNetwork(NetworkServer network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects the ProtocolBridge.
|
||||
*
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.openautonomousconnection.protocol.side.web;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.file.FileUtils;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.utils.ClientAuthMode;
|
||||
import dev.unlegitdqrk.unlegitlibrary.string.RandomString;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebRequestPacket;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket;
|
||||
@@ -25,54 +23,30 @@ public abstract class ProtocolWebServer extends ProtocolCustomServer {
|
||||
* Folder for web content.
|
||||
*/
|
||||
private final File contentFolder;
|
||||
|
||||
public final File getContentFolder() {
|
||||
return contentFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Folder for error pages.
|
||||
*/
|
||||
private final File errorsFolder;
|
||||
|
||||
public final File getErrorsFolder() {
|
||||
return errorsFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique secret for session management.
|
||||
*/
|
||||
private final String uniqueSessionString;
|
||||
|
||||
public final String getUniqueSessionString() {
|
||||
return uniqueSessionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* The expiration time of a Session in minutes
|
||||
*/
|
||||
private final int sessionExpire;
|
||||
|
||||
public final int getSessionExpire() {
|
||||
return sessionExpire;
|
||||
}
|
||||
|
||||
/**
|
||||
* The max upload size in MB
|
||||
*/
|
||||
private final int maxUploadSize;
|
||||
|
||||
public final int getMaxUploadSize() {
|
||||
return maxUploadSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the web server with the given configuration, authentication, and rules files.
|
||||
*
|
||||
* @param authFile The authentication file.
|
||||
* @param rulesFile The rules file.
|
||||
* @param authFile The authentication file.
|
||||
* @param rulesFile The rules file.
|
||||
* @param sessionExpire The expiration time of a Session in minutes
|
||||
* @param uploadSize The max upload size in MB
|
||||
* @param uploadSize The max upload size in MB
|
||||
* @throws Exception If an error occurs during initialization.
|
||||
*/
|
||||
public ProtocolWebServer(File authFile, File rulesFile, int sessionExpire, int uploadSize) throws Exception {
|
||||
@@ -126,6 +100,26 @@ public abstract class ProtocolWebServer extends ProtocolCustomServer {
|
||||
RuleManager.loadRules(rulesFile);
|
||||
}
|
||||
|
||||
public final File getContentFolder() {
|
||||
return contentFolder;
|
||||
}
|
||||
|
||||
public final File getErrorsFolder() {
|
||||
return errorsFolder;
|
||||
}
|
||||
|
||||
public final String getUniqueSessionString() {
|
||||
return uniqueSessionString;
|
||||
}
|
||||
|
||||
public final int getSessionExpire() {
|
||||
return sessionExpire;
|
||||
}
|
||||
|
||||
public final int getMaxUploadSize() {
|
||||
return maxUploadSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server receives a WebRequestPacket from the client.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user