mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-14 05:04:12 +08:00
Merge aa39663c369dad2929d4cdcb76c5a9f976e0950a into 72170d8b6be0d83af1624f6d31b81cf73f1a189c
This commit is contained in:
commit
76ad74cc35
@ -407,18 +407,6 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw
|
|||||||
func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
|
func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
|
||||||
outbounds := session.OutboundsFromContext(ctx)
|
outbounds := session.OutboundsFromContext(ctx)
|
||||||
ob := outbounds[len(outbounds)-1]
|
ob := outbounds[len(outbounds)-1]
|
||||||
if hosts, ok := d.dns.(dns.HostsLookup); ok && destination.Address.Family().IsDomain() {
|
|
||||||
proxied := hosts.LookupHosts(ob.Target.String())
|
|
||||||
if proxied != nil {
|
|
||||||
ro := ob.RouteTarget == destination
|
|
||||||
destination.Address = *proxied
|
|
||||||
if ro {
|
|
||||||
ob.RouteTarget = destination
|
|
||||||
} else {
|
|
||||||
ob.Target = destination
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var handler outbound.Handler
|
var handler outbound.Handler
|
||||||
|
|
||||||
|
@ -243,22 +243,6 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er
|
|||||||
return nil, 0, dns.ErrEmptyResponse
|
return nil, 0, dns.ErrEmptyResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupHosts implements dns.HostsLookup.
|
|
||||||
func (s *DNS) LookupHosts(domain string) *net.Address {
|
|
||||||
domain = strings.TrimSuffix(domain, ".")
|
|
||||||
if domain == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// Normalize the FQDN form query
|
|
||||||
addrs := s.hosts.Lookup(domain, *s.ipOption)
|
|
||||||
if len(addrs) > 0 {
|
|
||||||
errors.LogInfo(s.ctx, "domain replaced: ", domain, " -> ", addrs[0].String())
|
|
||||||
return &addrs[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DNS) sortClients(domain string) []*Client {
|
func (s *DNS) sortClients(domain string) []*Client {
|
||||||
clients := make([]*Client, 0, len(s.clients))
|
clients := make([]*Client, 0, len(s.clients))
|
||||||
clientUsed := make([]bool, len(s.clients))
|
clientUsed := make([]bool, len(s.clients))
|
||||||
|
@ -24,10 +24,6 @@ type Client interface {
|
|||||||
LookupIP(domain string, option IPOption) ([]net.IP, uint32, error)
|
LookupIP(domain string, option IPOption) ([]net.IP, uint32, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type HostsLookup interface {
|
|
||||||
LookupHosts(domain string) *net.Address
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
|
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
|
||||||
//
|
//
|
||||||
// xray:api:beta
|
// xray:api:beta
|
||||||
|
Loading…
x
Reference in New Issue
Block a user