nixosTests.sing-box: use tun inbound for wireguard (#495428)

This commit is contained in:
Sizhe Zhao
2026-03-01 11:26:08 +00:00
committed by GitHub
+13 -7
View File
@@ -314,6 +314,9 @@ in
services.sing-box = {
enable = true;
settings = {
inbounds = [
tunInbound
];
outbounds = [
{
type = "block";
@@ -324,7 +327,6 @@ in
{
type = "wireguard";
tag = "outbound:wireguard";
name = "wg0";
address = [ "10.23.42.2/32" ];
mtu = 1280;
private_key = wg-keys.peer1.privateKey;
@@ -336,12 +338,19 @@ in
allowed_ips = [ "0.0.0.0/0" ];
}
];
system = true;
}
];
route = {
default_interface = "eth1";
final = "outbound:block";
rules = [
{
inbound = [
"inbound:tun"
];
outbound = "outbound:wireguard";
}
];
};
};
};
@@ -527,7 +536,6 @@ in
with subtest("tun"):
tun.wait_for_unit("sing-box.service")
tun.wait_for_unit("sys-devices-virtual-net-${tunInbound.interface_name}.device")
tun.wait_until_succeeds("ip route get ${hosts."${target_host}"} | grep 'dev ${tunInbound.interface_name}'")
tun.succeed("ip addr show ${tunInbound.interface_name}")
tun.succeed("ip route show table ${toString tunInbound.iproute2_table_index} | grep ${tunInbound.interface_name}")
@@ -539,9 +547,8 @@ in
with subtest("wireguard"):
wireguard.wait_for_unit("sing-box.service")
wireguard.wait_for_unit("sys-devices-virtual-net-wg0.device")
wireguard.succeed("ip addr show wg0")
test_curl(wireguard, "--interface wg0")
fakeip.wait_until_succeeds("ip route get ${hosts."${target_host}"} | grep 'dev ${tunInbound.interface_name}'")
test_curl(wireguard)
with subtest("tproxy"):
tproxy.wait_for_unit("sing-box.service")
@@ -549,7 +556,6 @@ in
with subtest("fakeip"):
fakeip.wait_for_unit("sing-box.service")
fakeip.wait_for_unit("sys-devices-virtual-net-${tunInbound.interface_name}.device")
fakeip.wait_until_succeeds("ip route get ${hosts."${target_host}"} | grep 'dev ${tunInbound.interface_name}'")
fakeip.succeed("dig +short A ${target_host} @${target_host} | grep '^198.18.'")
'';