platformsetup

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 8 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 platformsetup separates installation history, executable-scoped rule inspection, and rule writes. None of them asserts actual ICE reachability.

Index

Constants

View Source
const CheckTimeout = 8 * time.Second
View Source
const InspectionScope = "executable-inbound-rules"

InspectionScope excludes all-program rules; even RulePresent is not evidence that the host's complete effective policy allows this executable.

View Source
const PreferenceEnvironment = "WINDSHARE_NETWORK_PREFERENCE"
View Source
const PreferenceFileName = "network-preference.json"

Variables

View Source
var ErrUnsupported = errors.New("network setup is unsupported on this platform")

Functions

This section is empty.

Types

type Choice

type Choice uint8
const (
	Ask Choice = iota
	Configure
	Skip
)

func (Choice) String

func (v Choice) String() string

func (Choice) Valid

func (v Choice) Valid() bool

type FilePreferences

type FilePreferences struct{ Path string }

func (FilePreferences) Load

func (store FilePreferences) Load() (Preference, error)

func (FilePreferences) Save

func (store FilePreferences) Save(preference Preference) error

type Finding

type Finding struct {
	Network  Network
	Protocol Protocol
	Status   RuleStatus
	Reason   Reason
	Rules    []Rule
}

func Evaluate

func Evaluate(snapshot Snapshot) []Finding

Evaluate reports the configuration observed within InspectionScope. It does not attempt to resolve arbitrary address ranges, ports, IPsec, or global rules.

func (Finding) SuggestSetup

func (f Finding) SuggestSetup() bool

type InboundAction

type InboundAction uint8
const (
	UnknownAction InboundAction = iota
	Allow
	Block
)

func (InboundAction) String

func (v InboundAction) String() string

type Network

type Network struct {
	Interface string
	Profile   Profile
}

type Operation

type Operation struct {
	State  OperationState `json:"state"`
	Detail string         `json:"detail,omitempty"`
}

func (Operation) Succeeded

func (operation Operation) Succeeded() bool

type OperationState

type OperationState string
const (
	RulesApplied          OperationState = "applied"
	RulesRemoved          OperationState = "removed"
	AuthorizationDeclined OperationState = "authorization-declined"
	PermissionRequired    OperationState = "permission-required"
	OperationFailed       OperationState = "failed"
	OperationUnsupported  OperationState = "unsupported"
)

type Platform

type Platform interface {
	Inspect(context.Context, string) (Snapshot, error)
	Apply(context.Context, string, RuleAction, bool) Operation
}

type Preference

type Preference struct {
	Choice     Choice
	Executable string
}

Configure records a completed rule write for one installation, not live policy. Skip belongs to the user and deliberately has no installation identity.

func (Preference) Valid

func (p Preference) Valid() bool

type Preferences

type Preferences interface {
	Load() (Preference, error)
	Save(Preference) error
}

type Profile

type Profile uint8
const (
	UnknownProfile Profile = iota
	Domain
	Private
	Public
)

func (Profile) String

func (v Profile) String() string

type ProfilePolicy

type ProfilePolicy struct {
	Profile            Profile
	Enabled            Setting
	AllowInboundRules  Setting
	AllowLocalRules    Setting
	DefaultInbound     InboundAction
	DisabledInterfaces []string
}

type Protocol

type Protocol uint8
const (
	AnyProtocol Protocol = iota
	UDP
	TCP
)

func (Protocol) String

func (v Protocol) String() string

type Reason

type Reason uint8
const (
	IncompleteEvidence Reason = iota
	UnsupportedPlatform
	ReadFailed
	NoActiveNetwork
	FirewallDisabled
	InterfaceExempt
	InboundRulesDisabled
	ExplicitBlock
	ConditionalRule
	ExplicitAllow
	DefaultAllow
	NoMatchingRule
	LocalRulesDisabled
)

func (Reason) String

func (v Reason) String() string

type Report

type Report struct {
	Executable      string
	Preference      Preference
	PreferenceError string
	InspectionError string
	Findings        []Finding
}

func (Report) SuggestSetup

func (report Report) SuggestSetup() bool

type Rule

type Rule struct {
	Name         string
	Profiles     []Profile
	Protocol     Protocol
	Action       InboundAction
	Local        bool
	Conditional  bool
	Restrictions string
}

The adapter selects explicit executable paths. Restricted rules are retained for diagnosis without attempting to evaluate their arbitrary traffic selectors.

type RuleAction

type RuleAction uint8
const (
	EnsureRules RuleAction = iota
	RemoveRules
)

type RuleStatus

type RuleStatus uint8
const (
	UnknownStatus RuleStatus = iota
	RulePresent
	RuleMissing
	RuleRestricted
	PolicyRestricted
	RuleNotRequired
)

func (RuleStatus) String

func (v RuleStatus) String() string

type Service

type Service struct {
	Platform    Platform
	Preferences Preferences
	Executable  func() (string, error) // Canonical installation path used by rule ownership.
}

func New

func New() *Service

func (*Service) Check

func (service *Service) Check(ctx context.Context) Report

func (*Service) Setup

func (service *Service) Setup(ctx context.Context, action RuleAction, allowElevation bool) (Operation, Report)

Explicit setup always inspects current executable rules, even after a failed operation. A successful write records installation history, not reachability.

func (*Service) Skip

func (service *Service) Skip() error

func (*Service) Startup

func (service *Service) Startup() StartupReport

func (*Service) SupportsSetup

func (service *Service) SupportsSetup() bool

SupportsSetup reports whether Setup can apply host firewall rules for this installation. Non-Windows hosts return false through ErrUnsupported.

type Setting

type Setting uint8

Setting preserves missing evidence instead of silently interpreting it as false.

const (
	Unspecified Setting = iota
	Yes
	No
)

type Snapshot

type Snapshot struct {
	Networks []Network
	Profiles []ProfilePolicy
	Rules    []Rule
}

type StartupDecision

type StartupDecision uint8

StartupDecision describes installation history only. It never claims a current firewall verdict, so ordinary transfers need no system-policy query.

const (
	SetupUnchosen StartupDecision = iota + 1
	SetupSkipped
	SetupRecorded
	SetupPathChanged
	SetupReadFailed
	SetupUnsupported
)

func (StartupDecision) String

func (v StartupDecision) String() string

func (StartupDecision) SuggestSetup

func (v StartupDecision) SuggestSetup() bool

func (StartupDecision) Valid

func (v StartupDecision) Valid() bool

type StartupReport

type StartupReport struct {
	Decision             StartupDecision
	Executable           string
	ConfiguredExecutable string
	Error                string
}

Jump to

Keyboard shortcuts

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