Compare commits
3 commits
09bd450a46
...
f61a91234b
Author | SHA1 | Date | |
---|---|---|---|
f61a91234b | |||
bf8c16f565 | |||
82012066e8 |
4 changed files with 27 additions and 9 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -185,9 +185,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.10"
|
||||
version = "1.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||
checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
|
|
@ -237,9 +237,9 @@
|
|||
if IPV4 and IPV6:
|
||||
update_records("127.0.0.1", domain="test", ipv4="1.2.3.4", ipv6="::1234")
|
||||
elif IPV4:
|
||||
update_records("127.0.0.1", ipv4="1.2.3.4")
|
||||
update_records("127.0.0.1", ipv4="1.2.3.4", ipv6="")
|
||||
elif IPV6:
|
||||
update_records("[::1]", ipv6="::1234")
|
||||
update_records("[::1]", ipv4="", ipv6="::1234")
|
||||
|
||||
for domain in DYNAMIC_DOMAINS:
|
||||
if IPV4:
|
||||
|
|
6
flake.lock
generated
6
flake.lock
generated
|
@ -37,11 +37,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1738021509,
|
||||
"narHash": "sha256-JNUiceGsr7cVBUQxLBF1ILCe99E0qLxsVuet6GsZUuw=",
|
||||
"lastModified": 1738142207,
|
||||
"narHash": "sha256-NGqpVVxNAHwIicXpgaVqJEJWeyqzoQJ9oc8lnK9+WC4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9db269672dbdbb519e0bd3ea24f01506c135e46f",
|
||||
"rev": "9d3ae807ebd2981d593cddd0080856873139aa40",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -414,6 +414,24 @@ fn main() -> Result<()> {
|
|||
.wrap_err("failed to run main loop")
|
||||
}
|
||||
|
||||
/// Serde deserialization decorator to map empty Strings to None,
|
||||
///
|
||||
/// Adapted from: <https://github.com/tokio-rs/axum/blob/main/examples/query-params-with-empty-strings/src/main.rs>
|
||||
fn empty_string_as_none<'de, D, T>(de: D) -> Result<Option<T>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
T: std::str::FromStr,
|
||||
T::Err: std::fmt::Display,
|
||||
{
|
||||
use serde::Deserialize;
|
||||
|
||||
let opt = Option::<&'de str>::deserialize(de)?;
|
||||
match opt {
|
||||
None | Some("") => Ok(None),
|
||||
Some(s) => s.parse::<T>().map_err(serde::de::Error::custom).map(Some),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct FritzBoxUpdateParams {
|
||||
|
@ -422,10 +440,10 @@ struct FritzBoxUpdateParams {
|
|||
#[serde(default)]
|
||||
domain: Option<String>,
|
||||
/// IPv4 address for the domain
|
||||
#[serde(default)]
|
||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||
ipv4: Option<Ipv4Addr>,
|
||||
/// IPv6 address for the domain
|
||||
#[serde(default)]
|
||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||
ipv6: Option<Ipv6Addr>,
|
||||
/// IPv6 prefix for the home network
|
||||
#[allow(unused)]
|
||||
|
|
Loading…
Add table
Reference in a new issue