daemon

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package daemon provides the background service functionality for scanorama. It manages scheduled discovery and scanning jobs, handles API endpoints, and coordinates the overall operation of the scanning system.

Index

Constants

View Source
const (
	DefaultDirPermissions  = 0o750
	DefaultFilePermissions = 0o600
)

File permission constants.

Variables

This section is empty.

Functions

func DropPrivileges added in v0.23.0

func DropPrivileges(userName, groupName string, logf func(string, ...any)) error

DropPrivileges drops root privileges to the given user and group when the process is running as root and both names are non-empty. It is safe to call when not root — it logs a notice and returns nil. The logf argument accepts a printf-style function so callers can plug in any logger.

Order matters: group must be changed before user because setuid discards the ability to call setgid afterwards.

WARNING: once privileges are dropped the process cannot reclaim them. Callers that need to invoke nmap with raw-socket access (SYN/OS-detection scans) must do so before calling this function.

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon represents the main daemon process.

func New

func New(cfg *config.Config) *Daemon

New creates a new daemon instance.

func (*Daemon) GetConfig

func (d *Daemon) GetConfig() *config.Config

GetConfig returns the daemon configuration.

func (*Daemon) GetContext

func (d *Daemon) GetContext() context.Context

GetContext returns the daemon's context.

func (*Daemon) GetDatabase

func (d *Daemon) GetDatabase() *db.DB

GetDatabase returns the database connection.

func (*Daemon) GetPID

func (d *Daemon) GetPID() int

GetPID returns the daemon's PID.

func (*Daemon) IsDebugMode added in v0.9.0

func (d *Daemon) IsDebugMode() bool

IsDebugMode returns the current debug mode state.

func (*Daemon) IsRunning

func (d *Daemon) IsRunning() bool

IsRunning checks if the daemon is running.

func (*Daemon) Start

func (d *Daemon) Start() error

Start starts the daemon.

func (*Daemon) Stop

func (d *Daemon) Stop() error

Stop stops the daemon gracefully.

Jump to

Keyboard shortcuts

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