diff --git a/input_kafka_test.go b/input_kafka_test.go index b41ec8f..f987ccd 100644 --- a/input_kafka_test.go +++ b/input_kafka_test.go @@ -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{ diff --git a/proto/fuzz.go b/proto/fuzz.go index f72bfbc..0220c7a 100644 --- a/proto/fuzz.go +++ b/proto/fuzz.go @@ -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 } diff --git a/proto/proto.go b/proto/proto.go index 18c6f29..e70226f 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -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 diff --git a/proto/proto_test.go b/proto/proto_test.go index c685931..58e6062 100644 --- a/proto/proto_test.go +++ b/proto/proto_test.go @@ -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 + }) } } diff --git a/raw_socket_listener/listener.go b/raw_socket_listener/listener.go index 9a8b83f..7edd639 100644 --- a/raw_socket_listener/listener.go +++ b/raw_socket_listener/listener.go @@ -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, } } diff --git a/raw_socket_listener/tcp_message.go b/raw_socket_listener/tcp_message.go index 5319594..d2d2abb 100644 --- a/raw_socket_listener/tcp_message.go +++ b/raw_socket_listener/tcp_message.go @@ -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 diff --git a/raw_socket_listener/tcp_message_test.go b/raw_socket_listener/tcp_message_test.go index 1ce0d19..92f61ae 100644 --- a/raw_socket_listener/tcp_message_test.go +++ b/raw_socket_listener/tcp_message_test.go @@ -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) } } - diff --git a/raw_socket_listener/tcp_packet.go b/raw_socket_listener/tcp_packet.go index f2ba82c..9427a3c 100644 --- a/raw_socket_listener/tcp_packet.go +++ b/raw_socket_listener/tcp_packet.go @@ -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, } }