From c50e482085509898083a3061cc3a63750391e09b Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 4 Mar 2025 15:16:32 -0300 Subject: [PATCH] remove domain only access, that can be done in the reverse proxy side --- cmd/http3-ytproxy/main.go | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/cmd/http3-ytproxy/main.go b/cmd/http3-ytproxy/main.go index 6ea5bf2..107815f 100644 --- a/cmd/http3-ytproxy/main.go +++ b/cmd/http3-ytproxy/main.go @@ -24,12 +24,6 @@ import ( "github.com/quic-go/quic-go/http3" ) -var h3s bool - -var domain_only_access bool = false - -var version string - type ConnectionWatcher struct { totalEstablished int64 established int64 @@ -37,6 +31,10 @@ type ConnectionWatcher struct { idle int64 } +var h3s bool +var version string +var cw ConnectionWatcher + // https://stackoverflow.com/questions/51317122/how-to-get-number-of-idle-and-active-connections-in-go // OnStateChange records open connections in response to connection // state changes. Set net/http Server.ConnState to this method @@ -53,8 +51,6 @@ func (cw *ConnectionWatcher) OnStateChange(conn net.Conn, state http.ConnState) } } -var cw ConnectionWatcher - var tx uint64 func blockCheckerCalc(p *procfs.Proc) { @@ -109,13 +105,6 @@ func blockChecker(gh string, cooldown int) { func beforeMisc(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { defer utils.PanicHandler(w) - - // To prevent accessing from the bare IP address - if domain_only_access && (req.Host == "" || net.ParseIP(strings.Split(req.Host, ":")[0]) != nil) { - w.WriteHeader(444) - return - } - next(w, req) } } @@ -124,12 +113,6 @@ func beforeProxy(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { defer utils.PanicHandler(w) - // To prevent accessing from the bare IP address - if domain_only_access && (req.Host == "" || net.ParseIP(strings.Split(req.Host, ":")[0]) != nil) { - w.WriteHeader(444) - return - } - w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "*") w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS") @@ -194,9 +177,6 @@ func main() { if strings.ToLower(getenv("BLOCK_CHECKER")) == "false" { bc = false } - if strings.ToLower(getenv("DOMAIN_ONLY_ACCESS")) == "true" { - domain_only_access = true - } tls_cert := getenv("TLS_CERT") if tls_cert == "" {