mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-05-06 05:28:02 +03:00
rac urls and change nicks colors
This commit is contained in:
parent
091c1bca03
commit
fa75ca60c4
@ -408,7 +408,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
|||||||
|
|
||||||
let server_list = ListBox::new();
|
let server_list = ListBox::new();
|
||||||
|
|
||||||
for url in ["meex.lol:42666", "meex.lol:11234", "91.192.22.20:42666"] {
|
for url in ["rac://meex.lol", "rac://meex.lol:11234", "rac://91.192.22.20"] {
|
||||||
let url = url.to_string();
|
let url = url.to_string();
|
||||||
|
|
||||||
let label = Label::builder()
|
let label = Label::builder()
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
.message-name { font-weight: bold; }
|
.message-name { font-weight: bold; }
|
||||||
|
|
||||||
.message-name-green { color: #16a516; }
|
.message-name-green { color: #70fa7a; }
|
||||||
.message-name-red { color: #b91818; }
|
.message-name-red { color: #fa7070; }
|
||||||
.message-name-magenta { color: #b619b6; }
|
.message-name-magenta { color: #da70fa; }
|
||||||
.message-name-cyan { color: #19b1b1; }
|
.message-name-cyan { color: #70fadc; }
|
@ -53,6 +53,61 @@ pub fn parse_socks5_url(url: &str) -> Option<(String, Option<(String, String)>)>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// url -> (host, ssl, wrac) \
|
||||||
|
/// `127.0.0.1` -> `("127.0.0.1:42666", false, false)` \
|
||||||
|
/// `127.0.0.1:12345` -> `("127.0.0.1:12345", false, false)` \
|
||||||
|
/// `rac://127.0.0.1/` -> `("127.0.0.1:42666", false, false)` \
|
||||||
|
/// `racs://127.0.0.1/` -> `("127.0.0.1:42667", true, false)` \
|
||||||
|
/// `wrac://127.0.0.1/` -> `("127.0.0.1:52666", false, true)` \
|
||||||
|
/// `wracs://127.0.0.1/` -> `(127.0.0.1:52667, true, true)` \
|
||||||
|
pub fn parse_rac_url(url: &str) -> Option<(String, bool, bool)> {
|
||||||
|
let (scheme, url) = url.split_once("://").unwrap_or(("rac", url));
|
||||||
|
let (host, _) = url.split_once("/").unwrap_or((url, ""));
|
||||||
|
match scheme.to_lowercase().as_str() {
|
||||||
|
"rac" => {
|
||||||
|
Some((
|
||||||
|
if host.contains(":") {
|
||||||
|
host.to_string()
|
||||||
|
} else {
|
||||||
|
format!("{host}:42666")
|
||||||
|
},
|
||||||
|
false, false
|
||||||
|
))
|
||||||
|
},
|
||||||
|
"racs" => {
|
||||||
|
Some((
|
||||||
|
if host.contains(":") {
|
||||||
|
host.to_string()
|
||||||
|
} else {
|
||||||
|
format!("{host}:42667")
|
||||||
|
},
|
||||||
|
true, false
|
||||||
|
))
|
||||||
|
},
|
||||||
|
"wrac" => {
|
||||||
|
Some((
|
||||||
|
if host.contains(":") {
|
||||||
|
host.to_string()
|
||||||
|
} else {
|
||||||
|
format!("{host}:52666")
|
||||||
|
},
|
||||||
|
false, true
|
||||||
|
))
|
||||||
|
},
|
||||||
|
"wracs" => {
|
||||||
|
Some((
|
||||||
|
if host.contains(":") {
|
||||||
|
host.to_string()
|
||||||
|
} else {
|
||||||
|
format!("{host}:52667")
|
||||||
|
},
|
||||||
|
true, true
|
||||||
|
))
|
||||||
|
},
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create RAC connection (also you can just TcpStream::connect)
|
/// Create RAC connection (also you can just TcpStream::connect)
|
||||||
///
|
///
|
||||||
/// host - host string, example: "example.com:12345", "example.com" (default port is 42666)
|
/// host - host string, example: "example.com:12345", "example.com" (default port is 42666)
|
||||||
@ -60,11 +115,8 @@ pub fn parse_socks5_url(url: &str) -> Option<(String, Option<(String, String)>)>
|
|||||||
/// proxy - socks5 proxy (host, (user, pass))
|
/// proxy - socks5 proxy (host, (user, pass))
|
||||||
/// wrac - to use wrac protocol
|
/// wrac - to use wrac protocol
|
||||||
pub fn connect(host: &str, ssl: bool, proxy: Option<String>, wrac: bool) -> Result<RacStream, Box<dyn Error>> {
|
pub fn connect(host: &str, ssl: bool, proxy: Option<String>, wrac: bool) -> Result<RacStream, Box<dyn Error>> {
|
||||||
let host = if host.contains(":") {
|
let (host, ssl_, wrac_) = parse_rac_url(host).ok_or::<Box<dyn Error>>("url parse error".into())?;
|
||||||
host.to_string()
|
let (ssl, wrac) = (ssl_ || ssl, wrac_ || wrac);
|
||||||
} else {
|
|
||||||
format!("{host}:42666")
|
|
||||||
};
|
|
||||||
|
|
||||||
let stream: Box<dyn Stream> = if let Some(proxy) = proxy {
|
let stream: Box<dyn Stream> = if let Some(proxy) = proxy {
|
||||||
if let Some((proxy, auth)) = parse_socks5_url(&proxy) {
|
if let Some((proxy, auth)) = parse_socks5_url(&proxy) {
|
||||||
|
Loading…
Reference in New Issue
Block a user