server-core

module
v0.0.0-...-3f647e7 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0

README

NetTact

NetTact Server Core

English | 简体中文

NetTact Server Core is the reusable Go module behind the NetTact server. It receives Agent data, stores metrics and configuration, detects faults, organizes incidents and notifications, and exposes the HTTP API and live updates consumed by the web console.

This repository is a library and does not contain a standalone main program. End users should follow the deployment guide to install NetTact Server, or use NetTact Desktop for an all-in-one local experience. Both products use this repository and therefore provide the same core server behavior.

Capabilities

  • Agent enrollment, authentication, connectivity state, and persistent WebSocket sessions
  • Ingestion of ICMP, DNS, HTTP, TCP, NAT, host, Wi-Fi, and game data
  • SQLite storage, WAL, separate read/write pools, embedded migrations, rollups, and retention
  • Sites, Agent groups, monitor groups, targets, and egress-proxy configuration
  • Target status, availability, fault signals, fluctuations, and incident lifecycle
  • Incident snapshots, traceroute reports, and diagnostic-evidence orchestration
  • Notification policies, channels, templates, and delivery history
  • Single-user sessions, management APIs, SSE live updates, and optional web-console hosting
  • Historical-data cleanup, operational issues, auditing, and update checks

Why the Core Is a Library

  • Consistent behavior: the self-hosted Server and Desktop do not implement separate alerting, storage, or API stacks.
  • Embeddable: host products can choose their listener, TLS, frontend resources, version policy, and process lifecycle.
  • Simple runtime: the default pure-Go SQLite driver requires neither an external database nor CGO.
  • Read/write isolation: one SQLite writer and a separate read pool prevent dashboard queries from blocking telemetry ingestion.
  • Clear module boundaries: storage, enrollment, configuration, metrics, faults, notifications, and APIs can be tested and composed independently.

Deployment

Server Core is not a deployable unit. See the NetTact deployment guide for Docker Compose, standalone hosting, first login, Agent enrollment, upgrades, backups, HTTPS, and troubleshooting. See Server configuration for server flags, retention, and session settings.

This README documents the library and its integration surface; deployment commands and runtime configuration are intentionally maintained only in the user documentation.

Using It in a Go Project

go get github.com/nettact/server-core@latest

Packages can be composed independently. For example, opening the database creates the file when needed and applies embedded migrations:

package main

import (
    "log"

    "github.com/nettact/server-core/settings"
    "github.com/nettact/server-core/store"
)

func main() {
    db, err := store.Open("./nettact.db")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    settingsService := settings.New(db)
    _ = settingsService
}

A complete server must wire together enrollment, metrics, configuration, the Agent WebSocket, faults, notifications, background workers, and api.Router. These components have lifecycle and dependency ordering requirements. Use server's server package as the reference assembly instead of copying wiring into an empty HTTP server.

Main packages:

Package Purpose
store, metrics, gamedata Database, time-series metrics, and game data
registry, agentws, ingest Agent enrollment, connections, and ingestion
config, site, inventory Monitoring configuration, sites, and inventory
fault, incident, incidentops Fault detection, incidents, and diagnostic orchestration
notification, notifypolicy Notification channels, templates, and delivery policy
targetstatus, agentstatus Current target and Agent status aggregation
api, sse HTTP APIs, session authentication, and live event streams
cleanup, settings, audit Data governance, server settings, and auditing

Data and Security Boundaries

  • Data is stored in the SQLite file chosen by the host. A deployment must back up the database together with its WAL/SHM files, or stop gracefully before copying it.
  • Agents use signed enrollment and persistent credentials; console APIs use an HttpOnly session cookie.
  • Production hosts should serve native TLS or sit behind a trusted TLS-terminating reverse proxy with Secure cookies enabled.
  • api.Router provides application routes only. The host program owns listeners, TLS, signals, database paths, and the web UI lifecycle.

Local Development

The project requires Go 1.25 and the sibling protocol module in the same workspace:

go test ./...
go build ./...

The root go.work resolves local dependencies during multi-repository development. To run the complete product, start nettact-server from server rather than trying to execute this repository directly.

License

Apache License 2.0

Directories

