2 tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
3 manager, WARC/geminispace browser
4 Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
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.
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.
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/>.
27 "go.cypherpunks.ru/ucspi"
28 "go.stargrave.org/tofuproxy"
29 "go.stargrave.org/tofuproxy/fifos"
30 "go.stargrave.org/tofuproxy/rounds"
31 ttls "go.stargrave.org/tofuproxy/tls"
35 crtPath := flag.String("cert", "cert.pem", "Path to server X.509 certificate")
36 prvPath := flag.String("key", "cert.pem", "Path to server PKCS#8 private key")
37 bind := flag.String("bind", "[::1]:8080", "Bind address")
38 certs := flag.String("certs", "./certs", "Directory with pinned certificates")
39 ccerts := flag.String("ccerts", "./ccerts", "Directory with client certificates")
40 dnsSrv := flag.String("dns", "[::1]:53", "DNS server")
41 fifosDir := flag.String("fifos", "fifos", "Directory with FIFOs")
42 notai := flag.Bool("notai", false, "Do not prepend TAI64N to logs")
43 warcOnly := flag.Bool("warc-only", false, "Server only WARC URIs")
45 log.SetFlags(log.Lshortfile)
48 _, caCert, err := ucspi.CertificateFromFile(*crtPath)
52 caPrv, err := ucspi.PrivateKeyFromFile(*prvPath)
58 fifos.Start(*fifosDir)
62 tofuproxy.CACert = caCert
63 tofuproxy.CAPrv = caPrv
64 rounds.WARCOnly = *warcOnly
66 ln, err := net.Listen("tcp", *bind)
71 Handler: &tofuproxy.Handler{},
72 TLSNextProto: tofuproxy.TLSNextProtoS,
74 log.Println("listening:", *bind, "dns:", *dnsSrv, "certs:", *certs, "ccerts:", *ccerts)
75 if err := srv.Serve(ln); err != nil {