From de174016b8d0a6dadde991a1f265f75bd86d52fc Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 8 Sep 2021 00:51:02 +0300 Subject: [PATCH] Xombrero does not send User-Agent with HEAD --- doc/index.texi | 3 ++- rounds/05noHead.go | 7 +------ rounds/40transcodeWebP.go | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/index.texi b/doc/index.texi index 0d27a68..7759710 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -61,7 +61,8 @@ creating some kind of complex configuration framework. @item TLS connection between client and @command{tofuproxy} has the proper hostname set in ephemeral on-the-fly generated certificate. -@item @code{HEAD} method for Xombrero is forbidden, as it loves it too much. +@item @code{HEAD} method is forbidden, as Xombrero loves it too much and + it does not send User-Agent to differentiate it from others. @item @code{www.reddit.com} is redirected to @code{old.reddit.com}. diff --git a/rounds/05noHead.go b/rounds/05noHead.go index 2396e02..e382432 100644 --- a/rounds/05noHead.go +++ b/rounds/05noHead.go @@ -19,20 +19,15 @@ package rounds import ( "net/http" - "strings" ) -func isXombrero(req *http.Request) bool { - return strings.Contains(req.Header.Get("User-Agent"), "AppleWebKit/538.15") -} - func RoundNoHead( host string, resp *http.Response, w http.ResponseWriter, req *http.Request, ) (bool, error) { - if req.Method == http.MethodHead && isXombrero(req) { + if req.Method == http.MethodHead { http.Error(w, "deny HEAD", http.StatusMethodNotAllowed) return false, nil } diff --git a/rounds/40transcodeWebP.go b/rounds/40transcodeWebP.go index 43938ec..ff1fd8c 100644 --- a/rounds/40transcodeWebP.go +++ b/rounds/40transcodeWebP.go @@ -25,12 +25,17 @@ import ( "net/http" "os" "os/exec" + "strings" "go.stargrave.org/tofuproxy/fifos" ) const CmdDWebP = "dwebp" +func isXombrero(req *http.Request) bool { + return strings.Contains(req.Header.Get("User-Agent"), "AppleWebKit/538.15") +} + func RoundTranscodeWebP( host string, resp *http.Response, -- 2.44.0