cec395706daab70b756a49362d6e5b4f1fc81d3b
1 #![feature(macro_rules)]
15 * Comment stocker les clefs? à quels critères doivent elle répondre?
19 const PORT
: u16 = 4221;
22 println!("{} <genkey> | ...", os
::args()[0]);
26 let args
= os
::args();
28 if args
.iter().any(|a
| a
.as_slice() == "--help" || a
.as_slice() == "-h") {
30 } else if args
.len() > 1 && args
[1].as_slice() == "genkey" {
31 match crypto
::generate_key(256 / 8) {
32 Ok(key
) => println!("key: {}", key
),
33 Err(e
) => println!("Unable to generate a key. Error: {}", e
)
36 match server
::Server
::new(PORT
) {
38 println!("Server started");
40 match client
::Client
::new("127.0.0.1", PORT
) {
46 println!("Unable to create a client. Error: {}", e
);
51 println!("Press any key to quit");
52 io
::stdin().read_line().ok().expect("Failed to read line");
53 server
.close().ok().expect("Failed to close the server");
55 Err(e
) => println!("Unable to create a new server. Error: {}", e
)