Path Synopsis
Package agentconnectivity is the Agent-liveness detector (AGENT-002): it confirms a fault when an agent stays offline past a configurable grace period and resolves it after the agent reconnects for a confirmation period.
Package agentconnectivity is the Agent-liveness detector (AGENT-002): it confirms a fault when an agent stays offline past a configurable grace period and resolves it after the agent reconnects for a confirmation period.
Package agentstatus is the read-time aggregation behind the Agent status list (AGENT-001).
Package agentstatus is the read-time aggregation behind the Agent status list (AGENT-001).
Package agentws is the server side of the persistent agent WebSocket channel that replaced the HTTP POST telemetry endpoint.
Package agentws is the server side of the persistent agent WebSocket channel that replaced the HTTP POST telemetry endpoint.
Agent status list HTTP handler (AGENT-001).
Agent status list HTTP handler (AGENT-001).
Package asnlookup maps an IPv4 address to the autonomous system that announces it, from an offline table loaded into memory.
Package asnlookup maps an IPv4 address to the autonomous system that announces it, from an offline table loaded into memory.
Package audit records security-relevant actions (login, enroll, config changes).
Package audit records security-relevant actions (login, enroll, config changes).
Package baseline learns what "normal" looks like for each monitored target (ALERT-003), so the fault engine can call a target degraded relative to its own history instead of against a number somebody had to guess.
Package baseline learns what "normal" looks like for each monitored target (ALERT-003), so the fault engine can call a target degraded relative to its own history instead of against a number somebody had to guess.
Package cleanup runs history-data deletion as durable, restart-safe jobs.
Package cleanup runs history-data deletion as durable, restart-safe jobs.
Package config manages monitor groups and their monitoring targets (probe_tasks) and builds the DesiredState the server pushes down to agents.
Package config manages monitor groups and their monitoring targets (probe_tasks) and builds the DesiredState the server pushes down to agents.
Package eventbus is a tiny in-process pub/sub used to decouple server-core modules (architecture §6/§15.4).
Package eventbus is a tiny in-process pub/sub used to decouple server-core modules (architecture §6/§15.4).
Package fault is the built-in fault-detection domain (ALERT-002).
Package fault is the built-in fault-detection domain (ALERT-002).
Package gamedata stores and serves game presentation data: runs (one continuous stretch of a game presenting frames), the per-second buckets hanging from them, the stretches in which they produced no frames, and the machine-level seconds that run underneath all of it.
Package gamedata stores and serves game presentation data: runs (one continuous stretch of a game presenting frames), the per-second buckets hanging from them, the stretches in which they produced no frames, and the machine-level seconds that run underneath all of it.
Package hostlive holds the ephemeral, pull-on-demand host snapshots (live process and network-connection lists) that agents return in response to a console user opening the live page.
Package hostlive holds the ephemeral, pull-on-demand host snapshots (live process and network-connection lists) that agents return in response to a console user opening the live page.
Package identity handles the single admin user: bootstrap, password auth (bcrypt) and server-side sessions (HttpOnly cookie).
Package identity handles the single admin user: bootstrap, password auth (bcrypt) and server-side sessions (HttpOnly cookie).
Package incident is the group-aware read model over the incident tables.
Package incident is the group-aware read model over the incident tables.
Package incidentops is the server-side custody of an incident's evidence: the immutable server-authored snapshot base (INCIDENT-002), the scenes agents collect on their own fault edges (INCIDENT-005), and the traceroutes they run on their own initiative (DIAG-001).
Package incidentops is the server-side custody of an incident's evidence: the immutable server-authored snapshot base (INCIDENT-002), the scenes agents collect on their own fault edges (INCIDENT-005), and the traceroutes they run on their own initiative (DIAG-001).
Package ingest receives, validates, dedups and persists telemetry packets — the heart of the ingest loop (architecture §3.3 / §5.1).
Package ingest receives, validates, dedups and persists telemetry packets — the heart of the ingest loop (architecture §3.3 / §5.1).
Package inventory reads discovered devices/interfaces (written by ingest from agent inventory deltas and interface snapshots).
Package inventory reads discovered devices/interfaces (written by ingest from agent inventory deltas and interface snapshots).
Package metrics is the time-series layer: the SQLite series dictionary, the in-memory latest-value cache, the query planner, and the rollup/purge bookkeeping — while the sample data itself lives in the tsstore data plane (embedded Prometheus TSDB instances; see package tsstore for why SQLite stopped holding it: per-series B-tree tail pages made every 30s packet commit rewrite ~2.6KB per stored float).
Package metrics is the time-series layer: the SQLite series dictionary, the in-memory latest-value cache, the query planner, and the rollup/purge bookkeeping — while the sample data itself lives in the tsstore data plane (embedded Prometheus TSDB instances; see package tsstore for why SQLite stopped holding it: per-series B-tree tail pages made every 30s packet commit rewrite ~2.6KB per stored float).
Package notification delivers incident events to configured channels (webhook + SMTP + native OS desktop notification + the push platforms behind the Provider registry).
Package notification delivers incident events to configured channels (webhook + SMTP + native OS desktop notification + the push platforms behind the Provider registry).
Package notifypolicy decides whether, when and where a recorded fault is announced.
Package notifypolicy decides whether, when and where a recorded fault is announced.
Package opissue is the operational-issue engine for the agent local-permission policy.
Package opissue is the operational-issue engine for the agent local-permission policy.
Package registry tracks agents: identity, local permission policy, status and last-seen.
Package registry tracks agents: identity, local permission policy, status and last-seen.
Package routehist records the route history of periodic traceroute monitors (probe kind "trace") and detects route changes in it.
Package routehist records the route history of periodic traceroute monitors (probe kind "trace") and detects route changes in it.
Package settings is a tiny key/value store for global, UI-editable server settings backed by the app_settings table.
Package settings is a tiny key/value store for global, UI-editable server settings backed by the app_settings table.
Package site manages Sites — a home or office location that groups multiple agents (architecture §2.2).
Package site manages Sites — a home or office location that groups multiple agents (architecture §2.2).
Package sse is a minimal Server-Sent Events fan-out used to push live updates to connected consoles.
Package sse is a minimal Server-Sent Events fan-out used to push live updates to connected consoles.
Package statuspage owns the public status pages: the admin CRUD over a page and its agent-group/target selection, and the anonymous, sanitized reads that serve it to the world.
Package statuspage owns the public status pages: the admin CRUD over a page and its agent-group/target selection, and the anonymous, sanitized reads that serve it to the world.
Package store opens the SQLite database (pure-Go modernc driver, CGO-free) and applies embedded migrations.
Package store opens the SQLite database (pure-Go modernc driver, CGO-free) and applies embedded migrations.
storetest
Package storetest opens throwaway databases for tests.
Package storetest opens throwaway databases for tests.
Package targetstatus is the server-authoritative current-status domain service (STATUS-001).
Package targetstatus is the server-authoritative current-status domain service (STATUS-001).
Package tsstore is the time-series data plane: raw metric samples and their downsampled tiers live here, in four embedded Prometheus TSDB instances, while everything relational — the series dictionary, rollup watermarks, detector state, incidents — stays in SQLite.
Package tsstore is the time-series data plane: raw metric samples and their downsampled tiers live here, in four embedded Prometheus TSDB instances, while everything relational — the series dictionary, rollup watermarks, detector state, incidents — stays in SQLite.
tsstoretest
Package tsstoretest opens throwaway tsstore instances for tests, mirroring storetest's contract: a temp directory, production-like options, and a Windows-tolerant cleanup — the head chunks and WAL are memory-mapped, and Windows releases those handles slightly after Close, so removal is retried rather than silently skipped (a test that leaks a directory should say so).
Package tsstoretest opens throwaway tsstore instances for tests, mirroring storetest's contract: a temp directory, production-like options, and a Windows-tolerant cleanup — the head chunks and WAL are memory-mapped, and Windows releases those handles slightly after Close, so removal is retried rather than silently skipped (a test that leaks a directory should say so).
Package updatecheck reports whether a newer NetTact release exists for the running install, and what the newest agent release is (so the console can flag agents left behind).
Package updatecheck reports whether a newer NetTact release exists for the running install, and what the newest agent release is (so the console can flag agents left behind).
Package wireadapt is the per-wire-schema adapter registry for this module's own WebSocket hub and enrollment endpoint.
Package wireadapt is the per-wire-schema adapter registry for this module's own WebSocket hub and enrollment endpoint.

Jump to

Keyboard shortcuts

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