Compare commits
1 commit
738fa8accf
...
8c8ca6cd60
Author | SHA1 | Date | |
---|---|---|---|
8c8ca6cd60 |
1 changed files with 4 additions and 35 deletions
39
src/main.rs
39
src/main.rs
|
@ -285,37 +285,6 @@ fn load_ip(path: &Path) -> Result<Option<SavedIPs>> {
|
||||||
.map(Some)
|
.map(Some)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
struct Ipv6Prefix {
|
|
||||||
prefix: Ipv6Addr,
|
|
||||||
length: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for Ipv6Prefix {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
let Self { prefix, length } = self;
|
|
||||||
write!(f, "{prefix}/{length}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::str::FromStr for Ipv6Prefix {
|
|
||||||
type Err = miette::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
|
||||||
let (addr, len) = s.split_once('/').wrap_err("missing `/` in ipv6 prefix")?;
|
|
||||||
Ok(Self {
|
|
||||||
prefix: addr
|
|
||||||
.parse()
|
|
||||||
.into_diagnostic()
|
|
||||||
.wrap_err("invalid ipv6 address for ipv6 prefix")?,
|
|
||||||
length: len
|
|
||||||
.parse()
|
|
||||||
.into_diagnostic()
|
|
||||||
.wrap_err("invalid length for ipv6 prefix")?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(err)]
|
#[tracing::instrument(err)]
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
// set panic hook to pretty print with miette's formatter
|
// set panic hook to pretty print with miette's formatter
|
||||||
|
@ -468,7 +437,7 @@ where
|
||||||
struct FritzBoxUpdateParams {
|
struct FritzBoxUpdateParams {
|
||||||
/// The domain that should be updated
|
/// The domain that should be updated
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default)]
|
||||||
domain: Option<String>,
|
domain: Option<String>,
|
||||||
/// IPv4 address for the domain
|
/// IPv4 address for the domain
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default, deserialize_with = "empty_string_as_none")]
|
||||||
|
@ -478,11 +447,11 @@ struct FritzBoxUpdateParams {
|
||||||
ipv6: Option<Ipv6Addr>,
|
ipv6: Option<Ipv6Addr>,
|
||||||
/// IPv6 prefix for the home network
|
/// IPv6 prefix for the home network
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default)]
|
||||||
ipv6prefix: Option<Ipv6Prefix>,
|
ipv6prefix: Option<String>,
|
||||||
/// Whether the networks uses both IPv4 and IPv6
|
/// Whether the networks uses both IPv4 and IPv6
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[serde(default, deserialize_with = "empty_string_as_none")]
|
#[serde(default)]
|
||||||
dualstack: Option<String>,
|
dualstack: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue