ps-core::links ports upstream's proxy_url_parsers.py and proxy_parsing.py: every scheme, each backend's refusals, XRay rendering, subscription decoding, tags and the server checks. Upstream's build-outbound tests are ported case for case, and tools/parity/links.py runs ~750 links through both implementations: no differences. config::privileged_changes names the edits only an administrator may make: anything that runs a program, passes arguments through, or names a local file, since the service runs as LocalSystem. Names that become paths or service names are validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
921 B
Rust
23 lines
921 B
Rust
//! For the parity check against upstream (tools/parity/links.py): JSON lines in,
|
|
//! `{"url", "tag", "backend"}`, JSON lines out, `{"ok": outbound}` or `{"error": message}`.
|
|
|
|
use std::io::{BufRead, Write};
|
|
|
|
use ps_core::links::{LinkBackend, build_outbound};
|
|
use serde_json::{Value, json};
|
|
|
|
fn main() {
|
|
let stdout = std::io::stdout();
|
|
let mut out = stdout.lock();
|
|
for line in std::io::stdin().lock().lines() {
|
|
let line = line.expect("stdin");
|
|
let req: Value = serde_json::from_str(&line).expect("a JSON request");
|
|
let backend = if req["backend"] == "xray" { LinkBackend::Xray } else { LinkBackend::SingBox };
|
|
let result = match build_outbound(req["url"].as_str().unwrap(), req["tag"].as_str().unwrap(), backend) {
|
|
Ok(ob) => json!({ "ok": ob }),
|
|
Err(e) => json!({ "error": e.to_string() }),
|
|
};
|
|
writeln!(out, "{result}").unwrap();
|
|
}
|
|
}
|