Forgot to set ProtocolBridge in Constructor

This commit is contained in:
Finn
2025-12-10 23:39:00 +01:00
parent 065414b82e
commit fecee6043c
5 changed files with 12 additions and 37 deletions

View File

@@ -110,7 +110,6 @@ public final class ProtocolBridge {
public ProtocolBridge(ProtocolINSServer protocolINSServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolINSServer = protocolINSServer;
this.protocolINSServer.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -136,7 +135,6 @@ public final class ProtocolBridge {
public ProtocolBridge(ProtocolWebServer protocolWebServer, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolWebServer = protocolWebServer;
this.protocolWebServer.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;
@@ -162,7 +160,6 @@ public final class ProtocolBridge {
public ProtocolBridge(ProtocolClient protocolClient, ProtocolSettings protocolSettings, ProtocolVersion protocolVersion, File logFolder) throws Exception {
// Assign the parameters to the class fields
this.protocolClient = protocolClient;
this.protocolClient.setProtocolBridge(this);
this.protocolSettings = protocolSettings;
this.protocolVersion = protocolVersion;

View File

@@ -54,7 +54,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
* The reference to the ProtocolBridge Object
*/
@Getter
private ProtocolBridge protocolBridge;
private final ProtocolBridge protocolBridge;
/**
* Initializes the ProtocolClient, setting up certificate folders and the INS client connection.
@@ -62,7 +62,9 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
* @throws CertificateException if there are issues with the certificates.
* @throws IOException if there are I/O issues during initialization.
*/
public ProtocolClient() throws CertificateException, IOException {
public ProtocolClient(ProtocolBridge protocolBridge) throws CertificateException, IOException {
this.protocolBridge = protocolBridge;
// Initialize and verify certificate folders and files
folderStructure = new ClientCertificateFolderStructure();
@@ -335,15 +337,6 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
clientToINS.sendPacket(new GetDestinationPacket(infoName, responseCode, protocolBridge));
}
/**
* Set protocol bridge.
*
* @param protocolBridge The ProtocolBridge object.
*/
public void setProtocolBridge(ProtocolBridge protocolBridge) {
if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
}
/**
* Callback method invoked when InfoName validation is completed.
*

View File

@@ -50,7 +50,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
* The reference to the ProtocolBridge Object
*/
@Getter
private ProtocolBridge protocolBridge;
private final ProtocolBridge protocolBridge;
/**
* Constructs a ProtocolINSServer with the specified configuration file.
@@ -59,7 +59,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
* @throws IOException If an I/O error occurs.
* @throws CertificateException If a certificate error occurs.
*/
public ProtocolINSServer(File configFile) throws IOException, CertificateException {
public ProtocolINSServer(File configFile, ProtocolBridge protocolBridge) throws IOException, CertificateException {
this.protocolBridge = protocolBridge;
// Ensure the configuration file exists
if (!configFile.exists()) configFile.createNewFile();
@@ -154,15 +155,6 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
return null;
}
/**
* Set protocol bridge
*
* @param protocolBridge The ProtocolBridge object
*/
public void setProtocolBridge(ProtocolBridge protocolBridge) {
if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
}
/**
* Gets the INS information site URL from the configuration.
*

View File

@@ -87,7 +87,7 @@ public final class ProtocolWebServer {
* The reference to the ProtocolBridge Object
*/
@Getter
private ProtocolBridge protocolBridge;
private final ProtocolBridge protocolBridge;
/**
* Initializes the web server with the given configuration, authentication, and rules files.
@@ -97,7 +97,9 @@ public final class ProtocolWebServer {
* @param rulesFile The rules file.
* @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, ProtocolBridge protocolBridge) throws Exception {
this.protocolBridge = protocolBridge;
// Initialize the list of connected clients
this.clients = new ArrayList<>();
@@ -183,15 +185,6 @@ public final class ProtocolWebServer {
return null;
}
/**
* Set protocol bridge
*
* @param protocolBridge The ProtocolBridge object
*/
public void setProtocolBridge(ProtocolBridge protocolBridge) {
if (this.protocolBridge == null) this.protocolBridge = protocolBridge;
}
/**
* Starts the web server to accept and handle client connections.
*