Documentation
¶
Index ¶
- func ApplyJobs(logger zerolog.Logger, path string) error
- func BackoffOnError(delay time.Duration) time.Duration
- func ResetJobs(logger zerolog.Logger, path string)
- func SaveJobs(path string, jobs []NetworkJob) error
- func SetupSystemProxy(_ context.Context, _ string, _ string) error
- type NetworkJob
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyJobs ¶ added in v1.5.6
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 ResetJobs ¶ added in v1.5.6
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.
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.
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.