Compare commits
No commits in common. "main" and "1.0.0" have entirely different histories.
5 changed files with 12 additions and 37 deletions
|
@ -137,7 +137,7 @@ jobs:
|
||||||
run: rm release_blobs/build.env
|
run: rm release_blobs/build.env
|
||||||
-
|
-
|
||||||
name: Release New Version
|
name: Release New Version
|
||||||
uses: actions/forgejo-release@v2
|
uses: actions/forgejo-release@v1
|
||||||
with:
|
with:
|
||||||
direction: upload
|
direction: upload
|
||||||
url: https://forgejo.neshweb.net
|
url: https://forgejo.neshweb.net
|
||||||
|
|
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -460,7 +460,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "domainlink"
|
name = "domainlink"
|
||||||
version = "1.0.3"
|
version = "1.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"confy",
|
"confy",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
authors = ["Neshura"]
|
authors = ["Neshura"]
|
||||||
name = "domainlink"
|
name = "domainlink"
|
||||||
version = "1.0.3"
|
version = "1.0.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Lightweight tool for handling (sub-)domain to URL redirects instead of having to deal with copy and pasting proxy rules"
|
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"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
|
@ -10,11 +10,12 @@ Any changes there will persist updates and supersede the default config. The Sys
|
||||||
|
|
||||||
#### User Configuration
|
#### 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.
|
Redirects are configured in an array, below is an example config.
|
||||||
```toml
|
```toml
|
||||||
[[domain_configs]]
|
[[domain_configs]]
|
||||||
domains = ["sub.domain.tld", "sub2.domain.tld"]
|
domains = ["sub.domain.tld", "sub2.domain.tld"]
|
||||||
target = "https://sub.domain.tld/query"
|
target = "https://sub.domain.tld/query"
|
||||||
```
|
```
|
||||||
By default, DomainLink does not create any redirect rules, you will have to create these yourself.
|
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.
|
38
src/main.rs
38
src/main.rs
|
@ -146,7 +146,6 @@ impl Config {
|
||||||
let msg = format!("Using {}", path);
|
let msg = format!("Using {}", path);
|
||||||
directories.push(system_path.to_path_buf());
|
directories.push(system_path.to_path_buf());
|
||||||
info!(msg);
|
info!(msg);
|
||||||
Self::check_for_duplicate_domains(&user_config.domain_configs);
|
|
||||||
Ok((Config {
|
Ok((Config {
|
||||||
user: user_config,
|
user: user_config,
|
||||||
system: data,
|
system: data,
|
||||||
|
@ -171,10 +170,8 @@ impl Config {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
let msg = format!("Using {config_path}/domains.toml");
|
||||||
let msg = format!("Using {config_path}/domains.toml");
|
info!(msg);
|
||||||
info!(msg);
|
|
||||||
}
|
|
||||||
(data, Some(config_path))
|
(data, Some(config_path))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -203,15 +200,18 @@ impl Config {
|
||||||
let root_metadata = fs::metadata(&root)?;
|
let root_metadata = fs::metadata(&root)?;
|
||||||
let uid = root_metadata.uid();
|
let uid = root_metadata.uid();
|
||||||
let gid = root_metadata.gid();
|
let gid = root_metadata.gid();
|
||||||
|
println!("uid: {uid}, gid: {gid}");
|
||||||
match paths.len() {
|
match paths.len() {
|
||||||
1 => {
|
1 => {
|
||||||
let new_root = root.join(paths[0]);
|
let new_root = root.join(paths[0]);
|
||||||
|
println!("{}", &new_root.display());
|
||||||
unix::fs::chown(new_root, Some(uid), Some(gid))
|
unix::fs::chown(new_root, Some(uid), Some(gid))
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let new_root = root.join(paths[0]);
|
let new_root = root.join(paths[0]);
|
||||||
|
println!("{}", &new_root.display());
|
||||||
let ret = unix::fs::chown(&new_root, Some(uid), Some(gid));
|
let ret = unix::fs::chown(&new_root, Some(uid), Some(gid));
|
||||||
|
|
||||||
let mut new_paths = paths.clone();
|
let mut new_paths = paths.clone();
|
||||||
new_paths.remove(0);
|
new_paths.remove(0);
|
||||||
match Self::fix_path_ownership(new_root, new_paths) {
|
match Self::fix_path_ownership(new_root, new_paths) {
|
||||||
|
@ -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]
|
#[actix_web::main]
|
||||||
|
|
Loading…
Reference in a new issue