mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
Refactoring modules
This commit is contained in:
parent
c0d3c314fc
commit
ed652622e2
89 changed files with 186 additions and 138 deletions
54
modules/net_sniff/net_sniff_views.go
Normal file
54
modules/net_sniff/net_sniff_views.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package net_sniff
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/bettercap/bettercap/session"
|
||||
|
||||
"github.com/evilsocket/islazy/tui"
|
||||
"github.com/google/gopacket/layers"
|
||||
)
|
||||
|
||||
func vIP(ip net.IP) string {
|
||||
if session.I.Interface.IP.Equal(ip) {
|
||||
return tui.Dim("local")
|
||||
} else if session.I.Gateway.IP.Equal(ip) {
|
||||
return "gateway"
|
||||
}
|
||||
|
||||
address := ip.String()
|
||||
host := session.I.Lan.GetByIp(address)
|
||||
if host != nil {
|
||||
if host.Hostname != "" {
|
||||
return host.Hostname
|
||||
}
|
||||
}
|
||||
|
||||
return address
|
||||
}
|
||||
|
||||
func vPort(p interface{}) string {
|
||||
sp := fmt.Sprintf("%d", p)
|
||||
if tcp, ok := p.(layers.TCPPort); ok {
|
||||
if name, found := layers.TCPPortNames[tcp]; found {
|
||||
sp = tui.Yellow(name)
|
||||
}
|
||||
} else if udp, ok := p.(layers.UDPPort); ok {
|
||||
if name, found := layers.UDPPortNames[udp]; found {
|
||||
sp = tui.Yellow(name)
|
||||
}
|
||||
}
|
||||
|
||||
return sp
|
||||
}
|
||||
|
||||
var maxUrlSize = 80
|
||||
|
||||
func vURL(u string) string {
|
||||
ul := len(u)
|
||||
if ul > maxUrlSize {
|
||||
u = fmt.Sprintf("%s...", u[0:maxUrlSize-3])
|
||||
}
|
||||
return u
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue