mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
refact: minor refactoring to endpoint structure
This commit is contained in:
parent
2221c510ba
commit
417a288b42
1 changed files with 11 additions and 3 deletions
|
@ -27,17 +27,25 @@ type Endpoint struct {
|
||||||
LastSeen time.Time `json:"last_seen"`
|
LastSeen time.Time `json:"last_seen"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ip2int(ip net.IP) uint32 {
|
||||||
|
if len(ip) == 16 {
|
||||||
|
return binary.BigEndian.Uint32(ip[12:16])
|
||||||
|
}
|
||||||
|
return binary.BigEndian.Uint32(ip)
|
||||||
|
}
|
||||||
|
|
||||||
func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
|
func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
|
||||||
|
addr := net.ParseIP(ip)
|
||||||
hw, _ := net.ParseMAC(mac)
|
hw, _ := net.ParseMAC(mac)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
e := &Endpoint{
|
e := &Endpoint{
|
||||||
IP: net.ParseIP(ip),
|
IP: addr,
|
||||||
|
IpAddress: ip,
|
||||||
|
IpAddressUint32: ip2int(addr),
|
||||||
Net: nil,
|
Net: nil,
|
||||||
HW: hw,
|
HW: hw,
|
||||||
IpAddress: ip,
|
|
||||||
SubnetBits: bits,
|
SubnetBits: bits,
|
||||||
IpAddressUint32: binary.BigEndian.Uint32(net.ParseIP(ip)[12:16]),
|
|
||||||
HwAddress: mac,
|
HwAddress: mac,
|
||||||
Hostname: name,
|
Hostname: name,
|
||||||
Vendor: OuiLookup(mac),
|
Vendor: OuiLookup(mac),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue