Skip to content

Commit 1aa9833

Browse files
committed
remove local ip
1 parent d0d292f commit 1aa9833

File tree

3 files changed

+11
-133
lines changed

3 files changed

+11
-133
lines changed

Cargo.lock

Lines changed: 9 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ config = { version = "0.14.0", default-features = false, features= ["rust-ini"]
2323
env_logger = { version="0.11.5", default-features = false, features = ["humantime", "auto-color"] }
2424
log = "0.4.22"
2525
clap = { version = "4.5.17", default-features = false, features = ["std", "help", "derive"] }
26-
local-ip-address = "0.6.2"
2726
minreq = { version = "2.12.0", default-features = false, features= ["json-using-serde", "https-rustls"] }
2827

2928
[dev-dependencies]

src/main.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ use config::Config;
55
use std::net::IpAddr;
66
use std::error::Error;
77
use serde_json::json;
8-
use local_ip_address::local_ip;
98

109
#[derive(Debug, Deserialize)]
1110
struct CloudflareConfig {
1211
zone_id: String,
1312
cloudflare_zone_api_token: String,
1413
dns_record: String, // Comma-separated DNS records
1514
ttl: u32,
16-
what_ip: String,
1715
}
1816

1917
#[derive(Parser, Debug)]
@@ -31,9 +29,6 @@ struct Args {
3129
#[arg(long)]
3230
ttl: Option<u32>,
3331

34-
#[arg(long)]
35-
what_ip: Option<String>,
36-
3732
#[arg(long)]
3833
config_file: Option<String>,
3934

@@ -61,15 +56,13 @@ fn merge_config(cli_args: Args, file_config: Option<CloudflareConfig>) -> Cloudf
6156
cloudflare_zone_api_token: "".to_string(),
6257
dns_record: "".to_string(),
6358
ttl: 1,
64-
what_ip: "external".to_string(),
6559
});
6660

6761
CloudflareConfig {
6862
zone_id: cli_args.zone_id.unwrap_or(default_config.zone_id),
6963
cloudflare_zone_api_token: cli_args.api_token.unwrap_or(default_config.cloudflare_zone_api_token),
7064
dns_record: cli_args.dns_record.unwrap_or(default_config.dns_record),
7165
ttl: cli_args.ttl.unwrap_or(default_config.ttl),
72-
what_ip: cli_args.what_ip.unwrap_or(default_config.what_ip),
7366
}
7467
}
7568

@@ -185,13 +178,9 @@ fn main() -> Result<(), Box<dyn Error>> {
185178
// now start the actual work
186179
log::info!("Starting Cloudflare DNS updater...");
187180

188-
let ip = match config.what_ip.as_str() {
189-
"external" => get_external_ip()?,
190-
"internal" => local_ip().unwrap(),
191-
_ => return Err("Invalid what_ip option".into()),
192-
};
181+
let ip = get_external_ip()?;
193182

194-
log::info!("IP address ({}): {}", config.what_ip, ip);
183+
log::info!("IP address: {}", ip);
195184

196185
update_cloudflare_dns(config, ip, dry)?;
197186

0 commit comments

Comments
 (0)