Skip to content

Commit

Permalink
remove subscribing goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
RicYaben committed Nov 15, 2024
1 parent cc1f9e7 commit 79ebfd3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions modules/mqtt/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *scan) makeMessageHandler() func(c paho.Client, m paho.Message) {
topic := m.Topic()
if isFull(topic) {
// unsubscribe and ignore the message
c.Unsubscribe(topic)
//c.Unsubscribe(topic)
return
}

Expand Down Expand Up @@ -172,17 +172,12 @@ func (s *scan) Grab() *zgrab2.ScanError {
}
defer client.Disconnect(250)

var subErr *zgrab2.ScanError
go func() {
s.SetFilters()
handler := s.makeMessageHandler()
if t := client.SubscribeMultiple(s.filters, handler); t.Wait() && t.Error() != nil {
subErr = zgrab2.NewScanError(zgrab2.SCAN_CONNECTION_REFUSED, t.Error())
}
}()
s.SetFilters()
handler := s.makeMessageHandler()
client.SubscribeMultiple(s.filters, handler)

s.wait(client)
return subErr
return nil
}

type ScanBuilder struct {
Expand Down

0 comments on commit 79ebfd3

Please sign in to comment.