Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mcp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,19 @@ server.tool("list_proxies", "List stored proxies (no credentials).", {}, async (

server.tool(
"add_proxy",
"Add a proxy to the store. Pass `proxy` as a string (scheme://user:pass@host:port) or explicit fields.",
"Add a proxy to the store. Pass `proxy` as a string (vless://uuid@host:port?..., scheme://user:pass@host:port) or explicit fields.",
{
proxy: z.string().optional(),
kind: z.enum(["socks5", "http", "https"]).optional(),
kind: z.enum(["socks5", "http", "https", "vless"]).optional(),
host: z.string().optional(),
port: z.number().optional(),
username: z.string().optional(),
password: z.string().optional(),
name: z.string().optional(),
country: z.string().optional(),
notes: z.string().optional(),
change_ip_url: z.string().optional(),
vless: z.record(z.string(), z.unknown()).optional(),
},
async (args) => text(await api("/proxies", { method: "POST", body: args })),
);
Expand Down
43 changes: 37 additions & 6 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2469,30 +2469,59 @@ components:

AddProxyRequest:
type: object
description: A proxy string OR explicit fields (string wins).
description: A proxy string OR explicit fields (if `proxy` is set, it wins and `vless` is ignored).
properties:
proxy:
type: string
description: "`scheme://user:pass@host:port` or `host:port:user:pass`."
kind: { type: string, enum: [socks5, http, https] }
description: "`vless://uuid@host:port?...`, `scheme://user:pass@host:port` or `host:port:user:pass`."
kind: { type: string, enum: [socks5, http, https, vless] }
host: { type: string }
port: { type: integer }
username: { type: string }
username: { type: string, description: "Proxy username, or VLESS UUID when `kind` is `vless`." }
password: { type: string }
name: { type: string }
country: { type: string }
notes: { type: string }
change_ip_url:
type: string
description: "The provider's change-IP link (http/https). Kept on this computer only, never returned."
vless:
$ref: "#/components/schemas/VlessConfig"

VlessConfig:
type: object
description: Extra transport and security parameters for VLESS proxies (the UUID sits in `username`; only `encryption=none` is supported).
properties:
encryption: { type: string, default: none }
flow: { type: string }
network: { type: string, default: tcp }
security: { type: string, default: none }
sni: { type: string }
fingerprint: { type: string }
public_key: { type: string }
short_id: { type: string }
spider_x: { type: string }
pqv: { type: string }
alpn: { type: string }
allow_insecure: { type: boolean }
pinned_peer_cert_sha256: { type: string }
verify_peer_cert_by_name: { type: string }
host: { type: string }
path: { type: string }
service_name: { type: string }
authority: { type: string }
mode: { type: string }
header_type: { type: string }
seed: { type: string }
extra: { type: string }

ProxySummary:
type: object
description: Stored proxy without credentials.
properties:
id: { type: string }
name: { type: string }
kind: { type: string, enum: [socks5, http, https] }
kind: { type: string, enum: [socks5, http, https, vless] }
host: { type: string }
port: { type: integer }
country: { type: string, description: Informational tag (e.g. "US"). }
Expand Down Expand Up @@ -2528,13 +2557,15 @@ components:
properties:
id: { type: string }
name: { type: string }
kind: { type: string, enum: [socks5, http, https] }
kind: { type: string, enum: [socks5, http, https, vless] }
host: { type: string }
port: { type: integer }
username: { type: string }
password: { type: string }
country: { type: string }
notes: { type: string }
vless:
$ref: "#/components/schemas/VlessConfig"

AutomationBranch:
description: |
Expand Down
5 changes: 3 additions & 2 deletions scripts/check-i18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const TEXT_PROPS = new Set([
// picker's own entries, and samples of code or headers.
const KEEP = new Set([
"ShardBrowser", "ShardBrowser Launcher", "ProxyShard", "ShardX", "Shard Helper", "GitHub", "MCP", "GPU", "CPU",
"URL", "SQL", "UDP", "TCP", "HTTP", "HTTPS", "SOCKS5", "Canvas", "WebGL",
"WebGPU", "WebRTC", "TLS", "CDP", "API", "JSON", "Cookie", "User-Agent",
"URL", "SQL", "UDP", "TCP", "HTTP", "HTTP/2", "HTTPS", "SOCKS5", "VLESS", "REALITY", "WebSocket", "XHTTP", "HTTPUpgrade", "Canvas", "WebGL",
"WebGPU", "WebRTC", "TLS", "CDP", "API", "JSON", "Cookie", "User-Agent", "h2,http/1.1",
"Chrome", "Firefox", "Safari", "Edge", "QQ",
"macOS", "MacOS", "Windows", "Windows 10", "Windows 11", "Linux", "Android",
"iOS", "IOS", "X", "Y", "ISP", "Do Not Track", "Esc", "Enter", "Ctrl", "Space", "Home", "End", "Delete", "Shift",
"Authorization: Bearer …", "Content-Type: application/json",
Expand Down
7 changes: 5 additions & 2 deletions scripts/lib/class-rules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// text, so scripts/check-classes.test.mjs can test every rule without
// Tailwind.
import { readFileSync, readdirSync, statSync } from "node:fs";
import { join, relative } from "node:path";
import { join, relative, sep } from "node:path";

/** Repo-relative path with forward slashes, so allowlists match on Windows. */
const repoPath = (root, p) => relative(root, p).split(sep).join("/");

/** Class-like tokens in one string. */
export const tokensOf = (s) => s.match(/[^\s"'`{}<;]+/g) ?? [];
Expand Down Expand Up @@ -209,7 +212,7 @@ export function scanRules(root) {
const walk = (dir) => {
for (const name of readdirSync(dir)) {
const p = join(dir, name);
const rel = relative(root, p);
const rel = repoPath(root, p);
if (SKIP.some((re) => re.test(rel))) continue;
if (statSync(p).isDirectory()) walk(p);
else if (/\.(tsx?|jsx?)$/.test(name)) {
Expand Down
13 changes: 13 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tauri-build = { version = "2", features = [] }
# Optional: only the automation runner uses them.
# `cookies` is what makes a session a session; the decompressors are what makes
# a real site's answer readable.
wreq = { version = "0.16.1", optional = true, features = ["cookies", "gzip", "brotli", "deflate", "zstd"] }
wreq = { version = "0.16.1", optional = true, features = ["cookies", "gzip", "brotli", "deflate", "zstd", "socks"] }
wreq-util = { version = "0.2.0", optional = true, features = ["emulation", "emulation-serde"] }
# Extra database drivers for the automation runner (SQLite is rusqlite above,
# always present). Optional + behind the automation feature so a non-automation
Expand Down
42 changes: 35 additions & 7 deletions src-tauri/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,9 @@ async fn list_fingerprints() -> ApiResult {

#[derive(Deserialize)]
struct AddProxyReq {
/// "scheme://user:pass@host:port" or "host:port:user:pass"; wins over fields.
/// "vless://uuid@host:port?...", "scheme://user:pass@host:port" or "host:port:user:pass"; wins over fields.
proxy: Option<String>,
/// socks5 | http | https (default socks5).
/// socks5 | http | https | vless (default socks5).
kind: Option<String>,
host: Option<String>,
port: Option<u16>,
Expand All @@ -775,6 +775,8 @@ struct AddProxyReq {
notes: Option<String>,
/// #162: the provider's change-IP link; kept on this computer, never returned.
change_ip_url: Option<String>,
#[serde(default)]
vless: Option<crate::space::proxy::VlessConfig>,
}

/// Add proxy (an identical one already stored is reused); returns summary.
Expand All @@ -790,22 +792,48 @@ async fn add_proxy(Extension(t): Extension<Ticket>, Json(body): Json<AddProxyReq
let port = body
.port
.ok_or_else(|| err(StatusCode::BAD_REQUEST, "`port` required"))?;
let kind = match body.kind.as_deref() {
let kind = match body.kind.as_deref().map(|k| k.trim().to_ascii_lowercase()).as_deref() {
None | Some("") | Some("socks5") => crate::space::proxy::ProxyKind::Socks5,
Some("http") => crate::space::proxy::ProxyKind::Http,
Some("https") => crate::space::proxy::ProxyKind::Https,
_ => crate::space::proxy::ProxyKind::Socks5,
Some("vless") => crate::space::proxy::ProxyKind::Vless,
Some(other) => {
return Err(err(
StatusCode::BAD_REQUEST,
format!("unsupported proxy kind `{other}`; expected socks5, http, https, or vless"),
));
}
};
let host_trimmed = host.trim().to_string();
if host_trimmed.is_empty() {
return Err(err(StatusCode::BAD_REQUEST, "`host` must not be empty"));
}
if port == 0 {
return Err(err(StatusCode::BAD_REQUEST, "`port` must be between 1 and 65535"));
}
let vless = if kind == crate::space::proxy::ProxyKind::Vless {
Some(body.vless.as_ref().map(|v| v.normalized()).unwrap_or_default())
} else {
None
};
crate::space::proxy::ProxyEntry {
let entry = crate::space::proxy::ProxyEntry {
id: String::new(),
name: String::new(),
name: format!("{host_trimmed}:{port}"),
kind,
host,
host: host_trimmed,
port,
username: body.username.clone().unwrap_or_default(),
password: body.password.clone().unwrap_or_default(),
country: String::new(),
notes: String::new(),
vless,
subscription_id: None,
};
if matches!(entry.kind, crate::space::proxy::ProxyKind::Vless) {
crate::vless::build_xray_config(&entry, 1080)
.map_err(|e| err(StatusCode::BAD_REQUEST, format!("{e:#}")))?;
}
entry
};
// metadata overrides (applied to parsed entries too).
if let Some(n) = body.name.filter(|s| !s.is_empty()) {
Expand Down
Loading