container_discovery/internal/discoverer/port.go

27 lines
799 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 scanPort(host *ocmd.Host, dp *ocmd.DiscoverPort, 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(host.MetaIPType) {
case ocmm.MetaIPTypeEnumV4:
2018-04-19 11:36:56 +00:00
ipv4.ScanPort(host, dp, resultChan, errChan, stopChan)
2018-06-13 10:20:14 +00:00
case ocmm.MetaIPTypeEnumV6:
2018-04-19 11:36:56 +00:00
ipv6.ScanPort(host, dp, 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
}