Compare commits

..

No commits in common. "main" and "1.0.0" have entirely different histories.
main ... 1.0.0

5 changed files with 12 additions and 37 deletions

View file

@ -137,7 +137,7 @@ jobs:
run: rm release_blobs/build.env
-
name: Release New Version
uses: actions/forgejo-release@v2
uses: actions/forgejo-release@v1
with:
direction: upload
url: https://forgejo.neshweb.net

2
Cargo.lock generated
View file

@ -460,7 +460,7 @@ dependencies = [
[[package]]
name = "domainlink"
version = "1.0.3"
version = "1.0.0"
dependencies = [
"actix-web",
"confy",

View file

@ -1,7 +1,7 @@
[package]
authors = ["Neshura"]
name = "domainlink"
version = "1.0.3"
version = "1.0.0"
edition = "2021"
description = "Lightweight tool for handling (sub-)domain to URL redirects instead of having to deal with copy and pasting proxy rules"
license = "GPL-3.0-or-later"

View file

@ -10,7 +10,7 @@ Any changes there will persist updates and supersede the default config. The Sys
#### User Configuration
DomainLink currently expects redirect files to be placed in any home directory, specifically `/home/{user}/.config/domainlink/domains.toml` or `/root/.config/domainlink/domains.toml`.
DomainLink currently expects redirect files to be placed in any home directory, specifically `/home/{user}/.config/domainlink/config.toml`.
Redirects are configured in an array, below is an example config.
```toml
[[domain_configs]]
@ -18,3 +18,4 @@ domains = ["sub.domain.tld", "sub2.domain.tld"]
target = "https://sub.domain.tld/query"
```
By default, DomainLink does not create any redirect rules, you will have to create these yourself.
Support for `/root/.config/domainlink/redirects` may come in the future.

View file

@ -146,7 +146,6 @@ impl Config {
let msg = format!("Using {}", path);
directories.push(system_path.to_path_buf());
info!(msg);
Self::check_for_duplicate_domains(&user_config.domain_configs);
Ok((Config {
user: user_config,
system: data,
@ -171,10 +170,8 @@ impl Config {
}
};
}
else {
let msg = format!("Using {config_path}/domains.toml");
info!(msg);
}
(data, Some(config_path))
},
Err(e) => {
@ -203,13 +200,16 @@ impl Config {
let root_metadata = fs::metadata(&root)?;
let uid = root_metadata.uid();
let gid = root_metadata.gid();
println!("uid: {uid}, gid: {gid}");
match paths.len() {
1 => {
let new_root = root.join(paths[0]);
println!("{}", &new_root.display());
unix::fs::chown(new_root, Some(uid), Some(gid))
},
_ => {
let new_root = root.join(paths[0]);
println!("{}", &new_root.display());
let ret = unix::fs::chown(&new_root, Some(uid), Some(gid));
let mut new_paths = paths.clone();
@ -224,32 +224,6 @@ impl Config {
}
}
}
fn check_for_duplicate_domains(domain_configs: &[DomainLinkConfig]) {
let mut checked_domains: Vec<String> = vec![];
for (cfg_idx, config) in domain_configs.iter().enumerate() {
for (idx, domain) in config.domains.iter().enumerate() {
if !checked_domains.contains(domain) {
if config.domains[idx+1..].contains(domain) {
// Error
let msg = format!("Duplicate Domain use detected for '{domain}");
warn!(msg);
checked_domains.push(domain.clone());
}
else {
for d in domain_configs[cfg_idx+1..].iter() {
if d.domains.contains(domain) {
let msg = format!("Duplicate Domain use detected for '{domain}");
warn!(msg);
checked_domains.push(domain.clone());
break;
}
}
}
}
}
}
}
}
#[actix_web::main]