Merge pull request #706 from boolooper/master

Improve code and fix race conditions
This commit is contained in:
Simone Margaritelli 2020-04-08 10:46:55 +02:00 committed by GitHub
commit 1cf74121a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 9 additions and 12 deletions

View file

@ -75,7 +75,7 @@ func (mod *EventsStream) dumpForm(body []byte) string {
if err != nil {
value = v
}
form = append(form, fmt.Sprintf("%s", tui.Bold(tui.Red(value))))
form = append(form, tui.Bold(tui.Red(value)))
}
}
return "\n" + strings.Join(form, "&") + "\n"
@ -113,7 +113,7 @@ func (mod *EventsStream) dumpJSON(body []byte) string {
if err := json.Indent(&buf, body, "", " "); err != nil {
pretty = string(body)
} else {
pretty = string(buf.Bytes())
pretty = buf.String()
}
return "\n" + reJsonKey.ReplaceAllString(pretty, tui.Green(`$1:`)) + "\n"

View file

@ -121,7 +121,7 @@ func (mod *MySQLServer) Start() error {
if _, err := conn.Write(packets.MySQLGreeting); err != nil {
mod.Warning("error while writing server greeting: %s", err)
continue
} else if read, err = reader.Read(readBuffer); err != nil {
} else if _, err = reader.Read(readBuffer); err != nil {
mod.Warning("error while reading client message: %s", err)
continue
}

View file

@ -13,7 +13,7 @@ import (
)
func upnpParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
if data := packets.UPNPGetMeta(pkt); data != nil && len(data) > 0 {
if data := packets.UPNPGetMeta(pkt); len(data) > 0 {
s := ""
for name, value := range data {
s += fmt.Sprintf("%s:%s ", tui.Blue(name), tui.Yellow(value))

View file

@ -227,8 +227,8 @@ func (mod *SynScanner) synScan() error {
mod.State.Store("progress", 0.0)
// start the collector
mod.waitGroup.Add(1)
go func() {
mod.waitGroup.Add(1)
defer mod.waitGroup.Done()
for packet := range mod.packets {

View file

@ -88,9 +88,8 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
}
return fmt.Errorf("%s is an unknown BSSID or it is in the association skip list.", to.String())
}
mod.writes.Add(1)
go func() {
mod.writes.Add(1)
defer mod.writes.Done()
// since we need to change the wifi adapter channel for each

View file

@ -113,8 +113,8 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
return fmt.Errorf("%s is an unknown BSSID, is in the deauth skip list, or doesn't have detected clients.", to.String())
}
mod.writes.Add(1)
go func() {
mod.writes.Add(1)
defer mod.writes.Done()
// since we need to change the wifi adapter channel for each

View file

@ -92,7 +92,7 @@ func (mod *WiFiModule) channelHopper() {
}
select {
case _ = <-mod.hopChanges:
case <-mod.hopChanges:
mod.Debug("hop changed")
break loopCurrentChannels
case <-time.After(delay):

View file

@ -65,9 +65,7 @@ func (p *EventPool) Listen() <-chan Event {
go func() {
for i := len(p.events) - 1; i >= 0; i-- {
defer func() {
if recover() != nil {
}
recover()
}()
l <- p.events[i]
}