-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy pathbuild.rs
More file actions
73 lines (59 loc) · 2.25 KB
/
Copy pathbuild.rs
File metadata and controls
73 lines (59 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use std::fs;
use std::path::Path;
fn main() {
// Compile protobuf files for RustDesk protocol
compile_protos();
// Generate minimal secrets module
generate_secrets();
// Rerun if the script itself changes
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=protos/rendezvous.proto");
println!("cargo:rerun-if-changed=protos/message.proto");
}
/// Compile protobuf files using protobuf-codegen (same as RustDesk server)
fn compile_protos() {
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
let protos_dir = out_dir.join("protos");
std::fs::create_dir_all(&protos_dir).unwrap();
protobuf_codegen::Codegen::new()
.pure()
.out_dir(&protos_dir)
.inputs(["protos/rendezvous.proto", "protos/message.proto"])
.include("protos")
.customize(protobuf_codegen::Customize::default().tokio_bytes(true))
.run()
.expect("Failed to compile protobuf files");
// Generate mod.rs for the protos module
let mod_content = r#"pub mod rendezvous;
pub mod message;
"#;
std::fs::write(protos_dir.join("mod.rs"), mod_content).unwrap();
}
/// Generate minimal secrets module with Google STUN server hardcoded
fn generate_secrets() {
let out_dir = std::env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("secrets_generated.rs");
// Generate the secrets module - no public servers provided
let code = r#"// Auto-generated secrets module
// DO NOT EDIT - This file is generated by build.rs
/// ICE server configuration (for WebRTC NAT traversal)
pub mod ice {
/// Google public STUN server URL (hardcoded)
pub const STUN_SERVER: &str = "stun:stun.l.google.com:19302";
}
/// RustDesk public server configuration - NOT PROVIDED
pub mod rustdesk {
/// Public RustDesk ID server - NOT PROVIDED
pub const PUBLIC_SERVER: &str = "";
/// Public key for the RustDesk server - NOT PROVIDED
pub const PUBLIC_KEY: &str = "";
/// Relay server authentication key - NOT PROVIDED
pub const RELAY_KEY: &str = "";
/// Always returns false
pub const fn has_public_server() -> bool {
false
}
}
"#;
fs::write(&dest_path, code).expect("Failed to write secrets_generated.rs");
}