Skip to content

Commit b174c05

Browse files
authored
Go 1.23.4 & minor linter issues fixed (#42)
* Update to Go 1.23.4 * fix minor linter issues --------- Signed-off-by: Wolfgang Ellsässer <67168186+wollomatic@users.noreply.github.com>
1 parent f223d39 commit b174c05

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM --platform=$BUILDPLATFORM golang:1.23.5-alpine3.21 AS build
2+
FROM --platform=$BUILDPLATFORM golang:1.23.6-alpine3.21 AS build
33
WORKDIR /application
44
COPY . ./
55
ARG TARGETOS

cmd/socket-proxy/handlehttprequest.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,24 @@ func isAllowedClient(remoteAddr string) (bool, error) {
5757
if err == nil {
5858
// AllowFrom is a valid CIDR, so check if IP address is in allowed network
5959
return allowedIPNet.Contains(clientIP), nil
60-
} else {
61-
// AllowFrom is not a valid CIDR, so try to resolve it via DNS
62-
// split over comma to support multiple hostnames
63-
allowFroms := strings.Split(cfg.AllowFrom, ",")
64-
for _, allowFrom := range allowFroms {
65-
ips, err := net.LookupIP(allowFrom)
66-
if err != nil {
67-
slog.Warn("error looking up allowed client hostname", "hostname", allowFrom, "error", err.Error())
68-
}
69-
for _, ip := range ips {
70-
// Check if IP address is one of the resolved IPs
71-
if ip.Equal(clientIP) {
72-
return true, nil
73-
}
60+
}
61+
62+
// AllowFrom is not a valid CIDR, so try to resolve it via DNS
63+
// split over comma to support multiple hostnames
64+
allowFromList := strings.Split(cfg.AllowFrom, ",")
65+
for _, allowFrom := range allowFromList {
66+
ips, err := net.LookupIP(allowFrom)
67+
if err != nil {
68+
slog.Warn("error looking up allowed client hostname", "hostname", allowFrom, "error", err.Error())
69+
}
70+
for _, ip := range ips {
71+
// Check if IP address is one of the resolved IPs
72+
if ip.Equal(clientIP) {
73+
return true, nil
7474
}
7575
}
76-
return false, nil
7776
}
77+
return false, nil
7878
}
7979

8080
// sendHTTPError sends a HTTP error with the given status code.

cmd/socket-proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func main() {
101101

102102
var l net.Listener
103103
if cfg.ProxySocketEndpoint != "" {
104-
if _, err := os.Stat(cfg.ProxySocketEndpoint); err == nil {
104+
if _, err = os.Stat(cfg.ProxySocketEndpoint); err == nil {
105105
slog.Warn(fmt.Sprintf("%s already exists, removing existing file", cfg.ProxySocketEndpoint))
106106
if err = os.Remove(cfg.ProxySocketEndpoint); err != nil {
107107
slog.Error("error removing existing socket file", "error", err)

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func InitConfig() (*Config, error) {
126126
}
127127
}
128128

129-
for i := 0; i < len(mr); i++ {
129+
for i := range mr {
130130
if val, ok := os.LookupEnv("SP_ALLOW_" + mr[i].method); ok && val != "" {
131131
mr[i].regexStringFromEnv = val
132132
}
@@ -144,7 +144,7 @@ func InitConfig() (*Config, error) {
144144
flag.UintVar(&cfg.WatchdogInterval, "watchdoginterval", defaultWatchdogInterval, "watchdog interval in seconds (0 to disable)")
145145
flag.StringVar(&cfg.ProxySocketEndpoint, "proxysocketendpoint", defaultProxySocketEndpoint, "unix socket endpoint (if set, used instead of the TCP listener)")
146146
flag.UintVar(&endpointFileMode, "proxysocketendpointfilemode", defaultProxySocketEndpointFileMode, "set the file mode of the unix socket endpoint")
147-
for i := 0; i < len(mr); i++ {
147+
for i := range mr {
148148
flag.StringVar(&mr[i].regexStringFromParam, "allow"+mr[i].method, "", "regex for "+mr[i].method+" requests (not set means method is not allowed)")
149149
}
150150
flag.Parse()

0 commit comments

Comments
 (0)