update context functions

This commit is contained in:
Darien Raymond 2017-02-09 22:49:38 +01:00
parent d270a99d4f
commit d04d92c187
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
15 changed files with 122 additions and 98 deletions

View File

@ -53,7 +53,7 @@ func (v *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
panic("Dispatcher: Invalid destination.")
}
ctx = proxy.ContextWithDestination(ctx, destination)
ctx = proxy.ContextWithTarget(ctx, destination)
if v.router != nil {
if tag, err := v.router.TakeDetour(ctx); err == nil {

View File

@ -44,13 +44,13 @@ func (w *tcpWorker) callback(conn internet.Connection) {
if w.recvOrigDest {
dest := tcp.GetOriginalDestination(conn)
if dest.IsValid() {
ctx = proxy.ContextWithOriginalDestination(ctx, dest)
ctx = proxy.ContextWithOriginalTarget(ctx, dest)
}
}
if len(w.tag) > 0 {
ctx = proxy.ContextWithInboundTag(ctx, w.tag)
}
ctx = proxy.ContextWithInboundDestination(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithSource(ctx, v2net.DestinationFromAddr(conn.RemoteAddr()))
if err := w.proxy.Process(ctx, v2net.Network_TCP, conn, w.dispatcher); err != nil {
log.Info("Proxyman|TCPWorker: Connection ends with ", err)
@ -205,13 +205,13 @@ func (w *udpWorker) callback(b *buf.Buffer, source v2net.Destination, originalDe
ctx, cancel := context.WithCancel(ctx)
conn.cancel = cancel
if originalDest.IsValid() {
ctx = proxy.ContextWithOriginalDestination(ctx, originalDest)
ctx = proxy.ContextWithOriginalTarget(ctx, originalDest)
}
if len(w.tag) > 0 {
ctx = proxy.ContextWithInboundTag(ctx, w.tag)
}
ctx = proxy.ContextWithSource(ctx, source)
ctx = proxy.ContextWithInboundDestination(ctx, v2net.UDPDestination(w.address, w.port))
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.UDPDestination(w.address, w.port))
if err := w.proxy.Process(ctx, v2net.Network_UDP, conn, w.dispatcher); err != nil {
log.Info("Proxyman|UDPWorker: Connection ends with ", err)
}

View File

@ -81,7 +81,7 @@ func (h *Handler) Dial(ctx context.Context, dest v2net.Destination) (internet.Co
handler := h.outboundManager.GetHandler(tag)
if handler != nil {
log.Info("Proxyman|OutboundHandler: Proxying to ", tag)
ctx = proxy.ContextWithDestination(ctx, dest)
ctx = proxy.ContextWithTarget(ctx, dest)
stream := ray.NewRay(ctx)
go handler.Dispatch(ctx, stream)
return NewConnection(stream), nil

View File

@ -76,7 +76,11 @@ func NewPlainDomainMatcher(pattern string) *PlainDomainMatcher {
}
func (v *PlainDomainMatcher) Apply(ctx context.Context) bool {
dest := proxy.DestinationFromContext(ctx)
dest, ok := proxy.TargetFromContext(ctx)
if !ok {
return false
}
if !dest.Address.Family().IsDomain() {
return false
}
@ -99,7 +103,10 @@ func NewRegexpDomainMatcher(pattern string) (*RegexpDomainMatcher, error) {
}
func (v *RegexpDomainMatcher) Apply(ctx context.Context) bool {
dest := proxy.DestinationFromContext(ctx)
dest, ok := proxy.TargetFromContext(ctx)
if !ok {
return false
}
if !dest.Address.Family().IsDomain() {
return false
}
@ -135,13 +142,14 @@ func (v *CIDRMatcher) Apply(ctx context.Context) bool {
}
var dest v2net.Destination
var ok bool
if v.onSource {
dest = proxy.SourceFromContext(ctx)
dest, ok = proxy.SourceFromContext(ctx)
} else {
dest = proxy.DestinationFromContext(ctx)
dest, ok = proxy.TargetFromContext(ctx)
}
if dest.IsValid() && dest.Address.Family().IsIPv6() {
if ok && dest.Address.Family().IsIPv6() {
ips = append(ips, dest.Address.IP())
}
@ -177,13 +185,14 @@ func (v *IPv4Matcher) Apply(ctx context.Context) bool {
}
var dest v2net.Destination
var ok bool
if v.onSource {
dest = proxy.SourceFromContext(ctx)
dest, ok = proxy.SourceFromContext(ctx)
} else {
dest = proxy.DestinationFromContext(ctx)
dest, ok = proxy.TargetFromContext(ctx)
}
if dest.IsValid() && dest.Address.Family().IsIPv4() {
if ok && dest.Address.Family().IsIPv4() {
ips = append(ips, dest.Address.IP())
}
@ -206,7 +215,10 @@ func NewPortMatcher(portRange v2net.PortRange) *PortMatcher {
}
func (v *PortMatcher) Apply(ctx context.Context) bool {
dest := proxy.DestinationFromContext(ctx)
dest, ok := proxy.TargetFromContext(ctx)
if !ok {
return false
}
return v.port.Contains(dest.Port)
}
@ -221,7 +233,10 @@ func NewNetworkMatcher(network *v2net.NetworkList) *NetworkMatcher {
}
func (v *NetworkMatcher) Apply(ctx context.Context) bool {
dest := proxy.DestinationFromContext(ctx)
dest, ok := proxy.TargetFromContext(ctx)
if !ok {
return false
}
return v.network.HasNetwork(dest.Network)
}
@ -259,8 +274,8 @@ func NewInboundTagMatcher(tags []string) *InboundTagMatcher {
}
func (v *InboundTagMatcher) Apply(ctx context.Context) bool {
tag := proxy.InboundTagFromContext(ctx)
if len(tag) == 0 {
tag, ok := proxy.InboundTagFromContext(ctx)
if !ok {
return false
}

View File

@ -70,7 +70,11 @@ func (v *Router) TakeDetour(ctx context.Context) (string, error) {
}
}
dest := proxy.DestinationFromContext(ctx)
dest, ok := proxy.TargetFromContext(ctx)
if !ok {
return "", ErrNoRuleApplicable
}
if v.domainStrategy == Config_IpIfNonMatch && dest.Address.Family().IsDomain() {
log.Info("Router: Looking up IP for ", dest)
ipDests := v.resolveIP(dest)

View File

@ -41,7 +41,7 @@ func TestSimpleRouter(t *testing.T) {
r := FromSpace(space)
ctx = proxy.ContextWithDestination(ctx, net.TCPDestination(net.DomainAddress("v2ray.com"), 80))
ctx = proxy.ContextWithTarget(ctx, net.TCPDestination(net.DomainAddress("v2ray.com"), 80))
tag, err := r.TakeDetour(ctx)
assert.Error(err).IsNil()
assert.String(tag).Equals("test")

View File

@ -10,9 +10,9 @@ type key int
const (
sourceKey key = iota
destinationKey
originalDestinationKey
inboundDestinationKey
targetKey
originalTargetKey
inboundEntryPointKey
inboundTagKey
resolvedIPsKey
)
@ -21,60 +21,45 @@ func ContextWithSource(ctx context.Context, src net.Destination) context.Context
return context.WithValue(ctx, sourceKey, src)
}
func SourceFromContext(ctx context.Context) net.Destination {
v := ctx.Value(sourceKey)
if v == nil {
return net.Destination{}
}
return v.(net.Destination)
func SourceFromContext(ctx context.Context) (net.Destination, bool) {
v, ok := ctx.Value(sourceKey).(net.Destination)
return v, ok
}
func ContextWithOriginalDestination(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, originalDestinationKey, dest)
func ContextWithOriginalTarget(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, originalTargetKey, dest)
}
func OriginalDestinationFromContext(ctx context.Context) net.Destination {
v := ctx.Value(originalDestinationKey)
if v == nil {
return net.Destination{}
}
return v.(net.Destination)
func OriginalTargetFromContext(ctx context.Context) (net.Destination, bool) {
v, ok := ctx.Value(originalTargetKey).(net.Destination)
return v, ok
}
func ContextWithDestination(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, destinationKey, dest)
func ContextWithTarget(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, targetKey, dest)
}
func DestinationFromContext(ctx context.Context) net.Destination {
v := ctx.Value(destinationKey)
if v == nil {
return net.Destination{}
}
return v.(net.Destination)
func TargetFromContext(ctx context.Context) (net.Destination, bool) {
v, ok := ctx.Value(targetKey).(net.Destination)
return v, ok
}
func ContextWithInboundDestination(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, inboundDestinationKey, dest)
func ContextWithInboundEntryPoint(ctx context.Context, dest net.Destination) context.Context {
return context.WithValue(ctx, inboundEntryPointKey, dest)
}
func InboundDestinationFromContext(ctx context.Context) net.Destination {
v := ctx.Value(inboundDestinationKey)
if v == nil {
return net.Destination{}
}
return v.(net.Destination)
func InboundEntryPointFromContext(ctx context.Context) (net.Destination, bool) {
v, ok := ctx.Value(inboundEntryPointKey).(net.Destination)
return v, ok
}
func ContextWithInboundTag(ctx context.Context, tag string) context.Context {
return context.WithValue(ctx, inboundTagKey, tag)
}
func InboundTagFromContext(ctx context.Context) string {
v := ctx.Value(inboundTagKey)
if v == nil {
return ""
}
return v.(string)
func InboundTagFromContext(ctx context.Context) (string, bool) {
v, ok := ctx.Value(inboundTagKey).(string)
return v, ok
}
func ContextWithResolveIPs(ctx context.Context, ips []net.Address) context.Context {

View File

@ -52,7 +52,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
Port: d.port,
}
if d.config.FollowRedirect {
if origDest := proxy.OriginalDestinationFromContext(ctx); origDest.IsValid() {
if origDest, ok := proxy.OriginalTargetFromContext(ctx); ok {
dest = origDest
}
}

View File

@ -74,7 +74,7 @@ func (v *Handler) ResolveIP(destination net.Destination) net.Destination {
}
func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dialer proxy.Dialer) error {
destination := proxy.DestinationFromContext(ctx)
destination, _ := proxy.TargetFromContext(ctx)
if v.destOverride != nil {
server := v.destOverride.Server
destination = net.Destination{

View File

@ -2,10 +2,9 @@ package shadowsocks
import (
"context"
"time"
"errors"
"runtime"
"time"
"v2ray.com/core/app/log"
"v2ray.com/core/common"
@ -40,7 +39,10 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
// Process implements OutboundHandler.Process().
func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, dialer proxy.Dialer) error {
destination := proxy.DestinationFromContext(ctx)
destination, ok := proxy.TargetFromContext(ctx)
if !ok {
return errors.New("Shadowsocks|Client: Target not specified.")
}
network := destination.Network
var server *protocol.ServerSpec

View File

@ -75,7 +75,6 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet
func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection, dispatcher dispatcher.Interface) error {
udpServer := udp.NewDispatcher(dispatcher)
source := proxy.SourceFromContext(ctx)
reader := buf.NewReader(conn)
for {
@ -86,8 +85,10 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
request, data, err := DecodeUDPPacket(v.user, payload)
if err != nil {
log.Info("Shadowsocks|Server: Skipping invalid UDP packet from: ", source, ": ", err)
log.Access(source, "", log.AccessRejected, err)
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Info("Shadowsocks|Server: Skipping invalid UDP packet from: ", source, ": ", err)
log.Access(source, "", log.AccessRejected, err)
}
payload.Release()
continue
}
@ -105,7 +106,9 @@ func (v *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection
}
dest := request.Destination()
log.Access(source, dest, log.AccessAccepted, "")
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Access(source, dest, log.AccessAccepted, "")
}
log.Info("Shadowsocks|Server: Tunnelling request to ", dest)
ctx = protocol.ContextWithUser(ctx, request.User)

View File

@ -2,7 +2,7 @@ package socks
import (
"context"
"errors"
"runtime"
"time"
@ -35,7 +35,10 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) {
}
func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy.Dialer) error {
destination := proxy.DestinationFromContext(ctx)
destination, ok := proxy.TargetFromContext(ctx)
if !ok {
return errors.New("Socks|Client: Target not specified.")
}
var server *protocol.ServerSpec
var conn internet.Connection

View File

@ -65,16 +65,20 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa
conn.SetReadDeadline(time.Now().Add(time.Second * 8))
reader := bufio.NewReader(conn)
inboundDest := proxy.InboundDestinationFromContext(ctx)
inboundDest, ok := proxy.InboundEntryPointFromContext(ctx)
if !ok {
return errors.New("Socks|Server: inbound entry point not specified.")
}
session := &ServerSession{
config: s.config,
port: inboundDest.Port,
}
source := proxy.SourceFromContext(ctx)
request, err := session.Handshake(reader, conn)
if err != nil {
log.Access(source, "", log.AccessRejected, err)
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Access(source, "", log.AccessRejected, err)
}
log.Info("Socks|Server: Failed to read request: ", err)
return err
}
@ -83,7 +87,9 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa
if request.Command == protocol.RequestCommandTCP {
dest := request.Destination()
log.Info("Socks|Server: TCP Connect request to ", dest)
log.Access(source, dest, log.AccessAccepted, "")
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Access(source, dest, log.AccessAccepted, "")
}
return s.transport(ctx, reader, conn, dest, dispatcher)
}
@ -155,8 +161,9 @@ func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ
func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, dispatcher dispatcher.Interface) error {
udpServer := udp.NewDispatcher(dispatcher)
source := proxy.SourceFromContext(ctx)
log.Info("Socks|Server: Client UDP connection from ", source)
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Info("Socks|Server: Client UDP connection from ", source)
}
reader := buf.NewReader(conn)
for {
@ -176,7 +183,9 @@ func (v *Server) handleUDPPayload(ctx context.Context, conn internet.Connection,
}
log.Info("Socks: Send packet to ", request.Destination(), " with ", len(data), " bytes")
log.Access(source, request.Destination, log.AccessAccepted, "")
if source, ok := proxy.SourceFromContext(ctx); ok {
log.Access(source, request.Destination, log.AccessAccepted, "")
}
dataBuf := buf.NewSmall()
dataBuf.Append(data)

View File

@ -67,7 +67,10 @@ func (v *VMessOutboundHandler) Process(ctx context.Context, outboundRay ray.Outb
}
defer conn.Close()
target := proxy.DestinationFromContext(ctx)
target, ok := proxy.TargetFromContext(ctx)
if !ok {
return errors.New("VMess|Outbound: Target not specified.")
}
log.Info("VMess|Outbound: Tunneling request to ", target, " via ", rec.Destination())
command := protocol.RequestCommandTCP

View File

@ -30,12 +30,12 @@ func TestChinaIPJson(t *testing.T) {
assert.String(rule.Tag).Equals("x")
cond, err := rule.BuildCondition()
assert.Error(err).IsNil()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("121.14.1.189"), 80)))).IsTrue() // sina.com.cn
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("101.226.103.106"), 80)))).IsTrue() // qq.com
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("115.239.210.36"), 80)))).IsTrue() // image.baidu.com
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("120.135.126.1"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("121.14.1.189"), 80)))).IsTrue() // sina.com.cn
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("101.226.103.106"), 80)))).IsTrue() // qq.com
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("115.239.210.36"), 80)))).IsTrue() // image.baidu.com
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("120.135.126.1"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("8.8.8.8"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("8.8.8.8"), 80)))).IsFalse()
}
func TestChinaSitesJson(t *testing.T) {
@ -49,12 +49,12 @@ func TestChinaSitesJson(t *testing.T) {
assert.String(rule.Tag).Equals("y")
cond, err := rule.BuildCondition()
assert.Error(err).IsNil()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("v.qq.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.163.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("ngacn.cc"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("12306.cn"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("v.qq.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.163.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("ngacn.cc"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("12306.cn"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("v2ray.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("v2ray.com"), 80)))).IsFalse()
}
func TestDomainRule(t *testing.T) {
@ -74,11 +74,11 @@ func TestDomainRule(t *testing.T) {
assert.Pointer(rule).IsNotNil()
cond, err := rule.BuildCondition()
assert.Error(err).IsNil()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.ooxx.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.aabb.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.12306.cn"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.acn.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.ooxx.com"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.aabb.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.12306.cn"), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.ParseAddress("www.acn.com"), 80)))).IsFalse()
}
func TestIPRule(t *testing.T) {
@ -97,10 +97,10 @@ func TestIPRule(t *testing.T) {
assert.Pointer(rule).IsNotNil()
cond, err := rule.BuildCondition()
assert.Error(err).IsNil()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.DomainAddress("www.ooxx.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithDestination(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{192, 0, 0, 1}), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.DomainAddress("www.ooxx.com"), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{10, 0, 0, 1}), 80)))).IsTrue()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), 80)))).IsFalse()
assert.Bool(cond.Apply(proxy.ContextWithTarget(context.Background(), v2net.TCPDestination(v2net.IPAddress([]byte{192, 0, 0, 1}), 80)))).IsTrue()
}
func TestSourceIPRule(t *testing.T) {