How ladybug-w/clashx works
ClashX is a macOS menu-bar client for the Clash rule-based proxy. Users configure or import a YAML profile, start the Clash core, choose proxy groups and modes from the status menu, and optionally route macOS system traffic through the proxy. The app also exposes dashboard/API controls, remote-control profiles, and privileged proxy-setting operations. The README documents HTTP(S)/SOCKS, GeoIP, VMess/Shadowsocks/SOCKS5, and TCP redirect capabilities, but the sampled files do not show their engine internals. Edges reflect shown calls or indexed references; unverified core wiring is dashed.
Main entry points: AppDelegate.swift App coordinator · ConfigManager.swift Config state · ApiRequest.swift Core API client · MenuItemFactory.swift Proxy menu factory
Components 22
App lifecycle
- App coordinator
ClashX/AppDelegate.swift - Status menu
ClashX/Views/StatusItemView.swift - Dashboard web view
ClashX/ViewControllers/ClashWebViewContoller.swift - External control UI
ClashX/ViewControllers/ExternalControlViewController.swift
Configuration
- Config state
ClashX/General/Managers/ConfigManager.swift - Config files
ClashX/General/Managers/ConfigFileManager.swift - Config model
ClashX/Models/ClashConfig.swift - Remote profiles
ClashX/General/Managers/RemoteConfigManager.swift - Remote profile model
ClashX/Models/RemoteConfigModel.swift - Saved selections
ClashX/Models/SavedProxyModel.swift
Proxy control
- Proxy models
ClashX/Models/ClashProxy.swift - Proxy menu factory
ClashX/General/Managers/MenuItemFactory.swift - Proxy menu items
ClashX/Views/ProxyMenuItem.swift - Remote control
ClashX/General/Managers/RemoteControlManager.swift - System proxy manager
ClashX/General/Managers/SystemProxyManager.swift - Privileged helper client
ClashX/General/Managers/PrivilegedHelperManager.swift - Proxy helper protocol
ProxyConfigHelper/ProxyConfigRemoteProcessProtocol.h
Runtime services
- Clash core
ClashX/goClash/main.go - Core API client
ClashX/General/ApiRequest.swift - Connection status
ClashX/General/Managers/ConnectionManager.swift - Logging
ClashX/Basic/Logger.swift
Other components
- Mac user
Connections 28
- Mac user → App coordinator: launches
- App coordinator → Status menu: creates
ClashX/AppDelegate.swift - App coordinator → Config files: copies sample
ClashX/AppDelegate.swift - App coordinator → Config state: starts proxy
ClashX/AppDelegate.swift - App coordinator → Remote profiles: coordinates
ClashX/AppDelegate.swift - App coordinator → System proxy manager: configures menu
ClashX/AppDelegate.swift - App coordinator → Connection status: adds menu option
ClashX/AppDelegate.swift - Config state → Config files: watches files
ClashX/General/Managers/ConfigManager.swift - Config state → Config model: holds current
ClashX/General/Managers/ConfigManager.swift - Config state → Saved selections: persists selections
ClashX/General/Managers/ConfigManager.swift - Remote profiles → Remote profile model: uses model
ClashX/General/Managers/RemoteConfigManager.swift - Remote profiles → Config state: updates state
ClashX/General/Managers/RemoteConfigManager.swift - External control UI → Remote control: controls
ClashX/ViewControllers/ExternalControlViewController.swift - Remote control → Config state: sets API override
ClashX/General/Managers/RemoteControlManager.swift - Remote control → Proxy menu factory: recreates menus
ClashX/General/Managers/RemoteControlManager.swift - Proxy menu factory → Core API client: requests proxy data
ClashX/General/Managers/MenuItemFactory.swift - Proxy menu factory → Proxy models: builds menus from
ClashX/General/Managers/MenuItemFactory.swift - Proxy menu factory → Proxy menu items: creates items
ClashX/General/Managers/MenuItemFactory.swift - Proxy menu items → Proxy models: displays
ClashX/Views/ProxyMenuItem.swift - Connection status → Core API client: requests status
ClashX/General/Managers/ConnectionManager.swift - Core API client → Config model: decodes config
ClashX/General/ApiRequest.swift - Dashboard web view → Core API client: uses API
- App coordinator → Clash core: starts core
- Core API client → Clash core: calls core API
- System proxy manager → Config state: reads ports
ClashX/General/Managers/SystemProxyManager.swift - System proxy manager → Privileged helper client: requests proxy changes
ClashX/General/Managers/SystemProxyManager.swift - Privileged helper client → Proxy helper protocol: uses protocol
- Privileged helper client → Logging: logs operations
ClashX/General/Managers/PrivilegedHelperManager.swift