From 40b3282f38cf18b4cbac329b3ec2feca2a7477cd Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 4 Oct 2018 18:32:17 +0900 Subject: [PATCH] redis bug --- redis/redis.go | 5 ++++- redis/redis_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/redis/redis.go b/redis/redis.go index 90d49e2..414292f 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -2,6 +2,7 @@ package redis import ( "bufio" + "log" "strconv" "strings" @@ -109,8 +110,9 @@ func (m *RedisMatcher) Match(matchCtx *osm.MatchCtx, index int, packet *osm.Pack case 1: // INFO response := string(packet.Bytes()) + m.parseResponse(matchCtx, response) if v, ok := matchCtx.GetAttribute("protected"); ok { - if _v, _err := strconv.ParseBool(v); nil != _err && _v { + if _v, _err := strconv.ParseBool(v); nil == _err && _v { m.parseResponse(matchCtx, response) } } @@ -159,6 +161,7 @@ func (m *RedisMatcher) parseResponse(matchCtx *osm.MatchCtx, response string) { scanner := bufio.NewScanner(strings.NewReader(response)) for scanner.Scan() { line := scanner.Text() + log.Println(line) if strings.Compare(line, "") == 0 { break } diff --git a/redis/redis_test.go b/redis/redis_test.go index ebcc07d..a669a76 100644 --- a/redis/redis_test.go +++ b/redis/redis_test.go @@ -23,7 +23,7 @@ func TestRedisMatcher(t *testing.T) { } defer conn.Close() - matchCtx := osm.NewMatchCtx("192.168.1.229", 6379) + matchCtx := osm.NewMatchCtx("192.168.1.229", 6321) for i := 0; i < m.PacketCount(matchCtx); i++ { _, err := conn.Write(m.Packet(matchCtx, i).Buffer)