remove port number from IP logs gemini
alex wennerberg alex@alexwennerberg.com
Sat, 02 Jan 2021 10:58:05 -0800
1 files changed,
6 insertions(+),
1 deletions(-)
jump to
M
log.go
→
log.go
@@ -149,7 +149,12 @@
// Anonymize user and IP? func logGemini(r *gmi.Request) { - line := fmt.Sprintf("gemini %s - [%s] %s %s\n", r.RemoteAddr.String(), + ipAddr := r.RemoteAddr.String() + host, _, err := net.SplitHostPort(ipAddr) + if err != nil { + host = ipAddr + } + line := fmt.Sprintf("gemini %s - [%s] %s %s\n", host, time.Now().Format("02/Jan/2006:15:04:05 -0700"), r.URL.Host, r.URL.Path)