redis bug
This commit is contained in:
parent
1ae4509bc6
commit
40b3282f38
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user