1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Added bench.ps1, Made a CRL file not there yet revoke nothing for clients too

- bench.ps1 runs the benchmarks (push_rate, replication_rate,
  compare_with_old) in release mode: -Only, -Sync full|normal. Plan
  step 13 done, every step of the plan is.
- A CRL file named in client.toml that isn't there yet: nothing revoked
  (the tool, Python's from_file), as on the server, which now warns in
  its log. A path given to the DLL's SetCrl or Client(crl=...) stays a
  FileError. Decided in revamp.md, dropped from known-issues.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 10:36:59 +01:00
parent 34eb6f4600
commit 39ba7fce6c
18 changed files with 115 additions and 31 deletions
+2 -2
View File
@@ -288,8 +288,8 @@ pub unsafe extern "C" fn BakaShrot_SetPrivateKeyW(key: *const u16) -> isize {
}
/// Sets the CA's CRL, optional: servers it revokes are refused. PEM text,
/// or the path of a file holding it; null or empty for none. Before
/// connecting.
/// or the path of a file holding it (one that isn't there is a
/// `FileError`); null or empty for none. Before connecting.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn BakaShrot_SetCrlA(crl: *const c_char) -> isize {
unsafe { set::<Utf8>(crl.cast(), "CRL", true, |state| &mut state.crl) }
+3
View File
@@ -85,6 +85,9 @@ fn exports() {
BakaShrot_SetPrivateKeyA(a(&file("kitchen.key")).as_ptr()),
1
);
// A CRL file asked for is needed (client.toml's may be missing).
assert_eq!(BakaShrot_SetCrlW(w(&file("missing.crl")).as_ptr()), 0);
assert_eq!(error().0, code(ErrorCode::FileError));
assert_eq!(BakaShrot_SetCrlW(std::ptr::null()), 1);
assert_eq!(BakaShrot_ConnectW(localhost.as_ptr(), 0), 0);
assert_eq!(error().0, code(ErrorCode::InvalidArgument));
+1 -1
View File
@@ -74,7 +74,7 @@ pub struct Server {
pub certificate: PathBuf,
/// The server's key.
pub key: PathBuf,
/// The CA's CRL, watched; none: nothing revoked.
/// The CA's CRL, watched; none, or no such file: nothing revoked.
#[serde(default)]
pub crl: Option<PathBuf>,
/// The SQLite database; `bakashrot.sqlite` by default.
+7 -2
View File
@@ -294,11 +294,16 @@ fn read(path: &Path) -> Result<String, String> {
std::fs::read_to_string(path).map_err(|error| format!("{}: {error}", path.display()))
}
/// The CRL file's revocations; none without one (no file, or not set).
/// The CRL file's revocations; none without one (not set, or no file:
/// warned, a CRL deleted by mistake would revoke nothing silently).
fn load_revocations(path: Option<&Path>, ca: &str) -> Result<Revocations, String> {
let Some(path) = path.filter(|path| path.exists()) else {
let Some(path) = path else {
return Ok(Revocations::none());
};
if !path.exists() {
warn!("{}: no such file, nothing revoked", path.display());
return Ok(Revocations::none());
}
Revocations::load(&read(path)?, ca).map_err(|error| format!("{}: {error}", path.display()))
}
@@ -316,9 +316,11 @@ fn connect(config: &Path) -> Result<Client, String> {
let ca = pem("CA's certificate", &settings.ca)?;
let certificate = pem("certificate", &settings.certificate)?;
let key = pem("key", &settings.key)?;
// No CRL file yet: nothing revoked, as on the server.
let crl = settings
.crl
.as_deref()
.filter(|path| folder.join(path).exists())
.map(|path| pem("CRL", path))
.transpose()?;
let pems = Settings {
+5 -1
View File
@@ -550,7 +550,11 @@ fn settings() {
format!("{kitchen}crl = \"none.crl\"\n"),
)
.unwrap();
run(folder, "crl", &["list"], None).fails(1, "Can't read the CRL");
// No CRL file yet: nothing revoked. One that isn't a CRL is refused.
let none = run(folder, "crl", &["list", "topics"], None);
assert_eq!(none.ok().out, "Topics (0):\n");
fs::write(folder.join("none.crl"), "not a CRL").unwrap();
run(folder, "crl", &["list"], None).fails(1, "the CRL");
let closed = kitchen.replace(&server.port.to_string(), "1");
fs::write(folder.join("closed.toml"), closed).unwrap();
run(folder, "closed", &["list"], None)