mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 14:03:17 -07:00
refact: renamed package net to network to avoid collision with golang net package.
This commit is contained in:
parent
21236c257e
commit
48d27f274a
28 changed files with 298 additions and 298 deletions
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
"github.com/evilsocket/bettercap-ng/firewall"
|
||||
bnet "github.com/evilsocket/bettercap-ng/net"
|
||||
"github.com/evilsocket/bettercap-ng/network"
|
||||
"github.com/evilsocket/bettercap-ng/packets"
|
||||
)
|
||||
|
||||
|
@ -34,8 +34,8 @@ var (
|
|||
|
||||
type Session struct {
|
||||
Options core.Options `json:"options"`
|
||||
Interface *bnet.Endpoint `json:"interface"`
|
||||
Gateway *bnet.Endpoint `json:"gateway"`
|
||||
Interface *network.Endpoint `json:"interface"`
|
||||
Gateway *network.Endpoint `json:"gateway"`
|
||||
Firewall firewall.FirewallManager `json:"-"`
|
||||
Env *Environment `json:"env"`
|
||||
Targets *Targets `json:"targets"`
|
||||
|
@ -306,9 +306,9 @@ func (s *Session) Start() error {
|
|||
return s.Modules[i].Name() < s.Modules[j].Name()
|
||||
})
|
||||
|
||||
bnet.OuiInit()
|
||||
network.OuiInit()
|
||||
|
||||
if s.Interface, err = bnet.FindInterface(*s.Options.InterfaceName); err != nil {
|
||||
if s.Interface, err = network.FindInterface(*s.Options.InterfaceName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ func (s *Session) Start() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if s.Gateway, err = bnet.FindGateway(s.Interface); err != nil {
|
||||
if s.Gateway, err = network.FindGateway(s.Interface); err != nil {
|
||||
s.Events.Log(core.WARNING, "%s", err.Error())
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
bnet "github.com/evilsocket/bettercap-ng/net"
|
||||
"github.com/evilsocket/bettercap-ng/network"
|
||||
)
|
||||
|
||||
const TargetsDefaultTTL = 10
|
||||
|
@ -20,21 +20,21 @@ type Targets struct {
|
|||
sync.Mutex
|
||||
|
||||
Session *Session `json:"-"`
|
||||
Interface *bnet.Endpoint
|
||||
Gateway *bnet.Endpoint
|
||||
Targets map[string]*bnet.Endpoint
|
||||
Interface *network.Endpoint
|
||||
Gateway *network.Endpoint
|
||||
Targets map[string]*network.Endpoint
|
||||
TTL map[string]uint
|
||||
Aliases map[string]string
|
||||
|
||||
aliasesFileName string
|
||||
}
|
||||
|
||||
func NewTargets(s *Session, iface, gateway *bnet.Endpoint) *Targets {
|
||||
func NewTargets(s *Session, iface, gateway *network.Endpoint) *Targets {
|
||||
t := &Targets{
|
||||
Session: s,
|
||||
Interface: iface,
|
||||
Gateway: gateway,
|
||||
Targets: make(map[string]*bnet.Endpoint),
|
||||
Targets: make(map[string]*network.Endpoint),
|
||||
TTL: make(map[string]uint),
|
||||
Aliases: make(map[string]string),
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ func NewTargets(s *Session, iface, gateway *bnet.Endpoint) *Targets {
|
|||
return t
|
||||
}
|
||||
|
||||
func (tp *Targets) List() (list []*bnet.Endpoint) {
|
||||
func (tp *Targets) List() (list []*network.Endpoint) {
|
||||
tp.Lock()
|
||||
defer tp.Unlock()
|
||||
|
||||
list = make([]*bnet.Endpoint, 0)
|
||||
list = make([]*network.Endpoint, 0)
|
||||
for _, t := range tp.Targets {
|
||||
list = append(list, t)
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func (tp *Targets) Has(ip string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (tp *Targets) AddIfNew(ip, mac string) *bnet.Endpoint {
|
||||
func (tp *Targets) AddIfNew(ip, mac string) *network.Endpoint {
|
||||
tp.Lock()
|
||||
defer tp.Unlock()
|
||||
|
||||
|
@ -176,7 +176,7 @@ func (tp *Targets) AddIfNew(ip, mac string) *bnet.Endpoint {
|
|||
return nil
|
||||
}
|
||||
|
||||
mac = bnet.NormalizeMac(mac)
|
||||
mac = network.NormalizeMac(mac)
|
||||
if t, found := tp.Targets[mac]; found {
|
||||
if tp.TTL[mac] < TargetsDefaultTTL {
|
||||
tp.TTL[mac]++
|
||||
|
@ -184,9 +184,9 @@ func (tp *Targets) AddIfNew(ip, mac string) *bnet.Endpoint {
|
|||
return t
|
||||
}
|
||||
|
||||
e := bnet.NewEndpoint(ip, mac)
|
||||
e := network.NewEndpoint(ip, mac)
|
||||
/*
|
||||
e.ResolvedCallback = func(e *bnet.Endpoint) {
|
||||
e.ResolvedCallback = func(e *network.Endpoint) {
|
||||
tp.Session.Events.Add("endpoint.resolved", e)
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue