From b7c743784048a9596e5df439d17e647917956637 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 15 Nov 2017 19:38:42 +0900 Subject: [PATCH] ing --- api/module/discovery/model/discovery.go | 43 +++++++++++++++++ api/module/discovery/model/host.go | 11 +++++ api/module/discovery/model/port.go | 9 ++++ api/module/discovery/model/service.go | 9 ++++ api/module/discovery/model/zone.go | 9 ++++ rpc/discovery_service.go | 63 +++---------------------- 6 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 api/module/discovery/model/discovery.go create mode 100644 api/module/discovery/model/host.go create mode 100644 api/module/discovery/model/port.go create mode 100644 api/module/discovery/model/service.go create mode 100644 api/module/discovery/model/zone.go diff --git a/api/module/discovery/model/discovery.go b/api/module/discovery/model/discovery.go new file mode 100644 index 0000000..83c9f11 --- /dev/null +++ b/api/module/discovery/model/discovery.go @@ -0,0 +1,43 @@ +package model + +type DiscoveryZone struct { + ExcludePatterns []string `json:"excludePatterns"` + + DiscoveryHost *DiscoveryHost `json:"discoveryHost"` +} + +type DiscoveryHost struct { + Zone Zone `json:"zone"` + + FirstScanRange string `json:"firstScanRange"` + LastScanRange string `json:"lastScanRange"` + ExcludeHosts []string `json:"excludeHosts"` + + DiscoveryPort *DiscoveryPort `json:"discoveryPort"` +} + +type DiscoveryPort struct { + Host Host `json:"host"` + + FirstScanRange int `json:"firstScanRange"` + LastScanRange int `json:"lastScanRange"` + ExcludePorts []int `json:"excludePorts"` + + DiscoveryService *DiscoveryService `json:"discoveryService"` +} + +type DiscoveryService struct { + Port Port `json:"port"` + + IncludeServices []string `json:"includeServices"` +} + +/* +Dzone --> zone --> Dhost --> host --> Dport --> port --> Dservice --> service + +zone --> Dhost --> host --> Dport --> port --> Dservice --> service + +host --> Dport --> port --> Dservice --> service + +port --> Dservice --> service +*/ diff --git a/api/module/discovery/model/host.go b/api/module/discovery/model/host.go new file mode 100644 index 0000000..03cfa81 --- /dev/null +++ b/api/module/discovery/model/host.go @@ -0,0 +1,11 @@ +package model + +type Host struct { + Zone *Zone `json:"zone"` + + ID int `json:"id,omitempty"` + IP string `json:"ip"` + Mac string `json:"mac"` + + OS string `json:"os,omitempty"` +} diff --git a/api/module/discovery/model/port.go b/api/module/discovery/model/port.go new file mode 100644 index 0000000..7737f84 --- /dev/null +++ b/api/module/discovery/model/port.go @@ -0,0 +1,9 @@ +package model + +type Port struct { + Host *Host `json:"host,omitempty"` + + ID int `json:"id,omitempty"` + PortType string `json:"portType,omitempty"` + PortNumber int `json:"portNumber,omitempty"` +} diff --git a/api/module/discovery/model/service.go b/api/module/discovery/model/service.go new file mode 100644 index 0000000..003b871 --- /dev/null +++ b/api/module/discovery/model/service.go @@ -0,0 +1,9 @@ +package model + +type Service struct { + Port *Port `json:"port,omitempty"` + + ID int `json:"id,omitempty"` + TLSType string `json:"tlsType,omitempty"` + ServiceName string `json:"serviceName,omitempty"` +} diff --git a/api/module/discovery/model/zone.go b/api/module/discovery/model/zone.go new file mode 100644 index 0000000..1cabc98 --- /dev/null +++ b/api/module/discovery/model/zone.go @@ -0,0 +1,9 @@ +package model + +type Zone struct { + ID int `json:"id,omitempty"` + Network string `json:"network"` + IP string `json:"ip"` + Iface string `json:"iface"` + Mac string `json:"mac"` +} diff --git a/rpc/discovery_service.go b/rpc/discovery_service.go index 6bc835f..89cc1f1 100644 --- a/rpc/discovery_service.go +++ b/rpc/discovery_service.go @@ -1,65 +1,14 @@ package rpc -import ( - "log" -) - type DiscoveryService struct { } -type StartRequestParam struct { - Name string - Count int +func (ds *DiscoveryService) Start(discoveryType string, param interface{}) error { + + return nil } -type StartResponseParam struct { - Result int -} - -// func (ds *DiscoveryService) Start(req *StartRequestParam) (*StartResponseParam, error) { -// log.Printf("DiscoveryService.Start param: Name[%s] Count[%d]", req.Name, req.Count) -// res := &StartResponseParam{} - -// res.Result = 10 + req.Count - -// return res, nil -// } - -// func (ds *DiscoveryService) Discovery(name string, req *StartRequestParam) error { -// log.Printf("DiscoveryService.Discovery param: Name[%s] req[%v]", name, req) - -// return nil -// } - -// func (ds *DiscoveryService) Discovery1(count int, name string, req *StartRequestParam) error { -// log.Printf("DiscoveryService.Discovery param: Count[%d] Name[%s] req[%v]", count, name, req) - -// return nil -// } - -func (ds *DiscoveryService) Discovery2(count int, name string, req *StartRequestParam) (*StartResponseParam, error) { - log.Printf("DiscoveryService.Discovery2 param: count[%d] name[%s] req.Name[%s] req.Count[%d]", count, name, req.Name, req.Count) - res := &StartResponseParam{} - - res.Result = 10 + req.Count - - return res, nil -} - -func (ds *DiscoveryService) Discovery3(names []string, req *StartRequestParam) (*StartResponseParam, error) { - log.Printf("DiscoveryService.Discovery3 param: names[%v] req.Name[%s] req.Count[%d]", names, req.Name, req.Count) - res := &StartResponseParam{} - - res.Result = 10 + req.Count - - return res, nil -} - -func (ds *DiscoveryService) Discovery4(names map[string]string, req *StartRequestParam) (*StartResponseParam, error) { - log.Printf("DiscoveryService.Discovery4 param: names[%v] req.Name[%s] req.Count[%d]", names, req.Name, req.Count) - res := &StartResponseParam{} - - res.Result = 10 + req.Count - - return res, nil +func (ds *DiscoveryService) Stop() error { + + return nil }