mirror of https://github.com/dnomd343/ClearDNS
Dnomd343
2 years ago
4 changed files with 1270 additions and 0 deletions
File diff suppressed because it is too large
@ -0,0 +1,12 @@ |
|||||
|
[package] |
||||
|
name = "assets" |
||||
|
version = "0.1.0" |
||||
|
edition = "2021" |
||||
|
|
||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||
|
|
||||
|
[dependencies] |
||||
|
env_logger = "0.10.0" |
||||
|
log = "0.4.17" |
||||
|
reqwest = { version = "0.11.14", features = ["blocking", "deflate", "gzip", "brotli"] } |
||||
|
tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] } |
@ -0,0 +1,51 @@ |
|||||
|
use reqwest::Client; |
||||
|
use std::env::set_var; |
||||
|
use std::time::Duration; |
||||
|
|
||||
|
const TIMEOUT: u64 = 60; |
||||
|
|
||||
|
async fn asset_fetch(url: &str) -> Result<String, String> { |
||||
|
let client = Client::builder() |
||||
|
.timeout(Duration::from_secs(TIMEOUT)) |
||||
|
.build().unwrap(); |
||||
|
match client.get(url).send().await { |
||||
|
Ok(response) => { |
||||
|
match response.text().await { |
||||
|
Ok(text) => { |
||||
|
Ok(text) |
||||
|
}, |
||||
|
Err(err) => Err(format!("http content error: {}", err)) |
||||
|
} |
||||
|
}, |
||||
|
Err(err) => Err(format!("http request failed: {}", err)) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
async fn demo() { |
||||
|
|
||||
|
println!("demo function start"); |
||||
|
|
||||
|
match asset_fetch("https://res.343.re/Share/cleardns/gfwlist.txt").await { |
||||
|
Ok(data) => { |
||||
|
// println!("{}", data);
|
||||
|
}, |
||||
|
Err(err) => println!("error -> {}", err) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
println!("demo function exit"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#[tokio::main] |
||||
|
async fn main() { |
||||
|
|
||||
|
// set_var("RUST_LOG", "debug");
|
||||
|
set_var("RUST_LOG", "trace"); |
||||
|
env_logger::init(); |
||||
|
|
||||
|
demo().await; |
||||
|
|
||||
|
println!("end demo"); |
||||
|
|
||||
|
} |
Loading…
Reference in new issue