Support direct control of the server listener

This commit is contained in:
Christian Weichel 2021-04-13 13:15:41 +00:00
parent 92d90be68a
commit 40f4251371
2 changed files with 7 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
@ -30,6 +31,8 @@ type Config struct {
Reverse bool
KeepAlive time.Duration
TLS TLSConfig
Listener net.Listener
}
// Server respresent a chisel service

View file

@ -23,6 +23,10 @@ type TLSConfig struct {
}
func (s *Server) listener(host, port string) (net.Listener, error) {
if s.config.Listener != nil {
return s.config.Listener, nil
}
hasDomains := len(s.config.TLS.Domains) > 0
hasKeyCert := s.config.TLS.Key != "" && s.config.TLS.Cert != ""
if hasDomains && hasKeyCert {