Fix setup of nsupdate

This commit is contained in:
notplants 2021-12-18 11:24:43 -05:00
parent 570f6a679b
commit 29cc40be48
7 changed files with 21 additions and 15 deletions

6
Cargo.lock generated
View File

@ -2432,7 +2432,7 @@ dependencies = [
[[package]]
name = "peach-dyndns-updater"
version = "0.1.6"
version = "0.1.7"
dependencies = [
"env_logger 0.6.2",
"log 0.4.14",
@ -2454,7 +2454,7 @@ dependencies = [
[[package]]
name = "peach-lib"
version = "1.3.1"
version = "1.3.2"
dependencies = [
"chrono",
"fslock",
@ -2541,7 +2541,7 @@ dependencies = [
[[package]]
name = "peach-web"
version = "0.4.15"
version = "0.4.16"
dependencies = [
"env_logger 0.8.4",
"log 0.4.14",

View File

@ -69,6 +69,7 @@ pub fn setup_peach(
"libssl-dev",
"nginx",
"wget",
"dnsutils",
"-y",
])?;

View File

@ -1,6 +1,6 @@
[package]
name = "peach-dyndns-updater"
version = "0.1.6"
version = "0.1.7"
authors = ["Max Fowler <mfowler@commoninternet.net>"]
edition = "2018"
description = "Sytemd timer which keeps a dynamic dns subdomain up to date with the latest device IP using nsupdate."

View File

@ -1,6 +1,6 @@
[package]
name = "peach-lib"
version = "1.3.1"
version = "1.3.2"
authors = ["Andrew Reid <glyph@mycelial.technology>"]
edition = "2018"

View File

@ -70,7 +70,7 @@ pub fn load_peach_config() -> Result<PeachConfig, PeachError> {
peach_config = PeachConfig {
external_domain: "".to_string(),
dyn_domain: "".to_string(),
dyn_dns_server_address: "".to_string(),
dyn_dns_server_address: "http://dynserver.dyn.peachcloud.org".to_string(),
dyn_tsig_key_path: "".to_string(),
dyn_enabled: false,
ssb_admin_ids: Vec::new(),
@ -122,6 +122,11 @@ pub fn get_peachcloud_domain() -> Result<Option<String>, PeachError> {
}
}
pub fn get_dyndns_server_address() -> Result<String, PeachError> {
let peach_config = load_peach_config()?;
Ok(peach_config.dyn_dns_server_address)
}
pub fn set_dyndns_enabled_value(enabled_value: bool) -> Result<PeachConfig, PeachError> {
let mut peach_config = load_peach_config()?;
peach_config.dyn_enabled = enabled_value;

View File

@ -27,9 +27,9 @@ use crate::{
config_manager::{load_peach_config, set_peach_dyndns_config},
error::PeachError,
};
use crate::config_manager::get_dyndns_server_address;
/// constants for dyndns configuration
pub const PEACH_DYNDNS_URL: &str = "http://dynserver.dyn.peachcloud.org";
pub const TSIG_KEY_PATH: &str = "/var/lib/peachcloud/peach-dyndns/tsig.key";
pub const PEACH_DYNDNS_CONFIG_PATH: &str = "/var/lib/peachcloud/peach-dyndns";
pub const DYNDNS_LOG_PATH: &str = "/var/lib/peachcloud/peach-dyndns/latest_result.log";
@ -62,9 +62,9 @@ pub fn save_dyndns_key(key: &str) -> Result<(), PeachError> {
pub fn register_domain(domain: &str) -> std::result::Result<String, PeachError> {
debug!("Creating HTTP transport for dyndns client.");
let transport = HttpTransport::new().standalone()?;
let http_server = PEACH_DYNDNS_URL;
debug!("Creating HTTP transport handle on {}.", http_server);
let transport_handle = transport.handle(http_server)?;
let http_server = get_dyndns_server_address()?;
debug!("Creating HTTP transport handle on {}.", &http_server);
let transport_handle = transport.handle(&http_server)?;
info!("Creating client for peach-dyndns service.");
let mut client = PeachDynDnsClient::new(transport_handle);
@ -73,7 +73,7 @@ pub fn register_domain(domain: &str) -> std::result::Result<String, PeachError>
// save new TSIG key
save_dyndns_key(&key)?;
// save new configuration values
let set_config_result = set_peach_dyndns_config(domain, PEACH_DYNDNS_URL, TSIG_KEY_PATH, true);
let set_config_result = set_peach_dyndns_config(domain, &http_server, TSIG_KEY_PATH, true);
match set_config_result {
Ok(_) => {
let response = "success".to_string();
@ -87,9 +87,9 @@ pub fn register_domain(domain: &str) -> std::result::Result<String, PeachError>
pub fn is_domain_available(domain: &str) -> std::result::Result<bool, PeachError> {
debug!("Creating HTTP transport for dyndns client.");
let transport = HttpTransport::new().standalone()?;
let http_server = PEACH_DYNDNS_URL;
debug!("Creating HTTP transport handle on {}.", http_server);
let transport_handle = transport.handle(http_server)?;
let http_server = get_dyndns_server_address()?;
debug!("Creating HTTP transport handle on {}.", &http_server);
let transport_handle = transport.handle(&http_server)?;
info!("Creating client for peach_network service.");
let mut client = PeachDynDnsClient::new(transport_handle);

View File

@ -1,6 +1,6 @@
[package]
name = "peach-web"
version = "0.4.15"
version = "0.4.16"
authors = ["Andrew Reid <gnomad@cryptolab.net>"]
edition = "2018"
description = "peach-web is a web application which provides a web interface for monitoring and interacting with the PeachCloud device. This allows administration of the single-board computer (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related plugins."