some fixes ok

This commit is contained in:
MeexReay 2025-04-17 23:54:44 +03:00
parent ebd8d15879
commit 5dd7dc0fdc
8 changed files with 63 additions and 421 deletions

255
Cargo.lock generated
View File

@ -62,7 +62,7 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -73,7 +73,7 @@ checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -94,8 +94,6 @@ version = "0.1.3+2.0"
dependencies = [
"chrono",
"clap",
"colored",
"crossterm",
"gtk4",
"homedir",
"lazy_static",
@ -238,24 +236,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "colored"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "convert_case"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb402b8d4c85569410425650ce3eddc7d698ed96d39a73f941b08fb63082f1e7"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "core-foundation"
version = "0.9.4"
@ -272,63 +252,6 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "crossterm"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
dependencies = [
"bitflags",
"crossterm_winapi",
"derive_more",
"document-features",
"mio",
"parking_lot",
"rustix 1.0.5",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]]
name = "crossterm_winapi"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
[[package]]
name = "derive_more"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "document-features"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d"
dependencies = [
"litrs",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -342,7 +265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -504,7 +427,7 @@ checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
dependencies = [
"cfg-if",
"libc",
"wasi 0.13.3+wasi-0.2.2",
"wasi",
"windows-targets",
]
@ -535,7 +458,7 @@ dependencies = [
"gobject-sys",
"libc",
"system-deps",
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -807,28 +730,6 @@ version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "linux-raw-sys"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
[[package]]
name = "litrs"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5"
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.25"
@ -850,18 +751,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "mio"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
dependencies = [
"libc",
"log",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.52.0",
]
[[package]]
name = "native-tls"
version = "0.2.14"
@ -974,29 +863,6 @@ dependencies = [
"system-deps",
]
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
@ -1081,15 +947,6 @@ dependencies = [
"zerocopy 0.8.17",
]
[[package]]
name = "redox_syscall"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.11.1"
@ -1137,21 +994,8 @@ dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
]
[[package]]
name = "rustix"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys 0.9.4",
"windows-sys 0.59.0",
"linux-raw-sys",
"windows-sys",
]
[[package]]
@ -1172,15 +1016,9 @@ version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d"
dependencies = [
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "security-framework"
version = "2.11.1"
@ -1260,36 +1098,6 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-mio"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd"
dependencies = [
"libc",
"mio",
"signal-hook",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]
[[package]]
name = "slab"
version = "0.4.9"
@ -1351,8 +1159,8 @@ dependencies = [
"fastrand",
"getrandom",
"once_cell",
"rustix 0.38.44",
"windows-sys 0.59.0",
"rustix",
"windows-sys",
]
[[package]]
@ -1395,12 +1203,6 @@ version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "utf8parse"
version = "0.2.2"
@ -1425,12 +1227,6 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasi"
version = "0.13.3+wasi-0.2.2"
@ -1504,28 +1300,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.57.0"
@ -1585,15 +1359,6 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"

View File

@ -6,21 +6,11 @@ edition = "2021"
[dependencies]
rand = "0.9.1"
regex = "1.11.1"
colored = "3.0.0"
lazy_static = "1.5.0"
serde_yml = "0.0.12"
homedir = "0.3.4"
native-tls = "0.2.14"
clap = { version = "4.5.36", features = ["derive"] }
serde = { version = "1.0.219", features = ["serde_derive"] }
serde_yml = "0.0.12"
crossterm = { version = "0.29.0", optional = true }
homedir = { version = "0.3.4", optional = true }
native-tls = { version = "0.2.14", optional = true }
gtk4 = { version = "0.9.6", optional = true, features = [ "v4_10" ] }
chrono = { version = "0.4.40", optional = true }
[features]
default = ["ssl", "homedir", "gtk_gui"]
tui = ["ssl", "homedir", "pretty_tui"]
ssl = ["dep:native-tls"]
pretty_tui = ["dep:crossterm"]
gtk_gui = ["dep:gtk4", "dep:chrono"]
homedir = ["dep:homedir"]
gtk4 = { version = "0.9.6", features = [ "v4_10" ] }
chrono = "0.4.40"

View File

@ -17,26 +17,6 @@
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
msrv = cargoToml.package.rust-version;
rustPackage = { version, features, deps }:
(pkgs.makeRustPlatform {
cargo = pkgs.rust-bin.stable.latest.minimal;
rustc = pkgs.rust-bin.stable.latest.minimal;
}).buildRustPackage {
inherit (cargoToml.package) name;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
version = lib.concatStrings [ cargoToml.package.version version ];
buildNoDefaultFeatures = true;
buildFeatures = features;
buildInputs = deps;
nativeBuildInputs = deps;
patchPhase = ''
substituteInPlace Cargo.toml --replace \
'version = "${cargoToml.package.version}"' \
'version = "${lib.concatStrings [ cargoToml.package.version version ]}"'
'';
};
mkDevShell = rustc:
pkgs.mkShell {
shellHook = ''
@ -54,26 +34,29 @@
packages.default = self'.packages.bRAC;
devShells.default = self'.devShells.stable;
packages.bRAC = (rustPackage {
version = "-gtk";
features = "ssl homedir gtk_gui";
deps = with pkgs; [
packages.bRAC = let
deps = [
pkg-config
openssl
gtk4
pango
];
});
packages.bRAC-tui = (rustPackage {
version = "";
features = "default";
deps = with pkgs; [ pkg-config openssl ];
});
packages.bRAC-minimal = (rustPackage {
version = "-minimal";
features = "";
deps = [];
});
in (pkgs.makeRustPlatform {
cargo = pkgs.rust-bin.stable.latest.minimal;
rustc = pkgs.rust-bin.stable.latest.minimal;
}).buildRustPackage {
inherit (cargoToml.package) name;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
version = lib.concatStrings [ cargoToml.package.version version ];
buildInputs = deps;
nativeBuildInputs = deps;
patchPhase = ''
substituteInPlace Cargo.toml --replace \
'version = "${cargoToml.package.version}"' \
'version = "${lib.concatStrings [ cargoToml.package.version version ]}"'
'';
};
devShells.nightly = (mkDevShell (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default)));
devShells.stable = (mkDevShell pkgs.rust-bin.stable.latest.default);

View File

@ -88,7 +88,7 @@ pub fn load_config(path: PathBuf) -> Config {
pub fn get_config_path() -> PathBuf {
let mut config_dir = PathBuf::from_str(".").unwrap();
#[cfg(all(feature = "homedir", not(target_os = "windows")))]
#[cfg(not(target_os = "windows"))]
if let Some(dir) = {
let home_dir = {
use homedir::my_home;

View File

@ -5,7 +5,6 @@ use std::error::Error;
use std::thread;
use chrono::Local;
use colored::{Color, Colorize};
use rand::Rng;
use gtk4::{
@ -20,7 +19,7 @@ use gtk4::{
use crate::proto::{connect, read_messages};
use super::{format_message, on_send_message, parse_message, set_chat, ChatStorage, ctx::Context};
use super::{on_send_message, parse_message, set_chat, ChatStorage, ctx::Context};
pub struct ChatContext {
pub messages: Arc<ChatStorage>,
@ -56,12 +55,6 @@ pub fn recv_tick(ctx: Arc<Context>) -> Result<(), Box<dyn Error>> {
ctx.enable_chunked
) {
Ok(Some((messages, size))) => {
let messages: Vec<String> = if ctx.disable_formatting {
messages
} else {
messages.into_iter().flat_map(|o| format_message(ctx.enable_ip_viewing, o)).collect()
};
if ctx.enable_chunked {
ctx.chat().messages.append_and_store(ctx.max_messages, messages.clone(), size);
for msg in messages {
@ -75,7 +68,7 @@ pub fn recv_tick(ctx: Arc<Context>) -> Result<(), Box<dyn Error>> {
}
},
Err(e) => {
let msg = format!("Read messages error: {}", e.to_string()).bright_red().to_string();
let msg = format!("Read messages error: {}", e.to_string()).to_string();
ctx.chat().messages.append(ctx.max_messages, vec![msg.clone()]);
add_chat_message(ctx.clone(), msg.clone());
}
@ -347,7 +340,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
));
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
let msg = format!("Send message error: {}", e.to_string()).bright_red().to_string();
let msg = format!("Send message error: {}", e.to_string()).to_string();
add_chat_message(ctx.clone(), msg);
}
}
@ -366,7 +359,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
));
if let Err(e) = on_send_message(ctx.clone(), &text_entry.text()) {
let msg = format!("Send message error: {}", e.to_string()).bright_red().to_string();
let msg = format!("Send message error: {}", e.to_string()).to_string();
add_chat_message(ctx.clone(), msg);
}
}
@ -437,7 +430,7 @@ fn setup(ctx: Arc<Context>, ui: UiModel) {
move || {
loop {
if let Err(e) = recv_tick(ctx.clone()) {
let _ = print_message(ctx.clone(), format!("Print messages error: {}", e.to_string()).bright_red().to_string());
let _ = print_message(ctx.clone(), format!("Print messages error: {}", e.to_string()).to_string());
thread::sleep(Duration::from_secs(1));
}
}
@ -528,26 +521,6 @@ fn on_add_message(ctx: Arc<Context>, ui: &UiModel, message: String) {
hbox.append(&date);
if let Some((name, color)) = nick {
let color = match color {
Color::Black => "black",
Color::Red => "red",
Color::Green => "green",
Color::Yellow => "yellow",
Color::Blue => "blue",
Color::Magenta => "magenta",
Color::Cyan => "cyan",
Color::White => "white",
Color::BrightBlack => "bright-black",
Color::BrightRed => "bright-red",
Color::BrightGreen => "bright-green",
Color::BrightYellow => "bright-yellow",
Color::BrightBlue => "bright-blue",
Color::BrightMagenta => "bright-magenta",
Color::BrightCyan => "bright-cyan",
Color::BrightWhite => "bright-white",
_ => "unknown"
};
let name = Label::builder()
.label(format!("<{name}>"))
.halign(Align::Start)

View File

@ -4,8 +4,6 @@ use std::{
time::{SystemTime, UNIX_EPOCH}
};
use colored::{Color, Colorize};
use crate::proto::{register_user, send_message_auth};
use super::{
@ -29,11 +27,11 @@ lazy_static! {
pub static ref DATE_REGEX: Regex = Regex::new(r"\[(.*?)\] (.*)").unwrap();
pub static ref IP_REGEX: Regex = Regex::new(r"\{(.*?)\} (.*)").unwrap();
pub static ref COLORED_USERNAMES: Vec<(Regex, Color)> = vec![
(Regex::new(r"\u{B9AC}\u{3E70}<(.*?)> (.*)").unwrap(), Color::Green), // bRAC
(Regex::new(r"\u{2550}\u{2550}\u{2550}<(.*?)> (.*)").unwrap(), Color::BrightRed), // CRAB
(Regex::new(r"\u{00B0}\u{0298}<(.*?)> (.*)").unwrap(), Color::Magenta), // Mefidroniy
(Regex::new(r"<(.*?)> (.*)").unwrap(), Color::Cyan), // clRAC
pub static ref COLORED_USERNAMES: Vec<(Regex, String)> = vec![
(Regex::new(r"\u{B9AC}\u{3E70}<(.*?)> (.*)").unwrap(), "green".to_string()), // bRAC
(Regex::new(r"\u{2550}\u{2550}\u{2550}<(.*?)> (.*)").unwrap(), "red".to_string()), // CRAB
(Regex::new(r"\u{00B0}\u{0298}<(.*?)> (.*)").unwrap(), "magenta".to_string()), // Mefidroniy
(Regex::new(r"<(.*?)> (.*)").unwrap(), "cyan".to_string()), // clRAC
];
}
@ -233,8 +231,8 @@ pub fn on_send_message(ctx: Arc<Context>, message: &str) -> Result<(), Box<dyn E
Ok(())
}
/// message -> (date, ip, text)
pub fn parse_message(message: String) -> Option<(String, Option<String>, String, Option<(String, Color)>)> {
/// message -> (date, ip, text, (name, color))
pub fn parse_message(message: String) -> Option<(String, Option<String>, String, Option<(String, String)>)> {
let message = sanitize_text(&message);
let message = message
@ -268,36 +266,8 @@ pub fn parse_message(message: String) -> Option<(String, Option<String>, String,
Some((date, ip, message, nick))
}
pub fn format_message(enable_ip_viewing: bool, message: String) -> Option<String> {
if let Some((date, ip, content, nick)) = parse_message(message.clone()) {
Some(format!(
"{} {}{}",
if enable_ip_viewing {
if let Some(ip) = ip {
format!("{}{} [{}]", ip, " ".repeat(if 15 >= ip.chars().count() {15-ip.chars().count()} else {0}), date)
} else {
format!("{} [{}]", " ".repeat(15), date)
}
} else {
format!("[{}]", date)
}.white().dimmed(),
nick.map(|(name, color)|
format!("<{}> ", name)
.color(color)
.bold()
.to_string()
).unwrap_or_default(),
content.white().blink()
))
} else if !message.is_empty() {
Some(message.bright_white().to_string())
} else {
None
}
}
// message -> (nick, content, color)
pub fn find_username_color(message: &str) -> Option<(String, String, Color)> {
pub fn find_username_color(message: &str) -> Option<(String, String, String)> {
for (re, color) in COLORED_USERNAMES.iter() {
if let Some(captures) = re.captures(message) {
return Some((captures[1].to_string(), captures[2].to_string(), color.clone()))

View File

@ -1,38 +1,3 @@
.message-content { color:rgb(0, 0, 0); }
.message-date { color:rgb(41, 41, 41); }
.message-ip { color:rgb(88, 88, 88); }
.send-button, .send-text { border-radius: 0; }
.calendar {
transform: scale(0.6);
margin: -35px;
}
.widget_box {
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.20);
border-bottom: 2px solid rgba(0, 0, 0, 0.20);
min-height: 121px;
}
.time {
font-size: 20px;
font-family: monospace;
font-weight: bold;
}
.message-name { font-weight: bold; }
.message-name-black { color: #2E2E2E; }
.message-name-bright-black { color: #555555; }
.message-name-red { color: #8B0000; }
.message-name-bright-red { color: #FF0000; }
.message-name-green { color: #006400; }
.message-name-bright-green { color: #00FF00; }
.message-name-yellow { color: #8B8B00; }
.message-name-bright-yellow { color: #FFFF00; }
.message-name-blue { color: #00008B; }
.message-name-bright-blue { color: #0000FF; }
.message-name-bright-magenta { color: #FF00FF; }
.message-name-magenta { color: #8B008B; }
.message-name-cyan { color: #008B8B; }
.message-name-bright-cyan { color: #00FFFF; }
.message-name-white { color: #A9A9A9; }
.message-name-bright-white { color: #FFFFFF; }

View File

@ -1,6 +1,7 @@
#![allow(unused)]
use std::{error::Error, fmt::Debug, io::{Read, Write}, net::TcpStream};
use native_tls::TlsConnector;
pub trait RacStream: Read + Write + Unpin + Send + Sync + Debug {}
impl<T: Read + Write + Unpin + Send + Sync + Debug> RacStream for T {}
@ -16,10 +17,6 @@ pub fn connect(host: &str, ssl: bool) -> Result<Box<dyn RacStream>, Box<dyn Erro
format!("{host}:42666")
};
#[cfg(feature = "ssl")]
{
use native_tls::TlsConnector;
if ssl {
let ip: String = host.split_once(":")
.map(|o| o.0.to_string())
@ -31,7 +28,6 @@ pub fn connect(host: &str, ssl: bool) -> Result<Box<dyn RacStream>, Box<dyn Erro
.build()?
.connect(&ip, connect(&host, false)?)?))
}
}
Ok(Box::new(TcpStream::connect(host)?))
}