mirror of
https://git.sr.ht/~emersion/tlstunnel
synced 2024-05-23 09:06:12 +02:00
18dd507ea5
Always listen on all hosts. Only use the host part of a frontend address for TLS cert names. Customizing the listen host will be better done with a `bind` directive, like Caddy does.
41 lines
654 B
Go
41 lines
654 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
|
|
"git.sr.ht/~emersion/tlstunnel"
|
|
"github.com/caddyserver/certmagic"
|
|
)
|
|
|
|
var (
|
|
configPath = "config"
|
|
certDataPath = ""
|
|
)
|
|
|
|
func main() {
|
|
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
|
flag.Parse()
|
|
|
|
cfg, err := tlstunnel.LoadConfig(configPath)
|
|
if err != nil {
|
|
log.Fatalf("failed to load config file: %v", err)
|
|
}
|
|
|
|
srv := tlstunnel.NewServer()
|
|
|
|
if certDataPath != "" {
|
|
srv.ACMEConfig.Storage = &certmagic.FileStorage{Path: certDataPath}
|
|
}
|
|
|
|
if err := srv.Load(cfg); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := srv.Start(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
select {}
|
|
}
|