2018-08-12 11:08:31 +00:00
|
|
|
package ipv4
|
|
|
|
|
2018-08-13 04:20:22 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-08-13 07:19:59 +00:00
|
|
|
omd "git.loafle.net/overflow/model/discovery"
|
2018-08-13 04:20:22 +00:00
|
|
|
omm "git.loafle.net/overflow/model/meta"
|
|
|
|
omu "git.loafle.net/overflow/model/util"
|
|
|
|
)
|
2018-08-12 11:08:31 +00:00
|
|
|
|
|
|
|
func TestHostScan(t *testing.T) {
|
|
|
|
|
2018-08-13 07:19:59 +00:00
|
|
|
z := &omd.Zone{
|
2018-08-13 04:20:22 +00:00
|
|
|
Network: "192.168.1.0/24",
|
2018-08-15 06:18:40 +00:00
|
|
|
Iface: "\\Device\\NPF_{1924FA2B-6927-4BA5-AF43-876C3F8853CE}",
|
2018-08-13 04:20:22 +00:00
|
|
|
Mac: "30:9C:23:15:A3:09",
|
|
|
|
Address: "192.168.1.201",
|
|
|
|
DiscoveredDate: omu.NowPtr(),
|
|
|
|
}
|
|
|
|
|
2018-08-13 07:19:59 +00:00
|
|
|
dp := &omd.DiscoverPort{
|
2018-08-13 04:20:22 +00:00
|
|
|
FirstScanRange: 1,
|
|
|
|
LastScanRange: 20000,
|
|
|
|
ExcludePorts: []int{
|
|
|
|
631,
|
|
|
|
},
|
|
|
|
IncludeTCP: true,
|
|
|
|
IncludeUDP: true,
|
|
|
|
DiscoverService: nil,
|
|
|
|
}
|
|
|
|
|
2018-08-13 07:19:59 +00:00
|
|
|
dh := &omd.DiscoverHost{
|
2018-08-13 04:20:22 +00:00
|
|
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
|
|
|
FirstScanRange: "192.168.1.1",
|
|
|
|
LastScanRange: "192.168.1.255",
|
|
|
|
DiscoverPort: dp,
|
|
|
|
}
|
|
|
|
|
|
|
|
resCh := make(chan interface{})
|
|
|
|
errCh := make(chan error)
|
|
|
|
stopCh := make(chan struct{})
|
|
|
|
ScanHost(z, dh, resCh, errCh, stopCh)
|
|
|
|
|
|
|
|
for res := range resCh {
|
|
|
|
t.Log(res)
|
|
|
|
}
|
|
|
|
|
|
|
|
for err := range errCh {
|
|
|
|
t.Log(err)
|
|
|
|
}
|
2018-08-12 11:08:31 +00:00
|
|
|
}
|