Skip to content

Commit

Permalink
update: scan each ip and fast report it records to channel instead of…
Browse files Browse the repository at this point in the history
… scan whole ip net and then report
  • Loading branch information
Esonhugh committed Mar 21, 2024
1 parent 8b6f0a9 commit 2da4ceb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/mutli/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (s *SubnetScanner) ScanSubnet(subnet *net.IPNet) <-chan []define.Record {

func (s *SubnetScanner) scan(subnet *net.IPNet, to chan []define.Record) {
s.wg.Add(1)
to <- scanner.ScanSubnet(subnet)
// to <- scanner.ScanSubnet(subnet)
for _, ip := range pkg.ParseIPNetToIPs(subnet) {
to <- scanner.ScanSingleIP(ip)
}
s.wg.Done()
}
12 changes: 12 additions & 0 deletions pkg/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ import (
log "github.com/sirupsen/logrus"
)

func ScanSingleIP(subnet net.IP) (records []define.Record) {
ptr := pkg.PTRRecord(subnet)
if len(ptr) > 0 {
for _, domain := range ptr {
log.Infof("PTRrecord %v --> %v", subnet, domain)
r := define.Record{Ip: subnet, SvcDomain: domain}
records = append(records, r)
}
}
return
}

func ScanSubnet(subnet *net.IPNet) (records []define.Record) {
for _, ip := range pkg.ParseIPNetToIPs(subnet) {
ptr := pkg.PTRRecord(ip)
Expand Down

0 comments on commit 2da4ceb

Please sign in to comment.