small fixes
This commit is contained in:
5 files changed
+38
-44
No files matched your search
@@ -154,19 +154,15 @@ let
|
|||||||
r.proxy.geoips ++ direct.geoips ++ r.block.geoips ++ lib.concatMap (rule: rule.geoips) customRules
|
r.proxy.geoips ++ direct.geoips ++ r.block.geoips ++ lib.concatMap (rule: rule.geoips) customRules
|
||||||
);
|
);
|
||||||
|
|
||||||
geositeRuleSets = map (name: {
|
mkRuleSet = kind: pkg: name: {
|
||||||
tag = "geosite-${name}";
|
tag = "${kind}-${name}";
|
||||||
type = "local";
|
type = "local";
|
||||||
format = "binary";
|
format = "binary";
|
||||||
path = "${pkgs.sing-geosite}/share/sing-box/rule-set/geosite-${name}.srs";
|
path = "${pkg}/share/sing-box/rule-set/${kind}-${name}.srs";
|
||||||
}) allGeositeNames;
|
};
|
||||||
|
|
||||||
geoIPRuleSets = map (name: {
|
geositeRuleSets = map (mkRuleSet "geosite" pkgs.sing-geosite) allGeositeNames;
|
||||||
tag = "geoip-${name}";
|
geoIPRuleSets = map (mkRuleSet "geoip" pkgs.sing-geoip) allGeoIPNames;
|
||||||
type = "local";
|
|
||||||
format = "binary";
|
|
||||||
path = "${pkgs.sing-geoip}/share/sing-box/rule-set/geoip-${name}.srs";
|
|
||||||
}) allGeoIPNames;
|
|
||||||
|
|
||||||
routingRules = lib.flatten [
|
routingRules = lib.flatten [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -197,6 +197,11 @@ let
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
perAppZapretDesyncMarks = [
|
||||||
|
67108864
|
||||||
|
134217728
|
||||||
|
];
|
||||||
|
|
||||||
forbiddenValueAssertions =
|
forbiddenValueAssertions =
|
||||||
map (item: forbiddenValues item.condition item.value item.disallowed item.message)
|
map (item: forbiddenValues item.condition item.value item.disallowed item.message)
|
||||||
[
|
[
|
||||||
@@ -212,46 +217,31 @@ let
|
|||||||
{
|
{
|
||||||
condition = perAppZapretCfg.enable;
|
condition = perAppZapretCfg.enable;
|
||||||
value = globalTproxy.fwmark;
|
value = globalTproxy.fwmark;
|
||||||
disallowed = [
|
disallowed = perAppZapretDesyncMarks;
|
||||||
67108864
|
|
||||||
134217728
|
|
||||||
];
|
|
||||||
message = "proxy-suite: singBox.tproxy.fwmark must not use per-app-zapret internal desync mark bits";
|
message = "proxy-suite: singBox.tproxy.fwmark must not use per-app-zapret internal desync mark bits";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
condition = perAppZapretCfg.enable;
|
condition = perAppZapretCfg.enable;
|
||||||
value = globalTproxy.proxyMark;
|
value = globalTproxy.proxyMark;
|
||||||
disallowed = [
|
disallowed = perAppZapretDesyncMarks;
|
||||||
67108864
|
|
||||||
134217728
|
|
||||||
];
|
|
||||||
message = "proxy-suite: singBox.tproxy.proxyMark must not use per-app-zapret internal desync mark bits";
|
message = "proxy-suite: singBox.tproxy.proxyMark must not use per-app-zapret internal desync mark bits";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
condition = perAppRoutingTun.enable && perAppZapretCfg.enable;
|
condition = perAppRoutingTun.enable && perAppZapretCfg.enable;
|
||||||
value = perAppRoutingTun.fwmark;
|
value = perAppRoutingTun.fwmark;
|
||||||
disallowed = [
|
disallowed = perAppZapretDesyncMarks;
|
||||||
67108864
|
|
||||||
134217728
|
|
||||||
];
|
|
||||||
message = "proxy-suite: singBox.tun.perApp.fwmark must not use per-app-zapret internal desync mark bits";
|
message = "proxy-suite: singBox.tun.perApp.fwmark must not use per-app-zapret internal desync mark bits";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
condition = perAppRoutingTproxy.enable && perAppZapretCfg.enable;
|
condition = perAppRoutingTproxy.enable && perAppZapretCfg.enable;
|
||||||
value = perAppRoutingTproxy.fwmark;
|
value = perAppRoutingTproxy.fwmark;
|
||||||
disallowed = [
|
disallowed = perAppZapretDesyncMarks;
|
||||||
67108864
|
|
||||||
134217728
|
|
||||||
];
|
|
||||||
message = "proxy-suite: singBox.tproxy.perApp.fwmark must not use per-app-zapret internal desync mark bits";
|
message = "proxy-suite: singBox.tproxy.perApp.fwmark must not use per-app-zapret internal desync mark bits";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
condition = perAppZapretCfg.enable;
|
condition = perAppZapretCfg.enable;
|
||||||
value = perAppZapretCfg.filterMark;
|
value = perAppZapretCfg.filterMark;
|
||||||
disallowed = [
|
disallowed = perAppZapretDesyncMarks;
|
||||||
67108864
|
|
||||||
134217728
|
|
||||||
];
|
|
||||||
message = "proxy-suite: zapret.perApp.filterMark must not use per-app-zapret internal desync mark bits";
|
message = "proxy-suite: zapret.perApp.filterMark must not use per-app-zapret internal desync mark bits";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -10,16 +10,18 @@ let
|
|||||||
t = cfg.tgWsProxy;
|
t = cfg.tgWsProxy;
|
||||||
tgPkg = packages.tg-ws-proxy;
|
tgPkg = packages.tg-ws-proxy;
|
||||||
|
|
||||||
dcArgs = lib.concatMapStrings (id: " --dc-ip=${id}:${t.dcIps.${id}}") (builtins.attrNames t.dcIps);
|
dcArgs = lib.concatMapStrings
|
||||||
|
(id: " --dc-ip=${lib.escapeShellArg "${id}:${t.dcIps.${id}}"}")
|
||||||
|
(builtins.attrNames t.dcIps);
|
||||||
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
startScript = pkgs.writeShellScript "proxy-suite-tg-ws-proxy-start" ''
|
||||||
exec ${tgPkg}/bin/tg-ws-proxy \
|
exec ${tgPkg}/bin/tg-ws-proxy \
|
||||||
--port=${toString t.port} \
|
--port=${toString t.port} \
|
||||||
--host=${t.host} \
|
--host=${lib.escapeShellArg t.host} \
|
||||||
${
|
${
|
||||||
if t.secretFile != null then
|
if t.secretFile != null then
|
||||||
"--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
"--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
||||||
else
|
else
|
||||||
"--secret=${t.secret}"
|
"--secret=${lib.escapeShellArg t.secret}"
|
||||||
}${dcArgs}
|
}${dcArgs}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|||||||
+12
-9
@@ -56,14 +56,17 @@ _svc_active() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_status_tray() {
|
_status_tray() {
|
||||||
printf 'socks_available=%s\n' "$(_bool _svc_exists proxy-suite-socks)"
|
local pair key svc
|
||||||
printf 'socks_active=%s\n' "$(_bool _svc_active proxy-suite-socks)"
|
for pair in \
|
||||||
printf 'tproxy_available=%s\n' "$(_bool _svc_exists proxy-suite-tproxy)"
|
socks:proxy-suite-socks \
|
||||||
printf 'tproxy_active=%s\n' "$(_bool _svc_active proxy-suite-tproxy)"
|
tproxy:proxy-suite-tproxy \
|
||||||
printf 'tun_available=%s\n' "$(_bool _svc_exists proxy-suite-tun)"
|
tun:proxy-suite-tun \
|
||||||
printf 'tun_active=%s\n' "$(_bool _svc_active proxy-suite-tun)"
|
zapret:zapret-discord-youtube; do
|
||||||
printf 'zapret_available=%s\n' "$(_bool _svc_exists zapret-discord-youtube)"
|
key="${pair%%:*}"
|
||||||
printf 'zapret_active=%s\n' "$(_bool _svc_active zapret-discord-youtube)"
|
svc="${pair##*:}"
|
||||||
|
printf '%s_available=%s\n' "$key" "$(_bool _svc_exists "$svc")"
|
||||||
|
printf '%s_active=%s\n' "$key" "$(_bool _svc_active "$svc")"
|
||||||
|
done
|
||||||
printf 'subscription_update_available=%s\n' "$(_bool _svc_exists proxy-suite-subscription-update)"
|
printf 'subscription_update_available=%s\n' "$(_bool _svc_exists proxy-suite-subscription-update)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +251,7 @@ cmd_apps() {
|
|||||||
|
|
||||||
cmd_wrap() {
|
cmd_wrap() {
|
||||||
local route
|
local route
|
||||||
profile="${1:?Usage: proxy-ctl wrap <profile> -- <command> [args...]}"
|
local profile="${1:?Usage: proxy-ctl wrap <profile> -- <command> [args...]}"
|
||||||
shift || true
|
shift || true
|
||||||
if [ "${1:-}" = "--" ]; then
|
if [ "${1:-}" = "--" ]; then
|
||||||
shift
|
shift
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import binascii
|
||||||
import json
|
import json
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ def _parse_url_parts(url: str, scheme: str) -> tuple[str, str, str, dict]:
|
|||||||
userinfo = ""
|
userinfo = ""
|
||||||
hostpart, _, query = rest.partition("?")
|
hostpart, _, query = rest.partition("?")
|
||||||
host, _, port = hostpart.rpartition(":")
|
host, _, port = hostpart.rpartition(":")
|
||||||
|
if host.startswith("[") and host.endswith("]"):
|
||||||
|
host = host[1:-1]
|
||||||
return userinfo, host, port, _qs(query)
|
return userinfo, host, port, _qs(query)
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +115,7 @@ def parse_vmess(url: str, tag: str) -> dict:
|
|||||||
pad = "=" * (-len(b64) % 4)
|
pad = "=" * (-len(b64) % 4)
|
||||||
try:
|
try:
|
||||||
data = json.loads(base64.b64decode(b64 + pad))
|
data = json.loads(base64.b64decode(b64 + pad))
|
||||||
except Exception:
|
except (binascii.Error, ValueError):
|
||||||
data = json.loads(base64.urlsafe_b64decode(b64 + pad))
|
data = json.loads(base64.urlsafe_b64decode(b64 + pad))
|
||||||
|
|
||||||
host = str(data["add"])
|
host = str(data["add"])
|
||||||
@@ -189,7 +192,7 @@ def parse_shadowsocks(url: str, tag: str) -> dict:
|
|||||||
if ":" not in decoded:
|
if ":" not in decoded:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
method, password = decoded.split(":", 1)
|
method, password = decoded.split(":", 1)
|
||||||
except Exception:
|
except (binascii.Error, UnicodeDecodeError, ValueError):
|
||||||
plain = urllib.parse.unquote(userinfo)
|
plain = urllib.parse.unquote(userinfo)
|
||||||
method, password = plain.split(":", 1)
|
method, password = plain.split(":", 1)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user