Move executable to cmd/tlstunnel
This allows us to expose the toplevel tlstunnel package.
This commit is contained in:
parent
6ec8fd1f15
commit
ec2a768909
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ MANDIR = share/man
|
||||||
all: tlstunnel tlstunnel.1
|
all: tlstunnel tlstunnel.1
|
||||||
|
|
||||||
tlstunnel:
|
tlstunnel:
|
||||||
$(GO) build $(GOFLAGS) .
|
$(GO) build $(GOFLAGS) ./cmd/tlstunnel
|
||||||
tlstunnel.1: tlstunnel.1.scd
|
tlstunnel.1: tlstunnel.1.scd
|
||||||
$(SCDOC) <tlstunnel.1.scd >tlstunnel.1
|
$(SCDOC) <tlstunnel.1.scd >tlstunnel.1
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.sr.ht/~emersion/tlstunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configPath = "config"
|
var configPath = "config"
|
||||||
|
@ -15,12 +17,12 @@ func main() {
|
||||||
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
cfg, err := LoadConfig(configPath)
|
cfg, err := tlstunnel.LoadConfig(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to load config file: %v", err)
|
log.Fatalf("failed to load config file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
srv := NewServer()
|
srv := tlstunnel.NewServer()
|
||||||
|
|
||||||
for _, d := range cfg.Children {
|
for _, d := range cfg.Children {
|
||||||
var err error
|
var err error
|
||||||
|
@ -44,8 +46,8 @@ func main() {
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFrontend(srv *Server, d *Directive) error {
|
func parseFrontend(srv *tlstunnel.Server, d *tlstunnel.Directive) error {
|
||||||
frontend := &Frontend{Server: srv}
|
frontend := &tlstunnel.Frontend{Server: srv}
|
||||||
srv.Frontends = append(srv.Frontends, frontend)
|
srv.Frontends = append(srv.Frontends, frontend)
|
||||||
|
|
||||||
// TODO: support multiple backends
|
// TODO: support multiple backends
|
||||||
|
@ -83,7 +85,7 @@ func parseFrontend(srv *Server, d *Directive) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseBackend(backend *Backend, d *Directive) error {
|
func parseBackend(backend *tlstunnel.Backend, d *tlstunnel.Directive) error {
|
||||||
var backendURI string
|
var backendURI string
|
||||||
if err := d.ParseParams(&backendURI); err != nil {
|
if err := d.ParseParams(&backendURI); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -117,7 +119,7 @@ func parseBackend(backend *Backend, d *Directive) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTLS(srv *Server, d *Directive) error {
|
func parseTLS(srv *tlstunnel.Server, d *tlstunnel.Directive) error {
|
||||||
for _, child := range d.Children {
|
for _, child := range d.Children {
|
||||||
switch child.Name {
|
switch child.Name {
|
||||||
case "acme_ca":
|
case "acme_ca":
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package tlstunnel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package tlstunnel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
@ -16,9 +16,9 @@ type Server struct {
|
||||||
Listeners map[string]*Listener // indexed by listening address
|
Listeners map[string]*Listener // indexed by listening address
|
||||||
Frontends []*Frontend
|
Frontends []*Frontend
|
||||||
ManagedNames []string
|
ManagedNames []string
|
||||||
ACMEManager *certmagic.ACMEManager
|
ACMEManager *certmagic.ACMEManager
|
||||||
|
|
||||||
certmagic *certmagic.Config
|
certmagic *certmagic.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer() *Server {
|
func NewServer() *Server {
|
||||||
|
|
Loading…
Reference in New Issue