remove asymetric ecryption
This commit is contained in:
+3
-14
@@ -1,12 +1,11 @@
|
||||
mod net;
|
||||
use std::{net::UdpSocket, process::exit, sync::Arc};
|
||||
|
||||
use rsa::pkcs8::der::zeroize::Zeroize;
|
||||
fn main() -> std::io::Result<()> {
|
||||
{
|
||||
let socket: Arc<UdpSocket> = Arc::new(
|
||||
(|| -> std::io::Result<UdpSocket> {
|
||||
let listen_port: u16 = 60000;
|
||||
let listen_port: u16 = pea_2_pea::SERVER_PORT;
|
||||
match UdpSocket::bind(format!("0.0.0.0:{}", listen_port)) {
|
||||
Ok(socket) => return Ok(socket),
|
||||
Err(e) => return Err(e),
|
||||
@@ -15,23 +14,13 @@ fn main() -> std::io::Result<()> {
|
||||
.expect("Failed to bind to any available port"),
|
||||
);
|
||||
|
||||
let server_key_pear: pea_2_pea::shared::crypto::KeyPair =
|
||||
pea_2_pea::shared::crypto::generate_rsa_key_pair();
|
||||
|
||||
let mut buf: [u8; pea_2_pea::BUFFER_SIZE] = [0; pea_2_pea::BUFFER_SIZE];
|
||||
smol::block_on(async {
|
||||
loop {
|
||||
buf.zeroize();
|
||||
match socket.recv_from(&mut buf) {
|
||||
Ok((data_length, src)) => {
|
||||
smol::spawn(net::handle_request(
|
||||
buf,
|
||||
socket.clone(),
|
||||
src,
|
||||
data_length,
|
||||
server_key_pear.clone(),
|
||||
))
|
||||
.detach();
|
||||
smol::spawn(net::handle_request(buf, socket.clone(), src, data_length))
|
||||
.detach();
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("Error receiving data: {}", e);
|
||||
|
||||
Reference in New Issue
Block a user