lynx-proxy 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,15 @@ pnpm start
14
14
 
15
15
  `pnpm start` runs the built CLI in foreground mode using the active profile. See `CLI.md` for the current command behavior and known CLI limitations.
16
16
 
17
+ Besides the CLI, LynxProxy ships two Clash Verge–style consoles (both work even when the proxy daemon is stopped, for offline config):
18
+
19
+ ```bash
20
+ lynx tui # full-screen terminal console
21
+ lynx web # web console in your browser (http://127.0.0.1:9876; --port/--no-open)
22
+ ```
23
+
24
+ `lynx web` serves a React UI from `dist/web.mjs` (built with Vite into `dist/web-assets/`). Use `pnpm dev:web` for frontend development with HMR.
25
+
17
26
  Packaged CLI usage loads the active profile from `~/.config/lynx-proxy/user.json`:
18
27
 
19
28
  ```bash
@@ -90,8 +99,48 @@ lynx config current
90
99
  lynx groups select default DIRECT
91
100
  ```
92
101
 
93
- Subscription profiles (Clash-style): `lynx config add <name> --url <url>` fetches a subscription over a direct connection (with a clash-like User-Agent, overridable via `--user-agent`), validates it, and saves it as a profile (default `.yaml`), recording the url, update time, and traffic info in `state.json`. `lynx config update [name]` re-fetches and overwrites the profile entirely — any local `groups rule set` edits are lost on update. If a `groups select` choice no longer exists in the refreshed config, the router degrades to the first resolvable group member at request time. `lynx config info [name]` shows the subscription url, last update time, traffic usage, and expiry. Updates require `lynx proxy restart` to take effect; automatic interval/cron updates are not implemented.
102
+ Subscription profiles (Clash-style): `lynx config add <name> --url <url>` fetches a subscription over a direct connection (with a clash-like User-Agent, overridable via `--user-agent`), validates it, and saves it as a profile (default `.yaml`), recording the url, update time, and traffic info in `state.json`. `--interval <seconds>` registers a periodic refresh task (daemon only); `--cron "5 * * * *"` uses cron scheduling. `lynx config update [name]` re-fetches and overwrites the profile entirely — any local `groups rule set` edits are lost on update. If a `groups select` choice no longer exists in the refreshed config, the router degrades to the first resolvable group member at request time. `lynx config info [name]` shows the subscription url, last update time, traffic usage, expiry, and count of skipped unsupported-protocol nodes.
103
+
104
+ Subscription User-Agent resolution is tiered (highest to lowest): profile-level `option.user_agent` (settable via `lynx profile add|update --user-agent|-UA <ua>`) → global default `subscription.user_agent` in `lynx.json` (`lynx config set subscription.user_agent=<ua>`) → built-in fallback `clash-verge/v1.6.0`. `lynx profile update -UA ""` clears the profile-level UA (falls back to the global/default).
105
+
106
+ **Live reload:** When the daemon is running, `lynx config update` triggers a hot `reload` after fetching. The proxy pool and group members are replaced atomically; runtime mode and group selections are preserved (with degradation as noted). Rules are unchanged — still restart for rule edits. The `lynx proxy reload` command triggers the same hot-reload path.
107
+
108
+ **HTTP providers:** `proxy-providers` and `rule-providers` with `type: "http"` are fetched and cached at daemon startup (or reload), and then expanded into ordinary proxies/rules. The `interval` field controls refresh frequency. `path` must be an absolute file name (no directory); caches live under the lynx config directory. Caching and degradation semantics match subscriptions — stale cache is used if re-fetch fails.
109
+
110
+ **Share-link subscriptions:** If a subscription is not valid Clash YAML/JSON/TOML, lynx first tries decoding it as base64, then parses it as a newline-separated list of share links. Only trojan links are converted to proxies and forwarded; `ss/vmess/vless/ssr` links are skipped with a `skipped N nodes` warning recorded in state.json.
111
+
112
+ **Encrypted subscriptions (decoders):** Some private clients wrap their subscription body in a proprietary encryption. `lynx profile add|update --decoder-plugin <uid>` decrypts the body before it hits disk. Built-in decoder: `D_xxyun` (three-layer AES-128-CBC scheme documented in `xxyun-decrypt-scheme.md`). Each profile can carry its own key via `--decoder-key <hex>` (stored in `profiles.yaml` under `option.decoder_key`) — useful when different subscriptions share the same decoder but use different keys, or when the upstream client rotates its AES key. Omit `--decoder-key` to fall back to the decoder's built-in constant. **Writing your own decoder:** drop a JS file with `function main(content, keyHex) -> string` and install it with `lynx profile decoder add <file> --target <uid>`. The plugin runs in a `node:vm` sandbox (5s timeout) with `Buffer` / `atob` / `btoa` / `createDecipheriv` / `createCipheriv` available. See `docs/decoder-plugin.md`.
113
+
114
+ **Importing Clash Verge configs:** LynxProxy is not a full Clash implementation, but it accepts Clash Verge style profiles. Harmless top-level fields (`tun`, `dns`, `sniffer`, `hosts`, `external-controller`, `secret`, `profile`, etc.) are ignored with a warning and do not block loading. `proxy-providers` and `rule-providers` of `type: "file"` are expanded at load time into normal proxies/rules (relative `path` resolved against the profile directory); `proxy-groups.use` is expanded into group members, and `RULE-SET,<provider>,<target>` is materialized per `behavior` (`domain`→`DOMAIN-SUFFIX`, `ipcidr`→`IP-CIDR`, `classical`→line-as-is). `type: "http"` providers, unknown provider references, and duplicate proxy names raise a clear `ConfigError`. See `DEVELOPMENT.md` for the full field matrix.
94
115
 
