]> Sergey Matveev's repositories - tofuproxy.git/blob - fifos/start.go
Unify copyright comment format
[tofuproxy.git] / fifos / start.go
1 // tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
2 //              manager, WARC/geminispace browser
3 // Copyright (C) 2021-2024 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 package fifos
18
19 import (
20         "path/filepath"
21
22         "go.stargrave.org/tofuproxy/caches"
23         "go.stargrave.org/tofuproxy/warc"
24 )
25
26 func Start(fifos string) {
27         go logger(LogCert, filepath.Join(fifos, "log-cert"))
28         go logger(LogDANE, filepath.Join(fifos, "log-dane"))
29         go logger(LogErr, filepath.Join(fifos, "log-err"))
30         go logger(LogHTTPAuth, filepath.Join(fifos, "log-http-auth"))
31         go logger(LogNonOK, filepath.Join(fifos, "log-non-ok"))
32         go logger(LogOK, filepath.Join(fifos, "log-ok"))
33         go logger(LogRedir, filepath.Join(fifos, "log-redir"))
34         go logger(LogReq, filepath.Join(fifos, "log-req"))
35         go logger(LogTLS, filepath.Join(fifos, "log-tls"))
36         go logger(LogTLSAuth, filepath.Join(fifos, "log-tls-auth"))
37         go logger(LogVarious, filepath.Join(fifos, "log-various"))
38         go logger(LogWARC, filepath.Join(fifos, "log-warc"))
39
40         go listAccepted(filepath.Join(fifos, "list-accepted"))
41         go listHTTPAuth(filepath.Join(fifos, "list-http-auth"))
42         go listRejected(filepath.Join(fifos, "list-rejected"))
43         go listRestricted(filepath.Join(fifos, "list-restricted"))
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
61         go addRestricted(filepath.Join(fifos, "add-restricted"))
62
63         go addSpy(filepath.Join(fifos, "add-spies"))
64         go del(
65                 &caches.SpiesM, func(host string) {
66                         for i, spy := range caches.Spies {
67                                 if spy == host {
68                                         caches.Spies[i] = caches.Spies[len(caches.Spies)-1]
69                                         caches.Spies = caches.Spies[:len(caches.Spies)-1]
70                                         return
71                                 }
72                         }
73                 },
74                 filepath.Join(fifos, "del-spies"),
75         )
76
77         go addWARC(filepath.Join(fifos, "add-warcs"))
78         go del(
79                 &warc.WARCsM, func(warcPath string) {
80                         delete(warc.WARCs, warcPath)
81                         delete(warc.WARCsOffsets, warcPath)
82                 },
83                 filepath.Join(fifos, "del-warcs"),
84         )
85
86         go addTLSAuth(filepath.Join(fifos, "add-tls-auth"))
87         go del(
88                 &caches.TLSAuthCacheM, func(host string) { delete(caches.TLSAuthCache, host) },
89                 filepath.Join(fifos, "del-tls-auth"),
90         )
91 }