mirror of
https://github.com/maride/pancap.git
synced 2024-11-22 00:44:26 +00:00
Cleanup and go fmt
This commit is contained in:
parent
4a1c58b564
commit
1aa3572c30
@ -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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
2
file.go
2
file.go
@ -37,4 +37,4 @@ func openPCAP() (*gopacket.PacketSource, layers.LinkType, error) {
|
|||||||
// Open given handle as packet source and return it
|
// Open given handle as packet source and return it
|
||||||
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
|
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
|
||||||
return packetSource, handle.LinkType(), nil
|
return packetSource, handle.LinkType(), nil
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -59,7 +59,7 @@ func printMOTD() {
|
|||||||
"In Soviet Russia, traffic analyzes you.",
|
"In Soviet Russia, traffic analyzes you.",
|
||||||
"Who captures the captors?",
|
"Who captures the captors?",
|
||||||
"Respect other's privacy. Always.",
|
"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_
|
"Most traffic is just there to confuse the russians.", // hat-tip to twitter.com/_harryr_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,17 +2,18 @@ package output
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/maride/pancap/common"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/maride/pancap/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
registeredFiles []File
|
registeredFiles []File
|
||||||
notFound []string
|
notFound []string
|
||||||
extractedFiles int
|
extractedFiles int
|
||||||
)
|
)
|
||||||
|
|
||||||
// Registers a file with the given name and content.
|
// Registers a file with the given name and content.
|
||||||
|
Loading…
Reference in New Issue
Block a user