Use net.ErrClosed
This commit is contained in:
parent
bc53657f5d
commit
bf12dd3871
2
go.mod
2
go.mod
|
@ -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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue