From f078ce60cf21c1a54cc0ac823d80e8de7bf1386a Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 21 Apr 2024 16:09:28 +0300 Subject: [PATCH 1/8] Download link for 0.6.0 release --- doc/download.texi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/download.texi b/doc/download.texi index dd5bb5d..6484513 100644 --- a/doc/download.texi +++ b/doc/download.texi @@ -1,6 +1,12 @@ @multitable {XXXXX} {XXXX-XX-XX} {XXXX KiB} {meta4 tar pgp ssh} @headitem Version @tab Date @tab Size @tab Tarball +@item 0.6.0 @tab 2024-04-21 @tab 651 KiB @tab + @url{download/tofuproxy-0.6.0.tar.zst.meta4, meta4} + @url{download/tofuproxy-0.6.0.tar.zst, tar} + @url{download/tofuproxy-0.6.0.tar.zst.asc, pgp} + @url{download/tofuproxy-0.6.0.tar.zst.sig, ssh} + @item 0.5.0 @tab 2024-04-18 @tab 651 KiB @tab @url{download/tofuproxy-0.5.0.tar.zst.meta4, meta4} @url{download/tofuproxy-0.5.0.tar.zst, tar} -- 2.44.0 From 7992384bb7a5309e82d06cf12e6d040ecb953f71 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 23 Jul 2024 15:30:41 +0300 Subject: [PATCH 2/8] No explicit grey pallete --- httpauth.go | 1 - tls/tlsauth.go | 1 - tls/verify.go | 1 - 3 files changed, 3 deletions(-) diff --git a/httpauth.go b/httpauth.go index 8e32452..e14ed3f 100644 --- a/httpauth.go +++ b/httpauth.go @@ -31,7 +31,6 @@ func authDialog(host, realm string) (string, string, error) { var b bytes.Buffer userInit, passInit := netrc.Find(host) fmt.Fprintf(&b, ` -tk_setPalette grey wm title . "Unauthorized: %s" label .luser -text "User" diff --git a/tls/tlsauth.go b/tls/tlsauth.go index 1a9d957..0fc4375 100644 --- a/tls/tlsauth.go +++ b/tls/tlsauth.go @@ -56,7 +56,6 @@ func (g *ClientCertificateGetter) get( } var b bytes.Buffer fmt.Fprintf(&b, ` -tk_setPalette grey wm title . "TLS client authentication: %s" set lb [listbox .lb] diff --git a/tls/verify.go b/tls/verify.go index 6e45c3e..03f78f1 100644 --- a/tls/verify.go +++ b/tls/verify.go @@ -65,7 +65,6 @@ proc certsDecode {raws} { set certsTheir [certsDecode $certsTheir] set certsOur [certsDecode $certsOur] -tk_setPalette grey wm title . $host proc paginator {i delta t l certs} { -- 2.44.0 From 5e2488073c2e8f1e13f73dc0e62d1f5375692a85 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 23 Jul 2024 15:33:22 +0300 Subject: [PATCH 3/8] Change namespace because of domain expiration --- cmd/danechk/main.go | 2 +- cmd/tofuproxy/main.go | 2 +- fifos/log.go | 2 +- fifos/tls.go | 2 +- go.mod | 6 +++--- go.sum | 14 ++++++++------ httpauth.go | 2 +- tls/dial.go | 2 +- tls/tlsauth.go | 2 +- tls/verify.go | 2 +- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/danechk/main.go b/cmd/danechk/main.go index b4dda42..cdf6419 100644 --- a/cmd/danechk/main.go +++ b/cmd/danechk/main.go @@ -21,7 +21,7 @@ import ( "fmt" "log" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" ttls "go.stargrave.org/tofuproxy/tls" ) diff --git a/cmd/tofuproxy/main.go b/cmd/tofuproxy/main.go index 625535d..8bf62ff 100644 --- a/cmd/tofuproxy/main.go +++ b/cmd/tofuproxy/main.go @@ -22,7 +22,7 @@ import ( "net" "net/http" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" "go.stargrave.org/tofuproxy" "go.stargrave.org/tofuproxy/fifos" "go.stargrave.org/tofuproxy/rounds" diff --git a/fifos/log.go b/fifos/log.go index 6cdb87d..b0f7508 100644 --- a/fifos/log.go +++ b/fifos/log.go @@ -21,7 +21,7 @@ import ( "os" "time" - "go.cypherpunks.ru/tai64n/v2" + "go.cypherpunks.su/tai64n/v3" ) var ( diff --git a/fifos/tls.go b/fifos/tls.go index 01a7060..056f28c 100644 --- a/fifos/tls.go +++ b/fifos/tls.go @@ -21,7 +21,7 @@ import ( "log" "strings" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" "go.stargrave.org/tofuproxy/caches" ) diff --git a/go.mod b/go.mod index e1299a0..e53812b 100644 --- a/go.mod +++ b/go.mod @@ -5,9 +5,9 @@ go 1.21 require ( github.com/dustin/go-humanize v1.0.1 github.com/miekg/dns v1.1.57 - go.cypherpunks.ru/netrc v0.1.0 - go.cypherpunks.ru/tai64n/v2 v2.0.1 - go.cypherpunks.ru/ucspi v0.1.0 + go.cypherpunks.su/netrc/v2 v2.0.0 + go.cypherpunks.su/tai64n/v3 v3.0.0 + go.cypherpunks.su/ucspi/v2 v2.0.0 ) require ( diff --git a/go.sum b/go.sum index d0930ba..05f2eff 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM= github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk= -go.cypherpunks.ru/netrc v0.1.0 h1:dzaSh4lgpPXvLzUME/hTSegg+Uw1aPEmC79fxbPLFGk= -go.cypherpunks.ru/netrc v0.1.0/go.mod h1:ZmQaL9ENEII++WQooelccr33XZcBhKd8VgtcICf4SIE= -go.cypherpunks.ru/tai64n/v2 v2.0.1 h1:AnwUUgi0EixZcr6nzjUaOy2DFInFwbNRkBkgon4oJfU= -go.cypherpunks.ru/tai64n/v2 v2.0.1/go.mod h1:Jlva0YVJBpaRFAJ4jfY4BXVPuav0GMyGXzYPSKCCCL0= -go.cypherpunks.ru/ucspi v0.1.0 h1:1w0E1mSf5oo3ozSSRUZN8Mf4/Ba18S3q7c5CDeCuHZA= -go.cypherpunks.ru/ucspi v0.1.0/go.mod h1:mrkWllR0o0B/BocrUAL4DhcKLPK6XycObSswHUL5m6s= +go.cypherpunks.su/netrc/v2 v2.0.0 h1:IWJ0fPcQoccn8VbqzAQf1/4rj8zw0Bf6X5kAkzwEd48= +go.cypherpunks.su/netrc/v2 v2.0.0/go.mod h1:F5Ea8ii3R9dNUE0ixE61OYIhvJQVLLdIJjrU/3qROjw= +go.cypherpunks.su/tai64n/v3 v3.0.0 h1:JvQiZJwkswUttMNcPrYS4KUK9Zfl6xllD0N6ZnSZX/U= +go.cypherpunks.su/tai64n/v3 v3.0.0/go.mod h1:zGDFuyiFKJk+iem8lyBaFeCm+MNMOn7RRWy456n1J78= +go.cypherpunks.su/ucspi/v2 v2.0.0 h1:Ha/0xfi0nXL/4xdiXqKbHdbXWE/qKcnXux4hG7c/lwM= +go.cypherpunks.su/ucspi/v2 v2.0.0/go.mod h1:GIIOgXFLLze7hG1sAmXmPNTopVrAaFi5m+GMUA72fXY= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= diff --git a/httpauth.go b/httpauth.go index e14ed3f..df1cf85 100644 --- a/httpauth.go +++ b/httpauth.go @@ -23,7 +23,7 @@ import ( "os/exec" "strings" - "go.cypherpunks.ru/netrc" + "go.cypherpunks.su/netrc/v2" ttls "go.stargrave.org/tofuproxy/tls" ) diff --git a/tls/dial.go b/tls/dial.go index aead1c8..35f43a9 100644 --- a/tls/dial.go +++ b/tls/dial.go @@ -23,7 +23,7 @@ import ( "fmt" "net" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" "go.stargrave.org/tofuproxy/fifos" ) diff --git a/tls/tlsauth.go b/tls/tlsauth.go index 0fc4375..2aea588 100644 --- a/tls/tlsauth.go +++ b/tls/tlsauth.go @@ -29,7 +29,7 @@ import ( "strconv" "strings" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" "go.stargrave.org/tofuproxy/caches" "go.stargrave.org/tofuproxy/fifos" ) diff --git a/tls/verify.go b/tls/verify.go index 03f78f1..cbd89be 100644 --- a/tls/verify.go +++ b/tls/verify.go @@ -32,7 +32,7 @@ import ( "strings" "sync" - "go.cypherpunks.ru/ucspi" + "go.cypherpunks.su/ucspi/v2" "go.stargrave.org/tofuproxy/caches" "go.stargrave.org/tofuproxy/fifos" ) -- 2.44.0 From 7bac0d14b220a580619e7734d4bdaf1515bfd48a Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 24 Jul 2024 11:55:36 +0300 Subject: [PATCH 4/8] I do not use Newsboat for a long time --- doc/index.texi | 5 ++--- rounds/redirectHTML.go | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/index.texi b/doc/index.texi index de9d845..629ffd8 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -57,9 +57,8 @@ input dialogue is shown. It automatically loads initial form values from @item 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. +are followed if it is neither @url{https://www.feeder.stargrave.org/, go.stargrave.org/feeder} +user-agent, nor image paths. @item JPEG XL, AVIF and WebP images are transparently transcoded to PNG, diff --git a/rounds/redirectHTML.go b/rounds/redirectHTML.go index 4f8dec3..c5cc1d4 100644 --- a/rounds/redirectHTML.go +++ b/rounds/redirectHTML.go @@ -43,9 +43,6 @@ var imageExts = map[string]struct{}{ } 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 } -- 2.44.0 From 6a4ee978f94f7a9051c8aed7422443ee33444abe Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 24 Jul 2024 11:56:22 +0300 Subject: [PATCH 5/8] Fix various typos --- doc/index.texi | 4 ++-- doc/integrity.texi | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/index.texi b/doc/index.texi index 629ffd8..ad78c5c 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -21,7 +21,7 @@ capabilities: @item Full TLS connection termination between Web-servers and @command{tofuproxy} itself. TLS 1.3, session resumption, GOST -cryptography (if built with @url{http://www.gostls13.cypherpunks.ru/, +cryptography (if built with @url{http://www.gostls13.cypherpunks.su/, gostls13}) support. Connection between @command{tofuproxy} and browser itself uses ephemeral on-the-fly generated certificates with proper domain name. @@ -55,7 +55,7 @@ input dialogue is shown. It automatically loads initial form values from @file{.netrc}. @item -Permanent HTTP redirects are replaces with non-refreshing HTML page with +Permanent HTTP redirects are replaced 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://www.feeder.stargrave.org/, go.stargrave.org/feeder} user-agent, nor image paths. diff --git a/doc/integrity.texi b/doc/integrity.texi index f44863a..84efb55 100644 --- a/doc/integrity.texi +++ b/doc/integrity.texi @@ -27,7 +27,7 @@ $ gpg --auto-key-locate wkd --locate-keys tofuproxy at stargrave dot org Its fingerprint: @code{SHA256:NIDt9iZUizwivY3GoxmGvbQTH7mz/dmV7ZFOXeYfa2o}. @example -$ ssh-keygen -Y verify -f PUBKEY-SSH.pub -I tofuproxy@@cypherpunks.ru -n file \ +$ ssh-keygen -Y verify -f PUBKEY-SSH.pub -I tofuproxy@@stargrave.org -n file \ -s tofuproxy-@value{VERSION}.tar.zst.sig Date: Wed, 24 Jul 2024 11:56:57 +0300 Subject: [PATCH 6/8] I do not use Xombrero for a long time --- doc/why.texi | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/doc/why.texi b/doc/why.texi index 7e8aa24..1022e90 100644 --- a/doc/why.texi +++ b/doc/why.texi @@ -10,10 +10,7 @@ OpenSSL... All of them sucks, comparing to Go's @code{crypto/tls}. @item I am tired that everyone provides very limited certificates trust management capabilities, like either certificate or SPKI @url{https://en.wikipedia.org/wiki/Certificate_pinning, pinning} with -@url{https://en.wikipedia.org/wiki/Trust_on_first_use, TOFU}. Even my -beloved @url{https://en.wikipedia.org/wiki/Xombrero, Xombrero} browser -still pins only the whole certificate, but its public key would be much -more sufficient and convenient to work with. +@url{https://en.wikipedia.org/wiki/Trust_on_first_use, TOFU}. @item I am tired that many clients provides very few information about certificates and connections at all. @@ -27,8 +24,6 @@ kind of @url{https://en.wikipedia.org/wiki/Privoxy, Privoxy}, but it is not friendly with TLS connections, obviously. Or use yet another browser-specific plugin. -@item Xombrero sometimes has problems with HTTP-based authorization. - @item Hardly anyone does @url{https://en.wikipedia.org/wiki/DNS-based_Authentication_of_Named_Entities, DANE} checks. -- 2.44.0 From 54d58b571208b77a556920a032c44af39c601973 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 24 Jul 2024 11:58:57 +0300 Subject: [PATCH 7/8] JXL beats WebP even in lossless mode --- doc/why.texi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/why.texi b/doc/why.texi index 1022e90..0b61ae5 100644 --- a/doc/why.texi +++ b/doc/why.texi @@ -32,11 +32,9 @@ checks. Why the hell people just do not send PostScript documents instead!? @item And wonderful @url{http://jpegxl.info/, JPEG XL} image format is -not supported by most browsers. Even pretty old -@url{https://developers.google.com/speed/webp, WebP}, that has highest -compression ratio for lossless screenshots, is not supported everywhere, -especially on old browsers. -@url{https://aomediacodec.github.io/av1-avif/, AVIF} could be useful too. +not supported by all browsers. Even pretty old +@url{https://developers.google.com/speed/webp, WebP}, is not supported +everywhere, especially on old browsers. @item None of web browsers has ability to view web archives (@url{https://en.wikipedia.org/wiki/Web_ARChive, WARC}s). And most of -- 2.44.0 From 8d3f1048bf5d35f37b4f97d9245d5782ec3ad372 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 6 Aug 2024 15:02:21 +0300 Subject: [PATCH 8/8] Fix various lint warnings and suggestions --- caches/caches.go | 2 +- fifos/add.go | 2 +- fifos/del.go | 2 +- fifos/list.go | 9 +++++---- fifos/log.go | 2 +- fifos/restricted.go | 2 +- fifos/spies.go | 2 +- fifos/warcs.go | 2 +- rounds/gemini.go | 3 ++- rounds/redirectHTML.go | 5 +---- tls/tlsauth.go | 6 ++++-- trip.go | 34 +++++++++++++++++++--------------- warc/compressed.go | 12 ++++++------ warc/gzip.go | 4 ++-- warc/reader.go | 5 +++-- warc/record.go | 14 ++++++-------- warc/uris.go | 8 ++++---- 17 files changed, 59 insertions(+), 55 deletions(-) diff --git a/caches/caches.go b/caches/caches.go index 8144934..3d802d0 100644 --- a/caches/caches.go +++ b/caches/caches.go @@ -21,6 +21,6 @@ var ( Spies = make([]string, 0) SpiesM sync.RWMutex - Restricted = make(map[string][]string) + Restricted = make(map[string][]string) RestrictedM sync.RWMutex ) diff --git a/fifos/add.go b/fifos/add.go index cf8f3fd..bf573d0 100644 --- a/fifos/add.go +++ b/fifos/add.go @@ -23,7 +23,7 @@ import ( ) func readLinesFromFIFO(p string) []string { - fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/fifos/del.go b/fifos/del.go index a192302..d880658 100644 --- a/fifos/del.go +++ b/fifos/del.go @@ -25,7 +25,7 @@ import ( func del(l *sync.RWMutex, deleter func(string), p string) { for { - fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/fifos/list.go b/fifos/list.go index f571d04..13388f8 100644 --- a/fifos/list.go +++ b/fifos/list.go @@ -28,7 +28,7 @@ import ( func list(l *sync.RWMutex, m map[string]string, p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } @@ -53,7 +53,7 @@ func listRejected(p string) { func listHTTPAuth(p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } @@ -70,15 +70,16 @@ func listHTTPAuth(p string) { func listTLSAuth(p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } caches.TLSAuthCacheM.RLock() + var cert *x509.Certificate for host, tlsCert := range caches.TLSAuthCache { subj := "NONE" if len(tlsCert.Certificate) != 0 { - cert, err := x509.ParseCertificate(tlsCert.Certificate[0]) + cert, err = x509.ParseCertificate(tlsCert.Certificate[0]) if err != nil { log.Fatalln(err) } diff --git a/fifos/log.go b/fifos/log.go index b0f7508..e749eb3 100644 --- a/fifos/log.go +++ b/fifos/log.go @@ -44,7 +44,7 @@ var ( func logger(c chan string, p string) { tai := new(tai64n.TAI64N) for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/fifos/restricted.go b/fifos/restricted.go index 6b8c319..de6a7f4 100644 --- a/fifos/restricted.go +++ b/fifos/restricted.go @@ -27,7 +27,7 @@ import ( func listRestricted(p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/fifos/spies.go b/fifos/spies.go index d0fa4a9..51dc654 100644 --- a/fifos/spies.go +++ b/fifos/spies.go @@ -25,7 +25,7 @@ import ( func listSpies(p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/fifos/warcs.go b/fifos/warcs.go index 54f86a5..ba99b9f 100644 --- a/fifos/warcs.go +++ b/fifos/warcs.go @@ -26,7 +26,7 @@ import ( func listWARCs(p string) { for { - fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666)) + fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0o666)) if err != nil { log.Fatalln(err) } diff --git a/rounds/gemini.go b/rounds/gemini.go index 71da97f..2b480ed 100644 --- a/rounds/gemini.go +++ b/rounds/gemini.go @@ -195,7 +195,8 @@ func RoundGemini( !strings.Contains(req.Header.Get("Accept"), ContentTypeGemini) { w.Header().Add("Content-Type", "text/html") w.WriteHeader(http.StatusOK) - raw, err := io.ReadAll(br) + var raw []byte + raw, err = io.ReadAll(br) if err != nil { log.Printf("%s: can not read response body: %+v\n", req.URL, err) return false, err diff --git a/rounds/redirectHTML.go b/rounds/redirectHTML.go index c5cc1d4..93e9d49 100644 --- a/rounds/redirectHTML.go +++ b/rounds/redirectHTML.go @@ -43,10 +43,7 @@ var imageExts = map[string]struct{}{ } func isFeeder(req *http.Request) bool { - if strings.Contains(req.Header.Get("User-Agent"), "stargrave.org-feeder/") { - return true - } - return false + return strings.Contains(req.Header.Get("User-Agent"), "stargrave.org-feeder/") } func RoundRedirectHTML( diff --git a/tls/tlsauth.go b/tls/tlsauth.go index 2aea588..62763b9 100644 --- a/tls/tlsauth.go +++ b/tls/tlsauth.go @@ -104,11 +104,13 @@ foreach sigScheme {%s} { tlsCerts = append(tlsCerts, nil) for i, ent := range ents { p := filepath.Join(CCerts, ent.Name()) - _, cert, err := ucspi.CertificateFromFile(p) + var cert *x509.Certificate + _, cert, err = ucspi.CertificateFromFile(p) if err != nil { log.Fatalln(err) } - prv, err := ucspi.PrivateKeyFromFile(p) + var prv any + prv, err = ucspi.PrivateKeyFromFile(p) if err != nil { log.Fatalln(err) } diff --git a/trip.go b/trip.go index 06a6f90..0e179a5 100644 --- a/trip.go +++ b/trip.go @@ -103,7 +103,8 @@ Retry: fifos.LogVarious <- fmt.Sprintf( "%s %s\tHTTP authorization required", req.Method, req.URL.Host, ) - user, pass, err := authDialog(host, resp.Header.Get("WWW-Authenticate")) + var user, pass string + user, pass, err = authDialog(host, resp.Header.Get("WWW-Authenticate")) if err != nil { caches.HTTPAuthCacheM.Unlock() fifos.LogErr <- fmt.Sprintf("%s\t%s", req.URL.Host, err.Error()) @@ -132,20 +133,23 @@ Retry: } } - for _, round := range []Round{ - rounds.RoundDenyFonts, - rounds.RoundTranscodeWebP, - rounds.RoundTranscodeJXL, - rounds.RoundTranscodeAVIF, - rounds.RoundRedirectHTML, - } { - cont, err := round(host, resp, w, req) - if err != nil { - http.Error(w, err.Error(), http.StatusBadGateway) - return - } - if !cont { - return + { + var cont bool + for _, round := range []Round{ + rounds.RoundDenyFonts, + rounds.RoundTranscodeWebP, + rounds.RoundTranscodeJXL, + rounds.RoundTranscodeAVIF, + rounds.RoundRedirectHTML, + } { + cont, err = round(host, resp, w, req) + if err != nil { + http.Error(w, err.Error(), http.StatusBadGateway) + return + } + if !cont { + return + } } } diff --git a/warc/compressed.go b/warc/compressed.go index 84b30c3..c085227 100644 --- a/warc/compressed.go +++ b/warc/compressed.go @@ -29,12 +29,11 @@ import ( ) type CompressedReader struct { - cmd *exec.Cmd - fd *os.File - stdout io.ReadCloser - offsets []Offset - + stdout io.ReadCloser + cmd *exec.Cmd + fd *os.File offW *os.File + offsets []Offset offReader sync.WaitGroup } @@ -79,7 +78,8 @@ func NewCompressedReader( cmd.Stdin = io.MultiReader(bytes.NewReader(dict), fd) } if offsets == nil { - offR, offW, err := os.Pipe() + var offR, offW *os.File + offR, offW, err = os.Pipe() if err != nil { fd.Close() return nil, err diff --git a/warc/gzip.go b/warc/gzip.go index fc20ac4..6a675ee 100644 --- a/warc/gzip.go +++ b/warc/gzip.go @@ -91,9 +91,9 @@ func NewGZIPReader( gr := GZIPReader{r: r} go func() { z.Multistream(false) - var offset, offsetPrev int64 + var offset, offsetPrev, written int64 for { - written, err := io.Copy(w, z) + written, err = io.Copy(w, z) if err != nil { w.CloseWithError(err) return diff --git a/warc/reader.go b/warc/reader.go index 50037c7..6d0993c 100644 --- a/warc/reader.go +++ b/warc/reader.go @@ -30,9 +30,9 @@ type Reader struct { Path string rrr RawRecordReader br *bufio.Reader - offset int64 prevRec *Record offsets []Offset + offset int64 } func NewReader(warcPath string) (*Reader, error) { @@ -81,7 +81,8 @@ func (r *Reader) ReadRecord() (*Record, io.Reader, error) { hdrLen := len(line) hdr := NewHeader() for { - line, err := r.br.ReadString('\n') + var line string + line, err = r.br.ReadString('\n') if err != nil { return nil, nil, err } diff --git a/warc/record.go b/warc/record.go index 38181ab..de30151 100644 --- a/warc/record.go +++ b/warc/record.go @@ -22,15 +22,13 @@ import ( ) type Record struct { - WARCPath string - Offset int64 - Size int64 - - Hdr Header - HdrLen int - HdrLines []string - + WARCPath string + Hdr Header + HdrLines []string Continuations []*Record + Offset int64 + Size int64 + HdrLen int } func (rec *Record) URI() string { diff --git a/warc/uris.go b/warc/uris.go index 56cd415..37644ac 100644 --- a/warc/uris.go +++ b/warc/uris.go @@ -46,10 +46,10 @@ func Add(warcPath string) error { var uris map[string]*Record var offsets []Offset dec := gob.NewDecoder(fd) - if err := dec.Decode(&uris); err != nil { + if err = dec.Decode(&uris); err != nil { return err } - if err := dec.Decode(&offsets); err != nil { + if err = dec.Decode(&offsets); err != nil { return err } WARCsM.Lock() @@ -59,7 +59,7 @@ func Add(warcPath string) error { log.Println("loaded marshalled index:", warcPath+IndexExt) return nil } - if err != nil && !errors.Is(err, fs.ErrNotExist) { + if !errors.Is(err, fs.ErrNotExist) { return err } r, err := NewReader(warcPath) @@ -135,7 +135,7 @@ func SaveIndices() error { fd, err := os.OpenFile( p+tmpSuffix, os.O_WRONLY|os.O_CREATE|os.O_EXCL, - os.FileMode(0666), + os.FileMode(0o666), ) if err != nil { return err -- 2.44.0