started structuring project for testing + lint driven various refactoring

This commit is contained in:
evilsocket 2018-04-24 15:12:25 +02:00
parent 64099bc1fb
commit bc3be7dd2b
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
5 changed files with 17 additions and 18 deletions

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -162,7 +162,6 @@ func (s *EventsStream) Start() error {
} else {
log.Debug("Skipping ignored event %v", e)
}
break
case <-s.quit:
return

View file

@ -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" {