Files
ShadowsocksX-NG/ShadowsocksX-NG2/Domain/SystemProxyConfiguration.swift
T
Qiu Yuzhou d2a8d6105c feat(system-proxy): route writes through privileged LaunchDaemon helper
Implements issue #71 with ADR-0020 (supersedes ADR-0019's endpoint-signature
cleanup, startup cleanup, and health-gate cleanup).

- New ShadowsocksX-NG2SystemProxyHelper target: app-bundled root LaunchDaemon
  (SMAppService.daemon, on-demand via MachServices) that mechanically applies
  a closed typed configuration or executes an unconditional clear. Clients are
  accepted by code-signing bundle identifier only; requests run serially on a
  shared queue (last-writer-wins).
- SystemProxyConfiguration is now the closed typed apply payload (Codable over
  JSON XPC): explicit SOCKS/HTTP/HTTPS enable + endpoints, PAC and
  auto-discovery disabled with URL/JS removed, explicit simple-hostname
  exclusion, complete ExceptionsList. Unmodeled Proxies keys are preserved and
  equivalent values skip the commit.
- Cleanup is a side effect of a persisted system-proxy intent on-to-off
  transition only: the switch itself, or the agent-off cascade (persist both
  intents off, clear, then stop listeners; failed cascade persistence records
  no transition and clears nothing). Launch with the switch off, health-gate
  closure, invalid targets, and passive events never clear. Failed clears are
  surfaced without deferred retry.
- Endpoint-signature store, ownership migration, and direct Authorization
  Services writes are removed; old signature files stay inert. Helper
  unavailability or pending approval keeps an enabled intent pending and
  surfaces the Login Items approval path (HomeView button + menu label).
2026-09-30 12:26:40 +08:00

30 lines
1.3 KiB
Swift

import Foundation
/// GUI 准备、特权 helper 机械执行的 closed typed 系统代理配置(issue #71)。
/// 完整闭合:SOCKS/HTTP/HTTPS 的启停与端点、PAC、自动发现、简单主机名排除
/// 与完整例外列表全部显式给出;helper 不补默认值、不从 HTTP 推断 HTTPS、
/// 不把缺省解释为「保留旧值」。Codable 使其可跨 XPC 以 payload 传输。
/// 成员逐一内联默认值:GUI 策略恒为三协议族全开、PAC/自动发现关闭(issue #67)、
/// 简单主机名排除开启——合成 memberwise init 自带这些默认参数。
struct SystemProxyConfiguration: Codable, Equatable, Sendable {
/// 一个系统代理协议族指向的本地端点。
struct Endpoint: Codable, Equatable, Sendable {
let host: String
let port: Int
}
var socksEnabled = true
var socks: Endpoint
var httpEnabled = true
var http: Endpoint
/// HTTPS 系统代理由 GUI 显式赋值(当前实现与 HTTP 入站共用端点),
/// helper 只翻译不推断。
var httpsEnabled = true
var https: Endpoint
var pacEnabled = false
var autoDiscoveryEnabled = false
var excludeSimpleHostnames = true
/// 完整例外列表:每次 apply 全量覆盖,空列表也是显式值。
var exceptions: [String]
}