A cloudflare backed DDNS service written in Rust
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

  1. extern crate actix_web;
  2. extern crate clap;
  3. use clap::{App, Arg};
  4. mod server;
  5. fn main() {
  6. let args = App::new("Dynamic DNS Server")
  7. .version("0.1")
  8. .author("Drew Short <warrick@sothr.com>")
  9. .about("Recieve DDNS requests and update cloudflare subdomains")
  10. .arg(
  11. Arg::with_name("config")
  12. .short("c")
  13. .long("config")
  14. .value_name("PATH")
  15. .help("Set a custom configuration file path. DEFAULT=/etc/rsddns/rsddns.yml.")
  16. .takes_value(true),
  17. )
  18. .arg(
  19. Arg::with_name("port")
  20. .short("p")
  21. .long("port")
  22. .value_name("PORT")
  23. .help("The port to run the server on.")
  24. .takes_value(true),
  25. )
  26. .get_matches();
  27. let config: &str = args.value_of("config").unwrap_or("/etc/rsddns/rsddns.yml");
  28. let port: i32 = args
  29. .value_of("port")
  30. .unwrap_or("8080")
  31. .parse::<i32>()
  32. .unwrap_or(8080);
  33. println!("Starting server on {} with config {}", port, config);
  34. actix_web::server::new(|| actix_web::App::new().resource("/", |r| r.f(server::index)))
  35. .bind(format!("localhost:{}", port))
  36. .unwrap()
  37. .run();
  38. }