Skip to content

gosniff - A simple packet sniffer the makes use of gopacket

License

Notifications You must be signed in to change notification settings

michalis-papamichael/gosniff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gosniff

Go Doc

A simple packet sniffer that makes use of gopacket.

Quick Start

Installation

go get github.com/michalis-papamichael/gosniff

Usage

package main

import (
	"fmt"
	"time"

	"github.com/michalis-papamichael/gosniff"
)

func main(){
	filter := "tcp"
	sniffer := gosniff.Sniffer{InterfaceName: nil, BpfFilterExpr: &filter,
		SnapshotLength: 1024, Duration: 500 * time.Microsecond, Promiscuous: false}

	pkts, err := sniffer.Start()
	if err != nil {
		panic(err)
	}

	go func() {
		for p := range pkts {
			// do something
			fmt.Println(p)
		}
	}()

 	<-time.After(15 * time.Second)
 	fmt.Println("Closing packet sniffer")
 	stats, _ := sniffer.Stop(true)
	fmt.Printf("\n Packets Received: %v\n", stats.PacketsReceived)
}

License

gosniff is released under the MIT License.

About

gosniff - A simple packet sniffer the makes use of gopacket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published