95
116
  Proxy-group selections, the active group (`groups use`), and the runtime mode (`groups mode`) are written to `state.json` and resolved per request. When the daemon is running the active profile, these changes are applied live over a Unix domain socket control channel without a restart; otherwise they take effect on next start. Editing routing rules (`groups rule set`) still requires `lynx proxy restart`.
96
117
 
118
+ ## Proxy entry management
119
+
120
+ LynxProxy only manages the **exit** (picking an upstream proxy per routing rule). The **entry** — how applications send requests to lynx — must be managed in two independent layers:
121
+
122
+ | Layer | Covers | Mechanism | Set by |
123
+ | --- | --- | --- | --- |
124
+ | Environment variables (CLI) | curl / git / wget / node / python | process-startup `http_proxy` snapshot | `eval "$(lynx env on)"` (user) |
125
+ | System proxy (GUI) | browsers / Electron / WinINet apps | global state (gsettings / networksetup / registry) | `lynx proxy start`/`stop` (auto) |
126
+
127
+ CLI tools on every platform read only environment variables, never the system proxy. So routing curl/git through lynx requires `lynx env`; routing browsers requires `proxy start` syncing the system proxy. Use both layers together.
128
+
129
+ ```bash
130
+ # CLI tools: activate in the current shell
131
+ eval "$(lynx env on)"
132
+ curl https://example.com # now goes through lynx
133
+ eval "$(lynx env off)"
134
+
135
+ # GUI apps: start the daemon, which also syncs the system proxy
136
+ lynx proxy start
137
+ lynx proxy stop # clears the system proxy on stop
138
+ ```
139
+
140
+ `lynx` never modifies your shell rc files. `lynx env on/off` only prints statements for you to `eval` (POSIX) or paste (PowerShell/cmd). `no_proxy` defaults to `localhost,127.0.0.1,::1,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12`.
141
+
142
+ Platform support for the system-proxy layer: Linux GNOME (`gsettings`), KDE Plasma 6 (`kwriteconfig6` + dbus), macOS (`networksetup`); Windows registry layer is deferred (use `lynx env on` meanwhile). On a pure WM with no desktop proxy API, `proxy start` skips system-proxy sync and suggests `lynx env on`. Pass `--no-system-proxy` to `proxy start`/`stop` to opt out entirely.
143
+
144
+ Known limitation: if the daemon is killed by `SIGKILL` or power loss, the system-proxy residue persists until the next `proxy start`/`stop` (the `SIGINT`/`SIGTERM` trap and startup residue check shrink but cannot eliminate this window).
145
+
97
146
  See `CLI.md` for the CLI command reference, and `config.example.toml` / `DEVELOPMENT.md` for the full supported schema.
package/dist/index.d.mts CHANGED
@@ -1,11 +1 @@
1
- //#region src/index.d.ts
2
- interface CliOptions {
3
- commandArgs?: readonly string[];
4
- help: boolean;
5
- version: boolean;
6
- }
7
- declare function parseCliArgs(argv: readonly string[]): CliOptions;
8
- declare function main(argv?: readonly string[]): Promise<void>;
9
- //#endregion
10
- export { CliOptions, main, parseCliArgs };
11
- //# sourceMappingURL=index.d.mts.map
1
+ export { };