Add Fake DNS support (#309)

Co-authored-by: Xiaokang Wang <xiaokangwang@outlook.com>
Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
Co-authored-by: kslr <kslrwang@gmail.com>
This commit is contained in:
yuhan6665 2021-03-06 23:39:50 -05:00 committed by GitHub
parent db32ce6fd9
commit f50eff5ebb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1351 additions and 301 deletions

View file

@ -2,6 +2,7 @@ package dns
import (
"encoding/binary"
"strings"
"time"
"github.com/xtls/xray-core/common"
@ -13,7 +14,7 @@ import (
// Fqdn normalize domain make sure it ends with '.'
func Fqdn(domain string) string {
if len(domain) > 0 && domain[len(domain)-1] == '.' {
if len(domain) > 0 && strings.HasSuffix(domain, ".") {
return domain
}
return domain + "."
@ -112,7 +113,7 @@ func genEDNS0Options(clientIP net.IP) *dnsmessage.Resource {
return opt
}
func buildReqMsgs(domain string, option IPOption, reqIDGen func() uint16, reqOpts *dnsmessage.Resource) []*dnsRequest {
func buildReqMsgs(domain string, option dns_feature.IPOption, reqIDGen func() uint16, reqOpts *dnsmessage.Resource) []*dnsRequest {
qA := dnsmessage.Question{
Name: dnsmessage.MustNewName(domain),
Type: dnsmessage.TypeA,