networkpolicy

package
v2026.1030.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 16 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 networkpolicy stores Solomon's network selection independently of OS configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedLocal

func AllowedLocal(ip net.IP) bool

AllowedLocal checks the destination address accepted by the server.

func ApplyTailscaleStatus

func ApplyTailscaleStatus(rows []Interface, data []byte)

func DialContext

func DialContext(ctx context.Context, network, address string) (net.Conn, error)

func InterfaceType

func InterfaceType(name string, local bool) string

func LinuxInterfaceType

func LinuxInterfaceType(root, name string) string

func PolicyPath

func PolicyPath() (string, error)

func RunningInContainer

func RunningInContainer(readFile func(string) ([]byte, error)) bool

func Set

func Set(name string, enabled bool) error

func WrapDial

func WrapDial(fallback func(context.Context, string, string) (net.Conn, error), timeout ...time.Duration) func(context.Context, string, string) (net.Conn, error)

WrapDial preserves the caller timeout and custom dial behavior when unrestricted.

func WritePolicyFile

func WritePolicyFile(path string, p Policy) error

Types

type Interface

type Interface struct {
	Tailscale    *TailscaleInfo `json:"tailscale,omitempty"`
	Type         string         `json:"type"`
	DisplayLabel string         `json:"display_name"`
	Number       int            `json:"number"`
	Name         string         `json:"name"`
	Enabled      bool           `json:"enabled"`
	Up           bool           `json:"up"`
	Local        bool           `json:"local"`
	Addresses    []string       `json:"addresses"`
}

func List

func List() ([]Interface, error)

func ListUnfiltered

func ListUnfiltered(p Policy) ([]Interface, error)

func VisibleInterfaces

func VisibleInterfaces(rows []Interface, inContainer bool) []Interface

Filter the user-facing list only; hiding an interface must not alter routing or server access through Docker bridges.

func (Interface) DisplayName

func (i Interface) DisplayName() string

DisplayName keeps the actual interface name when its type cannot be established.

type Policy

type Policy struct {
	Disabled         map[string]bool `json:"disabled"`
	DisabledMagicDNS map[string]bool `json:"disabled_magic_dns,omitempty"`
}

func Read

func Read() (Policy, error)

func (Policy) AllowedHostname

func (p Policy) AllowedHostname(host string) bool

AllowedHostname controls Solomon access via the saved MagicDNS aliases.

type TailscaleInfo

type TailscaleInfo struct {
	MagicDNSEnabled bool   `json:"magic_dns_enabled"`
	MagicDNS        string `json:"magic_dns,omitempty"`
	Tailnet         string `json:"tailnet,omitempty"`
	DNSName         string `json:"dns_name,omitempty"`
	Account         string `json:"account,omitempty"`
	Tagged          bool   `json:"tagged,omitempty"`
}

Jump to

Keyboard shortcuts

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