Bugfix: IP could be set to '::' or '0.0.0.0'
This commit is contained in:
parent
7b6bdc37c7
commit
8a1c52cd90
1 changed files with 28 additions and 10 deletions
18
src/main.rs
18
src/main.rs
|
@ -61,6 +61,14 @@ impl Addresses {
|
||||||
match self.get_v4() {
|
match self.get_v4() {
|
||||||
Ok(ip) => {
|
Ok(ip) => {
|
||||||
if ip != self.ipv4 {
|
if ip != self.ipv4 {
|
||||||
|
if ip == Ipv4Addr::new(0,0,0,0) {
|
||||||
|
let warn_msg = "'0.0.0.0' detected as new IPv4, skipping changes".to_owned();
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => warn!("[WARN] {warn_msg}"),
|
||||||
|
false => println!("[WARN] {warn_msg}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
let info_msg = format!("IPv4 changed from '{}' to '{}'", self.ipv4, ip);
|
let info_msg = format!("IPv4 changed from '{}' to '{}'", self.ipv4, ip);
|
||||||
match connected_to_journal() {
|
match connected_to_journal() {
|
||||||
true => info!("[INFO] {info_msg}"),
|
true => info!("[INFO] {info_msg}"),
|
||||||
|
@ -69,6 +77,7 @@ impl Addresses {
|
||||||
self.ipv4 = ip;
|
self.ipv4 = ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let warn_msg = format!("Unable to fetch IPv4 from '{}'. Error: {}", self.ipv4_uri, e);
|
let warn_msg = format!("Unable to fetch IPv4 from '{}'. Error: {}", self.ipv4_uri, e);
|
||||||
match connected_to_journal() {
|
match connected_to_journal() {
|
||||||
|
@ -81,6 +90,14 @@ impl Addresses {
|
||||||
match self.get_v6() {
|
match self.get_v6() {
|
||||||
Ok(ip) => {
|
Ok(ip) => {
|
||||||
if ip != self.ipv6 {
|
if ip != self.ipv6 {
|
||||||
|
if ip == Ipv6Addr::new(0,0,0,0,0,0,0,0) {
|
||||||
|
let warn_msg = "'::' detected as new IPv6, skipping changes".to_owned();
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => warn!("[WARN] {warn_msg}"),
|
||||||
|
false => println!("[WARN] {warn_msg}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
let info_msg = format!("IPv6 changed from '{}' to '{}'", self.ipv6, ip);
|
let info_msg = format!("IPv6 changed from '{}' to '{}'", self.ipv6, ip);
|
||||||
match connected_to_journal() {
|
match connected_to_journal() {
|
||||||
true => info!("[INFO] {info_msg}"),
|
true => info!("[INFO] {info_msg}"),
|
||||||
|
@ -89,6 +106,7 @@ impl Addresses {
|
||||||
self.ipv6 = ip;
|
self.ipv6 = ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let warn_msg = format!("Unable to fetch IPv6 from '{}'. Error: {}", self.ipv6_uri, e);
|
let warn_msg = format!("Unable to fetch IPv6 from '{}'. Error: {}", self.ipv6_uri, e);
|
||||||
match connected_to_journal() {
|
match connected_to_journal() {
|
||||||
|
|
Loading…
Reference in a new issue