overflow_discovery/discovery/host.go
crusader 6ac80b1a88 ing
2017-11-18 00:12:38 +09:00

31 lines
780 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 scanHost(zone *model.Zone, dh *model.DiscoveryHost, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) {
_, ipNet, err := net.ParseCIDR(zone.Network)
if nil != err {
errChan <- err
doneChan <- struct{}{}
return
}
switch len(ipNet.IP) {
case net.IPv4len:
ipv4.ScanHost(zone, dh, resultChan, errChan, doneChan)
case net.IPv6len:
ipv6.ScanHost(zone, dh, resultChan, errChan, doneChan)
default:
errChan <- fmt.Errorf("Discovery: Not supported ip length")
doneChan <- struct{}{}
return
}
}