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>
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"
32 "go.stargrave.org/tofuproxy/warc"
36 ai := flag.String("ai", "eddsa", "ecdsa|eddsa (ECDSA-256 or EdDSA algorithm)")
37 crtPath := flag.String("cert", "cert.pem", "Path to server X.509 certificate")
38 prvPath := flag.String("key", "cert.pem", "Path to server PKCS#8 private key")
39 bind := flag.String("bind", "[::1]:8080", "Bind address")
40 certs := flag.String("certs", "./certs", "Directory with pinned certificates")
41 ccerts := flag.String("ccerts", "./ccerts", "Directory with client certificates")
42 dnsSrv := flag.String("dns", "[::1]:53", "DNS server")
43 fifosDir := flag.String("fifos", "fifos", "Directory with FIFOs")
44 notai := flag.Bool("notai", false, "Do not prepend TAI64N to logs")
45 warcOnly := flag.Bool("warc-only", false, "Server only WARC URIs")
46 unzstdPath := flag.String("unzstd", "cmd/zstd/unzstd", "Path to unzstd utility")
48 log.SetFlags(log.Lshortfile)
51 _, caCert, err := ucspi.CertificateFromFile(*crtPath)
55 caPrv, err := ucspi.PrivateKeyFromFile(*prvPath)
61 fifos.Start(*fifosDir)
65 tofuproxy.CACert = caCert
66 tofuproxy.CAPrv = caPrv
67 tofuproxy.X509Algo = *ai
68 rounds.WARCOnly = *warcOnly
69 warc.UnZSTDPath = *unzstdPath
71 ln, err := net.Listen("tcp", *bind)
76 Handler: &tofuproxy.Handler{},
77 TLSNextProto: tofuproxy.TLSNextProtoS,
79 log.Println("listening:", *bind, "dns:", *dnsSrv, "certs:", *certs, "ccerts:", *ccerts)
80 if err := srv.Serve(ln); err != nil {