mirror of
https://github.com/bettercap/bettercap
synced 2025-07-31 12:10:10 -07:00
started structuring project for testing + lint driven various refactoring
This commit is contained in:
parent
64099bc1fb
commit
bc3be7dd2b
5 changed files with 17 additions and 18 deletions
|
@ -46,9 +46,9 @@ func getPads(s string, maxLen int, align Alignment) (lPad int, rPad int) {
|
||||||
} else if align == AlignCenter {
|
} else if align == AlignCenter {
|
||||||
lPad = diff / 2
|
lPad = diff / 2
|
||||||
rPad = diff - lPad + 1
|
rPad = diff - lPad + 1
|
||||||
} else {
|
} /* else {
|
||||||
// TODO
|
TODO
|
||||||
}
|
} */
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ func Make(iface *network.Endpoint) FirewallManager {
|
||||||
firewall := &LinuxFirewall{
|
firewall := &LinuxFirewall{
|
||||||
iface: iface,
|
iface: iface,
|
||||||
forwarding: false,
|
forwarding: false,
|
||||||
redirections: make(map[string]*Redirection, 0),
|
redirections: make(map[string]*Redirection),
|
||||||
}
|
}
|
||||||
|
|
||||||
firewall.forwarding = firewall.IsForwardingEnabled()
|
firewall.forwarding = firewall.IsForwardingEnabled()
|
||||||
|
@ -45,11 +45,8 @@ func (f LinuxFirewall) enableFeature(filename string, enable bool) error {
|
||||||
}
|
}
|
||||||
defer fd.Close()
|
defer fd.Close()
|
||||||
|
|
||||||
if _, err = fd.WriteString(value); err != nil {
|
_, err = fd.WriteString(value)
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f LinuxFirewall) IsForwardingEnabled() bool {
|
func (f LinuxFirewall) IsForwardingEnabled() bool {
|
||||||
|
@ -67,7 +64,7 @@ func (f LinuxFirewall) EnableForwarding(enabled bool) error {
|
||||||
|
|
||||||
func (f *LinuxFirewall) getCommandLine(r *Redirection, enabled bool) (cmdLine []string) {
|
func (f *LinuxFirewall) getCommandLine(r *Redirection, enabled bool) (cmdLine []string) {
|
||||||
action := "-A"
|
action := "-A"
|
||||||
if enabled == false {
|
if !enabled {
|
||||||
action = "-D"
|
action = "-D"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +99,8 @@ func (f *LinuxFirewall) EnableRedirection(r *Redirection, enabled bool) error {
|
||||||
rkey := r.String()
|
rkey := r.String()
|
||||||
_, found := f.redirections[rkey]
|
_, found := f.redirections[rkey]
|
||||||
|
|
||||||
if enabled == true {
|
if !enabled {
|
||||||
if found == true {
|
if found {
|
||||||
return fmt.Errorf("Redirection '%s' already enabled.", rkey)
|
return fmt.Errorf("Redirection '%s' already enabled.", rkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +113,7 @@ func (f *LinuxFirewall) EnableRedirection(r *Redirection, enabled bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if found == false {
|
if !found {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,8 +241,11 @@ func (d *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) {
|
func (d *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) {
|
||||||
// timed out
|
if err != nil {
|
||||||
if d.currDevice == nil {
|
log.Warning("Connected to %s but with error: %s", p.ID(), err)
|
||||||
|
return
|
||||||
|
} else if d.currDevice == nil {
|
||||||
|
// timed out
|
||||||
log.Warning("Connected to %s but after the timeout :(", p.ID())
|
log.Warning("Connected to %s but after the timeout :(", p.ID())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,6 @@ func (s *EventsStream) Start() error {
|
||||||
} else {
|
} else {
|
||||||
log.Debug("Skipping ignored event %v", e)
|
log.Debug("Skipping ignored event %v", e)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
|
|
||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
return
|
return
|
||||||
|
|
|
@ -81,9 +81,9 @@ func (mc *MacChanger) Configure() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MacChanger) setMac(mac net.HardwareAddr) error {
|
func (mc *MacChanger) setMac(mac net.HardwareAddr) error {
|
||||||
os := runtime.GOOS
|
var args []string
|
||||||
args := []string{}
|
|
||||||
|
|
||||||
|
os := runtime.GOOS
|
||||||
if strings.Contains(os, "bsd") || os == "darwin" {
|
if strings.Contains(os, "bsd") || os == "darwin" {
|
||||||
args = []string{mc.iface, "ether", mac.String()}
|
args = []string{mc.iface, "ether", mac.String()}
|
||||||
} else if os == "linux" || os == "android" {
|
} else if os == "linux" || os == "android" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue