Docs update
This commit is contained in:
parent
2f5dc11dd6
commit
d18bf6dbdb
|
|
@ -1,5 +1,9 @@
|
|||
# sniffer
|
||||
|
||||
[](https://godoc.org/github.com/chenjiandongx/sniffer)
|
||||
[](https://goreportcard.com/report/github.com/chenjiandongx/sniffer)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
> *A modern alternative network traffic sniffer inspired by [bandwhich](https://github.com/imsnif/bandwhich)(Rust) and [nethogs](https://github.com/raboof/nethogs)(C++).*
|
||||
|
||||
https://user-images.githubusercontent.com/19553554/141692419-da8b63e1-e936-4d14-8ff5-5893e20a1f27.mov
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@ import (
|
|||
)
|
||||
|
||||
type lsofConn struct {
|
||||
invoker LsofInvoker
|
||||
invoker lsofInvoker
|
||||
}
|
||||
|
||||
type LsofInvoker struct{}
|
||||
type lsofInvoker struct{}
|
||||
|
||||
func (i LsofInvoker) Exec() ([]byte, error) {
|
||||
// Exec executes the command and return the output bytes of it.
|
||||
func (i lsofInvoker) Exec() ([]byte, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
|
|
|||
5
dns.go
5
dns.go
|
|
@ -50,6 +50,7 @@ func (c *DNSResolver) Close() {
|
|||
c.wg.Wait()
|
||||
}
|
||||
|
||||
// Lookup resolve remote ip to the domains.
|
||||
func (c *DNSResolver) Lookup(ip string) string {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
|
|
@ -62,6 +63,10 @@ func (c *DNSResolver) Lookup(ip string) string {
|
|||
return ip
|
||||
}
|
||||
|
||||
if len(addrs) == 1 {
|
||||
return addrs[0]
|
||||
}
|
||||
|
||||
sort.Strings(addrs)
|
||||
return addrs[0]
|
||||
}
|
||||
|
|
|
|||
14
ui.go
14
ui.go
|
|
@ -287,18 +287,12 @@ func (pv *PlotViewer) Shift() {
|
|||
pv.shiftIdx++
|
||||
width, height := termui.TerminalDimensions()
|
||||
pv.grid = pv.newGrid(width, height)
|
||||
if pv.count <= 1 {
|
||||
return
|
||||
}
|
||||
termui.Render(pv.grid)
|
||||
pv.render()
|
||||
}
|
||||
|
||||
func (pv *PlotViewer) Resize(width, height int) {
|
||||
pv.grid = pv.newGrid(width, height)
|
||||
if pv.count <= 1 {
|
||||
return
|
||||
}
|
||||
termui.Render(pv.grid)
|
||||
pv.render()
|
||||
}
|
||||
|
||||
func (pv *PlotViewer) Render(stats interface{}) {
|
||||
|
|
@ -313,6 +307,10 @@ func (pv *PlotViewer) Render(stats interface{}) {
|
|||
pv.updatePackets(data)
|
||||
pv.updateBytes(data)
|
||||
pv.updateConnections(data)
|
||||
pv.render()
|
||||
}
|
||||
|
||||
func (pv *PlotViewer) render() {
|
||||
if pv.count <= 1 {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue