mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-23 01:04:40 +07:00
fix: add DNS header to ResolveNetip req
This commit is contained in:
parent
7f5e4f8349
commit
f0f68ffb84
@ -8,9 +8,11 @@ package netutils
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/mzz2017/softwind/pkg/fastrand"
|
||||
"github.com/mzz2017/softwind/pool"
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
"golang.org/x/net/proxy"
|
||||
"math"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -53,7 +55,14 @@ func ResolveNetip(ctx context.Context, d proxy.Dialer, dns netip.AddrPort, host
|
||||
return nil, fmt.Errorf("only support to lookup A/AAAA record")
|
||||
}
|
||||
// Build DNS req.
|
||||
builder := dnsmessage.NewBuilder(nil, dnsmessage.Header{})
|
||||
builder := dnsmessage.NewBuilder(nil, dnsmessage.Header{
|
||||
ID: uint16(fastrand.Intn(math.MaxUint16 + 1)),
|
||||
Response: false,
|
||||
OpCode: 0,
|
||||
Truncated: false,
|
||||
RecursionDesired: true,
|
||||
Authoritative: false,
|
||||
})
|
||||
if err = builder.StartQuestions(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ func (c *ControlPlane) handlePkt(data []byte, src, dst netip.AddrPort, outboundI
|
||||
c.log.WithFields(logrus.Fields{
|
||||
"ipversions": ipversions,
|
||||
"l4protos": l4protos,
|
||||
}).Debugln("Choose DNS path")
|
||||
}).Traceln("Choose DNS path")
|
||||
// Get the min latency path.
|
||||
for _, ver := range ipversions {
|
||||
for _, proto := range l4protos {
|
||||
@ -208,7 +208,7 @@ func (c *ControlPlane) handlePkt(data []byte, src, dst netip.AddrPort, outboundI
|
||||
"ver": ver,
|
||||
"proto": proto,
|
||||
"outbound": outbound.Name,
|
||||
}).Debugln("Choice")
|
||||
}).Traceln("Choice")
|
||||
if bestDialer == nil || latency < bestLatency {
|
||||
bestDialer = d
|
||||
bestLatency = latency
|
||||
|
Loading…
Reference in New Issue
Block a user