Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 931f937

Browse files
committed
update dependencies
1 parent fd1089f commit 931f937

File tree

10 files changed

+198
-207
lines changed

10 files changed

+198
-207
lines changed

decoders/netflow/netflow.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ func (ts *BasicTemplateSystem) GetTemplates() map[uint16]map[uint32]map[uint16]i
254254
func (ts *BasicTemplateSystem) AddTemplate(version uint16, obsDomainId uint32, template interface{}) {
255255
ts.templateslock.Lock()
256256
_, exists := ts.templates[version]
257-
if exists != true {
257+
if !exists {
258258
ts.templates[version] = make(map[uint32]map[uint16]interface{})
259259
}
260260
_, exists = ts.templates[version][obsDomainId]
261-
if exists != true {
261+
if !exists {
262262
ts.templates[version][obsDomainId] = make(map[uint16]interface{})
263263
}
264264
var templateId uint16
@@ -322,13 +322,13 @@ func DecodeMessage(payload *bytes.Buffer, templates NetFlowTemplateSystem) (inte
322322
utils.BinaryDecoder(payload, &packetNFv9.Count, &packetNFv9.SystemUptime, &packetNFv9.UnixSeconds, &packetNFv9.SequenceNumber, &packetNFv9.SourceId)
323323
size = packetNFv9.Count
324324
packetNFv9.Version = version
325-
returnItem = *(&packetNFv9)
325+
returnItem = packetNFv9
326326
obsDomainId = packetNFv9.SourceId
327327
} else if version == 10 {
328328
utils.BinaryDecoder(payload, &packetIPFIX.Length, &packetIPFIX.ExportTime, &packetIPFIX.SequenceNumber, &packetIPFIX.ObservationDomainId)
329329
size = packetIPFIX.Length
330330
packetIPFIX.Version = version
331-
returnItem = *(&packetIPFIX)
331+
returnItem = packetIPFIX
332332
obsDomainId = packetIPFIX.ObservationDomainId
333333
} else {
334334
return nil, NewErrorVersion(version)

decoders/netflowlegacy/netflow.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func DecodeMessage(payload *bytes.Buffer) (interface{}, error) {
4444
)
4545

4646
if packet.Count > MAX_FLOWS_PER_PACKET {
47-
return nil, fmt.Errorf("Invalid amount of flows: %d", packet.Count)
47+
return nil, fmt.Errorf("invalid amount of flows: %d", packet.Count)
4848
}
4949

5050
packet.Records = make([]RecordsNetFlowV5, int(packet.Count))

decoders/sflow/sflow.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package sflow
22

33
import (
44
"bytes"
5-
"errors"
65
"fmt"
76

87
"github.com/cloudflare/goflow/v3/decoders/utils"
@@ -214,10 +213,10 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
214213
return flowRecord, err
215214
}
216215
if int(extendedGateway.ASPathLength) > payload.Len()-4 {
217-
return flowRecord, errors.New(fmt.Sprintf("Invalid AS path length: %v.", extendedGateway.ASPathLength))
216+
return flowRecord, fmt.Errorf("invalid AS path length: %v", extendedGateway.ASPathLength)
218217
}
219218
if extendedGateway.ASPathLength > MAX_AS_PATH_LENGTH {
220-
return flowRecord, fmt.Errorf("Invalid AS path length: %d", extendedGateway.ASPathLength)
219+
return flowRecord, fmt.Errorf("invalid AS path length: %d", extendedGateway.ASPathLength)
221220
}
222221
asPath = make([]uint32, extendedGateway.ASPathLength)
223222
if len(asPath) > 0 {
@@ -234,11 +233,11 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
234233
return flowRecord, err
235234
}
236235
if int(extendedGateway.CommunitiesLength) > payload.Len()-4 {
237-
return flowRecord, errors.New(fmt.Sprintf("Invalid Communities length: %v.", extendedGateway.CommunitiesLength))
236+
return flowRecord, fmt.Errorf("invalid Communities length: %v", extendedGateway.CommunitiesLength)
238237
}
239238

240239
if extendedGateway.CommunitiesLength > MAX_COMMUNITIES_LENGTH {
241-
return flowRecord, fmt.Errorf("Invalid communities length: %d", extendedGateway.CommunitiesLength)
240+
return flowRecord, fmt.Errorf("invalid communities length: %d", extendedGateway.CommunitiesLength)
242241
}
243242
communities := make([]uint32, extendedGateway.CommunitiesLength)
244243
if len(communities) > 0 {
@@ -255,7 +254,7 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
255254

256255
flowRecord.Data = extendedGateway
257256
default:
258-
return flowRecord, errors.New(fmt.Sprintf("Unknown data format %v.", (*header).DataFormat))
257+
return flowRecord, fmt.Errorf("unknown data format %v", (*header).DataFormat)
259258
}
260259
return flowRecord, nil
261260
}
@@ -301,7 +300,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
301300
}
302301
recordsCount = flowSample.FlowRecordsCount
303302
if recordsCount > MAX_FLOW_RECORDS {
304-
return flowSample, fmt.Errorf("Invalid number of flows records: %d", recordsCount)
303+
return flowSample, fmt.Errorf("invalid number of flows records: %d", recordsCount)
305304
}
306305
flowSample.Records = make([]FlowRecord, recordsCount)
307306
sample = flowSample
@@ -316,7 +315,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
316315
}
317316

318317
if recordsCount > MAX_SAMPLES_PER_PACKET {
319-
return flowSample, fmt.Errorf("Invalid number of samples: %d", recordsCount)
318+
return flowSample, fmt.Errorf("invalid number of samples: %d", recordsCount)
320319
}
321320
counterSample.Records = make([]CounterRecord, recordsCount)
322321
sample = counterSample

go.mod

+42-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,47 @@
11
module github.com/cloudflare/goflow/v3
22

3-
go 1.12
3+
go 1.21
4+
5+
toolchain go1.23.4
6+
7+
require (
8+
github.com/Shopify/sarama v1.38.1
9+
github.com/golang/protobuf v1.5.4
10+
github.com/libp2p/go-reuseport v0.4.0
11+
github.com/prometheus/client_golang v1.20.5
12+
github.com/sirupsen/logrus v1.9.3
13+
github.com/stretchr/testify v1.10.0
14+
)
415

516
require (
6-
github.com/Shopify/sarama v1.22.0
7-
github.com/golang/protobuf v1.4.3
8-
github.com/libp2p/go-reuseport v0.0.1
9-
github.com/prometheus/client_golang v1.11.1
10-
github.com/sirupsen/logrus v1.6.0
11-
github.com/stretchr/testify v1.4.0
17+
github.com/beorn7/perks v1.0.1 // indirect
18+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
19+
github.com/davecgh/go-spew v1.1.1 // indirect
20+
github.com/eapache/go-resiliency v1.7.0 // indirect
21+
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
22+
github.com/eapache/queue v1.1.0 // indirect
23+
github.com/golang/snappy v0.0.4 // indirect
24+
github.com/hashicorp/errwrap v1.1.0 // indirect
25+
github.com/hashicorp/go-multierror v1.1.1 // indirect
26+
github.com/hashicorp/go-uuid v1.0.3 // indirect
27+
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
28+
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
29+
github.com/jcmturner/gofork v1.7.6 // indirect
30+
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
31+
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
32+
github.com/klauspost/compress v1.17.11 // indirect
33+
github.com/kr/text v0.2.0 // indirect
34+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
35+
github.com/pierrec/lz4/v4 v4.1.22 // indirect
36+
github.com/pmezard/go-difflib v1.0.0 // indirect
37+
github.com/prometheus/client_model v0.6.1 // indirect
38+
github.com/prometheus/common v0.62.0 // indirect
39+
github.com/prometheus/procfs v0.15.1 // indirect
40+
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
41+
golang.org/x/crypto v0.32.0 // indirect
42+
golang.org/x/net v0.34.0 // indirect
43+
golang.org/x/sync v0.10.0 // indirect
44+
golang.org/x/sys v0.29.0 // indirect
45+
google.golang.org/protobuf v1.36.3 // indirect
46+
gopkg.in/yaml.v3 v3.0.1 // indirect
1247
)

0 commit comments

Comments
 (0)