diff --git a/discovery/ipv4/port.go b/discovery/ipv4/port.go new file mode 100644 index 0000000..11f7999 --- /dev/null +++ b/discovery/ipv4/port.go @@ -0,0 +1,7 @@ +package ipv4 + +import "git.loafle.net/overflow/overflow_discovery/api/module/discovery/model" + +func ScanPort(host *model.Host, dp *model.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) { + +} diff --git a/discovery/ipv6/port.go b/discovery/ipv6/port.go new file mode 100644 index 0000000..e4332c1 --- /dev/null +++ b/discovery/ipv6/port.go @@ -0,0 +1,7 @@ +package ipv6 + +import "git.loafle.net/overflow/overflow_discovery/api/module/discovery/model" + +func ScanPort(host *model.Host, dp *model.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) { + +} diff --git a/discovery/port.go b/discovery/port.go index e1af3c3..ef0459f 100644 --- a/discovery/port.go +++ b/discovery/port.go @@ -1,7 +1,30 @@ package discovery -import "git.loafle.net/overflow/overflow_discovery/api/module/discovery/model" +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 scanPort(host *model.Host, dp *model.DiscoveryPort, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}) { - doneChan <- struct{}{} + _, ipNet, err := net.ParseCIDR(host.Zone.Network) + if nil != err { + errChan <- err + doneChan <- struct{}{} + return + } + switch len(ipNet.IP) { + case net.IPv4len: + ipv4.ScanPort(host, dp, resultChan, errChan, doneChan) + case net.IPv6len: + ipv6.ScanPort(host, dp, resultChan, errChan, doneChan) + + default: + errChan <- fmt.Errorf("Discovery: Not supported ip length") + doneChan <- struct{}{} + return + } }