nixfiles/hosts/koi/services/sing-box.nix

114 lines
3.2 KiB
Nix
Raw Normal View History

2024-05-11 07:16:10 +03:00
{ pkgs, abs, config, ... }:
let
secrets = import (abs "lib/secrets.nix");
2024-06-07 11:53:19 +03:00
secretsUnsafe = pkgs.callPackage (abs "lib/secrets-unsafe.nix") {};
2024-05-11 07:16:10 +03:00
in {
imports = [
2024-06-07 11:53:19 +03:00
(secrets.declare [
"madohomu-singbox-pub"
"madohomu-singbox-sid"
"madohomu-singbox-koi-uuid"
2024-06-17 02:41:32 +03:00
"vless-sakura-ip"
"vless-sakura-pk"
"vless-sakura-sid"
"vless-sakura-uuid"
2024-06-07 11:53:19 +03:00
])
2024-05-11 07:16:10 +03:00
];
services.sing-box = {
enable = true;
settings = {
2024-06-17 02:41:32 +03:00
log.level = "warning";
2024-05-11 07:16:10 +03:00
inbounds = [
{
tag = "mixed-in";
type = "mixed";
listen = "0.0.0.0";
listen_port = 7890;
}
];
outbounds = [
{ tag = "direct"; type = "direct"; }
{
2024-06-07 11:53:19 +03:00
tag = "xtls-madoka";
type = "vless";
flow = "xtls-rprx-vision";
server = secretsUnsafe.readUnsafe "madoka-ip";
server_port = 443;
domain_strategy = "";
packet_encoding = "";
tls = {
2024-05-11 07:16:10 +03:00
enabled = true;
2024-06-07 11:53:19 +03:00
alpn = [ "h2" ];
server_name = "updates.cdn-apple.com";
reality = {
enabled = true;
public_key._secret = secrets.file config "madohomu-singbox-pub";
short_id._secret = secrets.file config "madohomu-singbox-sid";
};
utls = { enabled = true; fingerprint = "edge"; };
2024-05-11 07:16:10 +03:00
};
2024-06-07 11:53:19 +03:00
uuid._secret = secrets.file config "madohomu-singbox-koi-uuid";
}
{
tag = "xtls-homura";
type = "vless";
flow = "xtls-rprx-vision";
server = secretsUnsafe.readUnsafe "homura-ip";
server_port = 443;
domain_strategy = "";
packet_encoding = "";
tls = {
enabled = true;
alpn = [ "h2" ];
server_name = "updates.cdn-apple.com";
reality = {
enabled = true;
public_key._secret = secrets.file config "madohomu-singbox-pub";
short_id._secret = secrets.file config "madohomu-singbox-sid";
};
utls = { enabled = true; fingerprint = "edge"; };
};
uuid._secret = secrets.file config "madohomu-singbox-koi-uuid";
}
{
2024-06-17 02:41:32 +03:00
# thanks kamillaova
tag = "xtls-sakura";
flow = "xtls-rprx-vision";
server._secret = secrets.file config "vless-sakura-ip";
server_port = 443;
tls = {
alpn = [ "h2" ];
enabled = true;
reality = {
enabled = true;
public_key._secret = secrets.file config "vless-sakura-pk";
short_id._secret = secrets.file config "vless-sakura-sid";
};
server_name = "telegram.org";
utls = { enabled = true; fingerprint = "edge"; };
};
type = "vless";
uuid._secret = secrets.file config "vless-sakura-uuid";
}
{
tag = "final";
type = "urltest";
2024-06-17 02:41:32 +03:00
outbounds = [
"xtls-sakura"
2024-06-17 02:41:32 +03:00
"xtls-madoka"
"xtls-homura"
];
}
2024-05-11 07:16:10 +03:00
];
route.final = "final";
2024-05-11 07:16:10 +03:00
};
};
networking.firewall.allowedTCPPorts = [ 7890 ];
2024-05-11 07:16:10 +03:00
}