/*
-tofuproxy -- HTTP proxy with TLS certificates management
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
+tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+ manager, WARC/geminispace browser
+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
".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(
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 {
location := resp.Header.Get("Location")
w.Write([]byte(
fmt.Sprintf(
- `<html><head><title>%d %s: %s redirection</title></head>
-<body>Redirection to <a href="%s">%s</a></body></html>`,
+ `<!DOCTYPE html>
+<html><head><title>%d %s: %s redirection</title></head>
+<body><a href="%s">%s</a></body></html>`,
resp.StatusCode, http.StatusText(resp.StatusCode),
redirType, location, location,
)))