mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Update behaviour in QUIC listener handler
This commit is contained in:
parent
3dfa6d0cc9
commit
1e9a59edf9
1 changed files with 15 additions and 10 deletions
|
@ -3,6 +3,7 @@ package core
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
@ -77,18 +78,22 @@ func (l *linkQUIC) listen(ctx context.Context, url *url.URL, _ string) (net.List
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
qc, err := ql.Accept(ctx)
|
qc, err := ql.Accept(ctx)
|
||||||
if err != nil {
|
switch err {
|
||||||
|
case context.Canceled, context.DeadlineExceeded:
|
||||||
ql.Close()
|
ql.Close()
|
||||||
|
fallthrough
|
||||||
|
case quic.ErrServerClosed:
|
||||||
return
|
return
|
||||||
}
|
case nil:
|
||||||
qs, err := qc.AcceptStream(ctx)
|
qs, err := qc.AcceptStream(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ql.Close()
|
_ = qc.CloseWithError(1, fmt.Sprintf("stream error: %s", err))
|
||||||
return
|
continue
|
||||||
}
|
}
|
||||||
ch <- &linkQUICStream{
|
ch <- &linkQUICStream{
|
||||||
Connection: qc,
|
Connection: qc,
|
||||||
Stream: qs,
|
Stream: qs,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue