diff --git a/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServer.java b/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServer.java index 3b035af..b6e0f06 100644 --- a/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServer.java +++ b/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServer.java @@ -69,7 +69,7 @@ public class UDPNetSyslogServer extends AbstractSyslogServer { return; } - byte[] receiveData = new byte[SyslogConstants.SYSLOG_BUFFER_SIZE]; + byte[] receiveData = new byte[syslogBufferSize()]; handleInitialize(this); @@ -99,4 +99,11 @@ public class UDPNetSyslogServer extends AbstractSyslogServer { handleDestroy(this); } + + private int syslogBufferSize(){ + if (getConfig() instanceof UDPNetSyslogServerConfig){ + return ((UDPNetSyslogServerConfig) getConfig()).getMaxMessageSize(); + } + return SyslogConstants.SYSLOG_BUFFER_SIZE; + } } diff --git a/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServerConfig.java b/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServerConfig.java index 342df88..90baf79 100644 --- a/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServerConfig.java +++ b/src/main/java/org/graylog2/syslog4j/server/impl/net/udp/UDPNetSyslogServerConfig.java @@ -1,5 +1,6 @@ package org.graylog2.syslog4j.server.impl.net.udp; +import org.graylog2.syslog4j.SyslogConstants; import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig; /** @@ -15,6 +16,8 @@ import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig; public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig { private static final long serialVersionUID = -2005919161187055486L; + private int maxMessageSize = SyslogConstants.SYSLOG_BUFFER_SIZE; + public UDPNetSyslogServerConfig() { // } @@ -32,6 +35,20 @@ public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig { this.port = port; } + public UDPNetSyslogServerConfig(String host, int port, int maxMessageSize) { + this.host = host; + this.port = port; + this.maxMessageSize = maxMessageSize; + } + + public int getMaxMessageSize() { + return maxMessageSize; + } + + public void setMaxMessageSize(int maxMessageSize) { + this.maxMessageSize = maxMessageSize; + } + public Class getSyslogServerClass() { return UDPNetSyslogServer.class; }