server

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyJobs added in v1.5.6

func ApplyJobs(logger zerolog.Logger, path string) error

ApplyJobs reads the state file at path and executes each Apply command in order. On failure it calls ResetJobs to roll back before returning the error. No-op when path is empty or the file does not exist.

func BackoffOnError

func BackoffOnError(delay time.Duration) time.Duration

func ResetJobs added in v1.5.6

func ResetJobs(logger zerolog.Logger, path string)

ResetJobs reads the state file at path and executes each Reset command in LIFO order, then deletes the file. No-op when path is empty or the file does not exist, so safe to call at startup for stale-state cleanup.

func SaveJobs added in v1.5.6

func SaveJobs(path string, jobs []NetworkJob) error

SaveJobs marshals jobs to a JSON state file at path.

func SetupSystemProxy added in v1.5.6

func SetupSystemProxy(_ context.Context, _ string, _ string) error

SetupSystemProxy is a no-op on platforms without system proxy support.

Types

type NetworkJob added in v1.5.6

type NetworkJob struct {
	Description string `json:"description"`
	Apply       string `json:"apply,omitempty"`
	Reset       string `json:"reset,omitempty"`
}

NetworkJob is a serializable unit of network configuration. Jobs are applied in order and reset in LIFO order.

func LoadJobs added in v1.5.6

func LoadJobs(path string) ([]NetworkJob, bool, error)

LoadJobs reads and unmarshals the state file at path. Returns (nil, false, nil) when path is empty or the file does not exist.

type Server

type Server interface {
	ListenAndServe(ctx context.Context) error

	// Addr returns the network address or interface name the server is bound to
	Addr() string

	// SetupNetworkJobs builds the job list, saves it to the state file, and
	// returns the state file path. On darwin, HTTP/SOCKS5 also start the PAC
	// server, tied to ctx so it shuts down automatically when ctx is cancelled.
	// The returned path may be empty when the platform has nothing to configure.
	SetupNetworkJobs(ctx context.Context) (string, error)
}

Server represents a core component that processes network traffic. ListenAndServe blocks until ctx is cancelled, then releases all resources.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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