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 {
|
||||
lPad = diff / 2
|
||||
rPad = diff - lPad + 1
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
} /* else {
|
||||
TODO
|
||||
} */
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func Make(iface *network.Endpoint) FirewallManager {
|
|||
firewall := &LinuxFirewall{
|
||||
iface: iface,
|
||||
forwarding: false,
|
||||
redirections: make(map[string]*Redirection, 0),
|
||||
redirections: make(map[string]*Redirection),
|
||||
}
|
||||
|
||||
firewall.forwarding = firewall.IsForwardingEnabled()
|
||||
|
@ -45,13 +45,10 @@ func (f LinuxFirewall) enableFeature(filename string, enable bool) error {
|
|||
}
|
||||
defer fd.Close()
|
||||
|
||||
if _, err = fd.WriteString(value); err != nil {
|
||||
_, err = fd.WriteString(value)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f LinuxFirewall) IsForwardingEnabled() bool {
|
||||
|
||||
if out, err := ioutil.ReadFile(IPV4ForwardingFile); err != nil {
|
||||
|
@ -67,7 +64,7 @@ func (f LinuxFirewall) EnableForwarding(enabled bool) error {
|
|||
|
||||
func (f *LinuxFirewall) getCommandLine(r *Redirection, enabled bool) (cmdLine []string) {
|
||||
action := "-A"
|
||||
if enabled == false {
|
||||
if !enabled {
|
||||
action = "-D"
|
||||
}
|
||||
|
||||
|
@ -102,8 +99,8 @@ func (f *LinuxFirewall) EnableRedirection(r *Redirection, enabled bool) error {
|
|||
rkey := r.String()
|
||||
_, found := f.redirections[rkey]
|
||||
|
||||
if enabled == true {
|
||||
if found == true {
|
||||
if !enabled {
|
||||
if found {
|
||||
return fmt.Errorf("Redirection '%s' already enabled.", rkey)
|
||||
}
|
||||
|
||||
|
@ -116,7 +113,7 @@ func (f *LinuxFirewall) EnableRedirection(r *Redirection, enabled bool) error {
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
if found == false {
|
||||
if !found {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -241,8 +241,11 @@ func (d *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) {
|
|||
}
|
||||
|
||||
func (d *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) {
|
||||
if err != nil {
|
||||
log.Warning("Connected to %s but with error: %s", p.ID(), err)
|
||||
return
|
||||
} else if d.currDevice == nil {
|
||||
// timed out
|
||||
if d.currDevice == nil {
|
||||
log.Warning("Connected to %s but after the timeout :(", p.ID())
|
||||
return
|
||||
}
|
||||
|
|
|
@ -162,7 +162,6 @@ func (s *EventsStream) Start() error {
|
|||
} else {
|
||||
log.Debug("Skipping ignored event %v", e)
|
||||
}
|
||||
break
|
||||
|
||||
case <-s.quit:
|
||||
return
|
||||
|
|
|
@ -81,9 +81,9 @@ func (mc *MacChanger) Configure() (err error) {
|
|||
}
|
||||
|
||||
func (mc *MacChanger) setMac(mac net.HardwareAddr) error {
|
||||
os := runtime.GOOS
|
||||
args := []string{}
|
||||
var args []string
|
||||
|
||||
os := runtime.GOOS
|
||||
if strings.Contains(os, "bsd") || os == "darwin" {
|
||||
args = []string{mc.iface, "ether", mac.String()}
|
||||
} else if os == "linux" || os == "android" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue