detached 9e9308c

refactor: reuse IsTrustedProxy for loopback check; promote go-systemd to direct dep

commit
9e9308cf2a924de4e519b67b5572f58655b0fe78
author
brice · · 2026-04-03 15:26 UTC
parent
c9b8983
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +4 -13
M go.mod +2 -2
@@ -7,6 +7,7 @@ require (
77 github.com/charmbracelet/bubbles v1.0.0
88 github.com/charmbracelet/bubbletea v1.3.10
99 github.com/charmbracelet/lipgloss v1.1.0
10+ github.com/coreos/go-systemd/v22 v22.7.0
1011 github.com/docker/docker v28.5.2+incompatible
1112 github.com/docker/go-connections v0.6.0
1213 github.com/golang-jwt/jwt/v5 v5.3.1
@@ -25,6 +26,7 @@ require (
2526 go.opentelemetry.io/otel/sdk/log v0.18.0
2627 go.opentelemetry.io/otel/sdk/metric v1.42.0
2728 golang.org/x/mod v0.34.0
29+ golang.org/x/sync v0.20.0
2830 gopkg.in/natefinch/lumberjack.v2 v2.2.1
2931 )
3032
@@ -42,7 +44,6 @@ require (
4244 github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
4345 github.com/containerd/log v0.1.0 // indirect
4446 github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
45- github.com/coreos/go-systemd/v22 v22.7.0 // indirect
4647 github.com/docker/cli v29.3.0+incompatible // indirect
4748 github.com/docker/docker-credential-helpers v0.9.3 // indirect
4849 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
@@ -64,7 +65,6 @@ require (
6465 go.opentelemetry.io/proto/otlp v1.9.0 // indirect
6566 go.yaml.in/yaml/v3 v3.0.4 // indirect
6667 golang.org/x/net v0.52.0 // indirect
67- golang.org/x/sync v0.20.0 // indirect
6868 google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
6969 google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
7070 google.golang.org/grpc v1.79.3 // indirect
@@ -7,6 +7,7 @@ require (
7 github.com/charmbracelet/bubbles v1.0.07 github.com/charmbracelet/bubbles v1.0.0
8 github.com/charmbracelet/bubbletea v1.3.108 github.com/charmbracelet/bubbletea v1.3.10
9 github.com/charmbracelet/lipgloss v1.1.09 github.com/charmbracelet/lipgloss v1.1.0
10+ github.com/coreos/go-systemd/v22 v22.7.0
10 github.com/docker/docker v28.5.2+incompatible11 github.com/docker/docker v28.5.2+incompatible
11 github.com/docker/go-connections v0.6.012 github.com/docker/go-connections v0.6.0
12 github.com/golang-jwt/jwt/v5 v5.3.113 github.com/golang-jwt/jwt/v5 v5.3.1
@@ -25,6 +26,7 @@ require (
25 go.opentelemetry.io/otel/sdk/log v0.18.026 go.opentelemetry.io/otel/sdk/log v0.18.0
26 go.opentelemetry.io/otel/sdk/metric v1.42.027 go.opentelemetry.io/otel/sdk/metric v1.42.0
27 golang.org/x/mod v0.34.028 golang.org/x/mod v0.34.0
29+ golang.org/x/sync v0.20.0
28 gopkg.in/natefinch/lumberjack.v2 v2.2.130 gopkg.in/natefinch/lumberjack.v2 v2.2.1
29 )31 )
30 32
@@ -42,7 +44,6 @@ require (
42 github.com/clipperhouse/uax29/v2 v2.5.0 // indirect44 github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
43 github.com/containerd/log v0.1.0 // indirect45 github.com/containerd/log v0.1.0 // indirect
44 github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect46 github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
45- github.com/coreos/go-systemd/v22 v22.7.0 // indirect
46 github.com/docker/cli v29.3.0+incompatible // indirect47 github.com/docker/cli v29.3.0+incompatible // indirect
47 github.com/docker/docker-credential-helpers v0.9.3 // indirect48 github.com/docker/docker-credential-helpers v0.9.3 // indirect
48 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect49 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
@@ -64,7 +65,6 @@ require (
64 go.opentelemetry.io/proto/otlp v1.9.0 // indirect65 go.opentelemetry.io/proto/otlp v1.9.0 // indirect
65 go.yaml.in/yaml/v3 v3.0.4 // indirect66 go.yaml.in/yaml/v3 v3.0.4 // indirect
66 golang.org/x/net v0.52.0 // indirect67 golang.org/x/net v0.52.0 // indirect
67- golang.org/x/sync v0.20.0 // indirect
68 google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect68 google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
69 google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect69 google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
70 google.golang.org/grpc v1.79.3 // indirect70 google.golang.org/grpc v1.79.3 // indirect
M internal/adapters/in/http/middleware/accesslog.go +2 -11
@@ -18,18 +18,9 @@ var loopbackNets = func() []*net.IPNet {
1818 return []*net.IPNet{ipv4Loopback, ipv6Loopback}
1919 }()
2020
21-// isLoopback reports whether the given IP string is a loopback address.
21+// isLoopback reports whether ip is a loopback address.
2222 func isLoopback(ip string) bool {
23- parsed := net.ParseIP(ip)
24- if parsed == nil {
25- return false
26- }
27- for _, n := range loopbackNets {
28- if n.Contains(parsed) {
29- return true
30- }
31- }
32- return false
23+ return IsTrustedProxy(ip, loopbackNets)
3324 }
3425
3526 // AccessLogWriter is the interface the middleware needs from the output adapter.
@@ -18,18 +18,9 @@ var loopbackNets = func() []*net.IPNet {
18 return []*net.IPNet{ipv4Loopback, ipv6Loopback}18 return []*net.IPNet{ipv4Loopback, ipv6Loopback}
19 }()19 }()
20 20
21-// isLoopback reports whether the given IP string is a loopback address.21+// isLoopback reports whether ip is a loopback address.
22 func isLoopback(ip string) bool {22 func isLoopback(ip string) bool {
23- parsed := net.ParseIP(ip)23+ return IsTrustedProxy(ip, loopbackNets)
24- if parsed == nil {
25- return false
26- }
27- for _, n := range loopbackNets {
28- if n.Contains(parsed) {
29- return true
30- }
31- }
32- return false
33 }24 }
34 25
35 // AccessLogWriter is the interface the middleware needs from the output adapter.26 // AccessLogWriter is the interface the middleware needs from the output adapter.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close