Documentation
¶
Overview ¶
Package services provides business logic services for Scanorama. This file implements network management functionality including config-based network seeding, exclusion management, and integration with the discovery engine.
Index ¶
- type NetworkService
- func (s *NetworkService) AddExclusion(ctx context.Context, networkID *uuid.UUID, cidr, reason string) (*db.NetworkExclusion, error)
- func (s *NetworkService) CreateNetwork(ctx context.Context, name, cidr, description, method string, enabled bool) (*db.Network, error)
- func (s *NetworkService) DeleteNetwork(ctx context.Context, id uuid.UUID) error
- func (s *NetworkService) GenerateTargetsForNetwork(ctx context.Context, networkID uuid.UUID, maxHosts int) ([]string, error)
- func (s *NetworkService) GetActiveNetworks(ctx context.Context) ([]*NetworkWithExclusions, error)
- func (s *NetworkService) GetGlobalExclusions(ctx context.Context) ([]*db.NetworkExclusion, error)
- func (s *NetworkService) GetNetworkByID(ctx context.Context, id uuid.UUID) (*NetworkWithExclusions, error)
- func (s *NetworkService) GetNetworkByName(ctx context.Context, name string) (*NetworkWithExclusions, error)
- func (s *NetworkService) GetNetworkStats(ctx context.Context) (map[string]interface{}, error)
- func (s *NetworkService) ListNetworks(ctx context.Context, activeOnly bool) ([]*db.Network, error)
- func (s *NetworkService) RemoveExclusion(ctx context.Context, exclusionID uuid.UUID) error
- func (s *NetworkService) SeedNetworksFromConfig(ctx context.Context, cfg *config.Config) error
- func (s *NetworkService) UpdateNetwork(ctx context.Context, id uuid.UUID, name, cidr, description, method string, ...) (*db.Network, error)
- func (s *NetworkService) UpdateNetworkDiscoveryTime(ctx context.Context, networkID uuid.UUID, discoveredHosts, activeHosts int) error
- type NetworkWithExclusions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetworkService ¶
type NetworkService struct {
// contains filtered or unexported fields
}
NetworkService manages network configuration and exclusions.
func NewNetworkService ¶
func NewNetworkService(database *db.DB) *NetworkService
NewNetworkService creates a new network service.
func (*NetworkService) AddExclusion ¶
func (s *NetworkService) AddExclusion( ctx context.Context, networkID *uuid.UUID, cidr, reason string, ) (*db.NetworkExclusion, error)
AddExclusion adds a new exclusion rule.
func (*NetworkService) CreateNetwork ¶
func (s *NetworkService) CreateNetwork( ctx context.Context, name, cidr, description, method string, enabled bool, ) (*db.Network, error)
CreateNetwork creates a new network.
func (*NetworkService) DeleteNetwork ¶
DeleteNetwork deletes a network and all its exclusions.
func (*NetworkService) GenerateTargetsForNetwork ¶
func (s *NetworkService) GenerateTargetsForNetwork( ctx context.Context, networkID uuid.UUID, maxHosts int, ) ([]string, error)
GenerateTargetsForNetwork generates valid scan targets for a network, applying all exclusions.
func (*NetworkService) GetActiveNetworks ¶
func (s *NetworkService) GetActiveNetworks(ctx context.Context) ([]*NetworkWithExclusions, error)
GetActiveNetworks returns all active networks with their exclusions.
func (*NetworkService) GetGlobalExclusions ¶
func (s *NetworkService) GetGlobalExclusions(ctx context.Context) ([]*db.NetworkExclusion, error)
GetGlobalExclusions returns all global exclusions.
func (*NetworkService) GetNetworkByID ¶
func (s *NetworkService) GetNetworkByID(ctx context.Context, id uuid.UUID) (*NetworkWithExclusions, error)
GetNetworkByID retrieves a network by ID with its exclusions.
func (*NetworkService) GetNetworkByName ¶
func (s *NetworkService) GetNetworkByName(ctx context.Context, name string) (*NetworkWithExclusions, error)
GetNetworkByName retrieves a network by name with its exclusions.
func (*NetworkService) GetNetworkStats ¶
func (s *NetworkService) GetNetworkStats(ctx context.Context) (map[string]interface{}, error)
GetNetworkStats returns statistics about networks and exclusions.
func (*NetworkService) ListNetworks ¶
ListNetworks returns all networks with optional filtering.
func (*NetworkService) RemoveExclusion ¶
RemoveExclusion removes an exclusion rule.
func (*NetworkService) SeedNetworksFromConfig ¶
SeedNetworksFromConfig creates or updates networks based on config.
func (*NetworkService) UpdateNetwork ¶
func (s *NetworkService) UpdateNetwork( ctx context.Context, id uuid.UUID, name, cidr, description, method string, enabled bool, ) (*db.Network, error)
UpdateNetwork updates an existing network.
func (*NetworkService) UpdateNetworkDiscoveryTime ¶
func (s *NetworkService) UpdateNetworkDiscoveryTime( ctx context.Context, networkID uuid.UUID, discoveredHosts, activeHosts int, ) error
UpdateNetworkDiscoveryTime updates the last discovery timestamp for a network.
type NetworkWithExclusions ¶
type NetworkWithExclusions struct {
Network *db.Network
Exclusions []*db.NetworkExclusion
}
NetworkWithExclusions represents a network with its exclusions.