]> Sergey Matveev's repositories - tofuproxy.git/blob - fifos/start.go
WARC
[tofuproxy.git] / fifos / start.go
1 /*
2 tofuproxy -- flexible HTTP/WARC 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 fifos
19
20 import (
21         "path/filepath"
22
23         "go.stargrave.org/tofuproxy/caches"
24         "go.stargrave.org/tofuproxy/warc"
25 )
26
27 func Start(fifos string) {
28         go logger(LogCert, filepath.Join(fifos, "log-cert"))
29         go logger(LogDANE, filepath.Join(fifos, "log-dane"))
30         go logger(LogErr, filepath.Join(fifos, "log-err"))
31         go logger(LogHTTPAuth, filepath.Join(fifos, "log-http-auth"))
32         go logger(LogNonOK, filepath.Join(fifos, "log-non-ok"))
33         go logger(LogOK, filepath.Join(fifos, "log-ok"))
34         go logger(LogRedir, filepath.Join(fifos, "log-redir"))
35         go logger(LogReq, filepath.Join(fifos, "log-req"))
36         go logger(LogTLS, filepath.Join(fifos, "log-tls"))
37         go logger(LogTLSAuth, filepath.Join(fifos, "log-tls-auth"))
38         go logger(LogVarious, filepath.Join(fifos, "log-various"))
39         go logger(LogWARC, filepath.Join(fifos, "log-warc"))
40
41         go listAccepted(filepath.Join(fifos, "list-accepted"))
42         go listHTTPAuth(filepath.Join(fifos, "list-http-auth"))
43         go listRejected(filepath.Join(fifos, "list-rejected"))
44         go listSpies(filepath.Join(fifos, "list-spies"))
45         go listTLSAuth(filepath.Join(fifos, "list-tls-auth"))
46         go listWARCs(filepath.Join(fifos, "list-warcs"))
47
48         go del(
49                 &caches.AcceptedM, func(host string) { delete(caches.Accepted, host) },
50                 filepath.Join(fifos, "del-accepted"),
51         )
52         go del(
53                 &caches.HTTPAuthCacheM, func(host string) { delete(caches.HTTPAuthCache, host) },
54                 filepath.Join(fifos, "del-http-auth"),
55         )
56         go del(
57                 &caches.RejectedM, func(host string) { delete(caches.Rejected, host) },
58                 filepath.Join(fifos, "del-rejected"),
59         )
60         go del(
61                 &caches.TLSAuthCacheM, func(host string) { delete(caches.TLSAuthCache, host) },
62                 filepath.Join(fifos, "del-tls-auth"),
63         )
64
65         go addSpy(filepath.Join(fifos, "add-spies"))
66         go del(
67                 &caches.SpiesM, func(host string) {
68                         for i, spy := range caches.Spies {
69                                 if spy == host {
70                                         caches.Spies[i] = caches.Spies[len(caches.Spies)-1]
71                                         caches.Spies = caches.Spies[:len(caches.Spies)-1]
72                                         return
73                                 }
74                         }
75                 },
76                 filepath.Join(fifos, "del-spies"),
77         )
78
79         go addWARC(filepath.Join(fifos, "add-warcs"))
80         go del(
81                 &warc.WARCsM, func(warcPath string) { delete(warc.WARCs, warcPath) },
82                 filepath.Join(fifos, "del-warcs"),
83         )
84 }