Skip to content

Commit

Permalink
Merge pull request #1 from netography/AddDialTimeouts
Browse files Browse the repository at this point in the history
Support Dial timeouts/options
  • Loading branch information
weberr13 authored Sep 28, 2022
2 parents a4725f0 + 4753b18 commit 622be48
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 62 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ script/coverage --html

That will open a new browser tab showing coverage information.

# Contributions

contributions are expected to include tests and tests must pass. If existing tests start to fail due to
expired certs simply run

```
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout test/privkey.pem -days 730 -out test/cert.pem -config test/san.cnf
```

to generate new ones

# License

This project uses the New BSD License, the same as the Go project itself.
Expand All @@ -145,3 +156,5 @@ This project uses the New BSD License, the same as the Go project itself.

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.


22 changes: 17 additions & 5 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func (df dialerFunctionWrapper) Call() (serverConn, string, error) {
// function and adding it to the map.
func (w *Writer) getDialer() dialerFunctionWrapper {
dialers := map[string]dialerFunctionWrapper{
"": dialerFunctionWrapper{"unixDialer", w.unixDialer},
"tcp+tls": dialerFunctionWrapper{"tlsDialer", w.tlsDialer},
"custom": dialerFunctionWrapper{"customDialer", w.customDialer},
"": {"unixDialer", w.unixDialer},
"tcp+tls": {"tlsDialer", w.tlsDialer},
"custom": {"customDialer", w.customDialer},
}
dialer, ok := dialers[w.network]
if !ok {
Expand All @@ -60,7 +60,13 @@ func (w *Writer) unixDialer() (serverConn, string, error) {
// tlsDialer connects to TLS over TCP, and is used for the "tcp+tls" network
// type.
func (w *Writer) tlsDialer() (serverConn, string, error) {
c, err := tls.Dial("tcp", w.raddr, w.tlsConfig)
var c net.Conn
var err error
if w.dial != nil {
c, err = tls.DialWithDialer(w.dial, "tcp", w.raddr, w.tlsConfig)
} else {
c, err = tls.Dial("tcp", w.raddr, w.tlsConfig)
}
var sc serverConn
hostname := w.hostname
if err == nil {
Expand All @@ -75,7 +81,13 @@ func (w *Writer) tlsDialer() (serverConn, string, error) {
// basicDialer is the most common dialer for syslog, and supports both TCP and
// UDP connections.
func (w *Writer) basicDialer() (serverConn, string, error) {
c, err := net.Dial(w.network, w.raddr)
var c net.Conn
var err error
if w.dial != nil && w.dial.Timeout != 0 {
c, err = net.DialTimeout(w.network, w.raddr, w.dial.Timeout)
} else {
c, err = net.Dial(w.network, w.raddr)
}
var sc serverConn
hostname := w.hostname
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func RFC3164Formatter(p Priority, hostname, tag, content string) string {

// if string's length is greater than max, then use the last part
func truncateStartStr(s string, max int) string {
if (len(s) > max) {
return s[len(s) - max:]
if len(s) > max {
return s[len(s)-max:]
}
return s
}
Expand Down
10 changes: 5 additions & 5 deletions formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package srslog
import (
"fmt"
"os"
"strings"
"testing"
"time"
"strings"
)

func TestDefaultFormatter(t *testing.T) {
Expand Down Expand Up @@ -39,19 +39,19 @@ func TestRFC5424Formatter(t *testing.T) {
out := RFC5424Formatter(LOG_ERR, "hostname", "tag", "content")
expected := fmt.Sprintf("<%d>%d %s %s %s %d %s - %s",
LOG_ERR, 1, time.Now().Format(time.RFC3339), "hostname", truncateStartStr(os.Args[0], appNameMaxLength),
os.Getpid(), "tag", "content")
os.Getpid(), "tag", "content")
if out != expected {
t.Errorf("expected %v got %v", expected, out)
}
}

func TestTruncateStartStr(t *testing.T) {
out := truncateStartStr("abcde", 3)
if strings.Compare(out, "cde" ) != 0 {
if strings.Compare(out, "cde") != 0 {
t.Errorf("expected \"cde\" got %v", out)
}
out = truncateStartStr("abcde", 5)
if strings.Compare(out, "abcde" ) != 0 {
if strings.Compare(out, "abcde") != 0 {
t.Errorf("expected \"abcde\" got %v", out)
}
}
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/netography/srslog

go 1.19
28 changes: 22 additions & 6 deletions srslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net"
"os"
"time"
)

// This interface allows us to work with both local and network connections,
Expand Down Expand Up @@ -50,7 +51,7 @@ func DialWithCustomDialer(network, raddr string, priority Priority, tag string,
if customDial == nil {
return nil, ErrNilDialFunc
}
return dialAllParameters(network, raddr, priority, tag, nil, customDial)
return dialAllParameters(network, raddr, priority, tag, nil, customDial, &net.Dialer{})
}

// DialWithTLSCertPath establishes a secure connection to a log daemon by connecting to
Expand All @@ -68,24 +69,38 @@ func DialWithTLSCertPath(network, raddr string, priority Priority, tag, certPath
// DialWIthTLSCert establishes a secure connection to a log daemon by connecting to
// address raddr on the specified network. It uses serverCert to load a TLS certificate
// and configure the secure connection.
func DialWithTLSCert(network, raddr string, priority Priority, tag string, serverCert []byte) (*Writer, error) {
func DialWithTLSCert(network, raddr string, priority Priority, tag string, serverCert []byte, opts ...DialOption) (*Writer, error) {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(serverCert)
config := tls.Config{
RootCAs: pool,
}

return DialWithTLSConfig(network, raddr, priority, tag, &config)
return DialWithTLSConfig(network, raddr, priority, tag, &config, opts...)
}

type DialOption func(dial *net.Dialer)

func WithTimeout(d time.Duration) DialOption {
return func(dial *net.Dialer) {
if dial != nil {
dial.Timeout = d
}
}
}

// DialWithTLSConfig establishes a secure connection to a log daemon by connecting to
// address raddr on the specified network. It uses tlsConfig to configure the secure connection.
func DialWithTLSConfig(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config) (*Writer, error) {
return dialAllParameters(network, raddr, priority, tag, tlsConfig, nil)
func DialWithTLSConfig(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config, opts ...DialOption) (*Writer, error) {
dial := &net.Dialer{}
for _, o := range opts {
o(dial)
}
return dialAllParameters(network, raddr, priority, tag, tlsConfig, nil, dial)
}

// implementation of the various functions above
func dialAllParameters(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config, customDial DialFunc) (*Writer, error) {
func dialAllParameters(network, raddr string, priority Priority, tag string, tlsConfig *tls.Config, customDial DialFunc, dial *net.Dialer) (*Writer, error) {
if err := validatePriority(priority); err != nil {
return nil, err
}
Expand All @@ -103,6 +118,7 @@ func dialAllParameters(network, raddr string, priority Priority, tag string, tls
raddr: raddr,
tlsConfig: tlsConfig,
customDial: customDial,
dial: dial,
}

_, err := w.connect()
Expand Down
13 changes: 11 additions & 2 deletions srslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,16 @@ func TestDial(t *testing.T) {
t.Skip("skipping syslog test during -short")
}
f, err := Dial("", "", (LOG_LOCAL7|LOG_DEBUG)+1, "syslog_test")
if err == nil {
t.Fatalf("Should have trapped bad priority")
}
if f != nil {
t.Fatalf("Should have trapped bad priority")
}
f, err = Dial("", "", -1, "syslog_test")
if err == nil {
t.Fatalf("Should have trapped bad priority")
}
if f != nil {
t.Fatalf("Should have trapped bad priority")
}
Expand Down Expand Up @@ -426,7 +432,7 @@ func TestTLSCertWrite(t *testing.T) {
t.Fatalf("cold not read cert: %v", err)
}

l, err := DialWithTLSCert("tcp+tls", addr, test.pri, test.pre, cert)
l, err := DialWithTLSCert("tcp+tls", addr, test.pri, test.pre, cert, WithTimeout(10*time.Second))
if err != nil {
t.Fatalf("syslog.Dial() failed: %v", err)
}
Expand Down Expand Up @@ -541,7 +547,10 @@ func TestLocalConn(t *testing.T) {

lc := localConn{conn: conn}

lc.writeString(nil, nil, LOG_ERR, "hostname", "tag", "content")
err := lc.writeString(nil, nil, LOG_ERR, "hostname", "tag", "content")
if err != nil {
t.Fatalf("%v", err)
}

if len(messages) != 1 {
t.Errorf("should write one message")
Expand Down
46 changes: 30 additions & 16 deletions test/cert.pem
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
-----BEGIN CERT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zEwHFVB/cbCkBe1tUcCAwEA
AaMTMBEwDwYDVR0RBAgwBocEfwAAATANBgkqhkiG9w0BAQsFAAOCAgEAJc/RFlMt
2Of49JFwUo/hSLOiv5cw/vffcoSLj2+Ttn7iSZnWg80kLcbhwenAYw5AIA8HE5ql
04gZx4rAuEkDQqibI1V9NAeIMqQC521iRmaOOVQpyPQHQoyXoqHvcI6h2dzVclTw
mQZ38YbLkRo1RhoBSguzZJqPLp25lbj9Q69kXg+/t8sCZ0JQJ729YVrgta4q/6Au
73Rbg8QvrAPrrJYlMjDl98JlasHC0UnggxBAbXseLmADM/eJCq2YeyQwd+wh103c
dVpV3ajAAFxSvPlH1GDwZX7L0QXkyHsTLiFNZ8zjYc3SFJOJfVGTJBb3foHqsJim
F28ptNqnuKCosEvrpN8mjtuM3/NLXMG5rf1BJ1ewcvy1hoxJJX/FpGZVr2AMivZ2
JF1bJgJ3WQdd/e8f285snDrp5ruHrBL+MYoeKmb1gCXxJIWA426OxrCcDKxgSRPU
21WmenchHg2RvYXmxx/c0rMt/tuB90Fmb00A9xKNE49X2f8wRZ+cD5+EcghfleJ8
ifTEo/kj9BqBbjsRPYnHenNhr1J2byNeEwcVrp1nUaLaduiR/JHCc7ievBw3LY2K
oSpzMjcTv4L+/y9v8A02/+8Y1pCmjuKRjNb1CUvi8A2O5rhyJoKyUl0IjoQ9zrF5
TMTpNa2c4bRZLT0b4mo/WbHRBQ+Jtl5V6A4=
-----END CERTIFICATE-----
76 changes: 50 additions & 26 deletions test/privkey.pem
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDr9UU6xYOCGQgm
XOA3HH6ZW/xKATDzxn58nQWXy/1kqI84NFPb9elpWUxU0D86xcU7YZDV1I79N00S
aDTYyHAMLHi6WUt55nokLTRA15mxskRbYE8H5ANKB1+fBDP1LLtGgIhfU2mkfxJp
xtSkcSgmX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fGWmGbvPkxTA0kFazAEbAbtQkQix8V31endilgFuSP/
+8gEbEa4Aqk9Hn6m/HGe6M7syIAbbZwJej7g9ho4j+17+SbjSwx0XJIqfubJr7ni
4q6oCMkgs/JmK6/9TA3F2TAMJzAO2tT3RH0LC3ZI4xruo3XALuFfFuNDPqODk2EC
4lGHXT2J6tPWlbduLtv+gyW1vxYJnRxUWpKU/k1YlUJfWrHNUNEWxFDB0sMFAh2w
Fm5ceVYOvBDHaKq0w5wFZElTrSRhXcmfUTFGhVZiSBy67mFlV68cD1aWbHa05ofV
3WUfpJ+OdBn+3VO04PotF1cVOwBjxO/m
-----END PRIVATE KEY-----
18 changes: 18 additions & 0 deletions test/san.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[req]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
countryName = US
stateOrProvinceName = N/A
localityName = N/A
organizationName = Self-signed certificate
commonName = 120.0.0.1: Self-signed certificate
[req_ext]
subjectAltName = @alt_names
[v3_req]
subjectAltName = @alt_names
[alt_names]
IP.1 = 127.0.0.1
2 changes: 2 additions & 0 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package srslog

import (
"crypto/tls"
"net"
"strings"
"sync"
)
Expand All @@ -19,6 +20,7 @@ type Writer struct {

//non-nil if custom dialer set, used in getDialer
customDial DialFunc
dial *net.Dialer

mu sync.RWMutex // guards conn
conn serverConn
Expand Down

0 comments on commit 622be48

Please sign in to comment.