new: main packet queue is now used to gather network stats, update endpoint, etc

This commit is contained in:
evilsocket 2018-01-13 18:40:43 +01:00
commit 913c581f9f
4 changed files with 127 additions and 15 deletions

View file

@ -4,6 +4,7 @@ import (
"encoding/binary"
"fmt"
"net"
"time"
"github.com/evilsocket/bettercap-ng/core"
)
@ -11,6 +12,7 @@ import (
type OnHostResolvedCallback func(e *Endpoint)
type Endpoint struct {
IP net.IP `json:"-"`
Net *net.IPNet `json:"-"`
IPv6 net.IP `json:"."`
HW net.HardwareAddr `json:"-"`
IpAddress string `json:"ipv4"`
@ -21,12 +23,17 @@ type Endpoint struct {
Hostname string `json:"hostname"`
Vendor string `json:"vendor"`
ResolvedCallback OnHostResolvedCallback `json:"-"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
}
func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
hw, _ := net.ParseMAC(mac)
now := time.Now()
e := &Endpoint{
IP: net.ParseIP(ip),
Net: nil,
HW: hw,
IpAddress: ip,
SubnetBits: bits,
@ -35,8 +42,13 @@ func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
Hostname: name,
Vendor: OuiLookup(mac),
ResolvedCallback: nil,
FirstSeen: now,
LastSeen: now,
}
_, netw, _ := net.ParseCIDR(e.CIDR())
e.Net = netw
return e
}