mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
36 lines
1003 B
Go
36 lines
1003 B
Go
/*
|
|
Package capture provides traffic sniffier using AF_PACKET, pcap or pcap file.
|
|
it allows you to listen for traffic from any port (e.g. sniffing) because they operate on IP level.
|
|
Ports is TCP/IP feature, same as flow control, reliable transmission and etc.
|
|
Currently this package implements TCP layer: flow control is managed under tcp package.
|
|
BPF filters can also be applied.
|
|
|
|
example:
|
|
|
|
// for the transport should be "tcp"
|
|
listener, err := capture.NewListener(host, port, transport, engine, trackResponse)
|
|
if err != nil {
|
|
// handle error
|
|
}
|
|
listener.SetPcapOptions(opts)
|
|
err = listner.Activate()
|
|
if err != nil {
|
|
// handle it
|
|
}
|
|
|
|
if err := listener.Listen(context.Background(), handler); err != nil {
|
|
// handle error
|
|
}
|
|
// or
|
|
errCh := listener.ListenBackground(context.Background(), handler) // runs in the background
|
|
select {
|
|
case err := <- errCh:
|
|
// handle error
|
|
case <-quit:
|
|
//
|
|
case <- l.Reading: // if we have started reading
|
|
}
|
|
|
|
*/
|
|
package capture // import github.com/buger/goreplay/capture
|