]> Sergey Matveev's repositories - godlighty.git/commitdiff
Normalise IPv6 hostnames master
authorSergey Matveev <stargrave@stargrave.org>
Tue, 3 Mar 2026 11:30:23 +0000 (14:30 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 3 Mar 2026 11:30:42 +0000 (14:30 +0300)
godlighty.go
handler.go

index 60c1c4b5cd313e4358a856db400b35c6bcbd2fca..8233c4b6e1d7ae326f2deaa22efbac1924bdb373 100644 (file)
@@ -1,6 +1,6 @@
 // Highly-customizable HTTP, HTTP/2, HTTPS server
 package godlighty
 
-const Version = "godlighty/0.11.0"
+const Version = "godlighty/0.12.0"
 
 var BindAddr string
index e31a034bd5ea7cfea62d9822c0427899d5c37d4c..abdd27b06cddbd0f4b0b28fc1a215cd51a5aad0e 100644 (file)
@@ -361,5 +361,10 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
        if err != nil {
                host = r.Host
        }
+       if len(host) > 2 && host[0] == '[' && host[len(host)-1] == ']' {
+               if ip6 := net.ParseIP(host[1 : len(host)-1]); ip6 != nil {
+                       host = "[" + ip6.String() + "]"
+               }
+       }
        h.Handle(w, r, host, Hosts[host])
 }