mirror of
https://git.sr.ht/~emersion/tlstunnel
synced 2024-11-19 15:53:50 +01:00
Silence connection errors by default
Often times the connection-level errors clutter the logs, for instance with failed TLS handshakes or unknown hostname.
This commit is contained in:
parent
bb3c49e3b5
commit
3fd3471799
@ -17,6 +17,8 @@ import (
|
|||||||
var (
|
var (
|
||||||
configPath = "config"
|
configPath = "config"
|
||||||
certDataPath = ""
|
certDataPath = ""
|
||||||
|
|
||||||
|
debug = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func newServer() (*tlstunnel.Server, error) {
|
func newServer() (*tlstunnel.Server, error) {
|
||||||
@ -26,6 +28,7 @@ func newServer() (*tlstunnel.Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
srv := tlstunnel.NewServer()
|
srv := tlstunnel.NewServer()
|
||||||
|
srv.Debug = debug
|
||||||
|
|
||||||
loggerCfg := zap.Config{
|
loggerCfg := zap.Config{
|
||||||
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
|
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
|
||||||
@ -68,6 +71,7 @@ func bumpOpenedFileLimit() error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
flag.StringVar(&configPath, "config", configPath, "path to configuration file")
|
||||||
|
flag.BoolVar(&debug, "debug", false, "enable debug logging")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if err := bumpOpenedFileLimit(); err != nil {
|
if err := bumpOpenedFileLimit(); err != nil {
|
||||||
|
@ -38,6 +38,7 @@ func newACMECache() *acmeCache {
|
|||||||
type Server struct {
|
type Server struct {
|
||||||
Listeners map[string]*Listener // indexed by listening address
|
Listeners map[string]*Listener // indexed by listening address
|
||||||
Frontends []*Frontend
|
Frontends []*Frontend
|
||||||
|
Debug bool
|
||||||
|
|
||||||
ManagedNames []string
|
ManagedNames []string
|
||||||
UnmanagedCerts []tls.Certificate
|
UnmanagedCerts []tls.Certificate
|
||||||
@ -256,8 +257,10 @@ func (ln *Listener) serve() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := ln.handle(conn); err != nil {
|
err := ln.handle(conn)
|
||||||
log.Printf("listener %q: %v", ln.Address, err)
|
srv := ln.atomic.Load().(*listenerHandles).Server
|
||||||
|
if err != nil && srv.Debug {
|
||||||
|
log.Printf("listener %q: connection %q: %v", ln.Address, conn.RemoteAddr(), err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user