More fmt fixes

This commit is contained in:
Leonid Bugaev
2017-01-23 13:34:57 +03:00
parent 043c0b7436
commit e69570367b
8 changed files with 25 additions and 26 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ func TestInputKafkaRAW(t *testing.T) {
consumer.ExpectConsumePartition("test", 0, mocks.AnyOffset).YieldMessage(&sarama.ConsumerMessage{Value: []byte("1 2 3\nGET / HTTP1.1\r\nHeader: 1\r\n\r\n")})
consumer.SetTopicMetadata(
map[string][]int32{"test": []int32{0}},
map[string][]int32{"test": {0}},
)
input := NewKafkaInput("", &KafkaConfig{
@@ -39,7 +39,7 @@ func TestInputKafkaJSON(t *testing.T) {
consumer.ExpectConsumePartition("test", 0, mocks.AnyOffset).YieldMessage(&sarama.ConsumerMessage{Value: []byte(`{"Req_URL":"/","Req_Type":"1","Req_ID":"2","Req_Ts":"3","Req_Method":"GET","Req_Headers":{"Header":"1"}}`)})
consumer.SetTopicMetadata(
map[string][]int32{"test": []int32{0}},
map[string][]int32{"test": {0}},
)
input := NewKafkaInput("", &KafkaConfig{
+4 -4
View File
@@ -4,9 +4,9 @@ package proto
func Fuzz(data []byte) int {
ParseHeaders([][]byte{data}, func(header []byte, value []byte) bool {
return true
})
ParseHeaders([][]byte{data}, func(header []byte, value []byte) bool {
return true
})
return 1
return 1
}
+1 -1
View File
@@ -181,7 +181,7 @@ func HeadersEqual(h1 []byte, h2 []byte) bool {
// Parsing headers from multiple payloads
func ParseHeaders(payloads [][]byte, cb func(header []byte, value []byte) bool) {
hS := [2]int{0, 0} // header start
hS := [2]int{0, 0} // header start
hE := [2]int{-1, -1} // header end
vS := [2]int{-1, -1} // value start
vE := [2]int{-1, -1} // value end
+2 -2
View File
@@ -153,8 +153,8 @@ func TestFuzzCrashers(t *testing.T) {
for _, f := range crashers {
ParseHeaders([][]byte{[]byte(f)}, func(header []byte, value []byte) bool {
return true
})
return true
})
}
}
+6 -6
View File
@@ -34,9 +34,9 @@ import (
var _ = fmt.Println
type packet struct {
srcIP []byte
data []byte
timestamp time.Time
srcIP []byte
data []byte
timestamp time.Time
}
// Listener handle traffic capture
@@ -638,9 +638,9 @@ func (t *Listener) buildPacket(packetSrcIP []byte, packetData []byte, timestamp
copy(copyPacketData, packetSrcIP)
return &packet{
srcIP: packetSrcIP,
data: packetData,
timestamp:timestamp,
srcIP: packetSrcIP,
data: packetData,
timestamp: timestamp,
}
}
+2 -2
View File
@@ -357,7 +357,7 @@ func (t *TCPMessage) updateBodyType() {
var lengthB, encB, connB []byte
proto.ParseHeaders(t.packetsData(), func(header, value []byte)bool{
proto.ParseHeaders(t.packetsData(), func(header, value []byte) bool {
if proto.HeadersEqual(header, []byte("Content-Length")) {
lengthB = value
return false
@@ -438,7 +438,7 @@ func (t *TCPMessage) check100Continue() {
}
var expectB []byte
proto.ParseHeaders(t.packetsData(), func(header, value []byte)bool{
proto.ParseHeaders(t.packetsData(), func(header, value []byte) bool {
if proto.HeadersEqual(header, bExpectHeader) {
expectB = value
return false
-1
View File
@@ -255,4 +255,3 @@ func TestTcpMessageStart(t *testing.T) {
t.Error("Message timestamp should be equal to the lowest related packet timestamp", start, msg.Start)
}
}
+8 -8
View File
@@ -36,11 +36,11 @@ type TCPPacket struct {
DataOffset uint8
IsFIN bool
Raw []byte
Data []byte
Addr []byte
Raw []byte
Data []byte
Addr []byte
timestamp time.Time
ID tcpID
ID tcpID
}
// ParseTCPPacket takes address and tcp payload and returns parsed TCPPacket
@@ -85,7 +85,7 @@ func (t *TCPPacket) ParseBasic() {
func (t *TCPPacket) dump() *packet {
packetSrcIP := make([]byte, 16)
packetData := make([]byte, len(t.Data) + 16)
packetData := make([]byte, len(t.Data)+16)
copy(packetSrcIP, t.Addr)
@@ -104,9 +104,9 @@ func (t *TCPPacket) dump() *packet {
copy(packetData[16:], t.Data)
return &packet{
srcIP: packetSrcIP,
data:packetData,
timestamp:t.timestamp,
srcIP: packetSrcIP,
data: packetData,
timestamp: t.timestamp,
}
}