Compare commits

...

3 Commits

Author SHA1 Message Date
mirsal 0405ec3b16 Bind to IPv6
The Future
2021-03-30 17:54:35 +00:00
mirsal 749cf151bf cosmetics: Remove unnecessary newlines between use blocks 2021-03-30 08:50:55 +00:00
mirsal 60cf753b7f main: Fix the main function return type 2021-03-30 08:45:33 +00:00
2 changed files with 5 additions and 8 deletions

View File

@ -1,9 +1,7 @@
use ed25519_dalek::{Keypair, PublicKey, SecretKey};
use json::{object, JsonValue};
use rand::rngs::OsRng;
use regex::Regex;
use async_std::fs;
use async_std::path::PathBuf;
use async_trait::async_trait;

View File

@ -1,6 +1,5 @@
use clap::{load_yaml, App};
use ed25519_dalek::Keypair;
use async_std::fs;
use async_std::net::UdpSocket;
use async_std::path::PathBuf;
@ -34,7 +33,7 @@ fn parse_packet(packet: String) -> Host {
}
#[async_std::main]
async fn main() -> std::io::Result<()> {
async fn main() {
let options = load_yaml!("options.yaml");
let options = App::from(options).get_matches();
@ -45,7 +44,7 @@ async fn main() -> std::io::Result<()> {
.join("cosmoline")
.join("config.toml")),
};
let config = fs::read_to_string(config_file).await?;
let config = fs::read_to_string(config_file).await.unwrap();
let config: Config = toml::from_str(config.as_str()).unwrap();
let path = match options.value_of("path") {
@ -58,14 +57,14 @@ async fn main() -> std::io::Result<()> {
let keypair = Keypair::read_or_generate(path.join("secret")).await;
println!("{}", keypair.to_json().pretty(2));
let socket = UdpSocket::bind("0.0.0.0:8008").await?;
let socket = UdpSocket::bind(":::8008").await.unwrap();
let mut buf = [0u8; 1024];
loop {
let (amt, peer) = socket.recv_from(&mut buf).await?;
let (amt, peer) = socket.recv_from(&mut buf).await.unwrap();
let buf = &mut buf[..amt];
let packet = String::from_utf8(buf.to_vec()).unwrap();
println!("{:?}", (peer, parse_packet(packet)));
}
};
}