Skip to content

Commit

Permalink
don't use co;nflicting addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg committed Mar 23, 2023
1 parent db053b6 commit 78f4ed7
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions srt-tokio/tests/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
use std::time::{Duration, Instant};

use srt_tokio::SrtSocket;
use srt_tokio::{SrtSocket};

use bytes::Bytes;
use futures::{SinkExt, TryStreamExt};
use log::info;

use tokio::{spawn, time::sleep};

async fn test_crypto(size_listen: u16, size_call: u16) {
async fn test_crypto(size_listen: u16, size_call: u16, port: u16) {
let sender = SrtSocket::builder()
.encryption(size_listen, "password123")
.listen_on(":2000");
.listen_on(port);

let local_addr = format!("127.0.0.1:{port}");

let recvr = SrtSocket::builder()
.encryption(size_call, "password123")
.call("127.0.0.1:2000", None);
.call(local_addr.as_str(), None);

let t = spawn(async move {
let mut sender = sender.await.unwrap();
Expand All @@ -42,20 +44,16 @@ async fn test_crypto(size_listen: u16, size_call: u16) {
async fn crypto_exchange() {
let _ = pretty_env_logger::try_init();

test_crypto(16, 16).await;
sleep(Duration::from_millis(100)).await;
test_crypto(24, 24).await;
sleep(Duration::from_millis(100)).await;
test_crypto(32, 32).await;
test_crypto(16, 16, 2000).await;
test_crypto(24, 24, 2001).await;
test_crypto(32, 32, 2002).await;
}

#[tokio::test]
async fn key_size_mismatch() {
test_crypto(32, 16).await;
sleep(Duration::from_millis(100)).await;
test_crypto(32, 0).await;
sleep(Duration::from_millis(100)).await;
test_crypto(0, 32).await;
test_crypto(32, 16, 2003).await;
test_crypto(32, 0, 2004).await;
test_crypto(0, 32, 2005).await;
}

// TODO: bad password

0 comments on commit 78f4ed7

Please sign in to comment.