Use net.ErrClosed

This commit is contained in:
Simon Ser 2022-07-07 10:55:25 +02:00
parent bc53657f5d
commit bf12dd3871
2 changed files with 3 additions and 2 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module git.sr.ht/~emersion/tlstunnel module git.sr.ht/~emersion/tlstunnel
go 1.15 go 1.16
require ( require (
git.sr.ht/~emersion/go-scfg v0.0.0-20211215104734-c2c7a15d6c99 git.sr.ht/~emersion/go-scfg v0.0.0-20211215104734-c2c7a15d6c99

View File

@ -3,6 +3,7 @@ package tlstunnel
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -247,7 +248,7 @@ func (ln *Listener) UpdateFrom(new *Listener) *Listener {
func (ln *Listener) serve() error { func (ln *Listener) serve() error {
for { for {
conn, err := ln.netLn.Accept() conn, err := ln.netLn.Accept()
if err != nil && strings.Contains(err.Error(), "use of closed network connection") { if errors.Is(err, net.ErrClosed) {
// Listening socket has been closed by Stop() // Listening socket has been closed by Stop()
return nil return nil
} else if err != nil { } else if err != nil {