better ping printing
This commit is contained in:
parent
97b8129002
commit
79670a6f9c
4 changed files with 10 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4,4 +4,4 @@ version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "qft"
|
name = "qft"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "qft"
|
name = "qft"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
|
2
Cross.toml
Normal file
2
Cross.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[target.x86_64-apple-darwin]
|
||||||
|
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"
|
10
src/main.rs
10
src/main.rs
|
@ -247,10 +247,11 @@ fn sender(args: &Vec<String>) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let m = unix_millis();
|
||||||
sc.write_safe(&buf[..read]).expect("send error");
|
sc.write_safe(&buf[..read]).expect("send error");
|
||||||
bytes_sent += read as u64;
|
bytes_sent += read as u64;
|
||||||
if (bytes_sent % (br * 20) as u64) < (br as u64) {
|
if (bytes_sent % (br * 20) as u64) < (br as u64) {
|
||||||
print!("\rSent {} bytes", bytes_sent);
|
print!("\r\x1b[KSent {} bytes with ping {}", bytes_sent, unix_millis() - m);
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,10 +281,11 @@ fn receiver(args: &Vec<String>) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let m = unix_millis();
|
||||||
file.write(buf).expect("write error");
|
file.write(buf).expect("write error");
|
||||||
bytes_received += len as u64;
|
bytes_received += len as u64;
|
||||||
if (bytes_received % (br * 20) as u64) < (br as u64) {
|
if (bytes_received % (br * 20) as u64) < (br as u64) {
|
||||||
print!("\rReceived {} bytes", bytes_received);
|
print!("\r\x1b[KReceived {} bytes with ping {}", bytes_received, unix_millis() - m);
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,13 +336,11 @@ fn holepunch(args: &Vec<String>) -> UdpSocket {
|
||||||
println!("Waiting...");
|
println!("Waiting...");
|
||||||
let mut stop = false;
|
let mut stop = false;
|
||||||
while !stop {
|
while !stop {
|
||||||
let m = unix_millis();
|
thread::sleep(Duration::from_millis(500 - (unix_millis() % 500)));
|
||||||
thread::sleep(Duration::from_millis(500 - (m % 500)));
|
|
||||||
println!("CONNECT {}", unix_millis());
|
println!("CONNECT {}", unix_millis());
|
||||||
holepunch.send(&[0]).expect("connection failed");
|
holepunch.send(&[0]).expect("connection failed");
|
||||||
let result = holepunch.recv(&mut [0, 0]);
|
let result = holepunch.recv(&mut [0, 0]);
|
||||||
if result.is_ok() && result.unwrap() == 1 {
|
if result.is_ok() && result.unwrap() == 1 {
|
||||||
println!("Ping: {}", unix_millis() - m);
|
|
||||||
holepunch.send(&[0, 0]).expect("connection failed");
|
holepunch.send(&[0, 0]).expect("connection failed");
|
||||||
let result = holepunch.recv(&mut [0, 0]);
|
let result = holepunch.recv(&mut [0, 0]);
|
||||||
if result.is_ok() && result.unwrap() == 2 {
|
if result.is_ok() && result.unwrap() == 2 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue