~emersion/tlstunnel

ref: aae358811d2df82fb744f3441e7543e0d9458136 tlstunnel/cmd/tlstunnel/main.go -rw-r--r-- 654 bytes
aae35881Simon Ser Set PROXY protocol PP2_TYPE_SSL 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 {}
}