From 4bb1d822afb57d14bf479661d3a6cf3d2426efa7 Mon Sep 17 00:00:00 2001 From: v2ray Date: Sat, 6 Feb 2016 18:03:42 +0100 Subject: [PATCH] prefer Network over string --- app/router/rules/condition.go | 2 +- common/net/destination.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/router/rules/condition.go b/app/router/rules/condition.go index c8effc86..5dc72b35 100644 --- a/app/router/rules/condition.go +++ b/app/router/rules/condition.go @@ -165,5 +165,5 @@ func NewNetworkMatcher(network *v2net.NetworkList) *NetworkMatcher { } func (this *NetworkMatcher) Apply(dest v2net.Destination) bool { - return this.network.HasNetwork(v2net.Network(dest.Network())) + return this.network.HasNetwork(dest.Network()) } diff --git a/common/net/destination.go b/common/net/destination.go index 7c8d2437..0641bc7b 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -2,7 +2,7 @@ package net // Destination represents a network destination including address and protocol (tcp / udp). type Destination interface { - Network() string // Protocol of communication (tcp / udp) + Network() Network // Protocol of communication (tcp / udp) Address() Address // Address of destination Port() Port String() string // String representation of the destination @@ -28,8 +28,8 @@ type tcpDestination struct { port Port } -func (dest *tcpDestination) Network() string { - return "tcp" +func (dest *tcpDestination) Network() Network { + return TCPNetwork } func (dest *tcpDestination) Address() Address { @@ -74,8 +74,8 @@ type udpDestination struct { port Port } -func (dest *udpDestination) Network() string { - return "udp" +func (dest *udpDestination) Network() Network { + return UDPNetwork } func (dest *udpDestination) Address() Address {