feat: update tg-ws-proxy and its options
This commit is contained in:
6 files changed
+732
-29
No files matched your search
+453
@@ -124,13 +124,25 @@ Update module option docs there instead of editing this file by hand.
|
||||
- [package](#services-proxy-suite-proxy-xray-package)
|
||||
- tgWsProxy
|
||||
- [enable](#services-proxy-suite-tgwsproxy-enable)
|
||||
- [bufKb](#services-proxy-suite-tgwsproxy-bufkb)
|
||||
- [bypassTransparentProxy](#services-proxy-suite-tgwsproxy-bypasstransparentproxy)
|
||||
- [cfProxyDomains](#services-proxy-suite-tgwsproxy-cfproxydomains)
|
||||
- [cfProxyFallback](#services-proxy-suite-tgwsproxy-cfproxyfallback)
|
||||
- [cfProxyWorkerDomains](#services-proxy-suite-tgwsproxy-cfproxyworkerdomains)
|
||||
- [dcIps](#services-proxy-suite-tgwsproxy-dcips)
|
||||
- [fakeTlsDomain](#services-proxy-suite-tgwsproxy-faketlsdomain)
|
||||
- [host](#services-proxy-suite-tgwsproxy-host)
|
||||
- [logBackups](#services-proxy-suite-tgwsproxy-logbackups)
|
||||
- [logFile](#services-proxy-suite-tgwsproxy-logfile)
|
||||
- [logMaxMb](#services-proxy-suite-tgwsproxy-logmaxmb)
|
||||
- [poolSize](#services-proxy-suite-tgwsproxy-poolsize)
|
||||
- [port](#services-proxy-suite-tgwsproxy-port)
|
||||
- [proxyProtocol](#services-proxy-suite-tgwsproxy-proxyprotocol)
|
||||
- [routingMark](#services-proxy-suite-tgwsproxy-routingmark)
|
||||
- [secret](#services-proxy-suite-tgwsproxy-secret)
|
||||
- [secretFile](#services-proxy-suite-tgwsproxy-secretfile)
|
||||
- [verbose](#services-proxy-suite-tgwsproxy-verbose)
|
||||
- [wsKeepalive](#services-proxy-suite-tgwsproxy-wskeepalive)
|
||||
- tray
|
||||
- [enable](#services-proxy-suite-tray-enable)
|
||||
- [autostart](#services-proxy-suite-tray-autostart)
|
||||
@@ -287,14 +299,26 @@ services.proxy-suite = {
|
||||
};
|
||||
};
|
||||
tgWsProxy = {
|
||||
bufKb = 256;
|
||||
bypassTransparentProxy = true;
|
||||
cfProxyDomains = [ ];
|
||||
cfProxyFallback = true;
|
||||
cfProxyWorkerDomains = [ ];
|
||||
dcIps = { };
|
||||
enable = false;
|
||||
fakeTlsDomain = null;
|
||||
host = "127.0.0.1";
|
||||
logBackups = 1;
|
||||
logFile = null;
|
||||
logMaxMb = 5.0;
|
||||
poolSize = 4;
|
||||
port = 1443;
|
||||
proxyProtocol = false;
|
||||
routingMark = 4;
|
||||
secret = null;
|
||||
secretFile = null;
|
||||
verbose = false;
|
||||
wsKeepalive = 30.0;
|
||||
};
|
||||
tray = {
|
||||
autostart = true;
|
||||
@@ -536,18 +560,35 @@ services.proxy-suite = {
|
||||
};
|
||||
};
|
||||
tgWsProxy = {
|
||||
bufKb = 512;
|
||||
bypassTransparentProxy = true;
|
||||
cfProxyDomains = [
|
||||
"cdn.example.com"
|
||||
"edge.example.net"
|
||||
];
|
||||
cfProxyFallback = false;
|
||||
cfProxyWorkerDomains = [
|
||||
"worker.example.com"
|
||||
];
|
||||
dcIps = {
|
||||
"2" = "149.154.167.220";
|
||||
"203" = "149.154.167.220";
|
||||
"4" = "149.154.167.220";
|
||||
};
|
||||
enable = true;
|
||||
fakeTlsDomain = "www.example.com";
|
||||
host = "127.0.0.1";
|
||||
logBackups = 3;
|
||||
logFile = "/var/log/tg-ws-proxy.log";
|
||||
logMaxMb = 10.0;
|
||||
poolSize = 8;
|
||||
port = 1076;
|
||||
proxyProtocol = true;
|
||||
routingMark = 4;
|
||||
secret = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
secretFile = "/run/secrets/tg-ws-proxy-secret";
|
||||
verbose = true;
|
||||
wsKeepalive = 15.0;
|
||||
};
|
||||
tray = {
|
||||
autostart = true;
|
||||
@@ -3996,6 +4037,39 @@ true
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-bufkb"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.bufKb
|
||||
|
||||
|
||||
|
||||
Socket send and receive buffer size for tg-ws-proxy, in KiB\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
integer between 4 and 2147483647 (both inclusive)
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
256
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
512
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-bypasstransparentproxy"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.bypassTransparentProxy
|
||||
|
||||
@@ -4036,6 +4110,114 @@ true
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-cfproxydomains"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.cfProxyDomains
|
||||
|
||||
|
||||
|
||||
User-defined Cloudflare-proxied domains used by tg-ws-proxy for
|
||||
WebSocket fallback\. Each entry is passed as a separate
|
||||
–cfproxy-domain argument\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
list of string
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
[ ]
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
[
|
||||
"cdn.example.com"
|
||||
"edge.example.net"
|
||||
]
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-cfproxyfallback"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.cfProxyFallback
|
||||
|
||||
|
||||
|
||||
Whether to allow tg-ws-proxy to use Cloudflare proxy fallback when
|
||||
direct WebSocket routing is unavailable\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
true
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
false
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-cfproxyworkerdomains"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.cfProxyWorkerDomains
|
||||
|
||||
|
||||
|
||||
Cloudflare Worker domains used by tg-ws-proxy for WebSocket fallback\.
|
||||
These are tried before other fallback methods\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
list of string
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
[ ]
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
[
|
||||
"worker.example.com"
|
||||
]
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-dcips"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.dcIps
|
||||
|
||||
@@ -4075,6 +4257,40 @@ attribute set of string
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-faketlsdomain"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.fakeTlsDomain
|
||||
|
||||
|
||||
|
||||
Optional SNI domain used to enable tg-ws-proxy Fake TLS masking\.
|
||||
When set, tg-ws-proxy emits an ee-secret connection link\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
null or string matching the pattern \.+
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
null
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
"www.example.com"
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-host"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.host
|
||||
|
||||
@@ -4110,6 +4326,140 @@ string
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-logbackups"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.logBackups
|
||||
|
||||
Number of rotated tg-ws-proxy log files to keep\.
|
||||
Only used when tgWsProxy\.logFile is set\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
positive integer, meaning >0
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
1
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
3
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-logfile"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.logFile
|
||||
|
||||
|
||||
|
||||
Optional path where tg-ws-proxy writes rotating logs\.
|
||||
When unset, tg-ws-proxy logs to stderr only\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
null or string
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
null
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
"/var/log/tg-ws-proxy.log"
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-logmaxmb"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.logMaxMb
|
||||
|
||||
|
||||
|
||||
Maximum tg-ws-proxy log file size in MiB before rotation\.
|
||||
Only used when tgWsProxy\.logFile is set\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
positive integer or floating point number, meaning >0
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
5.0
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
10.0
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-poolsize"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.poolSize
|
||||
|
||||
|
||||
|
||||
WebSocket connection pool size per Telegram DC\.
|
||||
Set to 0 to disable connection pooling\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
unsigned integer, meaning >=0
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
4
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
8
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-port"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.port
|
||||
|
||||
@@ -4145,6 +4495,40 @@ WebSocket proxy\.
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-proxyprotocol"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.proxyProtocol
|
||||
|
||||
|
||||
|
||||
Whether tg-ws-proxy should accept a PROXY protocol v1 header from a
|
||||
fronting reverse proxy such as nginx or HAProxy\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
false
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
true
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-routingmark"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.routingMark
|
||||
|
||||
@@ -4253,9 +4637,78 @@ null
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-verbose"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.verbose
|
||||
|
||||
|
||||
|
||||
Whether to enable debug logging in tg-ws-proxy\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
false
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
true
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tgwsproxy-wskeepalive"></a>
|
||||
## services\.proxy-suite\.tgWsProxy\.wsKeepalive
|
||||
|
||||
|
||||
|
||||
Seconds between upstream WebSocket keepalive pings\.
|
||||
Set to 0 to disable keepalive pings\.
|
||||
|
||||
|
||||
|
||||
*Type:*
|
||||
nonnegative integer or floating point number, meaning >=0
|
||||
|
||||
|
||||
|
||||
*Default:*
|
||||
|
||||
```nix
|
||||
30.0
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
```nix
|
||||
15.0
|
||||
```
|
||||
|
||||
*Declared by:*
|
||||
- [modules/proxy-suite/options/other\.nix](https://github.com/FUFSoB/proxy-suite-flake/blob/main/modules/proxy-suite/options/other.nix)
|
||||
|
||||
|
||||
|
||||
<a id="services-proxy-suite-tray-enable"></a>
|
||||
## services\.proxy-suite\.tray\.enable
|
||||
|
||||
|
||||
|
||||
Whether to enable system tray indicator for proxy-suite\.
|
||||
|
||||
|
||||
|
||||
@@ -131,6 +131,128 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
verbose = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable debug logging in tg-ws-proxy.
|
||||
'';
|
||||
example = true;
|
||||
};
|
||||
|
||||
logFile = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Optional path where tg-ws-proxy writes rotating logs.
|
||||
When unset, tg-ws-proxy logs to stderr only.
|
||||
'';
|
||||
example = "/var/log/tg-ws-proxy.log";
|
||||
};
|
||||
|
||||
logMaxMb = mkOption {
|
||||
type = types.numbers.positive;
|
||||
default = 5.0;
|
||||
description = ''
|
||||
Maximum tg-ws-proxy log file size in MiB before rotation.
|
||||
Only used when tgWsProxy.logFile is set.
|
||||
'';
|
||||
example = 10.0;
|
||||
};
|
||||
|
||||
logBackups = mkOption {
|
||||
type = types.ints.positive;
|
||||
default = 1;
|
||||
description = ''
|
||||
Number of rotated tg-ws-proxy log files to keep.
|
||||
Only used when tgWsProxy.logFile is set.
|
||||
'';
|
||||
example = 3;
|
||||
};
|
||||
|
||||
bufKb = mkOption {
|
||||
type = types.ints.between 4 2147483647;
|
||||
default = 256;
|
||||
description = ''
|
||||
Socket send and receive buffer size for tg-ws-proxy, in KiB.
|
||||
'';
|
||||
example = 512;
|
||||
};
|
||||
|
||||
poolSize = mkOption {
|
||||
type = types.ints.unsigned;
|
||||
default = 4;
|
||||
description = ''
|
||||
WebSocket connection pool size per Telegram DC.
|
||||
Set to 0 to disable connection pooling.
|
||||
'';
|
||||
example = 8;
|
||||
};
|
||||
|
||||
cfProxyDomains = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
User-defined Cloudflare-proxied domains used by tg-ws-proxy for
|
||||
WebSocket fallback. Each entry is passed as a separate
|
||||
--cfproxy-domain argument.
|
||||
'';
|
||||
example = [
|
||||
"cdn.example.com"
|
||||
"edge.example.net"
|
||||
];
|
||||
};
|
||||
|
||||
cfProxyWorkerDomains = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Cloudflare Worker domains used by tg-ws-proxy for WebSocket fallback.
|
||||
These are tried before other fallback methods.
|
||||
'';
|
||||
example = [ "worker.example.com" ];
|
||||
};
|
||||
|
||||
cfProxyFallback = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to allow tg-ws-proxy to use Cloudflare proxy fallback when
|
||||
direct WebSocket routing is unavailable.
|
||||
'';
|
||||
example = false;
|
||||
};
|
||||
|
||||
fakeTlsDomain = mkOption {
|
||||
type = types.nullOr (types.strMatching ".+");
|
||||
default = null;
|
||||
description = ''
|
||||
Optional SNI domain used to enable tg-ws-proxy Fake TLS masking.
|
||||
When set, tg-ws-proxy emits an ee-secret connection link.
|
||||
'';
|
||||
example = "www.example.com";
|
||||
};
|
||||
|
||||
proxyProtocol = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether tg-ws-proxy should accept a PROXY protocol v1 header from a
|
||||
fronting reverse proxy such as nginx or HAProxy.
|
||||
'';
|
||||
example = true;
|
||||
};
|
||||
|
||||
wsKeepalive = mkOption {
|
||||
type = types.numbers.nonnegative;
|
||||
default = 30.0;
|
||||
description = ''
|
||||
Seconds between upstream WebSocket keepalive pings.
|
||||
Set to 0 to disable keepalive pings.
|
||||
'';
|
||||
example = 15.0;
|
||||
};
|
||||
|
||||
bypassTransparentProxy = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
|
||||
@@ -12,24 +12,40 @@ let
|
||||
ip = "${pkgs.iproute2}/bin/ip";
|
||||
|
||||
transparentBypassEnabled =
|
||||
t.bypassTransparentProxy
|
||||
&& cfg.proxy.enable
|
||||
&& (cfg.proxy.tun.enable || cfg.proxy.tproxy.enable);
|
||||
t.bypassTransparentProxy && cfg.proxy.enable && (cfg.proxy.tun.enable || cfg.proxy.tproxy.enable);
|
||||
bypassRulePriority = 8999;
|
||||
|
||||
dcArgs = lib.concatMapStrings
|
||||
(id: " --dc-ip=${lib.escapeShellArg "${id}:${t.dcIps.${id}}"}")
|
||||
(builtins.attrNames t.dcIps);
|
||||
mkValueArg = name: value: " args+=(${name}=${lib.escapeShellArg value})\n";
|
||||
mkRawValueArg = name: value: " args+=(${name}=${toString value})\n";
|
||||
mkFlagArg = condition: name: lib.optionalString condition " args+=(${name})\n";
|
||||
mkOptionalValueArg =
|
||||
condition: name: value:
|
||||
lib.optionalString condition (mkValueArg name value);
|
||||
mkRepeatedValueArgs = name: values: lib.concatMapStrings (value: mkValueArg name value) values;
|
||||
dcArgs = lib.concatMapStrings (id: mkValueArg "--dc-ip" "${id}:${t.dcIps.${id}}") (
|
||||
builtins.attrNames t.dcIps
|
||||
);
|
||||
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
||||
exec ${tgPkg}/bin/tg-ws-proxy \
|
||||
--port=${toString t.port} \
|
||||
--host=${lib.escapeShellArg t.host} \
|
||||
${
|
||||
if t.secretFile != null then
|
||||
"--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
||||
else
|
||||
"--secret=${lib.escapeShellArg t.secret}"
|
||||
}${dcArgs}
|
||||
args=(
|
||||
--port=${toString t.port}
|
||||
--host=${lib.escapeShellArg t.host}
|
||||
)
|
||||
${
|
||||
if t.secretFile != null then
|
||||
''args+=(--secret-file="$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret")''
|
||||
else
|
||||
"args+=(--secret=${lib.escapeShellArg t.secret})"
|
||||
}
|
||||
${dcArgs}${mkFlagArg t.verbose "--verbose"}${
|
||||
mkOptionalValueArg (t.logFile != null) "--log-file" t.logFile
|
||||
}${lib.optionalString (t.logFile != null) (mkRawValueArg "--log-max-mb" t.logMaxMb)}${
|
||||
lib.optionalString (t.logFile != null) (mkRawValueArg "--log-backups" t.logBackups)
|
||||
}${mkRawValueArg "--buf-kb" t.bufKb}${mkRawValueArg "--pool-size" t.poolSize}${mkRepeatedValueArgs "--cfproxy-domain" t.cfProxyDomains}${mkRepeatedValueArgs "--cfproxy-worker-domain" t.cfProxyWorkerDomains}${
|
||||
mkFlagArg (!t.cfProxyFallback) "--no-cfproxy"
|
||||
}${
|
||||
mkOptionalValueArg (t.fakeTlsDomain != null) "--fake-tls-domain" t.fakeTlsDomain
|
||||
}${mkFlagArg t.proxyProtocol "--proxy-protocol"}${mkRawValueArg "--ws-keepalive" t.wsKeepalive}
|
||||
exec ${tgPkg}/bin/tg-ws-proxy "''${args[@]}"
|
||||
'';
|
||||
|
||||
bypassUpScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-bypass-up" ''
|
||||
|
||||
+103
-8
@@ -674,6 +674,36 @@ let
|
||||
];
|
||||
tgSecretFileService = tgSecretFile.config.systemd.services."proxy-suite-tg-ws-proxy";
|
||||
|
||||
tgAllOptions = evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite.tgWsProxy = {
|
||||
enable = true;
|
||||
port = 2443;
|
||||
host = "0.0.0.0";
|
||||
secretFile = "/run/secrets/tg-ws-proxy";
|
||||
verbose = true;
|
||||
logFile = "/var/log/tg-ws-proxy.log";
|
||||
logMaxMb = 2.5;
|
||||
logBackups = 3;
|
||||
bufKb = 512;
|
||||
poolSize = 8;
|
||||
cfProxyDomains = [
|
||||
"cdn.example.com"
|
||||
"edge.example.net"
|
||||
];
|
||||
cfProxyWorkerDomains = [ "worker.example.com" ];
|
||||
cfProxyFallback = false;
|
||||
fakeTlsDomain = "mask.example.com";
|
||||
proxyProtocol = true;
|
||||
wsKeepalive = 0;
|
||||
};
|
||||
}
|
||||
];
|
||||
tgAllOptionsStartScript = builtins.readFile (
|
||||
tgAllOptions.config.systemd.services."proxy-suite-tg-ws-proxy".serviceConfig.ExecStart
|
||||
);
|
||||
|
||||
tgWithGlobalTun = evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
@@ -720,6 +750,46 @@ let
|
||||
}
|
||||
];
|
||||
|
||||
tgInvalidBufKb = mkBadFixture [
|
||||
{
|
||||
services.proxy-suite.tgWsProxy = {
|
||||
enable = true;
|
||||
secretFile = "/run/secrets/tg-ws-proxy";
|
||||
bufKb = 3;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
tgInvalidPoolSize = mkBadFixture [
|
||||
{
|
||||
services.proxy-suite.tgWsProxy = {
|
||||
enable = true;
|
||||
secretFile = "/run/secrets/tg-ws-proxy";
|
||||
poolSize = -1;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
tgInvalidLogBackups = mkBadFixture [
|
||||
{
|
||||
services.proxy-suite.tgWsProxy = {
|
||||
enable = true;
|
||||
secretFile = "/run/secrets/tg-ws-proxy";
|
||||
logBackups = 0;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
tgInvalidWsKeepalive = mkBadFixture [
|
||||
{
|
||||
services.proxy-suite.tgWsProxy = {
|
||||
enable = true;
|
||||
secretFile = "/run/secrets/tg-ws-proxy";
|
||||
wsKeepalive = -1;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
duplicateTags = forceEval (
|
||||
(mkFixture {
|
||||
enable = true;
|
||||
@@ -2084,6 +2154,31 @@ let
|
||||
assert minimal.config.services.proxy-suite.tgWsProxy.dcIps == { };
|
||||
true
|
||||
)
|
||||
# -- tg-ws-proxy: upstream runtime flags are exposed as typed module options --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "--port=2443" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--host=0.0.0.0" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--secret-file=\"$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret\""
|
||||
tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--verbose" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--log-file=/var/log/tg-ws-proxy.log" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--log-max-mb=2.500000" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--log-backups=3" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--buf-kb=512" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--pool-size=8" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--cfproxy-domain=cdn.example.com" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--cfproxy-domain=edge.example.net" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--cfproxy-worker-domain=worker.example.com" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--no-cfproxy" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--fake-tls-domain=mask.example.com" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--proxy-protocol" tgAllOptionsStartScript;
|
||||
assert pkgs.lib.hasInfix "--ws-keepalive=0" tgAllOptionsStartScript;
|
||||
assert tgInvalidBufKb.success == false;
|
||||
assert tgInvalidPoolSize.success == false;
|
||||
assert tgInvalidLogBackups.success == false;
|
||||
assert tgInvalidWsKeepalive.success == false;
|
||||
true
|
||||
)
|
||||
(
|
||||
assert
|
||||
tgSecretFile.config.systemd.services."proxy-suite-tg-ws-proxy".serviceConfig.LoadCredential
|
||||
@@ -2133,9 +2228,7 @@ let
|
||||
dnsBridgeRouteRule = builtins.head (
|
||||
builtins.filter (
|
||||
rule:
|
||||
(rule.action or "") == "hijack-dns"
|
||||
&& (rule ? inbound)
|
||||
&& builtins.elem "xray-dns-in" rule.inbound
|
||||
(rule.action or "") == "hijack-dns" && (rule ? inbound) && builtins.elem "xray-dns-in" rule.inbound
|
||||
) hybridTproxyConfig.route.rules
|
||||
);
|
||||
in
|
||||
@@ -2149,10 +2242,11 @@ let
|
||||
assert mixedInbound.type == "mixed";
|
||||
assert tproxyInbound.type == "tproxy";
|
||||
assert tunDnsBridgeInbound.listen_port == 18534;
|
||||
assert dnsBridgeRouteRule.network == [
|
||||
"tcp"
|
||||
"udp"
|
||||
];
|
||||
assert
|
||||
dnsBridgeRouteRule.network == [
|
||||
"tcp"
|
||||
"udp"
|
||||
];
|
||||
assert pkgs.lib.hasInfix "/bin/sing-box run -c" hybridStartScript;
|
||||
assert pkgs.lib.hasInfix "/bin/xray run -c" hybridStartScript;
|
||||
assert pkgs.lib.hasInfix "xray-sidecar.json" hybridStartScript;
|
||||
@@ -2173,7 +2267,8 @@ let
|
||||
assert pkgs.lib.hasInfix "xray-dns-in" hybridBackendJqFilter;
|
||||
assert pkgs.lib.hasInfix "--backend hybrid" hybridSubscriptionStartScript;
|
||||
assert pkgs.lib.hasInfix "--backend hybrid" hybridSubscriptionUpdateScript;
|
||||
assert pkgs.lib.hasInfix ''type == "object" and (.singBox | type == "array") and (.xray | type == "array")''
|
||||
assert pkgs.lib.hasInfix
|
||||
''type == "object" and (.singBox | type == "array") and (.xray | type == "array")''
|
||||
hybridSubscriptionStartScript;
|
||||
assert pkgs.lib.hasInfix ".singBox" hybridSubscriptionStartScript;
|
||||
assert pkgs.lib.hasInfix ".xray[]" hybridSubscriptionStartScript;
|
||||
|
||||
+21
-4
@@ -262,8 +262,25 @@ pkgs.runCommand "proxy-suite-options.md" { } ''
|
||||
}
|
||||
' "$section_index"
|
||||
|
||||
cat "$preamble" >"$out"
|
||||
cat "$toc" >>"$out"
|
||||
printf '\n' >>"$out"
|
||||
cat "$sections_with_anchors" >>"$out"
|
||||
raw="$TMPDIR/options.md.raw"
|
||||
|
||||
cat "$preamble" >"$raw"
|
||||
cat "$toc" >>"$raw"
|
||||
printf '\n' >>"$raw"
|
||||
cat "$sections_with_anchors" >>"$raw"
|
||||
|
||||
awk '
|
||||
NF {
|
||||
for (i = 0; i < blanks; i++) {
|
||||
print ""
|
||||
}
|
||||
blanks = 0
|
||||
print
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
blanks++
|
||||
}
|
||||
' "$raw" >"$out"
|
||||
''
|
||||
@@ -4,8 +4,8 @@ let
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Flowseal";
|
||||
repo = "tg-ws-proxy";
|
||||
rev = "v1.7.1";
|
||||
hash = "sha256-Mf9FCfBtwdCEZnwhbv9Cu6+pf6Icy3F1rbGPVouA8o0=";
|
||||
rev = "v1.7.3";
|
||||
hash = "sha256-b9Dmh41PEC3LZDhaSILUDrLApDgP0IiKXn//cvLfm9o=";
|
||||
};
|
||||
|
||||
pythonEnv = pkgs.python3.withPackages (
|
||||
|
||||
Reference in new issue
Block a user