1
1
Fork 0
mirror of https://git.sr.ht/~emersion/tlstunnel synced 2024-05-23 09:06:12 +02:00
tlstunnel/cmd/tlstunnel/main.go
Simon Ser 18dd507ea5
Don't try to guess listening address
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.
2020-09-12 13:41:11 +02:00

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 {}
}