diff --git a/build.gradle.kts b/build.gradle.kts
index f26a195..7e36900 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
}
group = "com.stmarygate"
-version = "1.0.12"
+version = "1.0.13"
repositories {
mavenCentral()
diff --git a/src/main/java/com/stmarygate/coral/network/BaseInitializer.java b/src/main/java/com/stmarygate/coral/network/BaseInitializer.java
index e0d4e57..b1b08db 100644
--- a/src/main/java/com/stmarygate/coral/network/BaseInitializer.java
+++ b/src/main/java/com/stmarygate/coral/network/BaseInitializer.java
@@ -2,8 +2,6 @@
import com.stmarygate.coral.network.codec.PacketDecoder;
import com.stmarygate.coral.network.codec.PacketEncoder;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
diff --git a/src/main/java/com/stmarygate/coral/network/ClientSession.java b/src/main/java/com/stmarygate/coral/network/ClientSession.java
index acb6495..1b02e46 100644
--- a/src/main/java/com/stmarygate/coral/network/ClientSession.java
+++ b/src/main/java/com/stmarygate/coral/network/ClientSession.java
@@ -2,12 +2,12 @@
import com.stmarygate.coral.network.packets.Packet;
import io.netty.channel.Channel;
-
import java.util.Arrays;
/**
* Represents a session associated with a client's communication channel. It provides methods to
- * send packets to the client and close the communication {@link Channel} associated with the client.
+ * send packets to the client and close the communication {@link Channel} associated with the
+ * client.
*/
public class ClientSession {
/** The communication channel associated with the client session. */
@@ -32,7 +32,15 @@ public void write(Packet packet) throws Exception {
try {
this.channel.writeAndFlush(packet);
} catch (Exception e) {
- throw new Exception("Error writing packet " + packet.getClass().getSimpleName() + " to client " + this.channel.remoteAddress().toString() + "\nError:\n" + e.getMessage() + "\n" + Arrays.toString(e.getStackTrace()));
+ throw new Exception(
+ "Error writing packet "
+ + packet.getClass().getSimpleName()
+ + " to client "
+ + this.channel.remoteAddress().toString()
+ + "\nError:\n"
+ + e.getMessage()
+ + "\n"
+ + Arrays.toString(e.getStackTrace()));
}
}
diff --git a/src/main/java/com/stmarygate/coral/network/PacketHandler.java b/src/main/java/com/stmarygate/coral/network/PacketHandler.java
index e96d3b7..b0dfd69 100644
--- a/src/main/java/com/stmarygate/coral/network/PacketHandler.java
+++ b/src/main/java/com/stmarygate/coral/network/PacketHandler.java
@@ -4,7 +4,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
-
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -24,7 +23,13 @@ public void handlePacket(Packet packet) throws Exception {
Method method = findHandlerMethod(packet);
method.invoke(this, packet);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
- throw new Exception("Error handling incoming packet " + packet.getClass().getSimpleName() + "\nError:\n" + e.getMessage() + "\n" + Arrays.toString(e.getStackTrace()));
+ throw new Exception(
+ "Error handling incoming packet "
+ + packet.getClass().getSimpleName()
+ + "\nError:\n"
+ + e.getMessage()
+ + "\n"
+ + Arrays.toString(e.getStackTrace()));
}
}
diff --git a/src/main/java/com/stmarygate/coral/network/codec/PacketDecoder.java b/src/main/java/com/stmarygate/coral/network/codec/PacketDecoder.java
index b58ee7e..ae43beb 100644
--- a/src/main/java/com/stmarygate/coral/network/codec/PacketDecoder.java
+++ b/src/main/java/com/stmarygate/coral/network/codec/PacketDecoder.java
@@ -10,41 +10,36 @@
import java.util.List;
/**
- *
The {@code PacketDecoder} class is responsible for decoding raw bytes received over the network
- * into instances of the {@link Packet} class. It extends {@link MessageToMessageDecoder} to integrate
- * with Netty's decoding pipeline.
+ * The {@code PacketDecoder} class is responsible for decoding raw bytes received over the network
+ * into instances of the {@link Packet} class. It extends {@link MessageToMessageDecoder} to
+ * integrate with Netty's decoding pipeline.
*
- *
This decoder works by maintaining an internal {@link ByteBuf} buffer to accumulate incoming bytes
- * until there is enough data to construct a complete packet. The decoding process involves reading
- * the packet ID and size from the buffer, then verifying if there is sufficient data to construct
- * the entire packet. If enough data is available, the packet is created using the {@link Protocol}
- * and {@link PacketBuffer}, and the decoded packet is added to the output list for further processing.
+ *
This decoder works by maintaining an internal {@link ByteBuf} buffer to accumulate incoming
+ * bytes until there is enough data to construct a complete packet. The decoding process involves
+ * reading the packet ID and size from the buffer, then verifying if there is sufficient data to
+ * construct the entire packet. If enough data is available, the packet is created using the {@link
+ * Protocol} and {@link PacketBuffer}, and the decoded packet is added to the output list for
+ * further processing.
*
- *
The decoding process is performed in a loop to handle multiple packets in the input buffer, and the
- * remaining bytes are retained in the buffer for subsequent decoding attempts.
+ *
The decoding process is performed in a loop to handle multiple packets in the input buffer,
+ * and the remaining bytes are retained in the buffer for subsequent decoding attempts.
*
- *
Example usage:
- * ```java
- * // Create an instance of PacketDecoder
- * PacketDecoder packetDecoder = new PacketDecoder();
+ *
Example usage: ```java // Create an instance of PacketDecoder PacketDecoder
+ * packetDecoder = new PacketDecoder();
*
- *
// Assume 'inputBytes' is a ByteBuf containing received network data
- * List outputPackets = new ArrayList<>();
- * packetDecoder.decode(ctx, inputBytes, outputPackets);
+ * // Assume 'inputBytes' is a ByteBuf containing received network data List
+ * outputPackets = new ArrayList<>(); packetDecoder.decode(ctx, inputBytes, outputPackets);
*
- * // Process the decoded packets in 'outputPackets'
- * ```
+ *
// Process the decoded packets in 'outputPackets' ```
*
- *
Note: It's crucial to properly release resources in Netty, especially ByteBuf instances, to prevent memory leaks.
- * Ensure that the {@code decode} method is called with sufficient frequency to handle incoming data and release
- * the retained ByteBuf instances appropriately.
+ *
Note: It's crucial to properly release resources in Netty, especially ByteBuf instances, to
+ * prevent memory leaks. Ensure that the {@code decode} method is called with sufficient frequency
+ * to handle incoming data and release the retained ByteBuf instances appropriately.
*/
public class PacketDecoder extends MessageToMessageDecoder {
private ByteBuf buffer;
- /**
- * Constructs a new {@code PacketDecoder}.
- */
+ /** Constructs a new {@code PacketDecoder}. */
public PacketDecoder() {}
/**
@@ -57,37 +52,40 @@ public PacketDecoder() {}
*/
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List out) throws Exception {
- // Duplicate and retain the incoming buffer for manipulation
- if (this.buffer == null || this.buffer.readableBytes() == 0) {
- this.buffer = msg.duplicate().retain();
- } else {
- this.buffer = Unpooled.copiedBuffer(this.buffer, msg).retain();
- }
+ // Duplicate and retain the incoming buffer for manipulation
+ if (this.buffer == null || this.buffer.readableBytes() == 0) {
+ this.buffer = msg.duplicate().retain();
+ } else {
+ this.buffer = Unpooled.copiedBuffer(this.buffer, msg).retain();
+ }
- // Continue decoding while there is enough data in the buffer
- while (this.buffer.readableBytes() > Packet.HEADER_SIZE) {
- int id = this.buffer.readShort();
- int size = this.buffer.readShort();
+ // Continue decoding while there is enough data in the buffer
+ while (this.buffer.readableBytes() > Packet.HEADER_SIZE) {
+ int id = this.buffer.readShort();
+ int size = this.buffer.readShort();
- // Check if there is enough data to read the entire packet
- if (size > this.buffer.readableBytes()) {
- // Not enough data to read the packet, wait for more data
- return;
- }
+ // Check if there is enough data to read the entire packet
+ if (size > this.buffer.readableBytes()) {
+ // Not enough data to read the packet, wait for more data
+ return;
+ }
- // Reset the reader index to the beginning of the packet
- this.buffer.resetReaderIndex();
+ // Reset the reader index to the beginning of the packet
+ this.buffer.resetReaderIndex();
- // Read a slice of the buffer containing the entire packet. The size add the header size because size dosn't include the header size
- ByteBuf slice = this.buffer.readSlice(size + Packet.HEADER_SIZE);
+ // Read a slice of the buffer containing the entire packet. The size add the header size
+ // because size dosn't include the header size
+ ByteBuf slice = this.buffer.readSlice(size + Packet.HEADER_SIZE);
- // Create a new packet instance using the Protocol and PacketBuffer
- Packet packet = Protocol.getInstance().getPacket(id);
+ // Create a new packet instance using the Protocol and PacketBuffer
+ Packet packet = Protocol.getInstance().getPacket(id);
+ if (packet != null) {
packet.decode(new PacketBuffer(slice, id, Packet.PacketAction.READ));
-
// Add the decoded packet to the output list
out.add(packet);
+ } else {
+ break;
}
+ }
}
}
-
diff --git a/src/main/java/com/stmarygate/coral/network/codec/PacketEncoder.java b/src/main/java/com/stmarygate/coral/network/codec/PacketEncoder.java
index b5d4e2c..ea40066 100644
--- a/src/main/java/com/stmarygate/coral/network/codec/PacketEncoder.java
+++ b/src/main/java/com/stmarygate/coral/network/codec/PacketEncoder.java
@@ -13,17 +13,17 @@
* integration with Netty's encoding pipeline.
*
* This encoder works by calling the {@link Packet#encode(PacketBuffer)} method on the provided
- * {@link Packet} instance, creating a {@link PacketBuffer} to write the encoded data into the specified
- * {@link ByteBuf} (output buffer). The encoded packet is then flushed to the network channel for transmission.
+ * {@link Packet} instance, creating a {@link PacketBuffer} to write the encoded data into the
+ * specified {@link ByteBuf} (output buffer). The encoded packet is then flushed to the network
+ * channel for transmission.
*
- *
The encoding process involves creating a {@link PacketBuffer} initialized with the output buffer,
- * the packet's ID, and the action type (in this case, {@link Packet.PacketAction#WRITE}). The packet's
- * encode method writes the packet's data into the buffer. The resulting byte stream is then flushed
- * to the network channel.
+ *
The encoding process involves creating a {@link PacketBuffer} initialized with the output
+ * buffer, the packet's ID, and the action type (in this case, {@link Packet.PacketAction#WRITE}).
+ * The packet's encode method writes the packet's data into the buffer. The resulting byte stream is
+ * then flushed to the network channel.
*
- *
Usage:
- * To use this encoder, add an instance of {@code PacketEncoder} to the Netty pipeline in your Netty
- * server or client bootstrap configuration.
+ *
Usage: To use this encoder, add an instance of {@code PacketEncoder} to the
+ * Netty pipeline in your Netty server or client bootstrap configuration.
*
*
{@code
* ChannelPipeline pipeline = ch.pipeline();
@@ -31,10 +31,9 @@
* // ... add other handlers to the pipeline
* }
*
- * Example:
- * Suppose you have a custom packet class named {@code MyPacket} that extends {@link Packet}. When you send
- * an instance of {@code MyPacket} over the network, the {@code PacketEncoder} will handle the encoding
- * process automatically.
+ *
Example: Suppose you have a custom packet class named {@code MyPacket} that
+ * extends {@link Packet}. When you send an instance of {@code MyPacket} over the network, the
+ * {@code PacketEncoder} will handle the encoding process automatically.
*
*
{@code
* MyPacket myPacket = new MyPacket(); // create an instance of your custom packet
@@ -49,8 +48,8 @@
public class PacketEncoder extends MessageToByteEncoder {
/**
- * Constructs a new {@code PacketEncoder} instance. This constructor sets the target class
- * for encoding to {@link Packet}.
+ * Constructs a new {@code PacketEncoder} instance. This constructor sets the target class for
+ * encoding to {@link Packet}.
*/
public PacketEncoder() {
super(Packet.class);
@@ -68,11 +67,12 @@ public PacketEncoder() {
@Override
protected void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
try {
- msg.encode(new PacketBuffer(out, Protocol.getInstance().getPacketId(msg), Packet.PacketAction.WRITE));
+ msg.encode(
+ new PacketBuffer(
+ out, Protocol.getInstance().getPacketId(msg), Packet.PacketAction.WRITE));
ctx.channel().flush();
} catch (Exception e) {
throw new Exception(e.getMessage(), e.getCause());
}
}
}
-
diff --git a/src/main/java/com/stmarygate/coral/network/packets/Packet.java b/src/main/java/com/stmarygate/coral/network/packets/Packet.java
index 489cd42..520f815 100644
--- a/src/main/java/com/stmarygate/coral/network/packets/Packet.java
+++ b/src/main/java/com/stmarygate/coral/network/packets/Packet.java
@@ -2,13 +2,9 @@
import com.stmarygate.coral.network.PacketHandler;
-/**
- * Represents a generic packet in the network communication.
- */
+/** Represents a generic packet in the network communication. */
public class Packet {
- /**
- * The size of the packet header in bytes.
- */
+ /** The size of the packet header in bytes. */
public static final int HEADER_SIZE = 4;
/**
@@ -39,19 +35,12 @@ public void handle(PacketHandler handler) throws Exception {
// Implementation specific to each packet type.
}
- /**
- * Enum representing the action type of packet (READ or WRITE).
- */
+ /** Enum representing the action type of packet (READ or WRITE). */
public enum PacketAction {
- /**
- * Indicates a packet is being read.
- */
+ /** Indicates a packet is being read. */
READ,
- /**
- * Indicates a packet is being written.
- */
+ /** Indicates a packet is being written. */
WRITE
}
}
-
diff --git a/src/main/java/com/stmarygate/coral/network/packets/Protocol.java b/src/main/java/com/stmarygate/coral/network/packets/Protocol.java
index ddc954b..67c3cea 100644
--- a/src/main/java/com/stmarygate/coral/network/packets/Protocol.java
+++ b/src/main/java/com/stmarygate/coral/network/packets/Protocol.java
@@ -3,7 +3,6 @@
import com.stmarygate.coral.network.packets.client.PacketLoginUsingCredentials;
import com.stmarygate.coral.network.packets.client.PacketVersion;
import com.stmarygate.coral.network.packets.server.PacketVersionResult;
-
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@@ -90,8 +89,8 @@ public Packet getPacket(int id)
IllegalAccessException,
NoSuchMethodException,
InvocationTargetException {
- if (!PACKETS_MAP.containsKey(id))
- throw new RuntimeException("Packet with id " + id + " is not registered.");
+ if (!PACKETS_MAP.containsKey(id)) return null;
+ // throw new RuntimeException("Packet with id " + id + " is not registered.");
return PACKETS_MAP.get(id).getDeclaredConstructor().newInstance();
}
diff --git a/src/main/java/com/stmarygate/coral/network/packets/client/PacketLoginUsingCredentials.java b/src/main/java/com/stmarygate/coral/network/packets/client/PacketLoginUsingCredentials.java
index 2f51b93..21f9509 100644
--- a/src/main/java/com/stmarygate/coral/network/packets/client/PacketLoginUsingCredentials.java
+++ b/src/main/java/com/stmarygate/coral/network/packets/client/PacketLoginUsingCredentials.java
@@ -16,13 +16,14 @@ public PacketLoginUsingCredentials(String username, String password) {
if (username.isEmpty() && password.isEmpty()) return;
this.username = username;
- Argon2PasswordEncoder argon2PasswordEncoder = new Argon2PasswordEncoder(
- 16, // saltLength
- 64, // hashLength
- 8, // parallelism (e.g., number of CPU cores)
- 65536, // memory in kilobytes
- 4 // iterations
- );
+ Argon2PasswordEncoder argon2PasswordEncoder =
+ new Argon2PasswordEncoder(
+ 16, // saltLength
+ 64, // hashLength
+ 8, // parallelism (e.g., number of CPU cores)
+ 65536, // memory in kilobytes
+ 4 // iterations
+ );
this.password = password;
this.encodedPassword = argon2PasswordEncoder.encode(password);
diff --git a/src/main/java/com/stmarygate/coral/network/packets/client/PacketVersion.java b/src/main/java/com/stmarygate/coral/network/packets/client/PacketVersion.java
index c020e05..b5e11ad 100644
--- a/src/main/java/com/stmarygate/coral/network/packets/client/PacketVersion.java
+++ b/src/main/java/com/stmarygate/coral/network/packets/client/PacketVersion.java
@@ -7,38 +7,29 @@
import lombok.Setter;
/**
- * Represents a version packet in the network communication.
- * Extends the base {@link Packet} class.
+ * Represents a version packet in the network communication. Extends the base {@link Packet} class.
*/
@Getter
@Setter
public class PacketVersion extends Packet {
- /**
- * The major version number.
- */
+ /** The major version number. */
private int major;
- /**
- * The minor version number.
- */
+ /** The minor version number. */
private int minor;
- /**
- * The patch version number.
- */
+ /** The patch version number. */
private int patch;
- /**
- * The build version string.
- */
+ /** The build version string. */
private String buildVersion;
/**
* Constructs a new {@code PacketVersion} with specified version information.
*
- * @param major The major version number.
- * @param minor The minor version number.
- * @param patch The patch version number.
+ * @param major The major version number.
+ * @param minor The minor version number.
+ * @param patch The patch version number.
* @param buildVersion The build version string.
*/
public PacketVersion(int major, int minor, int patch, String buildVersion) {
@@ -49,8 +40,8 @@ public PacketVersion(int major, int minor, int patch, String buildVersion) {
}
/**
- * Constructs a default {@code PacketVersion} with initial version information.
- * Defaults to version 0.0.1-SNAPSHOT.
+ * Constructs a default {@code PacketVersion} with initial version information. Defaults to
+ * version 0.0.1-SNAPSHOT.
*/
public PacketVersion() {
this(0, 0, 1, "SNAPSHOT");
@@ -100,10 +91,14 @@ public void handle(PacketHandler handler) throws Exception {
*/
@Override
public String toString() {
- return "{ major: " + major +
- ", minor: " + minor +
- ", patch: " + patch +
- ", build: " + buildVersion + " }";
+ return "{ major: "
+ + major
+ + ", minor: "
+ + minor
+ + ", patch: "
+ + patch
+ + ", build: "
+ + buildVersion
+ + " }";
}
}
-
diff --git a/src/main/java/com/stmarygate/coral/network/packets/server/PacketVersionResult.java b/src/main/java/com/stmarygate/coral/network/packets/server/PacketVersionResult.java
index 8d1f0b8..303d7a6 100644
--- a/src/main/java/com/stmarygate/coral/network/packets/server/PacketVersionResult.java
+++ b/src/main/java/com/stmarygate/coral/network/packets/server/PacketVersionResult.java
@@ -7,47 +7,38 @@
import lombok.Setter;
/**
- * Represents a version result packet in the network communication.
- * Extends the base {@link Packet} class.
+ * Represents a version result packet in the network communication. Extends the base {@link Packet}
+ * class.
*/
@Getter
@Setter
public class PacketVersionResult extends Packet {
- /**
- * Indicates whether the version is accepted.
- */
+ /** Indicates whether the version is accepted. */
private boolean accepted;
- /**
- * The major version number.
- */
+ /** The major version number. */
private int major;
- /**
- * The minor version number.
- */
+ /** The minor version number. */
private int minor;
- /**
- * The patch version number.
- */
+ /** The patch version number. */
private int patch;
- /**
- * The build version string.
- */
+ /** The build version string. */
private String buildVersion;
/**
* Constructs a new {@code PacketVersionResult} with specified version information.
*
- * @param accepted Whether the version is accepted.
- * @param major The major version number.
- * @param minor The minor version number.
- * @param patch The patch version number.
+ * @param accepted Whether the version is accepted.
+ * @param major The major version number.
+ * @param minor The minor version number.
+ * @param patch The patch version number.
* @param buildVersion The build version string.
*/
- public PacketVersionResult(boolean accepted, int major, int minor, int patch, String buildVersion) {
+ public PacketVersionResult(
+ boolean accepted, int major, int minor, int patch, String buildVersion) {
this.accepted = accepted;
this.major = major;
this.minor = minor;
@@ -55,9 +46,7 @@ public PacketVersionResult(boolean accepted, int major, int minor, int patch, St
this.buildVersion = buildVersion;
}
- /**
- * Constructs a default {@code PacketVersionResult} with all version information set to zero.
- */
+ /** Constructs a default {@code PacketVersionResult} with all version information set to zero. */
public PacketVersionResult() {
this(false, 0, 0, 0, "");
}
@@ -108,11 +97,16 @@ public void handle(PacketHandler handler) throws Exception {
*/
@Override
public String toString() {
- return "{ accepted: " + accepted +
- ", major: " + major +
- ", minor: " + minor +
- ", patch: " + patch +
- ", build: " + buildVersion + " }";
+ return "{ accepted: "
+ + accepted
+ + ", major: "
+ + major
+ + ", minor: "
+ + minor
+ + ", patch: "
+ + patch
+ + ", build: "
+ + buildVersion
+ + " }";
}
}
-
diff --git a/src/main/java/com/stmarygate/coral/utils/SSLContextUtils.java b/src/main/java/com/stmarygate/coral/utils/SSLContextUtils.java
new file mode 100644
index 0000000..025dff0
--- /dev/null
+++ b/src/main/java/com/stmarygate/coral/utils/SSLContextUtils.java
@@ -0,0 +1,32 @@
+package com.stmarygate.coral.utils;
+
+import java.io.FileInputStream;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+public class SSLContextUtils {
+ public static SSLContext createAndInitSSLContext(FileInputStream jksFile, String storePass)
+ throws Exception {
+ KeyStore trustStore = KeyStore.getInstance("jks");
+ trustStore.load(jksFile, storePass.toCharArray());
+
+ KeyManagerFactory keyManagerFactory =
+ KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ keyManagerFactory.init(trustStore, storePass.toCharArray());
+
+ TrustManagerFactory trustManagerFactory =
+ TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ trustManagerFactory.init(trustStore);
+
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(
+ keyManagerFactory.getKeyManagers(),
+ trustManagerFactory.getTrustManagers(),
+ new SecureRandom());
+
+ return sslContext;
+ }
+}
diff --git a/src/main/java/com/stmarygate/coral/utils/Utils.java b/src/main/java/com/stmarygate/coral/utils/Utils.java
index c46fc17..d1eb871 100644
--- a/src/main/java/com/stmarygate/coral/utils/Utils.java
+++ b/src/main/java/com/stmarygate/coral/utils/Utils.java
@@ -1,33 +1,32 @@
package com.stmarygate.coral.utils;
import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-
import java.net.SocketAddress;
+import org.slf4j.Logger;
public class Utils {
- /**
- * Wait the specified amount of time.
- *
- * @param ms The amount of time to wait in milliseconds.
- */
- public static void wait(int ms) {
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ /**
+ * Wait the specified amount of time.
+ *
+ * @param ms The amount of time to wait in milliseconds.
+ */
+ public static void wait(int ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
}
+ }
- public static void logChannel(Logger LOGGER, String remoteAddress, String message) {
- LOGGER.info("[{}] - {}", remoteAddress, message);
- }
+ public static void logChannel(Logger LOGGER, String remoteAddress, String message) {
+ LOGGER.info("[{}] - {}", remoteAddress, message);
+ }
- public static String getRemote(SocketAddress address) {
- return address.toString();
- }
+ public static String getRemote(SocketAddress address) {
+ return address.toString();
+ }
- public static String getRemote(ChannelHandlerContext ctx) {
- return ctx.channel().remoteAddress() == null ? "" : ctx.channel().remoteAddress().toString();
- }
+ public static String getRemote(ChannelHandlerContext ctx) {
+ return ctx.channel().remoteAddress() == null ? "" : ctx.channel().remoteAddress().toString();
+ }
}