feat: debug options

This commit is contained in:
FUFSoB committed 2026-10-11 11:18:48 +05:00
1 parent cacd51595c
commit e293efd1c1
33 files changed
+965 -77

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
{ lib, ... }:
let
inherit (lib) mkOption types;
inherit (import ./lib.nix { inherit lib; }) bool;
in
{
# Troubleshooting only: everything here logs more, some of it every site visited.
options.services.proxy-suite.debug = {
logLevel = mkOption {
type = types.enum [
"warn"
"info"
"debug"
"trace"
];
default = "warn";
description = ''
How much the proxy backends log to the journal (`proxy-ctl logs proxy-suite-socks`):
sing-box, and XRay where it runs (XRay has no "trace": it logs at "debug" then).
"info" logs every connection with its destination and the rule that routed it.
`/run/proxy-suite/xray-loglevel` still overrides XRay's level at the next start.
'';
example = "info";
};
connectionLog = {
enable = bool false ''
Record the backends' connections to the journal: each one as it opens, with its
listener, site, rule and exit, and as it closes, with the bytes each way and how long
it lasted. For failures that come and go: look back at the time one happened. A unit
per backend, up while it is: proxy-suite-connection-log for the local proxy and
global or per-app TProxy, proxy-suite-connection-log-tun for the global TUN and
proxy-suite-connection-log-per-app-tun for per-app TUN, whose Clash APIs this turns
on. The same view live: `proxy-ctl debug conns`. Polls the Clash API, so it needs the
sing-box or hybrid backend; a connection shorter than `interval` can be missed.
'';
hosts = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Record only connections to these domains and their subdomains, or these addresses.
Empty: every connection.
'';
example = [
"twimg.com"
"x.com"
];
};
inbounds = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Record only connections that came in on listeners whose tag starts with one of
these: "tproxy" for global and per-app TProxy, "tun-in" for the global and per-app
TUN, "per-app-pin" for apps run `--via` an outbound through TProxy, "mixed-in" for
the local proxy. Empty: every listener.
'';
example = [ "tproxy" ];
};
stallAfter = mkOption {
type = types.ints.unsigned;
default = 10;
description = ''
Seconds a connection may wait on an answer: one that has sent since it last
received, and received nothing for this long, is logged as stalled, and again
when it resumes. Several requests share a connection (HTTP/2), so a stall shows
only when all of them wait. 0: never.
'';
};
interval = mkOption {
type = types.numbers.positive;
default = 0.5;
description = "Seconds between looks at the connections.";
};
};
perAppDns = bool false ''
Log every lookup the per-app DNS forwarders send on (per-app TUN and TProxy, and apps
run through an AmneziaWG interface): the name, its type, the answer's code and how long
it took, and the lookups that got no answer. In the journals of
proxy-suite-per-app-tun-dns, proxy-suite-per-app-tproxy-dns and
proxy-suite-per-app-via@.
'';
zapret2 = {
packets = bool false "Log everything nfqws2 does to the journal, every packet included. Very verbose.";
autoHostlist = bool false "Log why sites are or are not learned (nfqws2's own learner).";
};
tgWsProxy = bool false "Log the Telegram proxy's debug messages.";
};
}
+1
View File
@@ -25,6 +25,7 @@
./user-control.nix
./kill-switch.nix
./host.nix
./debug.nix
];
options.services.proxy-suite.enable = lib.mkEnableOption "proxy-suite";
+8 -1
View File
@@ -23,6 +23,13 @@ in
(lib.mkRenamedOptionModule (p "tray.autostart") (p "gui.autostart"))
(lib.mkRenamedOptionModule (p "tray.pollInterval") (p "gui.refreshInterval"))
# Troubleshooting switches gathered under debug.
(lib.mkRenamedOptionModule (p "zapret.zapret2.debug") (p "debug.zapret2.packets"))
(lib.mkRenamedOptionModule (p "zapret.zapret2.autoHostlist.debugLog") (
p "debug.zapret2.autoHostlist"
))
(lib.mkRenamedOptionModule (p "tgWsProxy.log.verbose") (p "debug.tgWsProxy"))
# These were aliases; they are removal notices now, so there is one
# compatibility policy instead of two.
(rm "proxyInbounds" "Use services.proxy-suite.inbounds.")
@@ -65,7 +72,7 @@ in
(rm "tgWsProxy.cfProxyFallback" "Use services.proxy-suite.tgWsProxy.cloudflare.fallback.")
(rm "tgWsProxy.bufKb" "Use services.proxy-suite.tgWsProxy.bufferKiB.")
(rm "tgWsProxy.routingMark" "Use services.proxy-suite.tgWsProxy.fwmark.")
(rm "tgWsProxy.verbose" "Use services.proxy-suite.tgWsProxy.log.verbose.")
(rm "tgWsProxy.verbose" "Use services.proxy-suite.debug.tgWsProxy.")
(rm "tgWsProxy.logFile" "Use services.proxy-suite.tgWsProxy.log.file.")
(rm "tgWsProxy.logMaxMb" "Use services.proxy-suite.tgWsProxy.log.maxSizeMiB.")
(rm "tgWsProxy.logBackups" "Use services.proxy-suite.tgWsProxy.log.keep.")
@@ -94,12 +94,6 @@ in
};
log = {
verbose = mkOption {
type = types.bool;
default = false;
description = "Log debug messages.";
};
file = mkOption {
type = types.nullOr types.str;
default = null;
+2 -13
View File
@@ -120,16 +120,11 @@ in
default = true;
description = ''
Log each counted failure and strategy switch to the journal, per site
(`proxy-ctl logs proxy-suite-zapret`). Without it nfqws2 logs them only with `debug`.
(`proxy-ctl logs proxy-suite-zapret`). Without it nfqws2 logs them only with
`debug.zapret2.packets`.
'';
};
debug = mkOption {
type = types.bool;
default = false;
description = "Log everything nfqws2 does to the journal, every packet included. Very verbose: for troubleshooting.";
};
ipv6 = mkOption {
type = types.bool;
default = false;
@@ -160,12 +155,6 @@ in
udpOut = int 4 "UDP packets sent, with at most `udpIn` replies, that count as a failure.";
udpIn = int 1 "Most UDP replies that still count as no answer (see `udpOut`).";
debugLog = mkOption {
type = types.bool;
default = false;
description = "Log why sites are or are not learned (nfqws2's own learner).";
};
extendedDetection = mkOption {
type = types.bool;
default = true;