]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - rounds/redirectHTML.go
Raise copyright years
[tofuproxy.git] / rounds / redirectHTML.go
index 5e507ca9dd9f8818d836c8158428e8c6e668b3ef..abc657e6546a8926d249f5eb0c418c50d32a7698 100644 (file)
@@ -1,7 +1,7 @@
 /*
 tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
              manager, WARC/geminispace browser
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2021-2023 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -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"), "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 {