48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
|
package rpc
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
|
||
|
"git.loafle.net/overflow/overflow_discovery/api/module/discovery/model"
|
||
|
)
|
||
|
|
||
|
type DiscoveryService struct {
|
||
|
}
|
||
|
|
||
|
func zoneString(z *model.Zone) string {
|
||
|
return fmt.Sprintf("Zone (Iface[%s] Mac[%s] Network[%s] IP[%s])", z.Iface, z.Mac, z.Network, z.IP)
|
||
|
}
|
||
|
|
||
|
func hostString(h *model.Host) string {
|
||
|
return fmt.Sprintf("%s Host (Mac[%s] IP[%s] OS[%s])", zoneString(h.Zone), h.Mac, h.IP, h.OS)
|
||
|
}
|
||
|
|
||
|
func portString(p *model.Port) string {
|
||
|
return fmt.Sprintf("%s Port (Type[%s] Number[%d])", hostString(p.Host), p.PortType, p.PortNumber)
|
||
|
}
|
||
|
|
||
|
func serviceString(s *model.Service) string {
|
||
|
return fmt.Sprintf("%s Service (Type[%s] Name[%s])", portString(s.Port), s.CryptoType, s.ServiceName)
|
||
|
}
|
||
|
|
||
|
func (ds *DiscoveryService) DiscoveredZone(z *model.Zone) error {
|
||
|
log.Printf("DiscoveredZone: %s", zoneString(z))
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (ds *DiscoveryService) DiscoveredHost(h *model.Host) error {
|
||
|
log.Printf("DiscoveredHost: %v", hostString(h))
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (ds *DiscoveryService) DiscoveredPort(p *model.Port) error {
|
||
|
log.Printf("DiscoveredPort: %v", portString(p))
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (ds *DiscoveryService) DiscoveredService(s *model.Service) error {
|
||
|
log.Printf("DiscoveredService: %v", serviceString(s))
|
||
|
return nil
|
||
|
}
|