container_discovery/internal/discoverer/service.go
crusader 7d2e8170d7 ing
2018-04-26 18:00:24 +09:00

34 lines
831 B
Go

package discoverer
import (
"fmt"
"net"
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv4"
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv6"
)
func scanService(port *ocmd.Port, ds *ocmd.DiscoveryService, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}, stopChan chan struct{}) {
defer func() {
doneChan <- struct{}{}
}()
_, ipNet, err := net.ParseCIDR(port.Host.Zone.Network)
if nil != err {
errChan <- err
return
}
switch len(ipNet.IP) {
case net.IPv4len:
ipv4.ScanService(port, ds, resultChan, errChan, stopChan)
case net.IPv6len:
ipv6.ScanService(port, ds, resultChan, errChan, stopChan)
default:
errChan <- fmt.Errorf("Discovery: Not supported ip length")
return
}
}