use IPv4 for now
This commit is contained in:
parent
7db28b3793
commit
e5ce19e850
2
.env.dev
2
.env.dev
@ -1,5 +1,5 @@
|
|||||||
export DOMIPLY_HTTP_DOMAIN=localhost
|
export DOMIPLY_HTTP_DOMAIN=localhost
|
||||||
export DOMIPLY_PASSPHRASE=foobar
|
export DOMIPLY_PASSPHRASE=foobar
|
||||||
export DOMIPLY_ORIGIN_STORE_GIT_DIR_PATH=/tmp/domiply_dev_env/origin/git
|
export DOMIPLY_ORIGIN_STORE_GIT_DIR_PATH=/tmp/domiply_dev_env/origin/git
|
||||||
export DOMIPLY_DOMAIN_CHECKER_TARGET_AAAA=::1
|
export DOMIPLY_DOMAIN_CHECKER_TARGET_A=127.0.0.1
|
||||||
export DOMIPLY_DOMAIN_CONFIG_STORE_DIR_PATH=/tmp/domiply_dev_env/domain/config
|
export DOMIPLY_DOMAIN_CONFIG_STORE_DIR_PATH=/tmp/domiply_dev_env/domain/config
|
||||||
|
@ -20,8 +20,8 @@ pub enum NewDNSCheckerError {
|
|||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum CheckDomainError {
|
pub enum CheckDomainError {
|
||||||
#[error("target AAAA not set")]
|
#[error("target A not set")]
|
||||||
TargetAAAANotSet,
|
TargetANotSet,
|
||||||
|
|
||||||
#[error("challenge token not set")]
|
#[error("challenge token not set")]
|
||||||
ChallengeTokenNotSet,
|
ChallengeTokenNotSet,
|
||||||
@ -31,7 +31,7 @@ pub enum CheckDomainError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct DNSChecker {
|
pub struct DNSChecker {
|
||||||
target_aaaa: net::Ipv6Addr,
|
target_a: net::Ipv4Addr,
|
||||||
|
|
||||||
// TODO we should use some kind of connection pool here, I suppose
|
// TODO we should use some kind of connection pool here, I suppose
|
||||||
client: tokio::sync::Mutex<AsyncClient>,
|
client: tokio::sync::Mutex<AsyncClient>,
|
||||||
@ -39,7 +39,7 @@ pub struct DNSChecker {
|
|||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
tokio_runtime: sync::Arc<tokio::runtime::Runtime>,
|
tokio_runtime: sync::Arc<tokio::runtime::Runtime>,
|
||||||
target_aaaa: net::Ipv6Addr,
|
target_a: net::Ipv4Addr,
|
||||||
resolver_addr: &str,
|
resolver_addr: &str,
|
||||||
) -> Result<DNSChecker, NewDNSCheckerError> {
|
) -> Result<DNSChecker, NewDNSCheckerError> {
|
||||||
let resolver_addr = resolver_addr
|
let resolver_addr = resolver_addr
|
||||||
@ -55,7 +55,7 @@ pub fn new(
|
|||||||
tokio_runtime.spawn(bg);
|
tokio_runtime.spawn(bg);
|
||||||
|
|
||||||
Ok(DNSChecker {
|
Ok(DNSChecker {
|
||||||
target_aaaa,
|
target_a,
|
||||||
client: tokio::sync::Mutex::new(client),
|
client: tokio::sync::Mutex::new(client),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -84,14 +84,14 @@ impl DNSChecker {
|
|||||||
let records = response.answers();
|
let records = response.answers();
|
||||||
|
|
||||||
if records.len() != 1 {
|
if records.len() != 1 {
|
||||||
return Err(CheckDomainError::TargetAAAANotSet);
|
return Err(CheckDomainError::TargetANotSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the single record isn't a AAAA, or it's not the target AAAA, then return
|
// if the single record isn't a A, or it's not the target A, then return
|
||||||
// TargetAAAANAMENotSet
|
// TargetANAMENotSet
|
||||||
match records[0].data() {
|
match records[0].data() {
|
||||||
Some(RData::AAAA(remote_aaaa)) if remote_aaaa == &self.target_aaaa => (),
|
Some(RData::A(remote_a)) if remote_a == &self.target_a => (),
|
||||||
_ => return Err(CheckDomainError::TargetAAAANotSet),
|
_ => return Err(CheckDomainError::TargetANotSet),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ pub enum SyncWithConfigError {
|
|||||||
#[error("already in progress")]
|
#[error("already in progress")]
|
||||||
AlreadyInProgress,
|
AlreadyInProgress,
|
||||||
|
|
||||||
#[error("target AAAA not set")]
|
#[error("target A/AAAA not set")]
|
||||||
TargetAAAANotSet,
|
TargetANotSet,
|
||||||
|
|
||||||
#[error("challenge token not set")]
|
#[error("challenge token not set")]
|
||||||
ChallengeTokenNotSet,
|
ChallengeTokenNotSet,
|
||||||
@ -96,7 +96,7 @@ impl From<origin::store::SyncError> for SyncWithConfigError {
|
|||||||
impl From<checker::CheckDomainError> for SyncWithConfigError {
|
impl From<checker::CheckDomainError> for SyncWithConfigError {
|
||||||
fn from(e: checker::CheckDomainError) -> SyncWithConfigError {
|
fn from(e: checker::CheckDomainError) -> SyncWithConfigError {
|
||||||
match e {
|
match e {
|
||||||
checker::CheckDomainError::TargetAAAANotSet => SyncWithConfigError::TargetAAAANotSet,
|
checker::CheckDomainError::TargetANotSet => SyncWithConfigError::TargetANotSet,
|
||||||
checker::CheckDomainError::ChallengeTokenNotSet => {
|
checker::CheckDomainError::ChallengeTokenNotSet => {
|
||||||
SyncWithConfigError::ChallengeTokenNotSet
|
SyncWithConfigError::ChallengeTokenNotSet
|
||||||
}
|
}
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -29,8 +29,8 @@ struct Cli {
|
|||||||
#[arg(long, required = true, env = "DOMIPLY_ORIGIN_STORE_GIT_DIR_PATH")]
|
#[arg(long, required = true, env = "DOMIPLY_ORIGIN_STORE_GIT_DIR_PATH")]
|
||||||
origin_store_git_dir_path: path::PathBuf,
|
origin_store_git_dir_path: path::PathBuf,
|
||||||
|
|
||||||
#[arg(long, required = true, env = "DOMIPLY_DOMAIN_CHECKER_TARGET_AAAA")]
|
#[arg(long, required = true, env = "DOMIPLY_DOMAIN_CHECKER_TARGET_A")]
|
||||||
domain_checker_target_aaaa: std::net::Ipv6Addr,
|
domain_checker_target_a: std::net::Ipv4Addr,
|
||||||
|
|
||||||
#[arg(long, default_value_t = String::from("1.1.1.1:53"), env = "DOMIPLY_DOMAIN_CHECKER_RESOLVER_ADDR")]
|
#[arg(long, default_value_t = String::from("1.1.1.1:53"), env = "DOMIPLY_DOMAIN_CHECKER_RESOLVER_ADDR")]
|
||||||
domain_checker_resolver_addr: String,
|
domain_checker_resolver_addr: String,
|
||||||
@ -115,7 +115,7 @@ fn main() {
|
|||||||
|
|
||||||
let domain_checker = domiply::domain::checker::new(
|
let domain_checker = domiply::domain::checker::new(
|
||||||
tokio_runtime.clone(),
|
tokio_runtime.clone(),
|
||||||
config.domain_checker_target_aaaa,
|
config.domain_checker_target_a,
|
||||||
&config.domain_checker_resolver_addr,
|
&config.domain_checker_resolver_addr,
|
||||||
)
|
)
|
||||||
.expect("domain checker initialized");
|
.expect("domain checker initialized");
|
||||||
@ -128,9 +128,9 @@ fn main() {
|
|||||||
|
|
||||||
let service = domiply::service::new(
|
let service = domiply::service::new(
|
||||||
manager,
|
manager,
|
||||||
config.domain_checker_target_aaaa,
|
config.domain_checker_target_a,
|
||||||
config.passphrase,
|
config.passphrase,
|
||||||
config.http_domain,
|
config.http_domain.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let service = sync::Arc::new(service);
|
let service = sync::Arc::new(service);
|
||||||
@ -153,7 +153,7 @@ fn main() {
|
|||||||
tokio_runtime.spawn(async move {
|
tokio_runtime.spawn(async move {
|
||||||
let addr = config.http_listen_addr;
|
let addr = config.http_listen_addr;
|
||||||
|
|
||||||
println!("Listening on {addr}");
|
println!("Listening on http://{}:{}", config.http_domain, addr.port());
|
||||||
let server = hyper::Server::bind(&addr).serve(make_service);
|
let server = hyper::Server::bind(&addr).serve(make_service);
|
||||||
|
|
||||||
let graceful = server.with_graceful_shutdown(async {
|
let graceful = server.with_graceful_shutdown(async {
|
||||||
|
@ -17,7 +17,7 @@ type SvcResponse = Result<Response<hyper::body::Body>, String>;
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Service<'svc> {
|
pub struct Service<'svc> {
|
||||||
domain_manager: sync::Arc<dyn domain::manager::Manager>,
|
domain_manager: sync::Arc<dyn domain::manager::Manager>,
|
||||||
target_aaaa: net::Ipv6Addr,
|
target_a: net::Ipv4Addr,
|
||||||
passphrase: String,
|
passphrase: String,
|
||||||
http_domain: String,
|
http_domain: String,
|
||||||
handlebars: handlebars::Handlebars<'svc>,
|
handlebars: handlebars::Handlebars<'svc>,
|
||||||
@ -25,13 +25,13 @@ pub struct Service<'svc> {
|
|||||||
|
|
||||||
pub fn new<'svc, 'mgr>(
|
pub fn new<'svc, 'mgr>(
|
||||||
domain_manager: sync::Arc<dyn domain::manager::Manager>,
|
domain_manager: sync::Arc<dyn domain::manager::Manager>,
|
||||||
target_aaaa: net::Ipv6Addr,
|
target_a: net::Ipv4Addr,
|
||||||
passphrase: String,
|
passphrase: String,
|
||||||
http_domain: String,
|
http_domain: String,
|
||||||
) -> Service<'svc> {
|
) -> Service<'svc> {
|
||||||
Service {
|
Service {
|
||||||
domain_manager,
|
domain_manager,
|
||||||
target_aaaa,
|
target_a,
|
||||||
passphrase,
|
passphrase,
|
||||||
http_domain,
|
http_domain,
|
||||||
handlebars: self::http_tpl::get().expect("Retrieved Handlebars templates"),
|
handlebars: self::http_tpl::get().expect("Retrieved Handlebars templates"),
|
||||||
@ -202,7 +202,7 @@ impl<'svc> Service<'svc> {
|
|||||||
struct Response {
|
struct Response {
|
||||||
domain: domain::Name,
|
domain: domain::Name,
|
||||||
flat_config: util::FlatConfig,
|
flat_config: util::FlatConfig,
|
||||||
target_aaaa: net::Ipv6Addr,
|
target_a: net::Ipv4Addr,
|
||||||
challenge_token: String,
|
challenge_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ impl<'svc> Service<'svc> {
|
|||||||
&Response {
|
&Response {
|
||||||
domain: args.domain,
|
domain: args.domain,
|
||||||
flat_config: config.into(),
|
flat_config: config.into(),
|
||||||
target_aaaa: self.target_aaaa,
|
target_a: self.target_a,
|
||||||
challenge_token: config_hash,
|
challenge_token: config_hash,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -266,7 +266,7 @@ impl<'svc> Service<'svc> {
|
|||||||
Err(domain::manager::SyncWithConfigError::InvalidURL) => Some("Fetching the git repository failed, please double check that you input the correct URL.".to_string()),
|
Err(domain::manager::SyncWithConfigError::InvalidURL) => Some("Fetching the git repository failed, please double check that you input the correct URL.".to_string()),
|
||||||
Err(domain::manager::SyncWithConfigError::InvalidBranchName) => Some("The git repository does not have a branch of the given name, please double check that you input the correct name.".to_string()),
|
Err(domain::manager::SyncWithConfigError::InvalidBranchName) => Some("The git repository does not have a branch of the given name, please double check that you input the correct name.".to_string()),
|
||||||
Err(domain::manager::SyncWithConfigError::AlreadyInProgress) => Some("The configuration of your domain is still in progress, please refresh in a few minutes.".to_string()),
|
Err(domain::manager::SyncWithConfigError::AlreadyInProgress) => Some("The configuration of your domain is still in progress, please refresh in a few minutes.".to_string()),
|
||||||
Err(domain::manager::SyncWithConfigError::TargetAAAANotSet) => Some("The AAAA record is not set correctly on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
Err(domain::manager::SyncWithConfigError::TargetANotSet) => Some("The A record is not set correctly on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
||||||
Err(domain::manager::SyncWithConfigError::ChallengeTokenNotSet) => Some("The TXT record is not set correctly on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
Err(domain::manager::SyncWithConfigError::ChallengeTokenNotSet) => Some("The TXT record is not set correctly on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
||||||
Err(domain::manager::SyncWithConfigError::Unexpected(e)) => Some(format!("An unexpected error occurred: {e}")),
|
Err(domain::manager::SyncWithConfigError::Unexpected(e)) => Some(format!("An unexpected error occurred: {e}")),
|
||||||
};
|
};
|
||||||
|
@ -5,8 +5,8 @@ are two entries you will need to add:</p>
|
|||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
A <code>AAAA {{ data.domain }}</code> entry with the value
|
A <code>A {{ data.domain }}</code> entry with the value
|
||||||
<code>{{ data.target_aaaa }}</code>
|
<code>{{ data.target_a }}</code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
A <code>TXT _domiply_challenge.{{ data.domain }}</code> entry with the value
|
A <code>TXT _domiply_challenge.{{ data.domain }}</code> entry with the value
|
||||||
|
@ -47,7 +47,7 @@ the internet, the way it was always intended.</p>
|
|||||||
planned but not yet implemented:</p>
|
planned but not yet implemented:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Support for IPv4 and CNAME records</li>
|
<li>Support for AAAA and CNAME records</li>
|
||||||
<li>HTTPS support, with automatic certificate syncing via Let's Encrypt.</li>
|
<li>HTTPS support, with automatic certificate syncing via Let's Encrypt.</li>
|
||||||
<li>
|
<li>
|
||||||
Support for more backends than just git repositories, including:
|
Support for more backends than just git repositories, including:
|
||||||
|
Loading…
Reference in New Issue
Block a user