overflow_discovery/discovery/port.go

31 lines
785 B
Go
Raw Normal View History

2017-11-15 12:33:46 +00:00
package discovery
2017-11-18 08:23:39 +00:00
import (
"fmt"
"net"
"git.loafle.net/overflow/overflow_discovery/api/module/discovery/model"
"git.loafle.net/overflow/overflow_discovery/discovery/ipv4"
"git.loafle.net/overflow/overflow_discovery/discovery/ipv6"
)
2017-11-15 12:33:46 +00:00
2017-11-16 11:01:42 +00:00
func scanPort(host *model.Host, dp *model.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) {
2017-11-18 08:23:39 +00:00
_, ipNet, err := net.ParseCIDR(host.Zone.Network)
if nil != err {
errChan <- err
doneChan <- struct{}{}
return
}
switch len(ipNet.IP) {
case net.IPv4len:
ipv4.ScanPort(host, dp, resultChan, errChan, doneChan)
case net.IPv6len:
ipv6.ScanPort(host, dp, resultChan, errChan, doneChan)
default:
errChan <- fmt.Errorf("Discovery: Not supported ip length")
doneChan <- struct{}{}
return
}
2017-11-15 12:33:46 +00:00
}