Skip to content

[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 ​

text
┌────────────────────────────────────────────────────────┐
│ 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                        │
└────────────────────────────────────────────────────────┘
  1. Identical Configuration Format Plugin file syntax is identical to the main profile (standard INI format).
  2. 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.
  3. Network-Conditional Activation A plugin's activation state depends on its global toggle and subnet condition. 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:

ini
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:// or https://.
    • Quoting disambiguation: Enclose source in double quotes if it contains commas (,), leading/trailing whitespace, inline comment triggers, looks like key=value, starts with (, {, ), ], }, #, ;, or [ (except bare IPv6 socket literals), or equals %APPEND% or %INSERT%.
  • options: Optional parameter list separated by commas, formatted as key=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.

    ini
    Office = ./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%.

    ini
    subnet=ssid:Corp-Office-*
  • update-interval (Integer, unit: seconds, default 86400, remote only) Background auto-update interval for remote HTTP/HTTPS plugins (key-value option). Defaults to 86400 seconds when unset; setting <= 0 (such as 0 or -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.

    ini
    update-interval=43200
  • format (Enum: ring or surge, default ring) Specifies the parsing format for the plugin (key-value option, case-insensitive). Defaults to ring (native Ring syntax); set to surge to enable read-only Surge module compatibility. Unrecognized format values or other unknown key-value options do not fail validation; the system falls back to ring and preserves the original entries.

    ini
    format=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-WiFi or ssid:Office-*.

    ini
    subnet=ssid:Company-WiFi
  • bssid: (MAC address format, supports wildcards * and ?) Matches the hardware address (BSSID) of the connected wireless AP.

    ini
    subnet="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:CELLULAR matches cellular mobile data.

    ini
    subnet=type:CELLULAR
  • gateway: (IP address string) Matches the default gateway IP (reserved placeholder in current version).

    ini
    subnet=gateway:192.168.1.1
  • (No prefix) (Text string, supports wildcards) When no explicit prefix is provided, it defaults to matching Wi-Fi SSIDs.

    ini
    subnet=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:

  1. Single Scalar Values & Non-List Keys (e.g., log-level in [General])
    • Higher-priority plugins directly overwrite base configurations; key-level %APPEND% / %INSERT% directives are not supported.
  2. 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.
  3. 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.
  4. 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 the FINAL rule, ensuring appended rules participate in matching and FINAL remains the ultimate fallback;
    • Supports %INSERT% on the first statement line inside the section to explicitly indicate prepending.

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=surge to enable. The runtime translates the module in memory into standard Ring configuration for merging, and remote HTTP/HTTPS fetches include a Surge identifier in the request User-Agent. When unset or set to format=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):

ini
[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,DefaultProxy

Local Network Plugin (plugins/office.conf):

ini
[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,CorpProxy

Cellular Network Plugin (plugins/cellular.conf):

ini
[General]
# Adjust log level to warn when on cellular data
log-level = warn