configgen

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFirewallInbound  = []FirewallRule{{Port: "any", Proto: "icmp", Group: "any"}}
	DefaultFirewallOutbound = []FirewallRule{{Port: "any", Proto: "any", Group: "any"}}
)

DefaultFirewallInbound and DefaultFirewallOutbound are the baseline policy a host receives when its network has no stored firewall rules, or the stored rules are unusable: ICMP-only inbound (ping) and allow-all outbound. These are the values the management server emitted for every host before per-network firewall rules were wired through to generated configs.

Functions

func Generate

func Generate(input GeneratorInput) ([]byte, error)

Generate produces a Nebula config.yml from the given input by marshaling a typed struct through gopkg.in/yaml.v3. Replaces the previous text/template-based generator (GHSA-7hp6 follow-up, issue #126).

Types

type AdvancedUnsafeRoute

type AdvancedUnsafeRoute struct {
	Route string
	Via   string
}

AdvancedUnsafeRoute mirrors models.UnsafeRoute for the generator input.

type FirewallRule

type FirewallRule struct {
	Port      string // "any", "22", "443"
	Proto     string // "any", "tcp", "udp", "icmp"
	Group     string // "any", "admin", etc.
	Cidr      string // "", "any", "10.0.0.0/24" — remote (peer) address
	LocalCidr string // "", "any", "10.0.0.0/24" — local address
}

FirewallRule represents a single firewall rule. A rule carries exactly one peer selector — Group or Cidr — because Nebula OR's them; LocalCidr is an independent constraint AND'd into the matched selector.

func FirewallRulesFromJSON added in v0.4.0

func FirewallRulesFromJSON(jsonStr string) (inbound, outbound []FirewallRule, err error)

FirewallRulesFromJSON converts the management API's stored firewall JSON into generator rules.

It returns the safe defaults together with a nil error when jsonStr is empty or declares no rules at all — a network with no policy legitimately gets the baseline, which is not an error condition.

It returns the safe defaults together with a non-nil error when the JSON is malformed or any rule is unusable (an empty port or proto, no peer selector, or an unparseable cidr/local_cidr). The missing selector in particular is the work-322fy footgun: Nebula rejects a rule with neither group nor host, failing the whole config on load. Returning the defaults rather than the bad rules guarantees that wiring a network's stored policy into a host config can never produce an agent config Nebula refuses to load; the non-nil error lets the caller surface that the operator's policy is being dropped.

type GeneratorInput

type GeneratorInput struct {
	HostName         string
	NebulaIPs        []string
	IsLighthouse     bool
	IsRelay          bool
	CACertPath       string
	CertPath         string
	KeyPath          string
	ListenPort       int
	Lighthouses      []LighthouseInfo
	Relays           []string
	FirewallInbound  []FirewallRule
	FirewallOutbound []FirewallRule
	// HostFirewallInbound holds per-host inbound rules appended after the
	// network-wide FirewallInbound policy in the rendered config.
	HostFirewallInbound []FirewallRule
	Mobile              *MobileProfile

	// Optional per-host overrides. Zero values mean "use the default".
	PunchyOverride *bool
	// PunchyRespondOverride maps to punchy.respond. Nil leaves Nebula's own
	// default (false) in place, so an unset override renders as before.
	PunchyRespondOverride *bool
	ListenHost            string
	MTU                   int
	TunDevice             string
	UnsafeRoutes          []AdvancedUnsafeRoute

	// Optional inline PEM blocks. When CACertPEM is non-empty, CertPEM and
	// KeyPEM must also be non-empty; all three are emitted as literal-block
	// scalars in the pki section. When empty, the path-based fields above
	// are used instead. Mobile Nebula clients use the inline form since
	// they import a self-contained YAML config.
	CACertPEM string
	CertPEM   string
	KeyPEM    string

	// Blocklist is the per-CA list of revoked certificate fingerprints.
	// Emitted as pki.blocklist in config.yml so the Nebula daemon rejects
	// handshakes from revoked peers (GHSA-cm26-5974-52h8).
	Blocklist []string
}

GeneratorInput contains all parameters needed to generate a Nebula config.

type LighthouseInfo

type LighthouseInfo struct {
	NebulaIPs  []string
	PublicAddr string // "1.2.3.4:4242"
}

LighthouseInfo describes a lighthouse node for config generation.

type MobileProfile added in v0.9.0

type MobileProfile struct {
	DNSResolvers        []string
	MatchDomains        []string
	AllowPrivateRemotes bool
}

MobileProfile enables defaults and settings used by Mobile Nebula clients. A nil profile preserves the agent configuration shape.

Jump to

Keyboard shortcuts

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