introduce address family in v2net

This commit is contained in:
v2ray committed 2016-08-14 18:14:12 +02:00
1 parent a9d583b92f
commit 4419f1e3d6
15 files changed
+73 -78

No files matched your search

+4 -4
View File
@@ -73,7 +73,7 @@ func NewPlainDomainMatcher(pattern string) *PlainDomainMatcher {
}
func (this *PlainDomainMatcher) Apply(dest v2net.Destination) bool {
if !dest.Address().IsDomain() {
if !dest.Address().Family().IsDomain() {
return false
}
domain := dest.Address().Domain()
@@ -95,7 +95,7 @@ func NewRegexpDomainMatcher(pattern string) (*RegexpDomainMatcher, error) {
}
func (this *RegexpDomainMatcher) Apply(dest v2net.Destination) bool {
if !dest.Address().IsDomain() {
if !dest.Address().Family().IsDomain() {
return false
}
domain := dest.Address().Domain()
@@ -117,7 +117,7 @@ func NewCIDRMatcher(ipnet string) (*CIDRMatcher, error) {
}
func (this *CIDRMatcher) Apply(dest v2net.Destination) bool {
if !dest.Address().IsIPv4() && !dest.Address().IsIPv6() {
if !dest.Address().Family().Either(v2net.AddressFamilyIPv4, v2net.AddressFamilyIPv6) {
return false
}
return this.cidr.Contains(dest.Address().IP())
@@ -134,7 +134,7 @@ func NewIPv4Matcher(ipnet *v2net.IPNet) *IPv4Matcher {
}
func (this *IPv4Matcher) Apply(dest v2net.Destination) bool {
if !dest.Address().IsIPv4() {
if !dest.Address().Family().Either(v2net.AddressFamilyIPv4) {
return false
}
return this.ipv4net.Contains(dest.Address().IP())
+1 -1
View File
@@ -64,7 +64,7 @@ func (this *Router) takeDetourWithoutCache(dest v2net.Destination) (string, erro
return rule.Tag, nil
}
}
if this.config.DomainStrategy == UseIPIfNonMatch && dest.Address().IsDomain() {
if this.config.DomainStrategy == UseIPIfNonMatch && dest.Address().Family().IsDomain() {
log.Info("Router: Looking up IP for ", dest)
ipDests := this.ResolveIP(dest)
if ipDests != nil {