]> Sergey Matveev's repositories - tofuproxy.git/blob - fifos/start.go
gemini:// support
[tofuproxy.git] / fifos / start.go
1 /*
2 tofuproxy -- flexible HTTP proxy, TLS terminator, X.509 certificates
3              manager, WARC/Gemini browser
4 Copyright (C) 2021 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 listSpies(filepath.Join(fifos, "list-spies"))
46         go listTLSAuth(filepath.Join(fifos, "list-tls-auth"))
47         go listWARCs(filepath.Join(fifos, "list-warcs"))
48
49         go del(
50                 &caches.AcceptedM, func(host string) { delete(caches.Accepted, host) },
51                 filepath.Join(fifos, "del-accepted"),
52         )
53         go del(
54                 &caches.HTTPAuthCacheM, func(host string) { delete(caches.HTTPAuthCache, host) },
55                 filepath.Join(fifos, "del-http-auth"),
56         )
57         go del(
58                 &caches.RejectedM, func(host string) { delete(caches.Rejected, host) },
59                 filepath.Join(fifos, "del-rejected"),
60         )
61         go del(
62                 &caches.TLSAuthCacheM, func(host string) { delete(caches.TLSAuthCache, host) },
63                 filepath.Join(fifos, "del-tls-auth"),
64         )
65
66         go addSpy(filepath.Join(fifos, "add-spies"))
67         go del(
68                 &caches.SpiesM, func(host string) {
69                         for i, spy := range caches.Spies {
70                                 if spy == host {
71                                         caches.Spies[i] = caches.Spies[len(caches.Spies)-1]
72                                         caches.Spies = caches.Spies[:len(caches.Spies)-1]
73                                         return
74                                 }
75                         }
76                 },
77                 filepath.Join(fifos, "del-spies"),
78         )
79
80         go addWARC(filepath.Join(fifos, "add-warcs"))
81         go del(
82                 &warc.WARCsM, func(warcPath string) {
83                         delete(warc.WARCs, warcPath)
84                         delete(warc.WARCsOffsets, warcPath)
85                 },
86                 filepath.Join(fifos, "del-warcs"),
87         )
88 }