Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couldn't load wpcap.dll exit status 1 #1170

Open
0xMALVEE opened this issue May 21, 2024 · 1 comment
Open

couldn't load wpcap.dll exit status 1 #1170

0xMALVEE opened this issue May 21, 2024 · 1 comment

Comments

@0xMALVEE
Copy link

M Alvee@DESKTOP-E1SNL1U MINGW64 ~/Documents/GitHub/GoNetCapture (main)
$ go run .
2024/05/21 16:55:58 couldn't load wpcap.dll
exit status 1
@0xMALVEE
Copy link
Author

the go code

package main

import (
	"fmt"
	"log"

	"github.com/google/gopacket"
	"github.com/google/gopacket/pcap"
)

func main() {
    // Find all available network interfaces
    devices, err := pcap.FindAllDevs()
    if err != nil {
        log.Fatal(err)
    }

    // Choose the first network interface
    device := devices[0]

    // Open device for capturing
    handle, err := pcap.OpenLive(device.Name, 1600, true, pcap.BlockForever)
    if err != nil {
        log.Fatal(err)
    }
    defer handle.Close()

    // Set filter to capture only TCP packets
    err = handle.SetBPFFilter("tcp")
    if err != nil {
        log.Fatal(err)
    }

    // Start capturing packets
    packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
    for packet := range packetSource.Packets() {
        // Do something with the captured packet
        fmt.Println(packet)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant