overflow_discovery/discovery/port.go
crusader be4832f7a9 ing
2017-11-18 17:23:39 +09:00

31 lines
785 B
Go

package discovery
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"
)
func scanPort(host *model.Host, dp *model.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) {
_, 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
}
}