From: Sergey Matveev Date: Fri, 18 Feb 2022 07:23:31 +0000 (+0300) Subject: go.stargrave.org/feeder is another feeder X-Git-Tag: v0.1.0~31 X-Git-Url: http://www.git.stargrave.org/?p=tofuproxy.git;a=commitdiff_plain;h=6e77d8ac6328b4d26c7db73b26c7e269389fae70 go.stargrave.org/feeder is another feeder --- diff --git a/doc/index.texi b/doc/index.texi index 63c0254..ae61d9f 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -56,6 +56,7 @@ input dialogue is shown. It automatically loads initial form values from Permanent HTTP redirects are replaces with non-refreshing HTML page with the link, to make you explicitly allow that step. Temporary redirects are followed if it is neither @url{https://newsboat.org/, Newsboat} +nor @url{https://www.feeder.stargrave.org/, go.stargrave.org/feeder} user-agent, not image paths. @item diff --git a/rounds/redirectHTML.go b/rounds/redirectHTML.go index a5d4bd7..2e286d3 100644 --- a/rounds/redirectHTML.go +++ b/rounds/redirectHTML.go @@ -44,8 +44,14 @@ var imageExts = map[string]struct{}{ ".webp": {}, } -func isNewsboat(req *http.Request) bool { - return strings.Contains(req.Header.Get("User-Agent"), "newsboat/") +func isFeeder(req *http.Request) bool { + if strings.Contains(req.Header.Get("User-Agent"), "newsboat/") { + return true + } + if strings.Contains(req.Header.Get("User-Agent"), "go.stargrave.org-feeder/") { + return true + } + return false } func RoundRedirectHTML( @@ -62,7 +68,7 @@ func RoundRedirectHTML( case http.StatusMovedPermanently, http.StatusPermanentRedirect: redirType = "permanent" case http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect: - if isNewsboat(req) { + if isFeeder(req) { return true, nil } if _, ok := imageExts[filepath.Ext(req.URL.Path)]; ok {