2024-01-28 19:30:59 +00:00
|
|
|
use clap::Parser;
|
2024-01-28 22:48:35 +00:00
|
|
|
use std::{thread};
|
2024-01-28 19:30:59 +00:00
|
|
|
|
|
|
|
use log::{error, info, warn};
|
|
|
|
use simplelog::*;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::net::{SocketAddr, UdpSocket};
|
|
|
|
|
2024-01-28 22:48:35 +00:00
|
|
|
use dnstplib::dns_socket::DNSSocket;
|
|
|
|
|
2024-01-28 19:30:59 +00:00
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
#[command(author, version, about, long_about = None)]
|
|
|
|
struct Args {
|
|
|
|
/// Addresses to bind server to
|
|
|
|
#[arg(short, long)]
|
|
|
|
address: Vec<String>,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
CombinedLogger::init(
|
|
|
|
vec![
|
|
|
|
TermLogger::new(LevelFilter::Info, Config::default(), TerminalMode::Mixed, ColorChoice::Auto),
|
|
|
|
WriteLogger::new(LevelFilter::Info, Config::default(), File::create("dnstp.log").unwrap()),
|
|
|
|
]
|
|
|
|
).unwrap();
|
|
|
|
|
|
|
|
let args = Args::parse();
|
|
|
|
|
|
|
|
info!("======================");
|
|
|
|
info!(" dnstp");
|
|
|
|
info!("======================");
|
|
|
|
|
|
|
|
for a in args.address.iter() {
|
|
|
|
info!("Binding to {}", a)
|
|
|
|
}
|
|
|
|
|
|
|
|
let addresses: Vec<SocketAddr> = args.address
|
|
|
|
.iter()
|
|
|
|
.map(|x| x.parse().expect("Couldn't parse address"))
|
|
|
|
.collect();
|
|
|
|
|
2024-01-28 22:48:35 +00:00
|
|
|
let mut socket = DNSSocket::new(addresses);
|
|
|
|
socket.run();
|
2024-01-28 19:30:59 +00:00
|
|
|
|
2024-01-28 22:48:35 +00:00
|
|
|
thread::park();
|
2024-01-28 19:30:59 +00:00
|
|
|
}
|