[Plugin] Plugins
This section configures plugins. Plugin contents use the standard INI format, identical to the main profile. The system supports modularizing configurations through plugins, and conditionally activating them based on network environments (such as Wi-Fi or cellular networks).
Core Concepts
┌────────────────────────────────────────────────────────┐
│ Plugin 1 (High priority, e.g. matching office SSID) │
├────────────────────────────────────────────────────────┤
│ Plugin 2 (Lower priority, e.g. general remote config) │
├────────────────────────────────────────────────────────┤
│ Main Profile (Base configuration, lowest priority) │
└────────────────────────────────────────────────────────┘
│
▼ Perform Configuration Merge
┌────────────────────────────────────────────────────────┐
│ Effective Runtime Configuration │
└────────────────────────────────────────────────────────┘- Identical Configuration Format Plugin file syntax is identical to the main profile (standard INI format).
- Multi-Plugin Merging The main profile serves as the base. Enabled plugins take effect in order of declaration, with earlier declarations having higher priority than later ones. When merging, the system applies overlays from lowest to highest priority onto the base configuration.
- Network-Conditional Activation A plugin's activation state depends on its global toggle and
subnetcondition. When network environments change, the system updates matching states dynamically, loading or unloading corresponding plugin configurations.
Syntax Declaration
Each line in [Plugin] defines an independent plugin entry:
name = source, [options...]Syntax Elements
name: Unique identifier for the plugin. Must be unique within the main profile. Enclose in double quotes if it contains commas (,), equals signs (=), leading/trailing whitespace, inline comment triggers (whitespace followed by#or;), starts with#,;, or[, or equals%APPEND%or%INSERT%.source: Origin of the plugin file. Supports local paths and remote network URLs:- Local Path: Supports absolute paths, or relative paths evaluated relative to the directory of the main profile (e.g.,
./plugins/office.conf). - Remote URL: URLs starting with
http://orhttps://. - Quoting disambiguation: Enclose
sourcein double quotes if it contains commas (,), leading/trailing whitespace, inline comment triggers, looks likekey=value, starts with(,{,),],},#,;, or[(except bare IPv6 socket literals), or equals%APPEND%or%INSERT%.
- Local Path: Supports absolute paths, or relative paths evaluated relative to the directory of the main profile (e.g.,
options: Optional parameter list separated by commas, formatted askey=value.
Parameter Reference
source(Local path or HTTP/HTTPS URL, positional argument, required) Plugin configuration source (first positional argument). Relative paths are evaluated relative to the main profile directory; enclose in double quotes if the value contains commas, whitespace,key=value-like syntax, or structural delimiters.iniOffice = ./plugins/office.conf RemotePlugin = "https://rules.example.com/plugin.conf?token=1,2"subnet(Network condition string, unset) Network matching condition required to activate this plugin (key-value option). When unset, the plugin remains active as long as the global toggle is enabled. Enclose in double quotes if it contains commas, leading/trailing whitespace, inline comment triggers, starts with(,{,),],}, or[, or equals%APPEND%or%INSERT%.inisubnet=ssid:Corp-Office-*update-interval(Integer, unit: seconds, default86400, remote only) Background auto-update interval for remote HTTP/HTTPS plugins (key-value option). Defaults to86400seconds when unset; setting<= 0(such as0or-1) disables scheduled and background auto-updates (a missing local cache is still fetched once, and manual refreshes are unaffected). Only remote plugins support this option; configuring it on a local file plugin fails validation.iniupdate-interval=43200format(Enum:ringorsurge, defaultring) Specifies the parsing format for the plugin (key-value option, case-insensitive). Defaults toring(native Ring syntax); set tosurgeto enable read-only Surge module compatibility. Unrecognizedformatvalues or other unknown key-value options do not fail validation; the system falls back toringand preserves the original entries.iniformat=surge
Network Matching Conditions
The subnet parameter restricts plugin activation to specific network environments using the format prefix:pattern:
ssid:(Text string, supports wildcards*and?) Matches the connected Wi-Fi network name (SSID), e.g.,ssid:Company-WiFiorssid:Office-*.inisubnet=ssid:Company-WiFibssid:(MAC address format, supports wildcards*and?) Matches the hardware address (BSSID) of the connected wireless AP.inisubnet="bssid:00:11:22:33:44:55"type:(Enum, case-insensitive) Matches the connection type of the primary network interface:CELLULAR,WIFI,WIRED,LOOPBACK,OTHER. For example,type:CELLULARmatches cellular mobile data.inisubnet=type:CELLULARgateway:(IP address string) Matches the default gateway IP (reserved placeholder in current version).inisubnet=gateway:192.168.1.1(No prefix) (Text string, supports wildcards) When no explicit prefix is provided, it defaults to matching Wi-Fi SSIDs.
inisubnet=Home-WiFi
Merging Mechanism & Override Behavior
Precedence
Multiple active plugins take effect in declaration order: earlier declarations have higher priority than later ones; the main profile has the lowest priority (acting as the base). Nested [Plugin] sections inside plugins are ignored.
Section and Value Type Merging Rules
Different configuration sections and value types follow specific rules when merged:
- Single Scalar Values & Non-List Keys (e.g.,
log-levelin[General])- Higher-priority plugins directly overwrite base configurations; key-level
%APPEND%/%INSERT%directives are not supported.
- Higher-priority plugins directly overwrite base configurations; key-level
- Joinable List Keys (Key-Level
%APPEND%/%INSERT%)- Default behavior: Wholesale replacement (Replace);
key = %APPEND% <value>: Appends values to the end of the existing list (supports a single value, comma-separated list, or[...]on the right-hand side);key = %INSERT% <value>: Inserts values at the beginning of the existing list (supports a single value, comma-separated list, or[...]on the right-hand side);- Key-level
%APPEND%/%INSERT%merging applies only to the following list keys in[General]and[MITM]:[General](9 list keys):dns-server,always-real-ip,tun-included-routes,tun-excluded-routes,skip-proxy,hijack-dns,force-http-hostname,always-raw-tcp-hostname,suspend-ssids;[MITM](2 list keys):hostname,skip-hostname.
- Dictionary Sections (Keystore, Proxy, Proxy Group, Host, Script, Proxy Resource)
- Matched by item name (key): Identical names overwrite existing definitions; new names append to the section by default (
%APPEND%); - Supports
%INSERT%or%APPEND%on the first statement line inside the section (immediately below[Section]) to control whether new items are prepended or appended.
- Matched by item name (key): Identical names overwrite existing definitions; new names append to the section by default (
- Ordered Rule Lists (Rule, Response, URL Rewrite, Header Rewrite)
- Default behavior is insertion (
%INSERT%), placing plugin rules at the top of the existing list; - Specifying
%APPEND%on the first statement line inside the section appends rules to the end of the existing list; for[Rule],%APPEND%always appends rules before theFINALrule, ensuring appended rules participate in matching andFINALremains the ultimate fallback; - Supports
%INSERT%on the first statement line inside the section to explicitly indicate prepending.
- Default behavior is insertion (
Section-level
%APPEND%and%INSERT%directives must appear on their own statement line immediately inside the section (below[Section]), not on the same line after].
Surge Module Compatibility
- Activation: Set
format=surgeto enable. The runtime translates the module in memory into standard Ring configuration for merging, and remote HTTP/HTTPS fetches include aSurgeidentifier in the requestUser-Agent. When unset or set toformat=ring, the plugin is strictly validated as native Ring format. - Scope: Provided for best-effort transition only; full support is not guaranteed. Unsupported sections, rules, or parameter placeholders are safely skipped.
- Recommendation: Use native Ring plugin syntax for full capabilities.
Configuration Examples
Basic Configuration
Main Profile (main.conf):
[General]
log-level = info
dns-server = system
[Plugin]
# 1. Wi-Fi office network plugin
Office = ./plugins/office.conf, subnet=ssid:Corp-Office-*
# 2. Cellular network plugin
Cellular = ./plugins/cellular.conf, subnet=type:CELLULAR
# 3. Remote configuration plugin
AdBlock = "https://rules.example.com/adblock.conf", update-interval=43200
[Proxy]
DefaultProxy = socks, 198.51.100.1, 1080
[Rule]
FINAL,DefaultProxyLocal Network Plugin (plugins/office.conf):
[General]
# Key-level merge: append LAN subnet to the main profile's skip-proxy list
skip-proxy = %APPEND% 10.0.0.0/8
[MITM]
# Key-level merge: prepend internal domain to the hostname list
hostname = %INSERT% *.corp.internal
[Proxy]
# Section-level directive on first line inside section: append new entries (default for dictionary sections)
%APPEND%
CorpProxy = socks, 10.0.0.1, 1080
[Rule]
# Section-level directive on first line inside section: append before FINAL (defaults to %INSERT% when omitted)
%APPEND%
DOMAIN-SUFFIX,corp.internal,DIRECT
IP-CIDR,10.0.0.0/8,DIRECT,no-resolve
DOMAIN-SUFFIX,oa.example.com,CorpProxyCellular Network Plugin (plugins/cellular.conf):
[General]
# Adjust log level to warn when on cellular data
log-level = warn