fix(resolvers): QUIC: close as soon as the writing is done
All checks were successful
continuous-integration/drone/push Build is passing

This is required by RFC 9250, and would break some requests when done wrong

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2023-03-09 23:39:00 +01:00
parent 58fa7af2ea
commit 27ece358c6
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
2 changed files with 21 additions and 6 deletions

View file

@ -65,6 +65,11 @@ func (resolver *QUICResolver) LookUp(msg *dns.Msg) (resp util.Response, err erro
return resp, fmt.Errorf("doq: quic stream write: %w", err)
}
err = stream.Close()
if err != nil {
return resp, fmt.Errorf("doq: quic stream close: %w", err)
}
resolver.opts.Logger.Debug("quic: reading stream")
fullRes, err := io.ReadAll(stream)
@ -83,11 +88,6 @@ func (resolver *QUICResolver) LookUp(msg *dns.Msg) (resp util.Response, err erro
resolver.opts.Logger.Debug("quic: closing stream")
err = stream.Close()
if err != nil {
return resp, fmt.Errorf("doq: quic stream close: %w", err)
}
resp.DNS = &dns.Msg{}
resolver.opts.Logger.Debug("quic: unpacking response")

View file

@ -22,7 +22,7 @@ func TestQuic(t *testing.T) {
opts *util.Options
}{
{
"Valid",
"Valid, AdGuard",
&util.Options{
QUIC: true,
Logger: util.InitLogger(0),
@ -35,6 +35,21 @@ func TestQuic(t *testing.T) {
},
},
},
{
"Valid, Froth",
&util.Options{
QUIC: true,
Logger: util.InitLogger(0),
Request: util.Request{
Server: "dns.froth.zone",
Type: dns.TypeA,
Name: "git.freecumextremist.com",
Port: 853,
Timeout: 750 * time.Millisecond,
Retries: 3,
},
},
},
{
"Bad domain",
&util.Options{