services

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 10 Imported by: 0

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

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

func (s *NetworkService) DeleteNetwork(ctx context.Context, id uuid.UUID) error

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

func (s *NetworkService) ListNetworks(ctx context.Context, activeOnly bool) ([]*db.Network, error)

ListNetworks returns all networks with optional filtering.

func (*NetworkService) RemoveExclusion

func (s *NetworkService) RemoveExclusion(ctx context.Context, exclusionID uuid.UUID) error

RemoveExclusion removes an exclusion rule.

func (*NetworkService) SeedNetworksFromConfig

func (s *NetworkService) SeedNetworksFromConfig(ctx context.Context, cfg *config.Config) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL