]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - rounds/spy.go
Another refactor
[tofuproxy.git] / rounds / spy.go
similarity index 82%
rename from rounds/15spy.go
rename to rounds/spy.go
index 42ebd9ee92eb23cc7dd3e5e27c20b51c86b069cc..3b242f8cfd2b686a37d230c80553ee6508a3e558 100644 (file)
@@ -29,6 +29,7 @@ var spyDomains = []string{
        "google-analytics.com",
        "goo.gl",
        "ads.google.com",
+       "googletagmanager.com",
        "facebook.com",
        "facebook.net",
        "fbcdn.com",
@@ -44,23 +45,30 @@ var spyDomains = []string{
        "tns-counter.ru",
 }
 
+func IsSpy(host string) bool {
+       for _, spy := range spyDomains {
+               if strings.HasSuffix(host, spy) {
+                       return true
+               }
+       }
+       return false
+}
+
 func RoundDenySpy(
        host string,
        resp *http.Response,
        w http.ResponseWriter,
        req *http.Request,
 ) (bool, error) {
-       for _, spy := range spyDomains {
-               if strings.HasSuffix(host, spy) {
-                       http.NotFound(w, req)
-                       fifos.SinkOther <- fmt.Sprintf(
-                               "%s %s\t%d\tdeny spy",
-                               req.Method,
-                               req.URL.String(),
-                               http.StatusNotFound,
-                       )
-                       return false, nil
-               }
+       if IsSpy(host) {
+               http.NotFound(w, req)
+               fifos.SinkOther <- fmt.Sprintf(
+                       "%s %s\t%d\tdeny spy",
+                       req.Method,
+                       req.URL.String(),
+                       http.StatusNotFound,
+               )
+               return false, nil
        }
        return true, nil
 }