2 tofuproxy -- HTTP proxy with TLS certificates management
3 Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
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.
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.
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/>.
26 "go.cypherpunks.ru/tai64n/v2"
32 SinkCert = make(chan string)
33 SinkDANE = make(chan string)
34 SinkErr = make(chan string)
35 SinkOK = make(chan string)
36 SinkOther = make(chan string)
37 SinkRedir = make(chan string)
38 SinkReq = make(chan string)
39 SinkTLS = make(chan string)
42 func sinker(c chan string, p string) {
43 tai := new(tai64n.TAI64N)
45 fd, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND, os.FileMode(0666))
51 _, err = fd.WriteString(s + "\n")
53 tai.FromTime(time.Now())
54 _, err = fd.WriteString(tai64n.Encode(tai[:]) + " " + s + "\n")
65 go sinker(SinkCert, filepath.Join(FIFOs, "cert"))
66 go sinker(SinkDANE, filepath.Join(FIFOs, "dane"))
67 go sinker(SinkErr, filepath.Join(FIFOs, "err"))
68 go sinker(SinkOK, filepath.Join(FIFOs, "ok"))
69 go sinker(SinkOther, filepath.Join(FIFOs, "other"))
70 go sinker(SinkRedir, filepath.Join(FIFOs, "redir"))
71 go sinker(SinkReq, filepath.Join(FIFOs, "req"))
72 go sinker(SinkTLS, filepath.Join(FIFOs, "tls"))