]> Sergey Matveev's repositories - tofuproxy.git/blob - rounds/15spy.go
AVIF transcoding
[tofuproxy.git] / rounds / 15spy.go
1 /*
2 tofuproxy -- HTTP proxy with TLS certificates management
3 Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package rounds
19
20 import (
21         "fmt"
22         "net/http"
23         "strings"
24
25         "go.stargrave.org/tofuproxy/fifos"
26 )
27
28 var spyDomains = []string{
29         "google-analytics.com",
30         "goo.gl",
31         "ads.google.com",
32         "facebook.com",
33         "facebook.net",
34         "fbcdn.com",
35         "fbcdn.net",
36         "advertising.yandex.ru",
37         "an.yandex.ru",
38         "awaps.yandex.ru",
39         "bs.yandex.ru",
40         "informer.yandex.ru",
41         "mc.yandex.ru",
42         "metrika.yandex.ru",
43         "doubleclick.net",
44         "tns-counter.ru",
45 }
46
47 func RoundDenySpy(
48         host string,
49         resp *http.Response,
50         w http.ResponseWriter,
51         req *http.Request,
52 ) (bool, error) {
53         for _, spy := range spyDomains {
54                 if strings.HasSuffix(host, spy) {
55                         http.NotFound(w, req)
56                         fifos.SinkOther <- fmt.Sprintf(
57                                 "%s %s\t%d\tdeny spy",
58                                 req.Method,
59                                 req.URL.String(),
60                                 http.StatusNotFound,
61                         )
62                         return false, nil
63                 }
64         }
65         return true, nil
66 }