netguard

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netguard decides what a VM may reach on the network: the internet, never this machine, its local networks or the other VMs (through this machine's loopback, where their ports are forwarded), unless the user allows it in ~/.agent-vm/network. It runs in the hostagent, where every connection the guest opens is made (Lima's per-instance netstack).

Index

Constants

View Source
const FileName = "network"

FileName is the policy's file in agent-vm's state folder.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	// Open turns isolation off (AGENT_VM_UNSAFE_OPEN_NETWORK=1).
	Open bool
	// Allow are reachable whatever else: an address or network, every port
	// when Port is 0.
	Allow []Rule
	// Domains, when any, are the only names of the internet the VMs may
	// reach, subdomains included: an address is reachable once agent-vm's
	// DNS gave it for one of them.
	Domains []string
	// contains filtered or unexported fields
}

Policy is what the VMs may reach. The zero Policy is the default: the internet only.

func Load

func Load(stateDir string) (*Policy, error)

Load reads the policy from the state folder's network file (none: the default), and AGENT_VM_UNSAFE_OPEN_NETWORK.

func (*Policy) Allows

func (p *Policy) Allows(network string, dst netip.AddrPort) bool

Allows reports whether the guest may reach dst over network ("tcp" or "udp": nothing else is allowed).

func (*Policy) Answered

func (p *Policy) Answered(name string, ips []net.IP)

Answered records the addresses given for an allowed name: reachable for resolvedFor.

func (*Policy) Name

func (p *Policy) Name(name string) bool

Name reports whether the guest may resolve name: with Domains, those and their subdomains only. That includes host.lima.internal and the VM's own name, which then get NXDOMAIN from the resolver.

type Rule

type Rule struct {
	Net  netip.Prefix
	Port uint16
}

Rule is an allow line: a network, and a port or 0 for every one.

Jump to

Keyboard shortcuts

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