]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - rounds/spy.go
Unify copyright comment format
[tofuproxy.git] / rounds / spy.go
index 3b242f8cfd2b686a37d230c80553ee6508a3e558..73f44f520b8f684066f9c936ed2e9cc450b43841 100644 (file)
@@ -1,19 +1,18 @@
-/*
-tofuproxy -- HTTP proxy with TLS certificates management
-Copyright (C) 2021 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
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+// tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+//              manager, WARC/geminispace browser
+// Copyright (C) 2021-2024 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
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 package rounds
 
@@ -22,31 +21,14 @@ import (
        "net/http"
        "strings"
 
+       "go.stargrave.org/tofuproxy/caches"
        "go.stargrave.org/tofuproxy/fifos"
 )
 
-var spyDomains = []string{
-       "google-analytics.com",
-       "goo.gl",
-       "ads.google.com",
-       "googletagmanager.com",
-       "facebook.com",
-       "facebook.net",
-       "fbcdn.com",
-       "fbcdn.net",
-       "advertising.yandex.ru",
-       "an.yandex.ru",
-       "awaps.yandex.ru",
-       "bs.yandex.ru",
-       "informer.yandex.ru",
-       "mc.yandex.ru",
-       "metrika.yandex.ru",
-       "doubleclick.net",
-       "tns-counter.ru",
-}
-
 func IsSpy(host string) bool {
-       for _, spy := range spyDomains {
+       caches.SpiesM.RLock()
+       defer caches.SpiesM.RUnlock()
+       for _, spy := range caches.Spies {
                if strings.HasSuffix(host, spy) {
                        return true
                }
@@ -62,12 +44,7 @@ func RoundDenySpy(
 ) (bool, error) {
        if IsSpy(host) {
                http.NotFound(w, req)
-               fifos.SinkOther <- fmt.Sprintf(
-                       "%s %s\t%d\tdeny spy",
-                       req.Method,
-                       req.URL.String(),
-                       http.StatusNotFound,
-               )
+               fifos.LogVarious <- fmt.Sprintf("%s %s\tdeny spy", req.Method, req.URL)
                return false, nil
        }
        return true, nil