Skip to content

Commit

Permalink
Merge pull request #13 from wollomatic/develop
Browse files Browse the repository at this point in the history
reformat logging of allowlist on program start
  • Loading branch information
wollomatic authored Apr 23, 2024
2 parents 6b1ebaf + ff2769d commit 6370f42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions cmd/socket-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"errors"
"fmt"
"github.com/wollomatic/socket-proxy/internal/config"
"log/slog"
"net"
Expand All @@ -21,7 +22,7 @@ const (
)

var (
version = "0.1.0"
version = "dev" // will be overwritten by build system
socketProxy *httputil.ReverseProxy
cfg *config.Config
)
Expand Down Expand Up @@ -55,8 +56,19 @@ func main() {
} else {
slog.Info("watchdog disabled")
}
for method, regex := range config.AllowedRequests {
slog.Info("configured allowed request", "method", method, "regex", regex)

// print request allow list
if cfg.LogJSON {
for method, regex := range config.AllowedRequests {
slog.Info("configured allowed request", "method", method, "regex", regex)
}
} else {
// don't use slog here, as we want to print the regexes as they are
// see https://github.com/wollomatic/socket-proxy/issues/11
fmt.Printf("Request allowlist:\n %-8s %s\n", "Method", "Regex")
for method, regex := range config.AllowedRequests {
fmt.Printf(" %-8s %s\n", method, regex)
}
}

// check if the socket is available
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/wollomatic/socket-proxy

go 1.22
go 1.22.2

0 comments on commit 6370f42

Please sign in to comment.