Move executable to cmd/tlstunnel

This allows us to expose the toplevel tlstunnel package.
This commit is contained in:
Simon Ser 2020-09-10 14:49:59 +02:00
parent 6ec8fd1f15
commit ec2a768909
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
4 changed files with 13 additions and 11 deletions

View File

@ -12,7 +12,7 @@ MANDIR = share/man
all: tlstunnel tlstunnel.1
tlstunnel:
$(GO) build $(GOFLAGS) .
$(GO) build $(GOFLAGS) ./cmd/tlstunnel
tlstunnel.1: tlstunnel.1.scd
$(SCDOC) <tlstunnel.1.scd >tlstunnel.1

View File

@ -7,6 +7,8 @@ import (
"net"
"net/url"
"strings"
"git.sr.ht/~emersion/tlstunnel"
)
var configPath = "config"
@ -15,12 +17,12 @@ func main() {
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
flag.Parse()
cfg, err := LoadConfig(configPath)
cfg, err := tlstunnel.LoadConfig(configPath)
if err != nil {
log.Fatalf("failed to load config file: %v", err)
}
srv := NewServer()
srv := tlstunnel.NewServer()
for _, d := range cfg.Children {
var err error
@ -44,8 +46,8 @@ func main() {
select {}
}
func parseFrontend(srv *Server, d *Directive) error {
frontend := &Frontend{Server: srv}
func parseFrontend(srv *tlstunnel.Server, d *tlstunnel.Directive) error {
frontend := &tlstunnel.Frontend{Server: srv}
srv.Frontends = append(srv.Frontends, frontend)
// TODO: support multiple backends
@ -83,7 +85,7 @@ func parseFrontend(srv *Server, d *Directive) error {
return nil
}
func parseBackend(backend *Backend, d *Directive) error {
func parseBackend(backend *tlstunnel.Backend, d *tlstunnel.Directive) error {
var backendURI string
if err := d.ParseParams(&backendURI); err != nil {
return err
@ -117,7 +119,7 @@ func parseBackend(backend *Backend, d *Directive) error {
return nil
}
func parseTLS(srv *Server, d *Directive) error {
func parseTLS(srv *tlstunnel.Server, d *tlstunnel.Directive) error {
for _, child := range d.Children {
switch child.Name {
case "acme_ca":

View File

@ -1,4 +1,4 @@
package main
package tlstunnel
import (
"bufio"

View File

@ -1,4 +1,4 @@
package main
package tlstunnel
import (
"context"