Add dual-stack IPv4+IPv6 listening
All checks were successful
CI / test (push) Successful in 1m24s

Server now binds on both IPv4 (0.0.0.0) and IPv6 (::) by default.
Uses tokio::select! to accept from whichever listener has a connection.

New flags:
  --listen <addr>   IPv4 listen address (default: 0.0.0.0, "none" to disable)
  --listen6 <addr>  IPv6 listen address (default: ::, "none" to disable)

Examples:
  btest -s                          # listen on both v4 and v6
  btest -s --listen6 none           # IPv4 only
  btest -s --listen none            # IPv6 only
  btest -s --listen 192.168.1.1     # specific IPv4 address

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-31 18:28:48 +04:00
parent 2dec6cc007
commit 7bbb7c9d9b
4 changed files with 73 additions and 11 deletions

View File

@@ -10,7 +10,9 @@ async fn start_ecsrp5_server(port: u16) {
port,
Some("testuser".into()),
Some("testpass".into()),
true, // ecsrp5
true,
Some("127.0.0.1".into()),
None,
)
.await;
});
@@ -23,7 +25,9 @@ async fn start_md5_server(port: u16) {
port,
Some("testuser".into()),
Some("testpass".into()),
false, // md5
false,
Some("127.0.0.1".into()),
None,
)
.await;
});
@@ -32,7 +36,7 @@ async fn start_md5_server(port: u16) {
async fn start_noauth_server(port: u16) {
tokio::spawn(async move {
let _ = btest_rs::server::run_server(port, None, None, false).await;
let _ = btest_rs::server::run_server(port, None, None, false, Some("127.0.0.1".into()), None).await;
});
tokio::time::sleep(Duration::from_millis(200)).await;
}

View File

@@ -8,7 +8,7 @@ async fn start_test_server(port: u16, auth_user: Option<&str>, auth_pass: Option
let user = auth_user.map(String::from);
let pass = auth_pass.map(String::from);
tokio::spawn(async move {
let _ = btest_rs::server::run_server(port, user, pass, false).await;
let _ = btest_rs::server::run_server(port, user, pass, false, Some("127.0.0.1".into()), None).await;
});
tokio::time::sleep(Duration::from_millis(100)).await;
}