From 56345e5bae89e1a9a55800396d3962e2db895c80 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 5 Nov 2024 13:50:53 -0300 Subject: [PATCH] Prevent processing of already expired videoplayback links --- httppaths.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/httppaths.go b/httppaths.go index eeaea19..1652091 100644 --- a/httppaths.go +++ b/httppaths.go @@ -6,12 +6,26 @@ import ( "log" "net/http" "net/url" + "strconv" "strings" "sync/atomic" + "time" ) func videoplayback(w http.ResponseWriter, req *http.Request) { q := req.URL.Query() + expire, err := strconv.ParseInt(q.Get("expire"), 10, 64) + if err != nil { + w.WriteHeader(500) + } + + // Prevent the process of already expired playbacks + // since they will return 403 from googlevideo servers. + if (expire - time.Now().Unix()) <= 0 { + w.WriteHeader(403) + return + } + host := q.Get("host") q.Del("host")