mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-25 06:36:05 +03:00
parent
1447615f3a
commit
800b3bd3fe
@ -37,7 +37,7 @@ func (l *OutboundListener) Accept() (net.Conn, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close implement net.Listener.
|
// Close implements net.Listener.
|
||||||
func (l *OutboundListener) Close() error {
|
func (l *OutboundListener) Close() error {
|
||||||
common.Must(l.done.Close())
|
common.Must(l.done.Close())
|
||||||
L:
|
L:
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/xtls/xray-core/features/dns"
|
"github.com/xtls/xray-core/features/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// newFakeDNSSniffer Create a Fake DNS metadata sniffer
|
// newFakeDNSSniffer Creates a Fake DNS metadata sniffer
|
||||||
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) {
|
||||||
var fakeDNSEngine dns.FakeDNSEngine
|
var fakeDNSEngine dns.FakeDNSEngine
|
||||||
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
dns_feature "github.com/xtls/xray-core/features/dns"
|
dns_feature "github.com/xtls/xray-core/features/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fqdn normalize domain make sure it ends with '.'
|
// Fqdn normalizes domain make sure it ends with '.'
|
||||||
func Fqdn(domain string) string {
|
func Fqdn(domain string) string {
|
||||||
if len(domain) > 0 && strings.HasSuffix(domain, ".") {
|
if len(domain) > 0 && strings.HasSuffix(domain, ".") {
|
||||||
return domain
|
return domain
|
||||||
@ -163,7 +163,7 @@ func buildReqMsgs(domain string, option dns_feature.IPOption, reqIDGen func() ui
|
|||||||
return reqs
|
return reqs
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseResponse parse DNS answers from the returned payload
|
// parseResponse parses DNS answers from the returned payload
|
||||||
func parseResponse(payload []byte) (*IPRecord, error) {
|
func parseResponse(payload []byte) (*IPRecord, error) {
|
||||||
var parser dnsmessage.Parser
|
var parser dnsmessage.Parser
|
||||||
h, err := parser.Start(payload)
|
h, err := parser.Start(payload)
|
||||||
|
@ -92,7 +92,7 @@ func (fkdns *Holder) initialize(ipPoolCidr string, lruSize int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFakeIPForDomain check and generate a fake IP for a domain name
|
// GetFakeIPForDomain checks and generates a fake IP for a domain name
|
||||||
func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
|
func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
|
||||||
if v, ok := fkdns.domainToIP.Get(domain); ok {
|
if v, ok := fkdns.domainToIP.Get(domain); ok {
|
||||||
return []net.Address{v.(net.Address)}
|
return []net.Address{v.(net.Address)}
|
||||||
@ -123,7 +123,7 @@ func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
|
|||||||
return []net.Address{ip}
|
return []net.Address{ip}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDomainFromFakeDNS check if an IP is a fake IP and have corresponding domain name
|
// GetDomainFromFakeDNS checks if an IP is a fake IP and have corresponding domain name
|
||||||
func (fkdns *Holder) GetDomainFromFakeDNS(ip net.Address) string {
|
func (fkdns *Holder) GetDomainFromFakeDNS(ip net.Address) string {
|
||||||
if !ip.Family().IsIP() || !fkdns.ipRange.Contains(ip.IP()) {
|
if !ip.Family().IsIP() || !fkdns.ipRange.Contains(ip.IP()) {
|
||||||
return ""
|
return ""
|
||||||
|
@ -186,7 +186,7 @@ func (c *Client) Name() string {
|
|||||||
return c.server.Name()
|
return c.server.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryIP send DNS query to the name server with the client's IP.
|
// QueryIP sends DNS query to the name server with the client's IP.
|
||||||
func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) {
|
func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) {
|
||||||
ctx, cancel := context.WithTimeout(ctx, 4*time.Second)
|
ctx, cancel := context.WithTimeout(ctx, 4*time.Second)
|
||||||
ips, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache)
|
ips, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache)
|
||||||
|
Loading…
Reference in New Issue
Block a user