mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-05 03:16:03 +03:00
Add skipFakeDNS to inbound session
This commit is contained in:
parent
e316cd4c66
commit
14aa152a8a
@ -53,6 +53,8 @@ type Inbound struct {
|
|||||||
Uid uint32
|
Uid uint32
|
||||||
// SagerNet private: AppStatus is the android app's status for the inbound connection
|
// SagerNet private: AppStatus is the android app's status for the inbound connection
|
||||||
AppStatus []string
|
AppStatus []string
|
||||||
|
// SagerNet private
|
||||||
|
SkipFakeDNS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Outbound is the metadata of an outbound connection.
|
// Outbound is the metadata of an outbound connection.
|
||||||
|
@ -137,6 +137,13 @@ func (ctx *Context) GetAppStatus() []string {
|
|||||||
return ctx.Inbound.AppStatus
|
return ctx.Inbound.AppStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx Context) GetSkipFakeDNS() bool {
|
||||||
|
if ctx.Inbound == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return ctx.Inbound.SkipFakeDNS
|
||||||
|
}
|
||||||
|
|
||||||
// AsRoutingContext creates a context from context.context with session info.
|
// AsRoutingContext creates a context from context.context with session info.
|
||||||
func AsRoutingContext(ctx context.Context) routing.Context {
|
func AsRoutingContext(ctx context.Context) routing.Context {
|
||||||
return &Context{
|
return &Context{
|
||||||
|
@ -96,6 +96,12 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||||||
return newError("invalid outbound")
|
return newError("invalid outbound")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fakeDNS := true
|
||||||
|
inbound := session.InboundFromContext(ctx)
|
||||||
|
if inbound != nil && inbound.SkipFakeDNS {
|
||||||
|
fakeDNS = false
|
||||||
|
}
|
||||||
|
|
||||||
srcNetwork := outbound.Target.Network
|
srcNetwork := outbound.Target.Network
|
||||||
|
|
||||||
dest := outbound.Target
|
dest := outbound.Target
|
||||||
@ -171,7 +177,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||||||
if !h.isOwnLink(ctx) {
|
if !h.isOwnLink(ctx) {
|
||||||
isIPQuery, domain, id, qType := parseIPQuery(b.Bytes())
|
isIPQuery, domain, id, qType := parseIPQuery(b.Bytes())
|
||||||
if isIPQuery {
|
if isIPQuery {
|
||||||
go h.handleIPQuery(id, qType, domain, writer)
|
go h.handleIPQuery(id, qType, domain, writer, fakeDNS)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +214,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet.
|
|||||||
return nil
|
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 ips []net.IP
|
||||||
var err error
|
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{
|
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
||||||
IPv4Enable: true,
|
IPv4Enable: true,
|
||||||
IPv6Enable: false,
|
IPv6Enable: false,
|
||||||
FakeEnable: true,
|
FakeEnable: fakedns,
|
||||||
})
|
})
|
||||||
case dnsmessage.TypeAAAA:
|
case dnsmessage.TypeAAAA:
|
||||||
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
ips, err = h.client.LookupIP(domain, dns.IPOption{
|
||||||
IPv4Enable: false,
|
IPv4Enable: false,
|
||||||
IPv6Enable: true,
|
IPv6Enable: true,
|
||||||
FakeEnable: true,
|
FakeEnable: fakedns,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user