rinova-proxy-sdk
Proxy subscription to Clash config converter — Rust SDK.
v1.0.0 · Author: Rina
Install
[]
= "1.0.0"
= { = "1", = ["macros", "rt-multi-thread"] }
Quick Start
use convert;
async
API Reference
convert(url, opts) -> Result<ConvertResult>
Fetch a subscription URL, parse proxy nodes, and generate a complete Clash configuration.
use ;
// Basic
let result = convert.await?;
// With options
let result = convert.await?;
let ConvertResult = result;
| Parameter | Type | Default | Description |
|---|---|---|---|
url |
&str |
required | Proxy subscription URL |
opts.rules |
RuleMode |
Builtin |
Builtin or External (ACL4SSR RuleSet) |
opts.deduplicate |
bool |
true |
Append -2, -3 to duplicate node names |
Returns ConvertResult:
| Field | Type | Description |
|---|---|---|
yaml |
String |
Clash config as YAML |
config |
ClashConfig |
Full config object |
nodes |
Vec<ProxyNode> |
Parsed proxy nodes |
Errors ProxyError if subscription is empty or no valid nodes are found.
convert_from_lines(lines, opts) -> Result<ConvertResult>
Convert URI lines without network requests.
use ;
let lines = ;
let result = convert_from_lines?;
Same options and return type as convert().
parse_uri(uri) -> Result<ProxyNode>
Parse a single proxy URI.
use parse_uri;
let node = parse_uri?;
assert_eq!;
assert_eq!;
assert_eq!;
// Protocol-specific fields live in `extra`
let cipher = node.extra.get.and_then;
let password = node.extra.get.and_then;
Supported prefixes: ss://, vmess://, trojan://, hysteria2://, hy2://
parse_lines(lines) -> Vec<ProxyNode>
Parse multiple URI lines. Invalid lines are skipped with a warning to stderr.
use parse_lines;
let nodes = parse_lines;
assert_eq!;
fetch_subscription(url) -> Result<Vec<String>>
Fetch and decode a subscription into URI lines (Base64 / URL-decode tolerant).
use fetch_subscription;
async
User-Agent: @rinova/proxy-sdk/1.0.0
deduplicate_names(nodes: &mut [ProxyNode])
Rename duplicate nodes in-place: first keeps original name, others get -2, -3, …
use ;
let mut nodes = vec!;
deduplicate_names;
// → "Japan", "Japan-2"
build_config(nodes, rule_mode) -> ClashConfig
Build a Clash config from parsed nodes.
use ;
let nodes = parse_lines;
let config = build_config;
// config.proxies, config.proxy_groups, config.rules
Policy groups (ACL4SSR-style chained routing):
Rule MATCH / foreign domains
↓
🌍 国外网站 (default: 🚀 节点选择)
↓
🚀 节点选择 ← switch nodes in Verge
↓
specific proxy node
| Group | Purpose |
|---|---|
🚀 节点选择 |
Main node selector |
♻️ 自动选择 |
url-test, lowest latency |
🎯 直连 |
Direct or proxy |
🌍 国外网站 |
Referenced by rules, follows 🚀 节点选择 |
🇨🇳 国内网站 |
Domestic routing |
🛑 广告拦截 |
REJECT |
to_yaml(config) -> Result<String>
Serialize ClashConfig to YAML.
use ;
let yaml = to_yaml?;
write?;
start_server(opts) -> Result<ServerHandle>
Start an HTTP server with automatic subscription refresh.
use ;
async
HTTP endpoints (listen on 127.0.0.1:{port}):
| Method | Path | Description |
|---|---|---|
| GET | /clash.yaml |
Clash config YAML |
| GET | /health |
JSON: status, nodes, updatedAt, nextRefreshMin, lastError |
| POST | /refresh |
Manual refresh → { ok, skipped, nodes } |
| GET | /refresh |
405 Method Not Allowed |
All responses include Access-Control-Allow-Origin: *.
t(key, params) / t_with_fallback(key, params, fallback) / get_lang()
Localized messages based on LANG / LC_ALL.
use ;
match get_lang
println!;
println!;
println!;
Types
use ;
| Type | Description |
|---|---|
ProxyNode |
name, proxy_type, server, port, extra (protocol fields) |
ProxyGroup |
Policy group (name, group_type, proxies, …) |
ClashConfig |
Full config (proxies, proxy_groups, rules, ports) |
ConvertOptions |
{ rules: RuleMode, deduplicate: bool } |
ConvertResult |
{ config, yaml, nodes } |
RuleMode |
Builtin | External |
ProxyType |
Ss | Vmess | Trojan | Hysteria2 |
ServerOptions |
{ url, port, interval_min, rule_mode } |
ServerHandle |
Call .shutdown().await to stop |
Lang |
En | Zh |
ProxyError |
Error enum |
Result<T> |
std::result::Result<T, ProxyError> |
ProxyNode.extra fields (by protocol)
Protocol-specific options are stored in extra (IndexMap<String, Value>):
| Protocol | Common keys in extra |
|---|---|
| SS | cipher, password |
| VMess | uuid, alterId, cipher, network, tls, sni, ws-opts, grpc-opts, … |
| Trojan | password, sni, skip-cert-verify |
| Hysteria2 | password, sni, alpn, up, down, skip-cert-verify |
Modules
| Module | Exports |
|---|---|
| crate root | convert, convert_from_lines, re-exports |
parser |
parse_uri, parse_lines |
fetch |
fetch_subscription, deduplicate_names |
builder |
build_config, to_yaml |
server |
start_server, ServerHandle, ServerOptions |
i18n |
t, t_with_fallback, get_lang, Lang |
types |
All public types |
error |
ProxyError, Result |
License
MIT — Copyright (c) 2026 Rina