Skip to content

Commit

Permalink
Task #78 - README.md file updates and new env variables added, ShowVe…
Browse files Browse the repository at this point in the history
…rsionServlet fix
  • Loading branch information
ak committed Feb 14, 2024
1 parent cc4c471 commit 94ac689
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export WEB_DESCRIPTOR_PATH=/path/to/web.xml # web application config xml
export WEB_SOCKET_ENDPOINT_PATH=/ws-log # web socket endpoint context path
export WEB_SOCKET_MAX_MESSAGE_SIZE=65535 # web socket max message size in bytes
export WEB_SOCKET_IDLE_TIMEOUT_SECONDS=300 # web socket idle timeout in seconds
export SYSLOG_PROTOCOL=tcp # syslog protocol
export SYSLOG_HOST=localhost # syslog host
export SYSLOG_PORT=2514 # syslog port
export JSON_ADAPTER_BIND_ADDRESS=127.0.0.1 # json adapter bind address
export JSON_ADAPTER_PORT=28080 # json adapter port
export JSON_ADAPTER_PATH=/save-logs # json adapter path
export JSON_ADAPTER_TOKEN=token # json adapter token
```
Start server uber-jar:
```shell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.payneteasy.srvlog.syslog;

import com.nesscomputing.syslog4j.Syslog;
import com.nesscomputing.syslog4j.SyslogConstants;
import com.nesscomputing.syslog4j.SyslogFacility;
import com.nesscomputing.syslog4j.SyslogIF;
import com.payneteasy.srvlog.CommonIntegrationTest;
Expand Down Expand Up @@ -89,6 +90,11 @@ public String getSyslogProtocol() {
return "tcp";
}

@Override
public String getSyslogHost() {
return SyslogConstants.SYSLOG_HOST_DEFAULT;
}

@Override
public int getSyslogPort() {
return 1514;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.payneteasy.srvlog.adapter.syslog;

import com.payneteasy.startup.parameters.AStartupParameter;

/**
* Date: 04.01.13
*/
public interface ISyslogAdapterConfig {

@AStartupParameter(name = "SYSLOG_PROTOCOL", value = "tcp")
String getSyslogProtocol();

@AStartupParameter(name = "SYSLOG_HOST", value = "localhost")
String getSyslogHost();

@AStartupParameter(name = "SYSLOG_PORT", value = "2514")
int getSyslogPort();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.payneteasy.srvlog.data.LogFacility;
import com.payneteasy.srvlog.data.LogLevel;
import com.payneteasy.srvlog.service.ILogCollector;
import com.payneteasy.startup.parameters.StartupParametersFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -33,8 +34,8 @@ public class SyslogAdapter implements SyslogServerSessionlessEventHandlerIF {
@Autowired
private ILogCollector logCollector;

@Autowired
private ISyslogAdapterConfig logAdapterConfig;
private ISyslogAdapterConfig logAdapterConfig = StartupParametersFactory
.getStartupParameters(ISyslogAdapterConfig.class);

private SnortMessageManager snortMessageManager;

Expand All @@ -46,6 +47,7 @@ public class SyslogAdapter implements SyslogServerSessionlessEventHandlerIF {
public void init() {
suricataMessageManager = new SuricataMessageManager(checkNotNull(logCollector, "No logCollector"));

String host = logAdapterConfig.getSyslogHost();
int port = logAdapterConfig.getSyslogPort();
String protocol = logAdapterConfig.getSyslogProtocol();
LOG.info(" Starting syslog4j server on port = {} and on protocol = {} ...", port, protocol );
Expand All @@ -56,6 +58,7 @@ public void init() {
SyslogServer.initialize();
// Now create a new instance of Syslog.
syslog4jInstance = SyslogServer.getInstance(protocol);
syslog4jInstance.getConfig().setHost(host);
syslog4jInstance.getConfig().setPort(port);
syslog4jInstance.getConfig().addEventHandler(this);
syslog4jInstance.getConfig().setUseStructuredData(true);
Expand Down
2 changes: 0 additions & 2 deletions srvlog-service/src/main/resources/syslog4j.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ public String getSyslogProtocol() {
return SyslogConstants.UDP;
}

@Override
public String getSyslogHost() {
return SyslogConstants.SYSLOG_HOST_DEFAULT;
}

@Override
public int getSyslogPort() {
return 1514;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class ShowVersionServlet extends HttpServlet {

private static final Logger LOG = LoggerFactory.getLogger(ShowVersionServlet.class);

private static final String POM_PROPS_PATH = "/META-INF/maven/com.payneteasy.srvlog/srvlog-web/pom.properties";

private volatile String version = "no init";

@Override
Expand All @@ -30,8 +32,8 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
@Override
public void init(ServletConfig config) throws ServletException {
Properties properties = new Properties();
InputStream in = config.getServletContext().getResourceAsStream("/META-INF/maven/com.payneteasy.srvlog/srvlog-web/pom.properties");
if(in == null) {
InputStream in = getClass().getResourceAsStream(POM_PROPS_PATH);
if (in == null) {
version = "no input stream";
return;
}
Expand Down
2 changes: 0 additions & 2 deletions srvlog-web/src/test/resources/syslog4j.properties

This file was deleted.

0 comments on commit 94ac689

Please sign in to comment.