httpcapt

package module
v0.0.0-...-15085c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 16 Imported by: 0

README

httpcapt

a HTTP/1.1 packet capture library written in Go.

For Cgo enabled build, libpcap is needed. On Ubuntu/Debian, run the following command to install libpcap-dev.

sudo apt-get install -y libpcap-dev

On Linux, pure Go build is also possible with CGO_ENABLED=0 go build

I wrote a blog in Japanese.

Example

Please see cmd/httpcapt/main.go for example usage.

Install the example CLI with Cgo enabled build.

go install github.com/hnakamur/httpcapt/...

Or install the example CLI with pure Go build.

CGO_ENABLED=0 go install github.com/hnakamur/httpcapt/...

Credits

This library uses github.com/google/gopacket/pcap for cgo build, github.com/google/gopacket/pcapgo and github.com/packetcap/go-pcap/filter for pure go build. Thanks for useful libraries!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptureResult

type CaptureResult struct {
	RequestTime time.Time
	Time        time.Time
	Client      netip.AddrPort
	Server      netip.AddrPort
	Response    *http.Response
	Error       error
}

type Capturer

type Capturer interface {
	SetBPFFilter(expr string) error
	Capture(ctx context.Context, resultC chan<- CaptureResult)
}

func NewEthernetCapturer

func NewEthernetCapturer(device string) (Capturer, error)

NewEthernetCapturer creates a Capturer which captures packets for the device Ethernet device specified.

If device is "any", a captuerer for all devices on the host is returned.

func NewMultiEthernetCapturer

func NewMultiEthernetCapturer(devices []string) (Capturer, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL