Skip to content

Commit 6370f42

Browse files
authored
Merge pull request #13 from wollomatic/develop
reformat logging of allowlist on program start
2 parents 6b1ebaf + ff2769d commit 6370f42

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

cmd/socket-proxy/main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"github.com/wollomatic/socket-proxy/internal/config"
78
"log/slog"
89
"net"
@@ -21,7 +22,7 @@ const (
2122
)
2223

2324
var (
24-
version = "0.1.0"
25+
version = "dev" // will be overwritten by build system
2526
socketProxy *httputil.ReverseProxy
2627
cfg *config.Config
2728
)
@@ -55,8 +56,19 @@ func main() {
5556
} else {
5657
slog.Info("watchdog disabled")
5758
}
58-
for method, regex := range config.AllowedRequests {
59-
slog.Info("configured allowed request", "method", method, "regex", regex)
59+
60+
// print request allow list
61+
if cfg.LogJSON {
62+
for method, regex := range config.AllowedRequests {
63+
slog.Info("configured allowed request", "method", method, "regex", regex)
64+
}
65+
} else {
66+
// don't use slog here, as we want to print the regexes as they are
67+
// see https://github.com/wollomatic/socket-proxy/issues/11
68+
fmt.Printf("Request allowlist:\n %-8s %s\n", "Method", "Regex")
69+
for method, regex := range config.AllowedRequests {
70+
fmt.Printf(" %-8s %s\n", method, regex)
71+
}
6072
}
6173

6274
// check if the socket is available

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/wollomatic/socket-proxy
22

3-
go 1.22
3+
go 1.22.2

0 commit comments

Comments
 (0)