opensnitch/daemon/log/loggers/remote_syslog.go
Gustavo Iñiguez Goia a3826c50c9
improved remote logger
- Added MaxConnectAttempts configuration option:
   If not specified, it defaults to 0, which means that we'll try to connect
   indefinitely to the remote server.

 - Improved connection retry behaviour:
   We were not reconnecting to the server if we failed to connect on the
   first attempt. Now we'll try to connect until MaxConnectAttempts, or
   indefinitely if not specified (default value 0).

 - If the logger is not connected to the remote server, don't send
   messages to the queue.

Closes #1350.
2025-06-02 23:25:43 +02:00

32 lines
772 B
Go

package loggers
import (
"github.com/evilsocket/opensnitch/daemon/log"
)
const (
LOGGER_REMOTE_SYSLOG = "remote_syslog"
)
type RemoteSyslog struct {
*Remote
}
// NewRemoteSyslog returns a new object that manipulates and prints outbound connections
// to a remote syslog server, with the given format (RFC5424 by default)
func NewRemoteSyslog(cfg LoggerConfig) (*RemoteSyslog, error) {
log.Info("NewRemoteSyslog logger: %v", cfg)
r, err := NewRemote(cfg)
r.mu.Lock()
r.Name = LOGGER_REMOTE_SYSLOG
r.mu.Unlock()
rs := &RemoteSyslog{r}
return rs, err
}
// https://cs.opensource.google/go/go/+/refs/tags/go1.18.2:src/log/syslog/syslog.go;l=286;drc=0a1a092c4b56a1d4033372fbd07924dad8cbb50b
func (rs *RemoteSyslog) formatLine(msg string) string {
return msg
}