Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions plugSrc/redis/build/entry.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package build

import (
"github.com/google/gopacket"
"io"
"strings"
"bufio"
"fmt"
"io"
"strconv"
"bufio"
"strings"
"time"

"github.com/google/gopacket"
)

type Redis struct {
Expand Down Expand Up @@ -35,7 +37,8 @@ func (red Redis) ResolveStream(net, transport gopacket.Flow, r io.Reader) {

buf := bufio.NewReader(r)
var cmd string
var cmdCount = 0
var now int64
cmdCount := 0
for {

line, _, _ := buf.ReadLine()
Expand All @@ -55,22 +58,24 @@ func (red Redis) ResolveStream(net, transport gopacket.Flow, r io.Reader) {
}

//Do not display
if strings.EqualFold(transport.Src().String(), strconv.Itoa(red.port)) == true {
if strings.EqualFold(transport.Src().String(), strconv.Itoa(red.port)) {
continue
}

now = time.Now().Unix()
// Record time and client address
cmd = fmt.Sprintf("%d [%s:%s]", now, net.Src().String(), transport.Src().String())
//run
l := string(line[1])
cmdCount, _ = strconv.Atoi(l)
cmd = ""
for j := 0; j < cmdCount * 2; j++ {
c, _, _ := buf.ReadLine()
if j & 1 == 0 {
continue
}
cmd += " " + string(c)
}
fmt.Println(cmd)
fmt.Printf("%#v\n", cmd)
}
}

Expand Down