From 1aa3572c304c2a3f400c84bbb3836ec03a469bc5 Mon Sep 17 00:00:00 2001 From: maride Date: Sat, 2 Sep 2023 17:31:43 +0200 Subject: [PATCH] Cleanup and go fmt --- analyzer_test.go | 42 ------------------------------------------ file.go | 2 +- main.go | 2 +- output/filemanager.go | 7 ++++--- 4 files changed, 6 insertions(+), 47 deletions(-) delete mode 100644 analyzer_test.go diff --git a/analyzer_test.go b/analyzer_test.go deleted file mode 100644 index a36d425..0000000 --- a/analyzer_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "github.com/google/gopacket" - "github.com/google/gopacket/layers" - "testing" -) - -func Test_analyzePCAP(t *testing.T) { - type args struct { - source *gopacket.PacketSource - linkType layers.LinkType - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Faulty link type", - args: args{ - source: &gopacket.PacketSource{ - DecodeOptions: gopacket.DecodeOptions{ - Lazy: false, - NoCopy: false, - SkipDecodeRecovery: false, - DecodeStreamsAsDatagrams: false, - }, - }, - linkType: 2, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := analyzePCAP(tt.args.source, tt.args.linkType); (err != nil) != tt.wantErr { - t.Errorf("analyzePCAP() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} \ No newline at end of file diff --git a/file.go b/file.go index cea4470..a693db8 100644 --- a/file.go +++ b/file.go @@ -37,4 +37,4 @@ func openPCAP() (*gopacket.PacketSource, layers.LinkType, error) { // Open given handle as packet source and return it packetSource := gopacket.NewPacketSource(handle, handle.LinkType()) return packetSource, handle.LinkType(), nil -} \ No newline at end of file +} diff --git a/main.go b/main.go index 0d394e1..525f10d 100644 --- a/main.go +++ b/main.go @@ -59,7 +59,7 @@ func printMOTD() { "In Soviet Russia, traffic analyzes you.", "Who captures the captors?", "Respect other's privacy. Always.", - "Make public data available, protect private data.", // https://www.ccc.de/en/hackerethik + "Make public data available, protect private data.", // https://www.ccc.de/en/hackerethik "Most traffic is just there to confuse the russians.", // hat-tip to twitter.com/_harryr_ } diff --git a/output/filemanager.go b/output/filemanager.go index 4046c8e..5da3b13 100644 --- a/output/filemanager.go +++ b/output/filemanager.go @@ -2,17 +2,18 @@ package output import ( "fmt" - "github.com/maride/pancap/common" "io/ioutil" "log" "os" "strings" + + "github.com/maride/pancap/common" ) var ( registeredFiles []File - notFound []string - extractedFiles int + notFound []string + extractedFiles int ) // Registers a file with the given name and content.