projects
/
crypto_lab1.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Data used for packet error has been modified.
[crypto_lab1.git]
/
src
/
main.rs
diff --git
a/src/main.rs
b/src/main.rs
index
5f2fdf9
..
1fae4c1
100644
(file)
--- a/
src/main.rs
+++ b/
src/main.rs
@@
-12,21
+12,15
@@
mod crypto;
mod packet;
mod end_point;
mod packet;
mod end_point;
-/*
-TODO
- * Comment stocker les clefs? à quels critères doivent elle répondre?
- *
-*/
-
const PORT: u16 = 4221;
fn print_usage() {
println!("{} <genkey> | <tests> | ...", os::args()[0]);
}
const PORT: u16 = 4221;
fn print_usage() {
println!("{} <genkey> | <tests> | ...", os::args()[0]);
}
-fn main() {
+fn main() {
let args = os::args();
let args = os::args();
-
+
if args.iter().any(|a| a.as_slice() == "--help" || a.as_slice() == "-h") {
print_usage();
} else if args.len() > 1 && args[1].as_slice() == "genkey" {
if args.iter().any(|a| a.as_slice() == "--help" || a.as_slice() == "-h") {
print_usage();
} else if args.len() > 1 && args[1].as_slice() == "genkey" {
@@
-35,13
+29,17
@@
fn main() {
Err(e) => println!("Unable to generate a key. Error: {}", e)
}
} else {
Err(e) => println!("Unable to generate a key. Error: {}", e)
}
} else {
- println!("Starting server...
, Press any key to quit
");
-
+ println!("Starting server...");
+
match Server::new("::1", PORT) {
Ok(mut server) => {
println!("Server started");
match Server::new("::1", PORT) {
Ok(mut server) => {
println!("Server started");
- Client::start_tests("::1", PORT);
- io::stdin().read_line().ok().expect("Failed to read line");
+
+ Client::start_tests("::1", PORT);
+
+ println!("Press any key to quit");
+ io::stdin().read_line().ok().expect("Failed to read line");
+
server.close().ok().expect("Failed to close the server");
},
Err(e) =>
server.close().ok().expect("Failed to close the server");
},
Err(e) =>