Docs update
This commit is contained in:
parent
2f5dc11dd6
commit
d18bf6dbdb
|
|
@ -1,5 +1,9 @@
|
||||||
# sniffer
|
# 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++).*
|
> *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
|
https://user-images.githubusercontent.com/19553554/141692419-da8b63e1-e936-4d14-8ff5-5893e20a1f27.mov
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type lsofConn struct {
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
|
||||||
5
dns.go
5
dns.go
|
|
@ -50,6 +50,7 @@ func (c *DNSResolver) Close() {
|
||||||
c.wg.Wait()
|
c.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lookup resolve remote ip to the domains.
|
||||||
func (c *DNSResolver) Lookup(ip string) string {
|
func (c *DNSResolver) Lookup(ip string) string {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
@ -62,6 +63,10 @@ func (c *DNSResolver) Lookup(ip string) string {
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(addrs) == 1 {
|
||||||
|
return addrs[0]
|
||||||
|
}
|
||||||
|
|
||||||
sort.Strings(addrs)
|
sort.Strings(addrs)
|
||||||
return addrs[0]
|
return addrs[0]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
ui.go
14
ui.go
|
|
@ -287,18 +287,12 @@ func (pv *PlotViewer) Shift() {
|
||||||
pv.shiftIdx++
|
pv.shiftIdx++
|
||||||
width, height := termui.TerminalDimensions()
|
width, height := termui.TerminalDimensions()
|
||||||
pv.grid = pv.newGrid(width, height)
|
pv.grid = pv.newGrid(width, height)
|
||||||
if pv.count <= 1 {
|
pv.render()
|
||||||
return
|
|
||||||
}
|
|
||||||
termui.Render(pv.grid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pv *PlotViewer) Resize(width, height int) {
|
func (pv *PlotViewer) Resize(width, height int) {
|
||||||
pv.grid = pv.newGrid(width, height)
|
pv.grid = pv.newGrid(width, height)
|
||||||
if pv.count <= 1 {
|
pv.render()
|
||||||
return
|
|
||||||
}
|
|
||||||
termui.Render(pv.grid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pv *PlotViewer) Render(stats interface{}) {
|
func (pv *PlotViewer) Render(stats interface{}) {
|
||||||
|
|
@ -313,6 +307,10 @@ func (pv *PlotViewer) Render(stats interface{}) {
|
||||||
pv.updatePackets(data)
|
pv.updatePackets(data)
|
||||||
pv.updateBytes(data)
|
pv.updateBytes(data)
|
||||||
pv.updateConnections(data)
|
pv.updateConnections(data)
|
||||||
|
pv.render()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pv *PlotViewer) render() {
|
||||||
if pv.count <= 1 {
|
if pv.count <= 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue