mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-06-25 03:12:57 +03:00
refactor(config): remove fake auth and fix reset button for new settings
This commit is contained in:
parent
887d57e668
commit
4cb0064678
@ -49,8 +49,6 @@ pub struct Config {
|
||||
pub hide_my_ip: bool,
|
||||
#[serde(default)]
|
||||
pub show_other_ip: bool,
|
||||
#[serde(default)]
|
||||
pub auth_enabled: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub chunked_enabled: bool,
|
||||
#[serde(default = "default_true")]
|
||||
@ -140,8 +138,6 @@ pub struct Args {
|
||||
#[arg(long)]
|
||||
pub show_other_ip: Option<bool>,
|
||||
#[arg(long)]
|
||||
pub auth_enabled: Option<bool>,
|
||||
#[arg(long)]
|
||||
pub remove_gui_shit: Option<bool>,
|
||||
#[arg(long)]
|
||||
pub chunked_enabled: Option<bool>,
|
||||
@ -192,9 +188,6 @@ impl Args {
|
||||
if let Some(v) = self.remove_gui_shit {
|
||||
config.remove_gui_shit = v
|
||||
}
|
||||
if let Some(v) = self.auth_enabled {
|
||||
config.auth_enabled = v
|
||||
}
|
||||
if let Some(v) = self.chunked_enabled {
|
||||
config.chunked_enabled = v
|
||||
}
|
||||
|
@ -186,8 +186,6 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
let hide_my_ip_entry = gui_checkbox_setting!("Hide My IP", hide_my_ip, ctx, settings_vbox);
|
||||
let show_other_ip_entry =
|
||||
gui_checkbox_setting!("Show Other IP", show_other_ip, ctx, settings_vbox);
|
||||
let auth_enabled_entry =
|
||||
gui_checkbox_setting!("Fake Auth Enabled", auth_enabled, ctx, settings_vbox);
|
||||
let chunked_enabled_entry =
|
||||
gui_checkbox_setting!("Chunked Enabled", chunked_enabled, ctx, settings_vbox);
|
||||
let formatting_enabled_entry =
|
||||
@ -236,8 +234,6 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
#[weak]
|
||||
show_other_ip_entry,
|
||||
#[weak]
|
||||
auth_enabled_entry,
|
||||
#[weak]
|
||||
chunked_enabled_entry,
|
||||
#[weak]
|
||||
formatting_enabled_entry,
|
||||
@ -315,7 +311,6 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
hide_my_ip: hide_my_ip_entry.is_active(),
|
||||
remove_gui_shit: remove_gui_shit_entry.is_active(),
|
||||
show_other_ip: show_other_ip_entry.is_active(),
|
||||
auth_enabled: auth_enabled_entry.is_active(),
|
||||
chunked_enabled: chunked_enabled_entry.is_active(),
|
||||
formatting_enabled: formatting_enabled_entry.is_active(),
|
||||
commands_enabled: commands_enabled_entry.is_active(),
|
||||
@ -359,8 +354,6 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
#[weak]
|
||||
show_other_ip_entry,
|
||||
#[weak]
|
||||
auth_enabled_entry,
|
||||
#[weak]
|
||||
chunked_enabled_entry,
|
||||
#[weak]
|
||||
formatting_enabled_entry,
|
||||
@ -370,6 +363,14 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
notifications_enabled_entry,
|
||||
#[weak]
|
||||
proxy_entry,
|
||||
#[weak]
|
||||
debug_logs_entry,
|
||||
#[weak]
|
||||
oof_update_time_entry,
|
||||
#[weak]
|
||||
konata_size_entry,
|
||||
#[weak]
|
||||
remove_gui_shit_entry,
|
||||
move |_| {
|
||||
let config = Config::default();
|
||||
ctx.set_config(&config);
|
||||
@ -382,11 +383,14 @@ fn open_settings(ctx: Arc<Context>, app: &Application) {
|
||||
max_messages_entry.set_text(&config.max_messages.to_string());
|
||||
hide_my_ip_entry.set_active(config.hide_my_ip);
|
||||
show_other_ip_entry.set_active(config.show_other_ip);
|
||||
auth_enabled_entry.set_active(config.auth_enabled);
|
||||
chunked_enabled_entry.set_active(config.chunked_enabled);
|
||||
formatting_enabled_entry.set_active(config.formatting_enabled);
|
||||
commands_enabled_entry.set_active(config.commands_enabled);
|
||||
notifications_enabled_entry.set_active(config.notifications_enabled);
|
||||
debug_logs_entry.set_active(config.debug_logs);
|
||||
oof_update_time_entry.set_text(&config.oof_update_time.to_string());
|
||||
konata_size_entry.set_text(&config.konata_size.to_string());
|
||||
remove_gui_shit_entry.set_active(config.remove_gui_shit);
|
||||
}
|
||||
));
|
||||
let window = Window::builder()
|
||||
|
@ -7,7 +7,7 @@ use std::{
|
||||
use crate::connect_rac;
|
||||
|
||||
use super::proto::{
|
||||
connect, read_messages, register_user, send_message, send_message_auth, send_message_spoof_auth,
|
||||
connect, read_messages, register_user, send_message, send_message_auth,
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
@ -242,8 +242,6 @@ pub fn on_send_message(ctx: Arc<Context>, message: &str) -> Result<(), Box<dyn E
|
||||
|
||||
if let Some(password) = ctx.registered.read().unwrap().clone() {
|
||||
send_message_auth(connect_rac!(ctx), &ctx.name(), &password, &message)?;
|
||||
} else if ctx.config(|o| o.auth_enabled) {
|
||||
send_message_spoof_auth(connect_rac!(ctx), &message)?;
|
||||
} else {
|
||||
send_message(connect_rac!(ctx), &message)?;
|
||||
}
|
||||
|
@ -192,35 +192,6 @@ pub fn connect(host: &str, proxy: Option<String>) -> Result<RacStream, Box<dyn E
|
||||
}
|
||||
}
|
||||
|
||||
/// Send message with fake auth
|
||||
///
|
||||
/// Explaination:
|
||||
///
|
||||
/// let (name, message) = message.split("> ") else { return send_message(stream, message) }
|
||||
/// if send_message_auth(name, name, message) != 0 {
|
||||
/// let name = "\x1f" + name
|
||||
/// register_user(stream, name, name)
|
||||
/// send_message_spoof_auth(stream, name + "> " + message)
|
||||
/// }
|
||||
pub fn send_message_spoof_auth(
|
||||
stream: &mut RacStream,
|
||||
message: &str,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let Some((name, message)) = message.split_once("> ") else {
|
||||
return send_message(stream, message);
|
||||
};
|
||||
|
||||
if let Ok(f) = send_message_auth(stream, &name, &name, &message) {
|
||||
if f != 0 {
|
||||
let name = format!("\x1f{name}");
|
||||
register_user(stream, &name, &name)?;
|
||||
send_message_spoof_auth(stream, &format!("{name}> {message}"))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Send message
|
||||
///
|
||||
/// stream - any stream that can be written to
|
||||
|
Loading…
x
Reference in New Issue
Block a user