container_discovery/internal/discoverer/host.go

27 lines
797 B
Go
Raw Normal View History

2018-04-19 11:36:56 +00:00
package discoverer
import (
"fmt"
2018-04-26 09:00:24 +00:00
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
2018-06-13 10:20:14 +00:00
ocmm "git.loafle.net/overflow/commons-go/model/meta"
2018-04-19 11:36:56 +00:00
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv4"
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv6"
)
2018-04-27 16:20:01 +00:00
func scanHost(zone *ocmd.Zone, dh *ocmd.DiscoverHost, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}, stopChan chan struct{}) {
2018-04-19 11:36:56 +00:00
defer func() {
doneChan <- struct{}{}
}()
2018-06-13 10:20:14 +00:00
switch ocmm.ToMetaIPTypeEnum(dh.MetaIPType) {
case ocmm.MetaIPTypeEnumV4:
2018-04-19 11:36:56 +00:00
ipv4.ScanHost(zone, dh, resultChan, errChan, stopChan)
2018-06-13 10:20:14 +00:00
case ocmm.MetaIPTypeEnumV6:
2018-04-19 11:36:56 +00:00
ipv6.ScanHost(zone, dh, resultChan, errChan, stopChan)
default:
2018-06-13 10:20:14 +00:00
errChan <- fmt.Errorf("Discovery: Not supported MetaIPType")
2018-04-19 11:36:56 +00:00
}
2018-06-13 10:20:14 +00:00
2018-04-19 11:36:56 +00:00
}