👻 Smart Proxy Group
The Smart proxy group type uses adaptive weight-based node selection. Instead of simple round-robin or manual ordering, it continuously tracks each node’s real-world performance — latency, connection success rate, traffic volume — and automatically routes connections to the best available node.
New in v1.19.33
Section titled “New in v1.19.33”The smart group type comes from vernesong/mihomo. The group picks a node by weights computed from how the nodes actually perform: latency, connection success rate and traffic. Weight prediction by a LightGBM model can be enabled.
Since v1.19.33 the group also learns where each node leads and which sites refuse it:
- Node exit. The group finds out the country and network (ASN) where a node’s traffic comes out. To do that it sends a request through the node to
cloudflare.com/cdn-cgi/trace,api.ip.sboripwho.is, the next one if the previous does not answer. - Site responses. If a site refuses a node (blocked for its region, an error page,
403, a connection without any answer), the group remembers it and sends this site through other nodes. - No hasty verdicts. A region or a network is marked as refused only after several independent nodes from it fail. One refusal decides nothing, and a node that answers again clears the record.
Configuration
Section titled “Configuration”# Optional: global LightGBM settings (top-level in config)lgbm-auto-update: truelgbm-update-interval: 72lgbm-url: "https://github.com/vernesong/mihomo/releases/download/LightGBM-Model/Model.bin"
proxy-groups: - name: Smart Group type: smart proxies: - Proxy A - Proxy B - Proxy C policy-priority: "Premium:0.9;SG:1.3" uselightgbm: false collectdata: false sample-rate: 1 prefer-asn: true tolerance: 50Parameters
Section titled “Parameters”Group-level parameters
Section titled “Group-level parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
type | string | — | Must be smart |
policy-priority | string | "" | Priority multipliers by node name, see policy-priority |
uselightgbm | bool | false | Enable ML-based weight prediction via LightGBM |
collectdata | bool | false | Collect training data to CSV for custom model training |
sample-rate | float | 1 | Share of connections recorded by collectdata, in (0, 1]. Values outside this range (including 0) mean 1, i.e. 100% |
prefer-asn | bool | false | Prioritise ASN lookup during node selection |
tolerance | int | 0 | Latency difference in ms within which nodes count as equal when the group falls back to latency order; see tolerance |
Global LightGBM parameters (top-level)
Section titled “Global LightGBM parameters (top-level)”These keys sit at the top level of the config; they are also described on the General page.
| Parameter | Type | Default | Description |
|---|---|---|---|
lgbm-auto-update | bool | false | Automatically refresh the LightGBM model |
lgbm-update-interval | int | 72 | Model refresh interval in hours |
lgbm-url | string | the vernesong LightGBM-Model/Model.bin release | URL to download the Model.bin file from |
Profile parameter
Section titled “Profile parameter”See also smart-collector-size on the General page.
| Parameter | Type | Default | Description |
|---|---|---|---|
profile.smart-collector-size | float | 100 | Max size of smart_weight_data.csv in MB. It is a key of the top-level profile block, not of the group: in a group it is ignored |
policy-priority
Section titled “policy-priority”Adjusts the selection weight of nodes whose names match a regex pattern. Values below 1 lower priority; values above 1 raise it.
policy-priority: "Premium:0.9;SG:1.3"In this example, nodes matching Premium have their weight multiplied by 0.9 (lower priority), while nodes matching SG get a 1.3 multiplier (higher priority). Multiple rules are separated by ;. A pattern is tried as a regex first; a pattern that does not compile as a regex is matched as a plain substring. The first matching rule wins. A colon inside a pattern is escaped as \: (the last unescaped colon separates the pattern from the multiplier).
tolerance
Section titled “tolerance”Latency tolerance in milliseconds, from 0 to 65535. Not set or 0 means no tolerance.
The group normally picks nodes by the weights it has learned for a site. When it has too few such nodes, for example for a site it has not seen yet, it adds the remaining nodes in order of their latency from the health check (url / interval of the group). tolerance affects only this order:
- nodes whose latency differs by no more than
tolerancecount as equal and keep their order from theproxieslist; - without it, nodes are sorted strictly by latency, so two nodes with 41 and 43 ms can swap places after every check.
policy-priority is applied first: a node with a higher priority stays ahead regardless of tolerance. Nodes the group suspects of being blocked for the site always go last.
# strictly by latency (default)tolerance: 0
# nodes within 50 ms of each other are equal, the order in proxies decidestolerance: 50
# a larger margin: the first nodes of the list are kept unless they are much slowertolerance: 150How it works
Section titled “How it works”Weight calculation
Section titled “Weight calculation”The group continuously scores each node using five factors:
- Connection success rate — successful vs. failed attempts; recent failures carry more weight.
- Connection performance — connection establishment time and round-trip latency.
- Usage statistics — upload/download volume and session duration.
- Time decay — weights decay for nodes that haven’t been used recently.
- Connection type — separate scoring tracks for UDP and TCP connections.
All metrics are normalised into a base weight, then adjusted by policy-priority rules and ASN-specific tables. Weights are updated using weighted averaging.
Node selection
Section titled “Node selection”Selection follows this priority order:
- Domain-based history — if the destination domain has been seen before, the node with the best historical performance for that domain is preferred.
- ASN-based history — if no domain history exists, the node’s past performance for the destination’s Autonomous System is used.
- Pre-calculated cache — hot domains are pre-scored in memory (LRU) and on disk for fast lookup.
- Round-robin fallback — used when historical data is insufficient; random exploration prevents local optima.
Historical data is retained for 7 days. Expired entries are pruned automatically.
Failure handling
Section titled “Failure handling”When a node exceeds its failure threshold, its weight is penalised. A node the group suspects of being blocked for a site is set aside for that site for a limited time — 5 minutes for a transient failure, 10 minutes by default, up to 30 minutes for a regional block — and then tried again, so a temporary outage does not blacklist a node for good.
Machine Learning (LightGBM)
Section titled “Machine Learning (LightGBM)”When uselightgbm: true, the group uses a pre-trained LightGBM model to predict node weights instead of the rule-based system.
Model file location:
Model.binin the core’s working directory (the-dfolder; the name is matched case-insensitively)
Collecting training data
Section titled “Collecting training data”Enable collectdata: true to write connection metrics to smart_weight_data.csv in the core’s working directory.
Use sample-rate to reduce collection overhead — e.g. sample-rate: 0.1 records 10% of connections.
The collected CSV can be used to train a custom model with LightGBM 3.3.5.