78 lines
1.5 KiB
Go
78 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
cRPC "git.loafle.net/commons_go/rpc"
|
|
"git.loafle.net/overflow/ipc_client/rpc"
|
|
oodamdm "git.loafle.net/overflow/overflow_discovery/api/module/discovery/model"
|
|
"git.loafle.net/overflow/overflow_discovery/client"
|
|
)
|
|
|
|
func main() {
|
|
registry := cRPC.NewRegistry()
|
|
registry.RegisterService(new(rpc.DiscoveryService), "")
|
|
|
|
c := client.New("/tmp/discovery.sock", registry)
|
|
if err := c.Connect(); nil != err {
|
|
fmt.Printf("%v", err)
|
|
}
|
|
|
|
dz := newDiscoveryZone(true)
|
|
if err := c.Send("DiscoveryService.DiscoverZone", dz); nil != err {
|
|
fmt.Printf("%v\n", err)
|
|
}
|
|
|
|
time.Sleep(1 * time.Minute)
|
|
}
|
|
|
|
func newDiscoveryZone(includeDHost bool) *oodamdm.DiscoveryZone {
|
|
dz := &oodamdm.DiscoveryZone{
|
|
ExcludePatterns: []string{},
|
|
}
|
|
|
|
if includeDHost {
|
|
dz.DiscoveryHost = newDiscoveryHost(true)
|
|
}
|
|
|
|
return dz
|
|
}
|
|
|
|
func newDiscoveryHost(includeDPort bool) *oodamdm.DiscoveryHost {
|
|
dh := &oodamdm.DiscoveryHost{
|
|
FirstScanRange: "192.168.1.1",
|
|
LastScanRange: "192.168.1.254",
|
|
ExcludeHosts: []string{},
|
|
}
|
|
|
|
if includeDPort {
|
|
dh.DiscoveryPort = newDiscoveryPort(true)
|
|
}
|
|
|
|
return dh
|
|
}
|
|
|
|
func newDiscoveryPort(includeDService bool) *oodamdm.DiscoveryPort {
|
|
dp := &oodamdm.DiscoveryPort{
|
|
FirstScanRange: 1,
|
|
LastScanRange: 1024,
|
|
ExcludePorts: []int{},
|
|
IncludeTCP: true,
|
|
IncludeUDP: true,
|
|
}
|
|
|
|
if includeDService {
|
|
dp.DiscoveryService = newDiscoveryService()
|
|
}
|
|
|
|
return dp
|
|
}
|
|
|
|
func newDiscoveryService() *oodamdm.DiscoveryService {
|
|
ds := &oodamdm.DiscoveryService{
|
|
IncludeServices: []string{},
|
|
}
|
|
return ds
|
|
}
|