add geo-rules to block-outbound, fix tg secret path
This commit is contained in:
3 files changed
+23
-6
No files matched your search
@@ -276,6 +276,16 @@ in
|
|||||||
default = [ ];
|
default = [ ];
|
||||||
description = "IP CIDRs to block.";
|
description = "IP CIDRs to block.";
|
||||||
};
|
};
|
||||||
|
geosites = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "sing-geosite names to block.";
|
||||||
|
};
|
||||||
|
geoips = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "sing-geoip names to block.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Per-outbound and per-action routing rules.
|
# Per-outbound and per-action routing rules.
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ let
|
|||||||
allGeositeNames = lib.unique (
|
allGeositeNames = lib.unique (
|
||||||
r.proxy.geosites
|
r.proxy.geosites
|
||||||
++ r.direct.geosites
|
++ r.direct.geosites
|
||||||
|
++ r.block.geosites
|
||||||
++ lib.concatMap (rule: rule.geosites) customRules
|
++ lib.concatMap (rule: rule.geosites) customRules
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ let
|
|||||||
allGeoIPNames = lib.unique (
|
allGeoIPNames = lib.unique (
|
||||||
r.proxy.geoips
|
r.proxy.geoips
|
||||||
++ r.direct.geoips
|
++ r.direct.geoips
|
||||||
|
++ r.block.geoips
|
||||||
++ lib.concatMap (rule: rule.geoips) customRules
|
++ lib.concatMap (rule: rule.geoips) customRules
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -116,6 +118,8 @@ let
|
|||||||
# Block
|
# Block
|
||||||
(mkDomainRule "block" r.block.domains)
|
(mkDomainRule "block" r.block.domains)
|
||||||
(mkIPRule "block" r.block.ips)
|
(mkIPRule "block" r.block.ips)
|
||||||
|
(mkRulesetRule "block" (map (s: "geosite-${s}") r.block.geosites))
|
||||||
|
(mkRulesetRule "block" (map (s: "geoip-${s}") r.block.geoips))
|
||||||
];
|
];
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ let
|
|||||||
dcArgs = lib.concatMapStrings (id: " --dc-ip=${id}:${t.dcIps.${id}}") (
|
dcArgs = lib.concatMapStrings (id: " --dc-ip=${id}:${t.dcIps.${id}}") (
|
||||||
builtins.attrNames t.dcIps
|
builtins.attrNames t.dcIps
|
||||||
);
|
);
|
||||||
secretArg =
|
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
||||||
if t.secretFile != null then
|
exec ${tgPkg}/bin/tg-ws-proxy \
|
||||||
" --secret-file=%d/tg_ws_proxy_secret"
|
--port=${toString t.port} \
|
||||||
else
|
--host=${t.host} \
|
||||||
" --secret=${t.secret}";
|
${if t.secretFile != null
|
||||||
|
then "--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
||||||
|
else "--secret=${t.secret}"}${dcArgs}
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
systemd.services.proxy-suite-tg-ws-proxy = {
|
systemd.services.proxy-suite-tg-ws-proxy = {
|
||||||
@@ -20,7 +23,7 @@ in
|
|||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${tgPkg}/bin/tg-ws-proxy --port=${toString t.port} --host=${t.host}${secretArg}${dcArgs}";
|
ExecStart = "${startScript}";
|
||||||
LoadCredential = lib.optional (t.secretFile != null) "tg_ws_proxy_secret:${t.secretFile}";
|
LoadCredential = lib.optional (t.secretFile != null) "tg_ws_proxy_secret:${t.secretFile}";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = 5;
|
RestartSec = 5;
|
||||||
|
|||||||
Reference in new issue
Block a user