summaryrefslogtreecommitdiff
path: root/internal/server/doh.go
diff options
context:
space:
mode:
authorradhitya <alif@radhitya.org>2026-06-24 06:15:18 +0700
committerradhitya <alif@radhitya.org>2026-06-24 06:15:18 +0700
commita6823756f0024814a74e255f7584193c0cd77b43 (patch)
treeb2eb3c1eb1d9db5e463d8e797cdbb7fff00c89d3 /internal/server/doh.go
parent2c61900dd5efd81a5351513a20fa65580c8a6616 (diff)
fix dohHEADmaster
Diffstat (limited to 'internal/server/doh.go')
-rw-r--r--internal/server/doh.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/server/doh.go b/internal/server/doh.go
index 0feb094..9c04d2c 100644
--- a/internal/server/doh.go
+++ b/internal/server/doh.go
@@ -10,6 +10,13 @@ import (
"linum/internal/cache"
)
+func decodeDNSParam(s string) ([]byte, error) {
+ if b, err := base64.RawURLEncoding.DecodeString(s); err == nil {
+ return b, nil
+ }
+ return base64.URLEncoding.DecodeString(s)
+}
+
func (s *Server) dohHandler(w http.ResponseWriter, r *http.Request) {
clientIP := parseHTTPClientIP(r.RemoteAddr)
if !s.isAllowed(clientIP) {
@@ -44,7 +51,7 @@ func (s *Server) dohHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "missing dns param", http.StatusBadRequest)
return
}
- decoded, err := base64.RawURLEncoding.DecodeString(param)
+ decoded, err := decodeDNSParam(param)
if err != nil {
http.Error(w, "invalid base64url", http.StatusBadRequest)
return