aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 7fce58005d5828e28a6d0ac8e8bd8bcf134b7ee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::path::{Path, PathBuf};
use std::process::exit;
use clap::Parser;
use log::info;
use crate::config::Config;
use crate::dyndns_service::DynDnsService;
use crate::error::AppResult;
use crate::ip_service::IpService;

mod dyndns_service;
mod ip_service;
mod config;
mod error;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    #[arg(short, long, default_value = "~/.config/multiwan-dyndns/config.json")]
    config_file: PathBuf,
}

fn main() {
    env_logger::init();

    let args = Args::parse();
    match run(args) {
        Ok(_) => exit(0),
        Err(e) => {
            log::error!("{}", e);
            exit(1);
        }
    }
}

fn run(args: Args) -> AppResult<()> {
    let config = Config::load(&args.config_file)?;
    for network in config.networks {
        // let ip = IpService::resolve(&network.ip_service)?;
        // for dyndns in network.providers {
        //     DynDnsService::register(&dyndns, &ip)?;
        // }
    }

    Ok(())
}