nixos/turn-rs: fix

This commit is contained in:
liberodark
2026-05-04 14:05:34 +02:00
parent 4f92e0ad80
commit 72336f2367

View File

@@ -23,23 +23,23 @@
USER_1_CREDS="foobar"
'';
settings = {
turn = {
server = {
realm = "localhost";
interfaces = [
{
transport = "udp";
bind = "127.0.0.1:3478";
listen = "127.0.0.1:3478";
external = "127.0.0.1:3478";
}
{
transport = "tcp";
bind = "127.0.0.1:3478";
listen = "127.0.0.1:3478";
external = "127.0.0.1:3478";
}
];
};
auth.static_credentials.user1 = "$USER_1_CREDS";
auth."static-credentials".user1 = "$USER_1_CREDS";
};
};
};
@@ -47,15 +47,20 @@
testScript = # python
''
import json
start_all()
server.wait_for_unit('turn-rs.service')
server.wait_for_open_port(3000, "127.0.0.1")
server.wait_for_open_port(3478, "127.0.0.1")
info = server.succeed('curl http://localhost:3000/info')
jsonInfo = json.loads(info)
assert len(jsonInfo['interfaces']) == 2, f'Interfaces doesn\'t contain two entries:\n{json.dumps(jsonInfo, indent=2)}'
base = (
"${pkgs.coturn}/bin/turnutils_uclient"
" -L 127.0.0.1 -e 127.0.0.1 -u user1 -w foobar -X -y -t"
)
for extra in ["", "-s", "-t", "-t -s"]:
out = server.succeed(f"{base} {extra} 127.0.0.1")
assert "ERROR" not in out, f"turnutils_uclient errors:\n{out}"
assert "Total lost packets 0 (0.000000%)" in out, (
f"turnutils_uclient reported packet loss or did not finish:\n{out}"
)
config = server.succeed('cat /run/turn-rs/config.toml')
assert 'foobar' in config, f'Secrets are not properly injected:\n{config}'