]> Sergey Matveev's repositories - tofuproxy.git/blob - fifos/start.go
Download link for 0.6.0 release
[tofuproxy.git] / fifos / start.go
1 /*
2 tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
3              manager, WARC/geminispace browser
4 Copyright (C) 2021-2023 Sergey Matveev <stargrave@stargrave.org>
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 3 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package fifos
20
21 import (
22         "path/filepath"
23
24         "go.stargrave.org/tofuproxy/caches"
25         "go.stargrave.org/tofuproxy/warc"
26 )
27
28 func Start(fifos string) {
29         go logger(LogCert, filepath.Join(fifos, "log-cert"))
30         go logger(LogDANE, filepath.Join(fifos, "log-dane"))
31         go logger(LogErr, filepath.Join(fifos, "log-err"))
32         go logger(LogHTTPAuth, filepath.Join(fifos, "log-http-auth"))
33         go logger(LogNonOK, filepath.Join(fifos, "log-non-ok"))
34         go logger(LogOK, filepath.Join(fifos, "log-ok"))
35         go logger(LogRedir, filepath.Join(fifos, "log-redir"))
36         go logger(LogReq, filepath.Join(fifos, "log-req"))
37         go logger(LogTLS, filepath.Join(fifos, "log-tls"))
38         go logger(LogTLSAuth, filepath.Join(fifos, "log-tls-auth"))
39         go logger(LogVarious, filepath.Join(fifos, "log-various"))
40         go logger(LogWARC, filepath.Join(fifos, "log-warc"))
41
42         go listAccepted(filepath.Join(fifos, "list-accepted"))
43         go listHTTPAuth(filepath.Join(fifos, "list-http-auth"))
44         go listRejected(filepath.Join(fifos, "list-rejected"))
45         go listRestricted(filepath.Join(fifos, "list-restricted"))
46         go listSpies(filepath.Join(fifos, "list-spies"))
47         go listTLSAuth(filepath.Join(fifos, "list-tls-auth"))
48         go listWARCs(filepath.Join(fifos, "list-warcs"))
49
50         go del(
51                 &caches.AcceptedM, func(host string) { delete(caches.Accepted, host) },
52                 filepath.Join(fifos, "del-accepted"),
53         )
54         go del(
55                 &caches.HTTPAuthCacheM, func(host string) { delete(caches.HTTPAuthCache, host) },
56                 filepath.Join(fifos, "del-http-auth"),
57         )
58         go del(
59                 &caches.RejectedM, func(host string) { delete(caches.Rejected, host) },
60                 filepath.Join(fifos, "del-rejected"),
61         )
62
63         go addRestricted(filepath.Join(fifos, "add-restricted"))
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) {
82                         delete(warc.WARCs, warcPath)
83                         delete(warc.WARCsOffsets, warcPath)
84                 },
85                 filepath.Join(fifos, "del-warcs"),
86         )
87
88         go addTLSAuth(filepath.Join(fifos, "add-tls-auth"))
89         go del(
90                 &caches.TLSAuthCacheM, func(host string) { delete(caches.TLSAuthCache, host) },
91                 filepath.Join(fifos, "del-tls-auth"),
92         )
93 }