mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-03 02:38:40 +00:00
Add skipFakeDNS to inbound session
This commit is contained in:
parent
e316cd4c66
commit
14aa152a8a
3 changed files with 19 additions and 4 deletions
|
@ -96,6 +96,12 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||
return newError("invalid outbound")
|
||||
}
|
||||
|
||||
fakeDNS := true
|
||||
inbound := session.InboundFromContext(ctx)
|
||||
if inbound != nil && inbound.SkipFakeDNS {
|
||||
fakeDNS = false
|
||||
}
|
||||
|
||||
srcNetwork := outbound.Target.Network
|
||||
|
||||
dest := outbound.Target
|
||||
|
@ -171,7 +177,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||
if !h.isOwnLink(ctx) {
|
||||
isIPQuery, domain, id, qType := parseIPQuery(b.Bytes())
|
||||
if isIPQuery {
|
||||
go h.handleIPQuery(id, qType, domain, writer)
|
||||
go h.handleIPQuery(id, qType, domain, writer, fakeDNS)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +214,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, writer dns_proto.MessageWriter) {
|
||||
func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, writer dns_proto.MessageWriter, fakedns bool) {
|
||||
var ips []net.IP
|
||||
var err error
|
||||
|
||||
|
@ -219,13 +225,13 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string,
|
|||
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
IPv4Enable: true,
|
||||
IPv6Enable: false,
|
||||
FakeEnable: true,
|
||||
FakeEnable: fakedns,
|
||||
})
|
||||
case dnsmessage.TypeAAAA:
|
||||
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
||||
IPv4Enable: false,
|
||||
IPv6Enable: true,
|
||||
FakeEnable: true,
|
||||
FakeEnable: fakedns,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue