33 lines
813 B
Go
33 lines
813 B
Go
|
package discoverer
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net"
|
||
|
|
||
|
ocdm "git.loafle.net/overflow/commons-go/discovery/model"
|
||
|
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv4"
|
||
|
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv6"
|
||
|
)
|
||
|
|
||
|
func scanPort(host *ocdm.Host, dp *ocdm.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}, stopChan chan struct{}) {
|
||
|
defer func() {
|
||
|
doneChan <- struct{}{}
|
||
|
}()
|
||
|
|
||
|
_, ipNet, err := net.ParseCIDR(host.Zone.Network)
|
||
|
if nil != err {
|
||
|
errChan <- err
|
||
|
return
|
||
|
}
|
||
|
switch len(ipNet.IP) {
|
||
|
case net.IPv4len:
|
||
|
ipv4.ScanPort(host, dp, resultChan, errChan, stopChan)
|
||
|
case net.IPv6len:
|
||
|
ipv6.ScanPort(host, dp, resultChan, errChan, stopChan)
|
||
|
|
||
|
default:
|
||
|
errChan <- fmt.Errorf("Discovery: Not supported ip length")
|
||
|
return
|
||
|
}
|
||
|
}
|