Check if we got a file

This commit is contained in:
maride 2020-12-15 14:58:33 +01:00
parent 1c23ca3859
commit 8a76ed7d99

View File

@ -19,6 +19,11 @@ func registerFileFlags() {
// Opens the PCAP, returns its packets and the link type or an error // Opens the PCAP, returns its packets and the link type or an error
func openPCAP() (*gopacket.PacketSource, layers.LinkType, error) { func openPCAP() (*gopacket.PacketSource, layers.LinkType, error) {
// Check if we even got a file.
if *filenameFlag == "" {
return nil, 0, fmt.Errorf("missing file to analyze. Please specifiy it with --file")
}
// Open specified file // Open specified file
handle, openErr := pcap.OpenOffline(*filenameFlag) handle, openErr := pcap.OpenOffline(*filenameFlag)
if openErr != nil { if openErr != nil {