feat: add build.rs pubkey embedding and webhook license/v1 endpoints

This commit is contained in:
2026-05-18 22:39:05 +08:00
parent ebb3da2ad6
commit 5d615dd393
3 changed files with 72 additions and 1 deletions
+10 -1
View File
@@ -11,11 +11,20 @@ fn main() {
hash_dir(&src_dir, &mut hasher);
let digest = hasher.finalize();
let hash_hex = format!("{:x}", digest);
println!("cargo:rustc-env=BUILD_SRC_HASH={}", hash_hex);
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
fs::write(out_dir.join("build_hash.txt"), format!("{}\n", hash_hex)).unwrap();
// 嵌入 RSA 公钥(用于 selfhosted 验签)
let pubkey_path = PathBuf::from(&manifest_dir).join("embedded").join("pubkey.pem");
if let Ok(pubkey) = fs::read_to_string(&pubkey_path) {
let trimmed = pubkey.trim();
if !trimmed.is_empty() {
println!("cargo:rustc-env=CRAFTLABS_SELFHOSTED_PUBKEY={}", trimmed);
}
}
println!("cargo:rerun-if-changed=embedded/pubkey.pem");
}
fn hash_dir(dir: &PathBuf, hasher: &mut Sha256) {