Skip to content

Commit

Permalink
DNS: Support per-client configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vigilans committed Sep 12, 2022
1 parent 2e0ea88 commit e393017
Show file tree
Hide file tree
Showing 7 changed files with 942 additions and 492 deletions.
22 changes: 22 additions & 0 deletions app/dns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
package dns

import (
"golang.org/x/net/dns/dnsmessage"

"github.com/v2fly/v2ray-core/v5/common/net"
"github.com/v2fly/v2ray-core/v5/common/strmatcher"
"github.com/v2fly/v2ray-core/v5/common/uuid"
"github.com/v2fly/v2ray-core/v5/features/dns"
)

var typeMap = map[DomainMatchingType]strmatcher.Type{
Expand Down Expand Up @@ -60,6 +63,25 @@ func toNetIP(addrs []net.Address) ([]net.IP, error) {
return ips, nil
}

func toIPOption(s QueryStrategy) dns.IPOption {
return dns.IPOption{
IPv4Enable: s == QueryStrategy_USE_IP || s == QueryStrategy_USE_IP4,
IPv6Enable: s == QueryStrategy_USE_IP || s == QueryStrategy_USE_IP6,
FakeEnable: false,
}
}

func toReqTypes(option dns.IPOption) []dnsmessage.Type {
var reqTypes []dnsmessage.Type
if option.IPv4Enable {
reqTypes = append(reqTypes, dnsmessage.TypeA)
}
if option.IPv6Enable {
reqTypes = append(reqTypes, dnsmessage.TypeAAAA)
}
return reqTypes
}

func generateRandomTag() string {
id := uuid.New()
return "v2ray.system." + id.String()
Expand Down
Loading

0 comments on commit e393017

Please sign in to comment.