mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 11:25:56 +00:00
v0.1.5: CoA.AllowRemoteClients = 1 by default for Manager-installed servers; translations of settings, diagnostics and more
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38b5b86be1
commit
b03bc6de28
6 files changed
+24
-13
No files matched your search
@@ -138,6 +138,17 @@ pub fn materialize_module_configs(root: &Path) -> Result<Vec<String>> {
|
||||
let active = dir.join(format!("{stem}.conf"));
|
||||
if !active.exists() {
|
||||
fs::copy(e.path(), &active)?;
|
||||
if stem == "coa" {
|
||||
// This product serves the CoA client only, and the servers listen on this computer unless the owner
|
||||
// shares them; without this key the server drops CoA clients that connect from another address
|
||||
// (friends over a private network) right after login.
|
||||
if let Ok(bytes) = fs::read(&active) {
|
||||
if let Ok(mut conf) = parser::ConfFile::parse_bytes(&bytes) {
|
||||
conf.set("CoA.AllowRemoteClients", "1", &["Set by CoA Server Manager: this server is built for CoA clients"]);
|
||||
fsx::atomic_write(&active, conf.to_text().as_bytes())?;
|
||||
}
|
||||
}
|
||||
}
|
||||
created.push(format!("{stem}.conf"));
|
||||
} else if let (Ok(have), Ok(dist)) = (fs::read(&active), fs::read(e.path())) {
|
||||
if let (Ok(mut conf), Ok(dist)) = (parser::ConfFile::parse_bytes(&have), parser::ConfFile::parse_bytes(&dist)) {
|
||||
@@ -512,8 +523,8 @@ Spellbook.New = 5
|
||||
fs::write(m.join("coa_bugreport.conf.dist"), "x = 1
|
||||
").unwrap();
|
||||
assert_eq!(materialize_module_configs(&root).unwrap(), vec!["coa.conf".to_string(), "spellbook.conf (+1 keys)".to_string()]);
|
||||
assert_eq!(fs::read_to_string(m.join("coa.conf")).unwrap(), "CoA.Enable = 1
|
||||
");
|
||||
let coa = fs::read_to_string(m.join("coa.conf")).unwrap();
|
||||
assert!(coa.contains("CoA.Enable = 1") && coa.contains("CoA.AllowRemoteClients = 1"), "{coa}");
|
||||
let sb = fs::read_to_string(m.join("spellbook.conf")).unwrap();
|
||||
assert!(sb.contains("Spellbook.Enable = 0"), "existing values are never changed: {sb}");
|
||||
assert!(sb.contains("Spellbook.New = 5"), "new documented key was added: {sb}");
|
||||
|
||||
@@ -94,9 +94,9 @@ pub fn set_open(root: &Path, meta: &Path, open: bool) -> Result<bool> {
|
||||
let coa_conf = root.join("Core/configs/modules/coa.conf");
|
||||
if let Ok(bytes) = fs::read(&coa_conf) {
|
||||
let mut conf = ConfFile::parse_bytes(&bytes)?;
|
||||
let want_remote = if open { "1" } else { "0" };
|
||||
if conf.get("CoA.AllowRemoteClients").map(str::trim) != Some(want_remote) {
|
||||
conf.set("CoA.AllowRemoteClients", want_remote, &["Set by CoA Server Manager together with the friends mode"]);
|
||||
// Opening turns it on; closing leaves it alone (it only matters while the servers listen beyond this computer).
|
||||
if open && conf.get("CoA.AllowRemoteClients").map(str::trim) != Some("1") {
|
||||
conf.set("CoA.AllowRemoteClients", "1", &["Set by CoA Server Manager together with the friends mode"]);
|
||||
originals.push((coa_conf.clone(), bytes));
|
||||
edits.push((coa_conf, conf.to_text()));
|
||||
}
|
||||
@@ -213,7 +213,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sharing_also_allows_remote_coa_clients_and_closing_takes_it_back() {
|
||||
fn sharing_also_allows_remote_coa_clients_and_closing_leaves_it() {
|
||||
let (_d, root, meta) = setup();
|
||||
let coa = root.join("Core/configs/modules/coa.conf");
|
||||
fs::create_dir_all(coa.parent().unwrap()).unwrap();
|
||||
@@ -224,7 +224,7 @@ CoA.AllowRemoteClients = 0
|
||||
assert!(fs::read_to_string(&coa).unwrap().contains("CoA.AllowRemoteClients = 1"));
|
||||
assert!(fs::read_to_string(&coa).unwrap().contains("CoA.Enable = 1"));
|
||||
assert!(set_open(&root, &meta, false).unwrap());
|
||||
assert!(fs::read_to_string(&coa).unwrap().contains("CoA.AllowRemoteClients = 0"));
|
||||
assert!(fs::read_to_string(&coa).unwrap().contains("CoA.AllowRemoteClients = 1"), "closing only changes BindIP");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user