window for tray icon, new toggles, formatting
This commit is contained in:
15 files changed
+644
-321
No files matched your search
@@ -4,21 +4,21 @@ Declarative proxy stack for NixOS. One flake, one module, done.
|
|||||||
|
|
||||||
Bundles [sing-box](https://github.com/SagerNet/sing-box), [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube), and [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy). Built specifically for dealing with Roskomnadzor (RKN) and the usual Russian ISP nonsense.
|
Bundles [sing-box](https://github.com/SagerNet/sing-box), [zapret-discord-youtube](https://github.com/kartavkun/zapret-discord-youtube), and [tg-ws-proxy](https://github.com/Flowseal/tg-ws-proxy). Built specifically for dealing with Roskomnadzor (RKN) and the usual Russian ISP nonsense.
|
||||||
|
|
||||||
The goal is to replace GUI clients like v2rayN and their ilk — you configure your proxies in Nix, rebuild, and they just work as systemd services.
|
The goal is to replace GUI clients like v2rayN and their ilk – you configure your proxies in Nix, rebuild, and they just work as systemd services.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## What it gives you
|
## What it gives you
|
||||||
|
|
||||||
- **SOCKS5/HTTP proxy** on `127.0.0.1:1080` by default — always running, always available to apps
|
- **SOCKS5/HTTP proxy** on `127.0.0.1:1080` by default – always running, always available to apps
|
||||||
- **Transparent proxy (TProxy)** — redirect all system traffic through sing-box without configuring each app; start/stop on demand
|
- **Transparent proxy (TProxy)** – redirect all system traffic through sing-box without configuring each app; start/stop on demand
|
||||||
- **TUN mode** — full tunnel via a virtual network interface; useful when TProxy doesn't cover something
|
- **TUN mode** – full tunnel via a virtual network interface; useful when TProxy doesn't cover something
|
||||||
- **Multiple outbounds** with automatic latency-based switching or manual selection
|
- **Multiple outbounds** with automatic latency-based switching or manual selection
|
||||||
- **Per-outbound routing** — route specific domains, IPs, or geo sets to specific servers
|
- **Per-outbound routing** – route specific domains, IPs, or geo sets to specific servers
|
||||||
- **Protocol support**: vless (Reality, TLS), vmess, trojan, shadowsocks, hysteria2, TUIC v5, socks5, socks4, http/https proxy
|
- **Protocol support**: vless (Reality, TLS), vmess, trojan, shadowsocks, hysteria2, TUIC v5, socks5, socks4, http/https proxy
|
||||||
- **`proxy-ctl`** — control script for managing services, switching outbounds, and following logs
|
- **`proxy-ctl`** – control script for managing services, switching outbounds, and following logs
|
||||||
- **DPI bypass** via zapret — handles YouTube, Discord, and other sites that are blocked by packet inspection rather than IP
|
- **DPI bypass** via zapret – handles YouTube, Discord, and other sites that are blocked by packet inspection rather than IP
|
||||||
- **Telegram proxy** — MTProto WebSocket relay for sharing with others or for clients that don't support SOCKS
|
- **Telegram proxy** – MTProto WebSocket relay for sharing with others or for clients that don't support SOCKS
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ Add to your flake inputs:
|
|||||||
inputs.proxy-suite.url = "github:FUFSoB/proxy-suite-flake";
|
inputs.proxy-suite.url = "github:FUFSoB/proxy-suite-flake";
|
||||||
```
|
```
|
||||||
|
|
||||||
No need to add zapret separately — it comes along as a transitive input.
|
No need to add zapret separately – it comes along as a transitive input.
|
||||||
|
|
||||||
Add the module to your NixOS configuration:
|
Add the module to your NixOS configuration:
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ services.proxy-suite = {
|
|||||||
outbounds = [
|
outbounds = [
|
||||||
{
|
{
|
||||||
tag = "vps";
|
tag = "vps";
|
||||||
# Runtime secret — not in the nix store.
|
# Runtime secret – not in the nix store.
|
||||||
# Works with sops-nix, agenix, or anything that gives you a file path.
|
# Works with sops-nix, agenix, or anything that gives you a file path.
|
||||||
urlFile = config.sops.secrets.proxy_url.path;
|
urlFile = config.sops.secrets.proxy_url.path;
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ outbounds = [
|
|||||||
];
|
];
|
||||||
```
|
```
|
||||||
|
|
||||||
**Explicit rules list** — also works for `direct` and `block`, in any selection mode:
|
**Explicit rules list** – also works for `direct` and `block`, in any selection mode:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
singBox.routing.rules = [
|
singBox.routing.rules = [
|
||||||
@@ -404,7 +404,10 @@ services.proxy-suite = {
|
|||||||
Features:
|
Features:
|
||||||
|
|
||||||
- **Status icon**: `network-vpn` (active), `network-vpn-acquiring` (partial), `network-vpn-disconnected` (stopped)
|
- **Status icon**: `network-vpn` (active), `network-vpn-acquiring` (partial), `network-vpn-disconnected` (stopped)
|
||||||
|
- **Quick controls window**: Opens on secondary activation and on hosts that emit StatusNotifier `Activate` on left-click (including niri)
|
||||||
|
- **Enable/Disable Proxy**: Toggles `proxy-suite-socks`; disabling proxy also stops active TProxy/TUN first
|
||||||
- **Toggle TProxy/TUN**: Only shown if the service is enabled in your config
|
- **Toggle TProxy/TUN**: Only shown if the service is enabled in your config
|
||||||
|
- **Close window**: Hides the floating controls window without exiting the tray
|
||||||
- **Restart services**: Restarts `proxy-suite-socks`, and `proxy-suite-tun` if it is active
|
- **Restart services**: Restarts `proxy-suite-socks`, and `proxy-suite-tun` if it is active
|
||||||
- **Polkit authentication**: Prompts for password when toggling services
|
- **Polkit authentication**: Prompts for password when toggling services
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "NixOS proxy suite — sing-box, zapret, tg-ws-proxy";
|
description = "NixOS proxy suite – sing-box, zapret, tg-ws-proxy";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
@@ -10,7 +10,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, zapret }:
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
zapret,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
proxySuiteModule = import ./modules/proxy-suite { inherit zapret; };
|
proxySuiteModule = import ./modules/proxy-suite { inherit zapret; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Main module — bakes in the zapret flake so consumers don't need it as a separate input.
|
# Main module – bakes in the zapret flake so consumers don't need it as a separate input.
|
||||||
nixosModules.default = proxySuiteModule;
|
nixosModules.default = proxySuiteModule;
|
||||||
|
|
||||||
# Re-export zapret standalone for users who want just that.
|
# Re-export zapret standalone for users who want just that.
|
||||||
@@ -37,13 +41,16 @@
|
|||||||
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { pkgs = pkgsFor system; };
|
proxy-suite-tray = import ./pkgs/proxy-suite-tray.nix { pkgs = pkgsFor system; };
|
||||||
});
|
});
|
||||||
|
|
||||||
checks = forAll (system: import ./nix/checks.nix {
|
checks = forAll (
|
||||||
inherit
|
system:
|
||||||
system
|
import ./nix/checks.nix {
|
||||||
nixpkgs
|
inherit
|
||||||
proxySuiteModule
|
system
|
||||||
zapret
|
nixpkgs
|
||||||
;
|
proxySuiteModule
|
||||||
});
|
zapret
|
||||||
|
;
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
# Build-time sing-box configuration templates.
|
# Build-time sing-box configuration templates.
|
||||||
# The proxy outbound(s) are injected at service start time, not here.
|
# The proxy outbound(s) are injected at service start time, not here.
|
||||||
{ lib, pkgs, cfg, rules }:
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
cfg,
|
||||||
|
rules,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
sb = cfg.singBox;
|
sb = cfg.singBox;
|
||||||
@@ -44,9 +49,7 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
dnsConfigTun = dnsConfig // {
|
dnsConfigTun = dnsConfig // {
|
||||||
servers = map (
|
servers = map (s: if s.tag == "local" then s // { detour = "proxy"; } else s) dnsConfig.servers;
|
||||||
s: if s.tag == "local" then s // { detour = "proxy"; } else s
|
|
||||||
) dnsConfig.servers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mkConfig =
|
mkConfig =
|
||||||
@@ -89,10 +92,16 @@ let
|
|||||||
# proxy outbound(s) are prepended at runtime by the start script
|
# proxy outbound(s) are prepended at runtime by the start script
|
||||||
outbounds = [
|
outbounds = [
|
||||||
(
|
(
|
||||||
{ type = "direct"; tag = "direct"; }
|
{
|
||||||
|
type = "direct";
|
||||||
|
tag = "direct";
|
||||||
|
}
|
||||||
// lib.optionalAttrs useOutboundRoutingMark { routing_mark = sb.proxyMark; }
|
// lib.optionalAttrs useOutboundRoutingMark { routing_mark = sb.proxyMark; }
|
||||||
)
|
)
|
||||||
{ type = "block"; tag = "block"; }
|
{
|
||||||
|
type = "block";
|
||||||
|
tag = "block";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
route = {
|
route = {
|
||||||
@@ -100,7 +109,8 @@ let
|
|||||||
rule_set = rules.geositeRuleSets ++ rules.geoIPRuleSets;
|
rule_set = rules.geositeRuleSets ++ rules.geoIPRuleSets;
|
||||||
rules = rules.routingRules;
|
rules = rules.routingRules;
|
||||||
final = if sb.proxyByDefault then "proxy" else "direct";
|
final = if sb.proxyByDefault then "proxy" else "direct";
|
||||||
} // lib.optionalAttrs enableTun { auto_detect_interface = true; };
|
}
|
||||||
|
// lib.optionalAttrs enableTun { auto_detect_interface = true; };
|
||||||
}
|
}
|
||||||
// clashApiBlock;
|
// clashApiBlock;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
# Factory function — receives the zapret flake, returns a NixOS module.
|
# Factory function – receives the zapret flake, returns a NixOS module.
|
||||||
# This lets consumers add a single flake input and get everything transitively.
|
# This lets consumers add a single flake input and get everything transitively.
|
||||||
{ zapret }:
|
{ zapret }:
|
||||||
|
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.proxy-suite;
|
cfg = config.services.proxy-suite;
|
||||||
@@ -15,32 +20,63 @@ in
|
|||||||
zapret.nixosModules.default
|
zapret.nixosModules.default
|
||||||
];
|
];
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
config = lib.mkIf cfg.enable (
|
||||||
(lib.mkIf cfg.singBox.enable (
|
lib.mkMerge [
|
||||||
let
|
(lib.mkIf cfg.singBox.enable (
|
||||||
rules = import ./rules.nix { inherit lib pkgs cfg zapret; };
|
let
|
||||||
configs = import ./config.nix { inherit lib pkgs cfg rules; };
|
rules = import ./rules.nix {
|
||||||
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
|
inherit
|
||||||
in
|
lib
|
||||||
import ./service.nix {
|
pkgs
|
||||||
inherit config lib pkgs cfg;
|
cfg
|
||||||
inherit (configs) tproxyFile tunFile;
|
zapret
|
||||||
inherit (nftr) nftablesRulesFile ip nft;
|
;
|
||||||
}
|
};
|
||||||
))
|
configs = import ./config.nix {
|
||||||
|
inherit
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
cfg
|
||||||
|
rules
|
||||||
|
;
|
||||||
|
};
|
||||||
|
nftr = import ./nftables.nix { inherit lib pkgs cfg; };
|
||||||
|
in
|
||||||
|
import ./service.nix {
|
||||||
|
inherit
|
||||||
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
cfg
|
||||||
|
;
|
||||||
|
inherit (configs) tproxyFile tunFile;
|
||||||
|
inherit (nftr) nftablesRulesFile ip nft;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
(lib.mkIf cfg.zapret.enable (
|
(lib.mkIf cfg.zapret.enable (
|
||||||
import ./zapret.nix {
|
import ./zapret.nix {
|
||||||
inherit lib pkgs cfg zapret;
|
inherit
|
||||||
}
|
lib
|
||||||
))
|
pkgs
|
||||||
|
cfg
|
||||||
|
zapret
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
(lib.mkIf cfg.tgWsProxy.enable (
|
(lib.mkIf cfg.tgWsProxy.enable (import ./tg-ws-proxy.nix { inherit lib pkgs cfg; }))
|
||||||
import ./tg-ws-proxy.nix { inherit lib pkgs cfg; }
|
|
||||||
))
|
|
||||||
|
|
||||||
(lib.mkIf cfg.tray.enable (
|
(lib.mkIf cfg.tray.enable (
|
||||||
import ./tray.nix { inherit config lib pkgs cfg; }
|
import ./tray.nix {
|
||||||
))
|
inherit
|
||||||
]);
|
config
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
cfg
|
||||||
|
;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -1,47 +1,51 @@
|
|||||||
# TProxy nftables rules
|
# TProxy nftables rules
|
||||||
{ lib, pkgs, cfg }:
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
cfg,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
sb = cfg.singBox;
|
sb = cfg.singBox;
|
||||||
|
|
||||||
localSubnetLines = lib.concatMapStrings (cidr: ''
|
localSubnetLines = lib.concatMapStrings (cidr: ''
|
||||||
ip daddr ${cidr} tcp dport != 53 return
|
ip daddr ${cidr} tcp dport != 53 return
|
||||||
ip daddr ${cidr} udp dport != 53 return
|
ip daddr ${cidr} udp dport != 53 return
|
||||||
'') sb.tproxy.localSubnets;
|
'') sb.tproxy.localSubnets;
|
||||||
|
|
||||||
nftablesRulesFile = pkgs.writeText "proxy-suite-tproxy.nft" ''
|
nftablesRulesFile = pkgs.writeText "proxy-suite-tproxy.nft" ''
|
||||||
define RESERVED_IP = {
|
define RESERVED_IP = {
|
||||||
10.0.0.0/8,
|
10.0.0.0/8,
|
||||||
100.64.0.0/10,
|
100.64.0.0/10,
|
||||||
127.0.0.0/8,
|
127.0.0.0/8,
|
||||||
169.254.0.0/16,
|
169.254.0.0/16,
|
||||||
172.16.0.0/12,
|
172.16.0.0/12,
|
||||||
192.0.0.0/24,
|
192.0.0.0/24,
|
||||||
224.0.0.0/4,
|
224.0.0.0/4,
|
||||||
240.0.0.0/4,
|
240.0.0.0/4,
|
||||||
255.255.255.255/32
|
255.255.255.255/32
|
||||||
}
|
}
|
||||||
|
|
||||||
table ip singbox {
|
table ip singbox {
|
||||||
chain prerouting {
|
chain prerouting {
|
||||||
type filter hook prerouting priority mangle; policy accept;
|
type filter hook prerouting priority mangle; policy accept;
|
||||||
ip daddr $RESERVED_IP return
|
ip daddr $RESERVED_IP return
|
||||||
# Packets re-entering via loopback after output marking should not
|
# Packets re-entering via loopback after output marking should not
|
||||||
# be skipped just because the host has an RFC1918 source address.
|
# be skipped just because the host has an RFC1918 source address.
|
||||||
iifname != "lo" ip saddr $RESERVED_IP return
|
iifname != "lo" ip saddr $RESERVED_IP return
|
||||||
${localSubnetLines}
|
${localSubnetLines}
|
||||||
ip protocol tcp tproxy to 127.0.0.1:${toString sb.tproxyPort} meta mark set ${toString sb.fwmark}
|
ip protocol tcp tproxy to 127.0.0.1:${toString sb.tproxyPort} meta mark set ${toString sb.fwmark}
|
||||||
ip protocol udp tproxy to 127.0.0.1:${toString sb.tproxyPort} meta mark set ${toString sb.fwmark}
|
ip protocol udp tproxy to 127.0.0.1:${toString sb.tproxyPort} meta mark set ${toString sb.fwmark}
|
||||||
}
|
}
|
||||||
chain output {
|
chain output {
|
||||||
type route hook output priority mangle; policy accept;
|
type route hook output priority mangle; policy accept;
|
||||||
ip daddr $RESERVED_IP return
|
ip daddr $RESERVED_IP return
|
||||||
${localSubnetLines}
|
${localSubnetLines}
|
||||||
meta mark ${toString sb.proxyMark} return
|
meta mark ${toString sb.proxyMark} return
|
||||||
ip protocol tcp meta mark set ${toString sb.fwmark}
|
ip protocol tcp meta mark set ${toString sb.fwmark}
|
||||||
ip protocol udp meta mark set ${toString sb.fwmark}
|
ip protocol udp meta mark set ${toString sb.fwmark}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
ip = "${pkgs.iproute2}/bin/ip";
|
ip = "${pkgs.iproute2}/bin/ip";
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# An explicit routing rule — associates traffic patterns with a named outbound.
|
# An explicit routing rule – associates traffic patterns with a named outbound.
|
||||||
routingRuleType = types.submodule {
|
routingRuleType = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
outbound = mkOption {
|
outbound = mkOption {
|
||||||
@@ -471,7 +471,10 @@ in
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "example";
|
name = "example";
|
||||||
domains = [ "example.com" "example.de" ];
|
domains = [
|
||||||
|
"example.com"
|
||||||
|
"example.de"
|
||||||
|
];
|
||||||
nfqwsArgs = [
|
nfqwsArgs = [
|
||||||
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
"--filter-tcp=443 --dpi-desync=fake,multisplit"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -32,16 +32,15 @@ let
|
|||||||
syncZapretDirectUserIps = z.enable && z.syncDirectRoutingUserIps;
|
syncZapretDirectUserIps = z.enable && z.syncDirectRoutingUserIps;
|
||||||
syncZapretDirectAnyIps = syncZapretDirectUpstreamIps || syncZapretDirectUserIps;
|
syncZapretDirectAnyIps = syncZapretDirectUpstreamIps || syncZapretDirectUserIps;
|
||||||
|
|
||||||
zapretDefaultDomainFiles =
|
zapretDefaultDomainFiles = [
|
||||||
[
|
"list-general.txt"
|
||||||
"list-general.txt"
|
"list-google.txt"
|
||||||
"list-google.txt"
|
]
|
||||||
]
|
++ lib.optionals z.includeExtraUpstreamLists [
|
||||||
++ lib.optionals z.includeExtraUpstreamLists [
|
"list-instagram.txt"
|
||||||
"list-instagram.txt"
|
"list-soundcloud.txt"
|
||||||
"list-soundcloud.txt"
|
"list-twitter.txt"
|
||||||
"list-twitter.txt"
|
];
|
||||||
];
|
|
||||||
|
|
||||||
zapretDefaultDomains =
|
zapretDefaultDomains =
|
||||||
if syncZapretDirectDomains then
|
if syncZapretDirectDomains then
|
||||||
@@ -192,7 +191,7 @@ let
|
|||||||
}
|
}
|
||||||
{ action = "sniff"; }
|
{ action = "sniff"; }
|
||||||
|
|
||||||
# Per-outbound and explicit rules come first — they take priority.
|
# Per-outbound and explicit rules come first – they take priority.
|
||||||
(lib.concatMap mkCustomRuleEntries customRules)
|
(lib.concatMap mkCustomRuleEntries customRules)
|
||||||
|
|
||||||
# Global proxy lists
|
# Global proxy lists
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ let
|
|||||||
if ob.json != null then
|
if ob.json != null then
|
||||||
let
|
let
|
||||||
outboundJson = builtins.toJSON (
|
outboundJson = builtins.toJSON (
|
||||||
ob.json
|
ob.json // { tag = tag; } // lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; }
|
||||||
// { tag = tag; }
|
|
||||||
// lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; }
|
|
||||||
);
|
);
|
||||||
jsonFile = pkgs.writeText "proxy-suite-ob-${tag}.json" outboundJson;
|
jsonFile = pkgs.writeText "proxy-suite-ob-${tag}.json" outboundJson;
|
||||||
in
|
in
|
||||||
@@ -58,7 +56,7 @@ let
|
|||||||
if ob.urlFile != null then
|
if ob.urlFile != null then
|
||||||
ob.urlFile
|
ob.urlFile
|
||||||
else
|
else
|
||||||
# Literal URL — write to nix store so the script can cat it.
|
# Literal URL – write to nix store so the script can cat it.
|
||||||
# Less secret than urlFile, but convenient for non-sensitive configs.
|
# Less secret than urlFile, but convenient for non-sensitive configs.
|
||||||
"${pkgs.writeText "proxy-suite-url-${ob.tag}" ob.url}";
|
"${pkgs.writeText "proxy-suite-url-${ob.tag}" ob.url}";
|
||||||
in
|
in
|
||||||
@@ -146,7 +144,10 @@ let
|
|||||||
|
|
||||||
proxyCtl = pkgs.writeShellApplication {
|
proxyCtl = pkgs.writeShellApplication {
|
||||||
name = "proxy-ctl";
|
name = "proxy-ctl";
|
||||||
runtimeInputs = with pkgs; [ curl jq ];
|
runtimeInputs = with pkgs; [
|
||||||
|
curl
|
||||||
|
jq
|
||||||
|
];
|
||||||
text = ''
|
text = ''
|
||||||
# Embedded at build time from module config
|
# Embedded at build time from module config
|
||||||
CLASH_API="${clashApi}"
|
CLASH_API="${clashApi}"
|
||||||
@@ -253,7 +254,7 @@ let
|
|||||||
-d "$payload" >/dev/null; then
|
-d "$payload" >/dev/null; then
|
||||||
echo "Switched to: $tag"
|
echo "Switched to: $tag"
|
||||||
else
|
else
|
||||||
echo "Failed — is proxy-suite-socks running with selector mode?"
|
echo "Failed – is proxy-suite-socks running with selector mode?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -272,45 +273,49 @@ in
|
|||||||
# nftables must be on for TProxy to work.
|
# nftables must be on for TProxy to work.
|
||||||
networking.nftables.enable = lib.mkIf sb.tproxy.enable (lib.mkDefault true);
|
networking.nftables.enable = lib.mkIf sb.tproxy.enable (lib.mkDefault true);
|
||||||
|
|
||||||
assertions =
|
assertions = [
|
||||||
[
|
{
|
||||||
{
|
assertion = !sb.enable || sb.outbounds != [ ];
|
||||||
assertion = !sb.enable || sb.outbounds != [ ];
|
message = "proxy-suite: singBox.outbounds must not be empty when singBox.enable = true";
|
||||||
message = "proxy-suite: singBox.outbounds must not be empty when singBox.enable = true";
|
}
|
||||||
}
|
{
|
||||||
{
|
assertion = builtins.length outboundTags == builtins.length (lib.unique outboundTags);
|
||||||
assertion = builtins.length outboundTags == builtins.length (lib.unique outboundTags);
|
message = "proxy-suite: outbound tags must be unique";
|
||||||
message = "proxy-suite: outbound tags must be unique";
|
}
|
||||||
}
|
{
|
||||||
{
|
assertion = builtins.all (tag: !builtins.elem tag builtinTags) outboundTags;
|
||||||
assertion = builtins.all (tag: !builtins.elem tag builtinTags) outboundTags;
|
message = "proxy-suite: outbound tags must not use reserved names: proxy, direct, block";
|
||||||
message = "proxy-suite: outbound tags must not use reserved names: proxy, direct, block";
|
}
|
||||||
}
|
{
|
||||||
{
|
assertion = invalidRoutingTargets == [ ];
|
||||||
assertion = invalidRoutingTargets == [ ];
|
message = "proxy-suite: routing.rules reference unknown outbound tag(s): ${lib.concatStringsSep ", " invalidRoutingTargets}";
|
||||||
message = "proxy-suite: routing.rules reference unknown outbound tag(s): ${lib.concatStringsSep ", " invalidRoutingTargets}";
|
}
|
||||||
}
|
{
|
||||||
{
|
assertion =
|
||||||
assertion =
|
!t.enable
|
||||||
!t.enable
|
||
|
||||||
|| builtins.length (builtins.filter (x: x != null) [
|
builtins.length (
|
||||||
t.secret
|
builtins.filter (x: x != null) [
|
||||||
t.secretFile
|
t.secret
|
||||||
]) == 1;
|
t.secretFile
|
||||||
message = "proxy-suite: tgWsProxy requires exactly one of secret or secretFile";
|
]
|
||||||
}
|
) == 1;
|
||||||
]
|
message = "proxy-suite: tgWsProxy requires exactly one of secret or secretFile";
|
||||||
++ lib.concatMap (ob: [
|
}
|
||||||
{
|
]
|
||||||
assertion =
|
++ lib.concatMap (ob: [
|
||||||
builtins.length (builtins.filter (x: x != null) [
|
{
|
||||||
|
assertion =
|
||||||
|
builtins.length (
|
||||||
|
builtins.filter (x: x != null) [
|
||||||
ob.urlFile
|
ob.urlFile
|
||||||
ob.url
|
ob.url
|
||||||
ob.json
|
ob.json
|
||||||
]) == 1;
|
]
|
||||||
message = "proxy-suite: outbound '${ob.tag}': set exactly one of urlFile, url, or json";
|
) == 1;
|
||||||
}
|
message = "proxy-suite: outbound '${ob.tag}': set exactly one of urlFile, url, or json";
|
||||||
]) sb.outbounds;
|
}
|
||||||
|
]) sb.outbounds;
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
# Always-on: SOCKS5/HTTP mixed inbound, also ready for TProxy interception.
|
# Always-on: SOCKS5/HTTP mixed inbound, also ready for TProxy interception.
|
||||||
@@ -331,7 +336,7 @@ in
|
|||||||
# systemctl start proxy-suite-tproxy
|
# systemctl start proxy-suite-tproxy
|
||||||
# systemctl stop proxy-suite-tproxy
|
# systemctl stop proxy-suite-tproxy
|
||||||
proxy-suite-tproxy = {
|
proxy-suite-tproxy = {
|
||||||
description = "sing-box TProxy — nftables rules and policy routing";
|
description = "sing-box TProxy – nftables rules and policy routing";
|
||||||
after = [
|
after = [
|
||||||
"network.target"
|
"network.target"
|
||||||
"proxy-suite-socks.service"
|
"proxy-suite-socks.service"
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
# Telegram MTProto WebSocket proxy service
|
# Telegram MTProto WebSocket proxy service
|
||||||
{ lib, pkgs, cfg }:
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
cfg,
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
t = cfg.tgWsProxy;
|
t = cfg.tgWsProxy;
|
||||||
tgPkg = import ../../pkgs/tg-ws-proxy.nix { inherit pkgs; };
|
tgPkg = import ../../pkgs/tg-ws-proxy.nix { inherit pkgs; };
|
||||||
|
|
||||||
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
|
|
||||||
);
|
|
||||||
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=${t.host} \
|
||||||
${if t.secretFile != null
|
${
|
||||||
then "--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
if t.secretFile != null then
|
||||||
else "--secret=${t.secret}"}${dcArgs}
|
"--secret-file=$CREDENTIALS_DIRECTORY/tg_ws_proxy_secret"
|
||||||
|
else
|
||||||
|
"--secret=${t.secret}"
|
||||||
|
}${dcArgs}
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
+110
-94
@@ -33,40 +33,52 @@ let
|
|||||||
|
|
||||||
upstreamZapretPackage =
|
upstreamZapretPackage =
|
||||||
let
|
let
|
||||||
upstreamPackages = zapret.packages.${pkgs.system};
|
upstreamPackages = zapret.packages.${pkgs.stdenv.hostPlatform.system};
|
||||||
in
|
in
|
||||||
if upstreamPackages ? zapret then upstreamPackages.zapret else upstreamPackages.default;
|
if upstreamPackages ? zapret then upstreamPackages.zapret else upstreamPackages.default;
|
||||||
|
|
||||||
listGeneralFile =
|
listGeneralFile =
|
||||||
if z.listGeneral != [ ] then pkgs.writeText "proxy-suite-zapret-list-general-user.txt" (
|
if z.listGeneral != [ ] then
|
||||||
lib.concatStringsSep "\n" z.listGeneral + "\n"
|
pkgs.writeText "proxy-suite-zapret-list-general-user.txt" (
|
||||||
) else null;
|
lib.concatStringsSep "\n" z.listGeneral + "\n"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
listExcludeFile =
|
listExcludeFile =
|
||||||
if z.listExclude != [ ] then pkgs.writeText "proxy-suite-zapret-list-exclude-user.txt" (
|
if z.listExclude != [ ] then
|
||||||
lib.concatStringsSep "\n" z.listExclude + "\n"
|
pkgs.writeText "proxy-suite-zapret-list-exclude-user.txt" (
|
||||||
) else null;
|
lib.concatStringsSep "\n" z.listExclude + "\n"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
ipsetAllFile =
|
ipsetAllFile =
|
||||||
if z.ipsetAll != [ ] then pkgs.writeText "proxy-suite-zapret-ipset-all.txt" (
|
if z.ipsetAll != [ ] then
|
||||||
lib.concatStringsSep "\n" z.ipsetAll + "\n"
|
pkgs.writeText "proxy-suite-zapret-ipset-all.txt" (lib.concatStringsSep "\n" z.ipsetAll + "\n")
|
||||||
) else null;
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
ipsetExcludeFile =
|
ipsetExcludeFile =
|
||||||
if z.ipsetExclude != [ ] then pkgs.writeText "proxy-suite-zapret-ipset-exclude-user.txt" (
|
if z.ipsetExclude != [ ] then
|
||||||
lib.concatStringsSep "\n" z.ipsetExclude + "\n"
|
pkgs.writeText "proxy-suite-zapret-ipset-exclude-user.txt" (
|
||||||
) else null;
|
lib.concatStringsSep "\n" z.ipsetExclude + "\n"
|
||||||
|
)
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
hostlistRuleSpec = pkgs.writeText "proxy-suite-zapret-hostlist-rules.json" (builtins.toJSON {
|
hostlistRuleSpec = pkgs.writeText "proxy-suite-zapret-hostlist-rules.json" (
|
||||||
includeExtraUpstreamLists = z.includeExtraUpstreamLists;
|
builtins.toJSON {
|
||||||
entries = map (rule: {
|
includeExtraUpstreamLists = z.includeExtraUpstreamLists;
|
||||||
inherit (rule)
|
entries = map (rule: {
|
||||||
name
|
inherit (rule)
|
||||||
preset
|
name
|
||||||
nfqwsArgs
|
preset
|
||||||
;
|
nfqwsArgs
|
||||||
}) z.hostlistRules;
|
;
|
||||||
});
|
}) z.hostlistRules;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
selectedConfigName = lib.strings.sanitizeDerivationName z.configName;
|
selectedConfigName = lib.strings.sanitizeDerivationName z.configName;
|
||||||
patchConfigScriptSrc = builtins.path {
|
patchConfigScriptSrc = builtins.path {
|
||||||
@@ -75,79 +87,83 @@ let
|
|||||||
};
|
};
|
||||||
patchConfigScript = "${pkgs.python3}/bin/python3 ${patchConfigScriptSrc}";
|
patchConfigScript = "${pkgs.python3}/bin/python3 ${patchConfigScriptSrc}";
|
||||||
|
|
||||||
customZapretPackage = pkgs.runCommand "proxy-suite-zapret-${selectedConfigName}" {
|
customZapretPackage =
|
||||||
nativeBuildInputs = with pkgs; [
|
pkgs.runCommand "proxy-suite-zapret-${selectedConfigName}"
|
||||||
coreutils
|
{
|
||||||
gnused
|
nativeBuildInputs = with pkgs; [
|
||||||
python3
|
coreutils
|
||||||
];
|
gnused
|
||||||
} ''
|
python3
|
||||||
set -euo pipefail
|
];
|
||||||
|
}
|
||||||
mkdir -p "$out"
|
|
||||||
cp -a ${upstreamZapretPackage}/. "$out/"
|
|
||||||
chmod -R u+w "$out/opt/zapret" "$out/bin"
|
|
||||||
|
|
||||||
find "$out/opt/zapret/configs" -type f -exec ${pkgs.gnused}/bin/sed -i \
|
|
||||||
-e 's|${upstreamZapretPackage}/opt/zapret|'"$out"'/opt/zapret|g' \
|
|
||||||
{} \;
|
|
||||||
|
|
||||||
if [ -f "$out/opt/zapret/configs/${z.configName}" ]; then
|
|
||||||
cp "$out/opt/zapret/configs/${z.configName}" "$out/opt/zapret/config"
|
|
||||||
else
|
|
||||||
echo "proxy-suite: zapret config '${z.configName}' not found in upstream package" >&2
|
|
||||||
ls -la "$out/opt/zapret/configs" >&2 || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
${pkgs.gnused}/bin/sed -i \
|
|
||||||
-e 's|${upstreamZapretPackage}/opt/zapret|'"$out"'/opt/zapret|g' \
|
|
||||||
"$out/opt/zapret/config"
|
|
||||||
|
|
||||||
append_list_file() {
|
|
||||||
local target="$1"
|
|
||||||
local extra_file="$2"
|
|
||||||
local tmp="$out/opt/zapret/hostlists/$target.tmp"
|
|
||||||
cat "$out/opt/zapret/hostlists/$target" > "$tmp"
|
|
||||||
${pkgs.gnused}/bin/sed -i -e '$a\' "$tmp"
|
|
||||||
cat "$extra_file" >> "$tmp"
|
|
||||||
mv "$tmp" "$out/opt/zapret/hostlists/$target"
|
|
||||||
}
|
|
||||||
|
|
||||||
${lib.optionalString (listGeneralFile != null) ''
|
|
||||||
append_list_file list-general-user.txt ${listGeneralFile}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${lib.optionalString (listExcludeFile != null) ''
|
|
||||||
append_list_file list-exclude-user.txt ${listExcludeFile}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${lib.optionalString (ipsetAllFile != null) ''
|
|
||||||
append_list_file ipset-all.txt ${ipsetAllFile}
|
|
||||||
''}
|
|
||||||
|
|
||||||
${lib.optionalString (ipsetExcludeFile != null) ''
|
|
||||||
append_list_file ipset-exclude-user.txt ${ipsetExcludeFile}
|
|
||||||
''}
|
|
||||||
|
|
||||||
rm -f "$out/opt/zapret/hostlists/.game_filter.enabled"
|
|
||||||
${lib.optionalString (z.gameFilter != "null") ''
|
|
||||||
echo "${z.gameFilter}" > "$out/opt/zapret/hostlists/.game_filter.enabled"
|
|
||||||
''}
|
|
||||||
|
|
||||||
${lib.concatMapStrings (rule:
|
|
||||||
let
|
|
||||||
domainsFile = pkgs.writeText "proxy-suite-zapret-hostlist-${rule.name}.txt" (
|
|
||||||
lib.concatStringsSep "\n" (lib.unique rule.domains) + "\n"
|
|
||||||
);
|
|
||||||
in
|
|
||||||
''
|
''
|
||||||
cp ${domainsFile} "$out/opt/zapret/hostlists/list-${rule.name}.txt"
|
set -euo pipefail
|
||||||
''
|
|
||||||
) z.hostlistRules}
|
|
||||||
|
|
||||||
${patchConfigScript} --config "$out/opt/zapret/config" --spec ${hostlistRuleSpec}
|
mkdir -p "$out"
|
||||||
'';
|
cp -a ${upstreamZapretPackage}/. "$out/"
|
||||||
|
chmod -R u+w "$out/opt/zapret" "$out/bin"
|
||||||
|
|
||||||
|
find "$out/opt/zapret/configs" -type f -exec ${pkgs.gnused}/bin/sed -i \
|
||||||
|
-e 's|${upstreamZapretPackage}/opt/zapret|'"$out"'/opt/zapret|g' \
|
||||||
|
{} \;
|
||||||
|
|
||||||
|
if [ -f "$out/opt/zapret/configs/${z.configName}" ]; then
|
||||||
|
cp "$out/opt/zapret/configs/${z.configName}" "$out/opt/zapret/config"
|
||||||
|
else
|
||||||
|
echo "proxy-suite: zapret config '${z.configName}' not found in upstream package" >&2
|
||||||
|
ls -la "$out/opt/zapret/configs" >&2 || true
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
${pkgs.gnused}/bin/sed -i \
|
||||||
|
-e 's|${upstreamZapretPackage}/opt/zapret|'"$out"'/opt/zapret|g' \
|
||||||
|
"$out/opt/zapret/config"
|
||||||
|
|
||||||
|
append_list_file() {
|
||||||
|
local target="$1"
|
||||||
|
local extra_file="$2"
|
||||||
|
local tmp="$out/opt/zapret/hostlists/$target.tmp"
|
||||||
|
cat "$out/opt/zapret/hostlists/$target" > "$tmp"
|
||||||
|
${pkgs.gnused}/bin/sed -i -e '$a\' "$tmp"
|
||||||
|
cat "$extra_file" >> "$tmp"
|
||||||
|
mv "$tmp" "$out/opt/zapret/hostlists/$target"
|
||||||
|
}
|
||||||
|
|
||||||
|
${lib.optionalString (listGeneralFile != null) ''
|
||||||
|
append_list_file list-general-user.txt ${listGeneralFile}
|
||||||
|
''}
|
||||||
|
|
||||||
|
${lib.optionalString (listExcludeFile != null) ''
|
||||||
|
append_list_file list-exclude-user.txt ${listExcludeFile}
|
||||||
|
''}
|
||||||
|
|
||||||
|
${lib.optionalString (ipsetAllFile != null) ''
|
||||||
|
append_list_file ipset-all.txt ${ipsetAllFile}
|
||||||
|
''}
|
||||||
|
|
||||||
|
${lib.optionalString (ipsetExcludeFile != null) ''
|
||||||
|
append_list_file ipset-exclude-user.txt ${ipsetExcludeFile}
|
||||||
|
''}
|
||||||
|
|
||||||
|
rm -f "$out/opt/zapret/hostlists/.game_filter.enabled"
|
||||||
|
${lib.optionalString (z.gameFilter != "null") ''
|
||||||
|
echo "${z.gameFilter}" > "$out/opt/zapret/hostlists/.game_filter.enabled"
|
||||||
|
''}
|
||||||
|
|
||||||
|
${lib.concatMapStrings (
|
||||||
|
rule:
|
||||||
|
let
|
||||||
|
domainsFile = pkgs.writeText "proxy-suite-zapret-hostlist-${rule.name}.txt" (
|
||||||
|
lib.concatStringsSep "\n" (lib.unique rule.domains) + "\n"
|
||||||
|
);
|
||||||
|
in
|
||||||
|
''
|
||||||
|
cp ${domainsFile} "$out/opt/zapret/hostlists/list-${rule.name}.txt"
|
||||||
|
''
|
||||||
|
) z.hostlistRules}
|
||||||
|
|
||||||
|
${patchConfigScript} --config "$out/opt/zapret/config" --spec ${hostlistRuleSpec}
|
||||||
|
'';
|
||||||
|
|
||||||
exemptStart = lib.concatMapStrings (cidr: ''
|
exemptStart = lib.concatMapStrings (cidr: ''
|
||||||
${iptables} -t mangle -I FORWARD 1 -d ${cidr} -j RETURN
|
${iptables} -t mangle -I FORWARD 1 -d ${cidr} -j RETURN
|
||||||
|
|||||||
+25
-19
@@ -58,7 +58,9 @@ let
|
|||||||
fixture:
|
fixture:
|
||||||
let
|
let
|
||||||
env = fixture.config.systemd.services.zapret-discord-youtube.serviceConfig.Environment;
|
env = fixture.config.systemd.services.zapret-discord-youtube.serviceConfig.Environment;
|
||||||
zapretBaseEnv = builtins.head (builtins.filter (value: pkgs.lib.hasPrefix "ZAPRET_BASE=" value) env);
|
zapretBaseEnv = builtins.head (
|
||||||
|
builtins.filter (value: pkgs.lib.hasPrefix "ZAPRET_BASE=" value) env
|
||||||
|
);
|
||||||
in
|
in
|
||||||
pkgs.lib.removePrefix "ZAPRET_BASE=" zapretBaseEnv;
|
pkgs.lib.removePrefix "ZAPRET_BASE=" zapretBaseEnv;
|
||||||
packagePathMatches =
|
packagePathMatches =
|
||||||
@@ -342,12 +344,18 @@ let
|
|||||||
hostlistRules = [
|
hostlistRules = [
|
||||||
{
|
{
|
||||||
name = "googlevideo";
|
name = "googlevideo";
|
||||||
domains = [ "googlevideo.com" "ggpht.com" ];
|
domains = [
|
||||||
|
"googlevideo.com"
|
||||||
|
"ggpht.com"
|
||||||
|
];
|
||||||
preset = "google";
|
preset = "google";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "example";
|
name = "example";
|
||||||
domains = [ "example.com" "example.de" ];
|
domains = [
|
||||||
|
"example.com"
|
||||||
|
"example.de"
|
||||||
|
];
|
||||||
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake,multisplit" ];
|
nfqwsArgs = [ "--filter-tcp=443 --dpi-desync=fake,multisplit" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -678,22 +686,20 @@ in
|
|||||||
{
|
{
|
||||||
proxy-suite-module = builtins.seq validated (pkgs.writeText "proxy-suite-module-check" "ok");
|
proxy-suite-module = builtins.seq validated (pkgs.writeText "proxy-suite-module-check" "ok");
|
||||||
|
|
||||||
zapret-hostlist-rules =
|
zapret-hostlist-rules = pkgs.runCommand "proxy-suite-zapret-hostlist-rules-check" { } ''
|
||||||
pkgs.runCommand "proxy-suite-zapret-hostlist-rules-check" { }
|
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-twitter.txt"' "${zapretSyncBase}/config"
|
||||||
''
|
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-instagram.txt"' "${zapretSyncBase}/config"
|
||||||
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-twitter.txt"' "${zapretSyncBase}/config"
|
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-soundcloud.txt"' "${zapretSyncBase}/config"
|
||||||
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-instagram.txt"' "${zapretSyncBase}/config"
|
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||||||
grep -F -- '--hostlist="${zapretSyncBase}/hostlists/list-soundcloud.txt"' "${zapretSyncBase}/config"
|
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||||||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-twitter.txt"' "${zapretSyncNoExtraListsBase}/config"
|
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncNoExtraListsBase}/config"
|
||||||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-instagram.txt"' "${zapretSyncNoExtraListsBase}/config"
|
grep -F 'googlevideo.com' "${zapretHostlistBase}/hostlists/list-googlevideo.txt"
|
||||||
! grep -F -- '--hostlist="${zapretSyncNoExtraListsBase}/hostlists/list-soundcloud.txt"' "${zapretSyncNoExtraListsBase}/config"
|
grep -F 'example.de' "${zapretHostlistBase}/hostlists/list-example.txt"
|
||||||
grep -F 'googlevideo.com' "${zapretHostlistBase}/hostlists/list-googlevideo.txt"
|
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-googlevideo.txt"' "${zapretHostlistBase}/config"
|
||||||
grep -F 'example.de' "${zapretHostlistBase}/hostlists/list-example.txt"
|
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-example.txt"' "${zapretHostlistBase}/config"
|
||||||
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-googlevideo.txt"' "${zapretHostlistBase}/config"
|
grep -F -- '--filter-tcp=443 --dpi-desync=fake,multisplit --hostlist="${zapretHostlistBase}/hostlists/list-example.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude-user.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude-user.txt" --new' "${zapretHostlistBase}/config"
|
||||||
grep -F -- '--hostlist="${zapretHostlistBase}/hostlists/list-example.txt"' "${zapretHostlistBase}/config"
|
touch "$out"
|
||||||
grep -F -- '--filter-tcp=443 --dpi-desync=fake,multisplit --hostlist="${zapretHostlistBase}/hostlists/list-example.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude-user.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude-user.txt" --new' "${zapretHostlistBase}/config"
|
'';
|
||||||
touch "$out"
|
|
||||||
'';
|
|
||||||
|
|
||||||
build-outbound-parser =
|
build-outbound-parser =
|
||||||
pkgs.runCommand "build-outbound-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
pkgs.runCommand "build-outbound-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ pkgs.stdenv.mkDerivation {
|
|||||||
src = ./proxy-suite-tray;
|
src = ./proxy-suite-tray;
|
||||||
|
|
||||||
nativeBuildInputs = [ pkgs.pkg-config ];
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
||||||
buildInputs = [ pkgs.gtk3 pkgs.libayatana-appindicator ];
|
buildInputs = [
|
||||||
|
pkgs.gtk3
|
||||||
|
pkgs.libayatana-appindicator
|
||||||
|
];
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
$CC -o proxy-suite-tray main.c \
|
$CC -o proxy-suite-tray main.c \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
#include <libayatana-appindicator/app-indicator.h>
|
#include <libayatana-appindicator/app-indicator.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -17,8 +18,15 @@
|
|||||||
static AppIndicator *indicator;
|
static AppIndicator *indicator;
|
||||||
static GtkWidget *menu;
|
static GtkWidget *menu;
|
||||||
static GtkWidget *status_item;
|
static GtkWidget *status_item;
|
||||||
|
static GtkWidget *proxy_item;
|
||||||
static GtkWidget *tproxy_item;
|
static GtkWidget *tproxy_item;
|
||||||
static GtkWidget *tun_item;
|
static GtkWidget *tun_item;
|
||||||
|
static GtkWidget *open_controls_item;
|
||||||
|
static GtkWidget *controls_window;
|
||||||
|
static GtkWidget *controls_status_label;
|
||||||
|
static GtkWidget *controls_proxy_button;
|
||||||
|
static GtkWidget *controls_tproxy_button;
|
||||||
|
static GtkWidget *controls_tun_button;
|
||||||
|
|
||||||
static gboolean command_succeeds(gchar **argv) {
|
static gboolean command_succeeds(gchar **argv) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -56,6 +64,55 @@ static gboolean command_stdout(gchar **argv, gchar **stdout_text) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean on_controls_delete(GtkWidget *widget, GdkEvent *event, gpointer data) {
|
||||||
|
(void)event; (void)data;
|
||||||
|
gtk_widget_hide(widget);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_close_controls(GtkWidget *item, gpointer data) {
|
||||||
|
(void)item; (void)data;
|
||||||
|
if (controls_window) {
|
||||||
|
gtk_widget_hide(controls_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_open_controls(GtkWidget *item, gpointer data);
|
||||||
|
|
||||||
|
static gboolean on_open_controls_idle(gpointer data) {
|
||||||
|
(void)data;
|
||||||
|
on_open_controls(NULL, NULL);
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GDBusMessage *on_session_bus_message(
|
||||||
|
GDBusConnection *connection,
|
||||||
|
GDBusMessage *message,
|
||||||
|
gboolean incoming,
|
||||||
|
gpointer user_data
|
||||||
|
) {
|
||||||
|
(void)connection; (void)user_data;
|
||||||
|
if (!incoming || !message) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
if (g_dbus_message_get_message_type(message) != G_DBUS_MESSAGE_TYPE_METHOD_CALL) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *iface = g_dbus_message_get_interface(message);
|
||||||
|
const gchar *member = g_dbus_message_get_member(message);
|
||||||
|
const gchar *path = g_dbus_message_get_path(message);
|
||||||
|
|
||||||
|
if (iface && member && path &&
|
||||||
|
strcmp(iface, "org.kde.StatusNotifierItem") == 0 &&
|
||||||
|
strcmp(member, "Activate") == 0 &&
|
||||||
|
g_str_has_prefix(path, "/org/ayatana/NotificationItem/")) {
|
||||||
|
g_idle_add(on_open_controls_idle, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean service_exists(const char *name) {
|
static gboolean service_exists(const char *name) {
|
||||||
gchar *load_state = NULL;
|
gchar *load_state = NULL;
|
||||||
gboolean exists = FALSE;
|
gboolean exists = FALSE;
|
||||||
@@ -110,35 +167,122 @@ static gboolean run_privileged(const char *action, const char *service) {
|
|||||||
return system(cmd) == 0;
|
return system(cmd) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *pick_icon_name(
|
||||||
|
const char *const *candidates,
|
||||||
|
gsize candidates_len,
|
||||||
|
const char *fallback
|
||||||
|
) {
|
||||||
|
GtkIconTheme *theme = gtk_icon_theme_get_default();
|
||||||
|
if (!theme) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (gsize i = 0; i < candidates_len; ++i) {
|
||||||
|
if (gtk_icon_theme_has_icon(theme, candidates[i])) {
|
||||||
|
return candidates[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
static void update_status(void) {
|
static void update_status(void) {
|
||||||
gboolean socks = service_active("proxy-suite-socks");
|
gboolean socks = service_active("proxy-suite-socks");
|
||||||
gboolean tproxy = service_active("proxy-suite-tproxy");
|
gboolean tproxy = service_active("proxy-suite-tproxy");
|
||||||
gboolean tun = service_active("proxy-suite-tun");
|
gboolean tun = service_active("proxy-suite-tun");
|
||||||
|
|
||||||
|
static const char *const active_icons[] = {
|
||||||
|
"network-vpn",
|
||||||
|
"network-vpn-symbolic"
|
||||||
|
};
|
||||||
|
static const char *const partial_icons[] = {
|
||||||
|
"network-vpn-acquiring",
|
||||||
|
"network-vpn",
|
||||||
|
"network-vpn-acquiring-symbolic",
|
||||||
|
"network-vpn-symbolic"
|
||||||
|
};
|
||||||
|
static const char *const disconnected_icons[] = {
|
||||||
|
"network-vpn-disconnected",
|
||||||
|
"network-offline",
|
||||||
|
"network-error",
|
||||||
|
"process-stop",
|
||||||
|
"dialog-error",
|
||||||
|
"network-vpn-disconnected-symbolic",
|
||||||
|
"network-offline-symbolic",
|
||||||
|
"network-error-symbolic",
|
||||||
|
"process-stop-symbolic",
|
||||||
|
"dialog-error-symbolic"
|
||||||
|
};
|
||||||
|
|
||||||
if (socks) {
|
if (socks) {
|
||||||
if (tproxy || tun) {
|
if (tproxy || tun) {
|
||||||
app_indicator_set_icon(indicator, "network-vpn");
|
app_indicator_set_icon(
|
||||||
|
indicator,
|
||||||
|
pick_icon_name(active_icons, G_N_ELEMENTS(active_icons), "network-vpn")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
app_indicator_set_icon(indicator, "network-vpn-acquiring");
|
app_indicator_set_icon(
|
||||||
|
indicator,
|
||||||
|
pick_icon_name(partial_icons, G_N_ELEMENTS(partial_icons), "network-vpn-acquiring")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app_indicator_set_icon(indicator, "network-vpn-disconnected");
|
app_indicator_set_icon(
|
||||||
|
indicator,
|
||||||
|
pick_icon_name(disconnected_icons, G_N_ELEMENTS(disconnected_icons), "network-vpn-disconnected")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_menu_item_set_label(GTK_MENU_ITEM(status_item),
|
gtk_menu_item_set_label(GTK_MENU_ITEM(status_item),
|
||||||
socks ? "SOCKS Proxy: Running" : "SOCKS Proxy: Stopped");
|
socks ? "SOCKS Proxy: Running" : "SOCKS Proxy: Stopped");
|
||||||
|
if (controls_status_label) {
|
||||||
|
gtk_label_set_text(GTK_LABEL(controls_status_label),
|
||||||
|
socks ? "SOCKS Proxy: Running" : "SOCKS Proxy: Stopped");
|
||||||
|
}
|
||||||
|
if (proxy_item) {
|
||||||
|
gtk_menu_item_set_label(GTK_MENU_ITEM(proxy_item),
|
||||||
|
socks ? "Disable Proxy" : "Enable Proxy");
|
||||||
|
}
|
||||||
|
if (controls_proxy_button) {
|
||||||
|
gtk_button_set_label(GTK_BUTTON(controls_proxy_button),
|
||||||
|
socks ? "Disable Proxy" : "Enable Proxy");
|
||||||
|
}
|
||||||
|
|
||||||
if (tproxy_item) {
|
if (tproxy_item) {
|
||||||
gtk_menu_item_set_label(GTK_MENU_ITEM(tproxy_item),
|
gtk_menu_item_set_label(GTK_MENU_ITEM(tproxy_item),
|
||||||
tproxy ? "Disable TProxy" : "Enable TProxy");
|
tproxy ? "Disable TProxy" : "Enable TProxy");
|
||||||
}
|
}
|
||||||
|
if (controls_tproxy_button) {
|
||||||
|
gtk_button_set_label(GTK_BUTTON(controls_tproxy_button),
|
||||||
|
tproxy ? "Disable TProxy" : "Enable TProxy");
|
||||||
|
}
|
||||||
if (tun_item) {
|
if (tun_item) {
|
||||||
gtk_menu_item_set_label(GTK_MENU_ITEM(tun_item),
|
gtk_menu_item_set_label(GTK_MENU_ITEM(tun_item),
|
||||||
tun ? "Disable TUN" : "Enable TUN");
|
tun ? "Disable TUN" : "Enable TUN");
|
||||||
}
|
}
|
||||||
|
if (controls_tun_button) {
|
||||||
|
gtk_button_set_label(GTK_BUTTON(controls_tun_button),
|
||||||
|
tun ? "Disable TUN" : "Enable TUN");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_tproxy_toggle(GtkMenuItem *item, gpointer data) {
|
static void on_proxy_toggle(GtkWidget *item, gpointer data) {
|
||||||
|
(void)item; (void)data;
|
||||||
|
if (service_active("proxy-suite-socks")) {
|
||||||
|
if (service_active("proxy-suite-tproxy")) {
|
||||||
|
run_privileged("stop", "proxy-suite-tproxy");
|
||||||
|
}
|
||||||
|
if (service_active("proxy-suite-tun")) {
|
||||||
|
run_privileged("stop", "proxy-suite-tun");
|
||||||
|
}
|
||||||
|
run_privileged("stop", "proxy-suite-socks");
|
||||||
|
} else {
|
||||||
|
run_privileged("start", "proxy-suite-socks");
|
||||||
|
}
|
||||||
|
update_status();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_tproxy_toggle(GtkWidget *item, gpointer data) {
|
||||||
(void)item; (void)data;
|
(void)item; (void)data;
|
||||||
if (service_active("proxy-suite-tproxy")) {
|
if (service_active("proxy-suite-tproxy")) {
|
||||||
run_privileged("stop", "proxy-suite-tproxy");
|
run_privileged("stop", "proxy-suite-tproxy");
|
||||||
@@ -148,7 +292,7 @@ static void on_tproxy_toggle(GtkMenuItem *item, gpointer data) {
|
|||||||
update_status();
|
update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_tun_toggle(GtkMenuItem *item, gpointer data) {
|
static void on_tun_toggle(GtkWidget *item, gpointer data) {
|
||||||
(void)item; (void)data;
|
(void)item; (void)data;
|
||||||
if (service_active("proxy-suite-tun")) {
|
if (service_active("proxy-suite-tun")) {
|
||||||
run_privileged("stop", "proxy-suite-tun");
|
run_privileged("stop", "proxy-suite-tun");
|
||||||
@@ -158,7 +302,7 @@ static void on_tun_toggle(GtkMenuItem *item, gpointer data) {
|
|||||||
update_status();
|
update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_restart(GtkMenuItem *item, gpointer data) {
|
static void on_restart(GtkWidget *item, gpointer data) {
|
||||||
(void)item; (void)data;
|
(void)item; (void)data;
|
||||||
gboolean tun_was_active = service_active("proxy-suite-tun");
|
gboolean tun_was_active = service_active("proxy-suite-tun");
|
||||||
|
|
||||||
@@ -169,7 +313,17 @@ static void on_restart(GtkMenuItem *item, gpointer data) {
|
|||||||
update_status();
|
update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_quit(GtkMenuItem *item, gpointer data) {
|
static void on_open_controls(GtkWidget *item, gpointer data) {
|
||||||
|
(void)item; (void)data;
|
||||||
|
if (!controls_window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
update_status();
|
||||||
|
gtk_widget_show_all(controls_window);
|
||||||
|
gtk_window_present(GTK_WINDOW(controls_window));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void on_quit(GtkWidget *item, gpointer data) {
|
||||||
(void)item; (void)data;
|
(void)item; (void)data;
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
@@ -180,6 +334,52 @@ static gboolean on_timer(gpointer data) {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void build_controls_window(void) {
|
||||||
|
controls_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
gtk_window_set_title(GTK_WINDOW(controls_window), "Proxy Suite Controls");
|
||||||
|
gtk_window_set_resizable(GTK_WINDOW(controls_window), FALSE);
|
||||||
|
gtk_container_set_border_width(GTK_CONTAINER(controls_window), 8);
|
||||||
|
g_signal_connect(controls_window, "delete-event", G_CALLBACK(on_controls_delete), NULL);
|
||||||
|
|
||||||
|
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
|
||||||
|
gtk_container_add(GTK_CONTAINER(controls_window), box);
|
||||||
|
|
||||||
|
controls_status_label = gtk_label_new("SOCKS Proxy: Unknown");
|
||||||
|
gtk_label_set_xalign(GTK_LABEL(controls_status_label), 0.0f);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), controls_status_label, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
controls_proxy_button = gtk_button_new_with_label("Enable Proxy");
|
||||||
|
g_signal_connect(controls_proxy_button, "clicked", G_CALLBACK(on_proxy_toggle), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), controls_proxy_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
if (service_exists("proxy-suite-tproxy")) {
|
||||||
|
controls_tproxy_button = gtk_button_new_with_label("Enable TProxy");
|
||||||
|
g_signal_connect(controls_tproxy_button, "clicked", G_CALLBACK(on_tproxy_toggle), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), controls_tproxy_button, FALSE, FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (service_exists("proxy-suite-tun")) {
|
||||||
|
controls_tun_button = gtk_button_new_with_label("Enable TUN");
|
||||||
|
g_signal_connect(controls_tun_button, "clicked", G_CALLBACK(on_tun_toggle), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), controls_tun_button, FALSE, FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *restart_button = gtk_button_new_with_label("Restart Services");
|
||||||
|
g_signal_connect(restart_button, "clicked", G_CALLBACK(on_restart), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), restart_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
GtkWidget *close_button = gtk_button_new_with_label("Close Window");
|
||||||
|
g_signal_connect(close_button, "clicked", G_CALLBACK(on_close_controls), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), close_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
GtkWidget *quit_button = gtk_button_new_with_label("Exit Tray");
|
||||||
|
g_signal_connect(quit_button, "clicked", G_CALLBACK(on_quit), NULL);
|
||||||
|
gtk_box_pack_start(GTK_BOX(box), quit_button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
gtk_widget_show_all(controls_window);
|
||||||
|
gtk_widget_hide(controls_window);
|
||||||
|
}
|
||||||
|
|
||||||
static void build_menu(void) {
|
static void build_menu(void) {
|
||||||
menu = gtk_menu_new();
|
menu = gtk_menu_new();
|
||||||
|
|
||||||
@@ -189,6 +389,16 @@ static void build_menu(void) {
|
|||||||
|
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
|
||||||
|
|
||||||
|
proxy_item = gtk_menu_item_new_with_label("Enable Proxy");
|
||||||
|
g_signal_connect(proxy_item, "activate", G_CALLBACK(on_proxy_toggle), NULL);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), proxy_item);
|
||||||
|
|
||||||
|
open_controls_item = gtk_menu_item_new_with_label("Open Controls");
|
||||||
|
g_signal_connect(open_controls_item, "activate", G_CALLBACK(on_open_controls), NULL);
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), open_controls_item);
|
||||||
|
|
||||||
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
|
||||||
|
|
||||||
if (service_exists("proxy-suite-tproxy")) {
|
if (service_exists("proxy-suite-tproxy")) {
|
||||||
tproxy_item = gtk_menu_item_new_with_label("Enable TProxy");
|
tproxy_item = gtk_menu_item_new_with_label("Enable TProxy");
|
||||||
g_signal_connect(tproxy_item, "activate", G_CALLBACK(on_tproxy_toggle), NULL);
|
g_signal_connect(tproxy_item, "activate", G_CALLBACK(on_tproxy_toggle), NULL);
|
||||||
@@ -222,6 +432,20 @@ int main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GError *bus_error = NULL;
|
||||||
|
GDBusConnection *session_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &bus_error);
|
||||||
|
if (session_bus) {
|
||||||
|
g_dbus_connection_add_filter(session_bus, on_session_bus_message, NULL, NULL);
|
||||||
|
g_object_unref(session_bus);
|
||||||
|
} else {
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
"proxy-suite-tray: warning: failed to monitor session bus: %s\n",
|
||||||
|
bus_error ? bus_error->message : "unknown error"
|
||||||
|
);
|
||||||
|
g_clear_error(&bus_error);
|
||||||
|
}
|
||||||
|
|
||||||
indicator = app_indicator_new(
|
indicator = app_indicator_new(
|
||||||
"proxy-suite-tray",
|
"proxy-suite-tray",
|
||||||
"network-vpn-disconnected",
|
"network-vpn-disconnected",
|
||||||
@@ -230,7 +454,9 @@ int main(int argc, char *argv[]) {
|
|||||||
app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
|
app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE);
|
||||||
|
|
||||||
build_menu();
|
build_menu();
|
||||||
|
build_controls_window();
|
||||||
app_indicator_set_menu(indicator, GTK_MENU(menu));
|
app_indicator_set_menu(indicator, GTK_MENU(menu));
|
||||||
|
app_indicator_set_secondary_activate_target(indicator, open_controls_item);
|
||||||
|
|
||||||
update_status();
|
update_status();
|
||||||
|
|
||||||
|
|||||||
+44
-44
@@ -20,56 +20,56 @@ pkgs.writeShellApplication {
|
|||||||
name = "tg-ws-proxy";
|
name = "tg-ws-proxy";
|
||||||
runtimeInputs = [ pythonEnv ];
|
runtimeInputs = [ pythonEnv ];
|
||||||
text = ''
|
text = ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
secret=""
|
secret=""
|
||||||
script_path="${src}/proxy/tg_ws_proxy.py"
|
script_path="${src}/proxy/tg_ws_proxy.py"
|
||||||
args=()
|
args=()
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--secret-file=*)
|
--secret-file=*)
|
||||||
secret=$(tr -d '\r\n' < "''${1#--secret-file=}")
|
secret=$(tr -d '\r\n' < "''${1#--secret-file=}")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--secret-file)
|
--secret-file)
|
||||||
secret=$(tr -d '\r\n' < "$2")
|
secret=$(tr -d '\r\n' < "$2")
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--secret=*)
|
--secret=*)
|
||||||
secret="''${1#--secret=}"
|
secret="''${1#--secret=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--secret)
|
--secret)
|
||||||
secret="$2"
|
secret="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
args+=("$1")
|
args+=("$1")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
export PYTHONPATH="${src}"
|
export PYTHONPATH="${src}"
|
||||||
if [ -n "$secret" ]; then
|
if [ -n "$secret" ]; then
|
||||||
export TG_WS_PROXY_SECRET="$secret"
|
export TG_WS_PROXY_SECRET="$secret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec python - "$script_path" "''${args[@]}" <<'PY'
|
exec python - "$script_path" "''${args[@]}" <<'PY'
|
||||||
import os
|
import os
|
||||||
import runpy
|
import runpy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
script_path = sys.argv[1]
|
script_path = sys.argv[1]
|
||||||
args = sys.argv[2:]
|
args = sys.argv[2:]
|
||||||
secret = os.environ.get("TG_WS_PROXY_SECRET")
|
secret = os.environ.get("TG_WS_PROXY_SECRET")
|
||||||
|
|
||||||
if secret is not None:
|
if secret is not None:
|
||||||
args.extend(["--secret", secret])
|
args.extend(["--secret", secret])
|
||||||
|
|
||||||
sys.argv = ["tg_ws_proxy.py", *args]
|
sys.argv = ["tg_ws_proxy.py", *args]
|
||||||
runpy.run_path(script_path, run_name="__main__")
|
runpy.run_path(script_path, run_name="__main__")
|
||||||
PY
|
PY
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
@@ -300,7 +300,7 @@ def parse_tuic(url: str, tag: str) -> dict:
|
|||||||
def parse_socks(url: str, tag: str) -> dict:
|
def parse_socks(url: str, tag: str) -> dict:
|
||||||
"""
|
"""
|
||||||
socks5://[user:pass@]host:port[#remark]
|
socks5://[user:pass@]host:port[#remark]
|
||||||
socks5h://... (socks5 with remote DNS resolution — same wire format)
|
socks5h://... (socks5 with remote DNS resolution – same wire format)
|
||||||
socks4://host:port[#remark]
|
socks4://host:port[#remark]
|
||||||
socks4a://host:port[#remark]
|
socks4a://host:port[#remark]
|
||||||
"""
|
"""
|
||||||
@@ -333,8 +333,8 @@ def parse_socks(url: str, tag: str) -> dict:
|
|||||||
|
|
||||||
def parse_http_proxy(url: str, tag: str) -> dict:
|
def parse_http_proxy(url: str, tag: str) -> dict:
|
||||||
"""
|
"""
|
||||||
http://[user:pass@]host:port[#remark] — plain HTTP CONNECT proxy
|
http://[user:pass@]host:port[#remark] – plain HTTP CONNECT proxy
|
||||||
https://[user:pass@]host:port[#remark] — HTTP CONNECT proxy over TLS
|
https://[user:pass@]host:port[#remark] – HTTP CONNECT proxy over TLS
|
||||||
"""
|
"""
|
||||||
scheme = url.split("://")[0].lower()
|
scheme = url.split("://")[0].lower()
|
||||||
rest = url[len(scheme) + 3:]
|
rest = url[len(scheme) + 3:]
|
||||||
|
|||||||
Reference in new issue
Block a user