ask for server ip

This commit is contained in:
Mystikfluu 2023-05-23 19:49:29 +02:00
parent e065ddc21b
commit 9926ca5de7

View File

@ -3,6 +3,7 @@ use std::{net::{UdpSocket, SocketAddr}, io::Write};
use serde::{Serialize, Deserialize};
use sha3::{Digest, Sha3_512};
use sha2::Sha512;
use std::io::{self, BufRead};
mod big_array;
use big_array::BigArray;
@ -28,10 +29,26 @@ struct Packet {
payload: [u8; MAX_PAYLOAD_U], //488 bytes
} //512 bytes
fn read_stdin(message: String) -> String {
print!("{}", message);
io::stdout().flush().unwrap();
let mut buffer = String::new();
let stdin = io::stdin();
let mut handle = stdin.lock();
handle.read_line(&mut buffer).unwrap();
buffer.trim().to_string()
}
fn main() {
let timeout = 1;
let server_ip = "213.47.107.152:1337";
let mut server_ip = read_stdin("Enter server ip: ".to_string());//e.g. 213.47.107.152:1337
if server_ip.find(":").is_none() {
server_ip.push_str(":1337"); //default port
}
let filename = "data.bin";