Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix QUIC stream close #21

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
/vendor/
.DS_Store
161 changes: 81 additions & 80 deletions client.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions client_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dns

import "net/netip"

type QueryOptions struct {
Strategy DomainStrategy
DisableCache bool
RewriteTTL *uint32
ClientSubnet netip.Prefix
}
8 changes: 6 additions & 2 deletions dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func (d *DialerWrapper) DialContext(ctx context.Context, network string, destina
if destination.IsIP() {
return d.dialer.DialContext(ctx, network, destination)
}
addresses, err := d.client.Lookup(ctx, d.transport, destination.Fqdn, d.strategy)
addresses, err := d.client.Lookup(ctx, d.transport, destination.Fqdn, QueryOptions{
Strategy: d.strategy,
})
if err != nil {
return nil, err
}
Expand All @@ -36,7 +38,9 @@ func (d *DialerWrapper) ListenPacket(ctx context.Context, destination M.Socksadd
if destination.IsIP() {
return d.dialer.ListenPacket(ctx, destination)
}
addresses, err := d.client.Lookup(ctx, d.transport, destination.Fqdn, d.strategy)
addresses, err := d.client.Lookup(ctx, d.transport, destination.Fqdn, QueryOptions{
Strategy: d.strategy,
})
if err != nil {
return nil, err
}
Expand Down
56 changes: 0 additions & 56 deletions extensions.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/miekg/dns v1.1.62
github.com/sagernet/quic-go v0.47.0-beta.2
github.com/sagernet/sing v0.5.0
github.com/sagernet/sing v0.6.0-alpha.10
github.com/stretchr/testify v1.9.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/sagernet/quic-go v0.47.0-beta.2 h1:1tCGWFOSaXIeuQaHrwOMJIYvlupjTcaVInGQw5ArULU=
github.com/sagernet/quic-go v0.47.0-beta.2/go.mod h1:bLVKvElSEMNv7pu7SZHscW02TYigzQ5lQu3Nh4wNh8Q=
github.com/sagernet/sing v0.5.0 h1:soo2wVwLcieKWWKIksFNK6CCAojUgAppqQVwyRYGkEM=
github.com/sagernet/sing v0.5.0/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/sagernet/sing v0.6.0-alpha.10 h1:gIUiFof6SDDcAg3m3pUOshOPZBLC7z9VCgDt4Tzs24g=
github.com/sagernet/sing v0.6.0-alpha.10/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
Expand Down
1 change: 1 addition & 0 deletions quic/transport_quic.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func (t *Transport) exchange(ctx context.Context, message *mDNS.Msg, conn quic.C
if err != nil {
return nil, err
}
_ = stream.Close()
buffer.Reset()
_, err = buffer.ReadFullFrom(stream, 2)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func TestTransports(t *testing.T) {
client := dns.NewClient(dns.ClientOptions{
Logger: logger.NOP(),
})
addresses, err := client.Lookup(context.Background(), transport, "cloudflare.com", dns.DomainStrategyAsIS)
addresses, err := client.Lookup(context.Background(), transport, "cloudflare.com", dns.QueryOptions{
Strategy: dns.DomainStrategyUseIPv4,
})
require.NoError(t, err)
require.NotEmpty(t, addresses)
})
Expand Down
Loading