Spaces:
Build error
Build error
Download src/meta_search/proxy.rs from LuckyMod/intentforge: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/LuckyMod/intentforge/resolve/main/src/meta_search/proxy.rs
- Command line
-
hf download hf://spaces/LuckyMod/intentforge/src/meta_search/proxy.rs
-
curl -L -o proxy.rs https://huggingface.co/spaces/LuckyMod/intentforge/resolve/main/src/meta_search/proxy.rs
1.17 kB
| use serde::{Deserialize, Serialize}; | |
| use std::time::Duration; | |
| pub enum ProxyProtocol { | |
| Http, | |
| Https, | |
| Socks4, | |
| Socks5, | |
| } | |
| pub struct Proxy { | |
| pub host: String, | |
| pub port: u16, | |
| pub protocol: ProxyProtocol, | |
| pub country: Option<String>, | |
| pub last_checked: Option<std::time::Instant>, | |
| pub latency: Option<Duration>, | |
| pub is_working: bool, | |
| } | |
| impl Proxy { | |
| pub fn new(host: String, port: u16, protocol: ProxyProtocol) -> Self { | |
| Self { | |
| host, | |
| port, | |
| protocol, | |
| country: None, | |
| last_checked: None, | |
| latency: None, | |
| is_working: false, | |
| } | |
| } | |
| pub fn to_url(&self) -> String { | |
| let proto = match self.protocol { | |
| ProxyProtocol::Http => "http", | |
| ProxyProtocol::Https => "https", | |
| ProxyProtocol::Socks4 => "socks4", | |
| ProxyProtocol::Socks5 => "socks5", | |
| }; | |
| format!("{}://{}:{}", proto, self.host, self.port) | |
| } | |
| } | |