diff --git a/src/app/panels/middle/xmrig.rs b/src/app/panels/middle/xmrig.rs index 6c7c183..a5cb278 100644 --- a/src/app/panels/middle/xmrig.rs +++ b/src/app/panels/middle/xmrig.rs @@ -158,6 +158,7 @@ impl Xmrig { ui.vertical(|ui| { self.api_ip_field(ui); self.api_port_field(ui); + self.api_token_field(ui); }); ui.separator(); debug!("XMRig Tab | Rendering [TLS/Keepalive] buttons"); @@ -190,7 +191,7 @@ impl Xmrig { } fn name_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" Name ") + .description(" Name ") .max_ch(30) .help_msg(XMRIG_NAME) .validations(&[|x| REGEXES.name.is_match(x)]) @@ -198,7 +199,7 @@ impl Xmrig { } fn rpc_port_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" RPC PORT ") + .description(" RPC PORT ") .max_ch(5) .help_msg(XMRIG_PORT) .validations(&[|x| REGEXES.port.is_match(x)]) @@ -206,7 +207,7 @@ impl Xmrig { } fn ip_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" IP ") + .description(" IP ") .max_ch(255) .help_msg(XMRIG_IP) .validations(&[|x| REGEXES.ipv4.is_match(x) || REGEXES.domain.is_match(x)]) @@ -214,14 +215,14 @@ impl Xmrig { } fn rig_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" RIG ID ") + .description(" RIG ID ") .max_ch(30) .help_msg(XMRIG_RIG) .build(ui, &mut self.rig) } fn api_ip_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" API IP ") + .description(" API IP ") .max_ch(255) .help_msg(XMRIG_API_IP) .validations(&[|x| REGEXES.ipv4.is_match(x) || REGEXES.domain.is_match(x)]) @@ -229,10 +230,17 @@ impl Xmrig { } fn api_port_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" API PORT ") + .description(" API PORT ") .max_ch(5) .help_msg(XMRIG_API_PORT) .validations(&[|x| REGEXES.port.is_match(x)]) .build(ui, &mut self.api_port) } + fn api_token_field(&mut self, ui: &mut Ui) -> bool { + StateTextEdit::new(ui) + .description(" API TOKEN ") + .max_ch(255) + .help_msg(XMRIG_API_TOKEN) + .build(ui, &mut self.token) + } } diff --git a/src/app/panels/middle/xmrig_proxy.rs b/src/app/panels/middle/xmrig_proxy.rs index 3cf9a8c..9094e64 100644 --- a/src/app/panels/middle/xmrig_proxy.rs +++ b/src/app/panels/middle/xmrig_proxy.rs @@ -34,6 +34,7 @@ use crate::{ XMRIG_TLS, }; +use super::XMRIG_API_TOKEN; use super::common::list_poolnode::PoolNode; use super::common::state_edit_field::StateTextEdit; @@ -155,6 +156,7 @@ impl XmrigProxy { // HTTP API self.api_ip_field(ui); self.api_port_field(ui); + self.api_token_field(ui); }); ui.separator(); @@ -188,7 +190,7 @@ impl XmrigProxy { } fn name_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" Name ") + .description(" Name ") .max_ch(30) .help_msg(XMRIG_NAME) .validations(&[|x| REGEXES.name.is_match(x)]) @@ -196,7 +198,7 @@ impl XmrigProxy { } fn rpc_port_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" RPC PORT ") + .description(" RPC PORT ") .max_ch(5) .help_msg(XMRIG_PORT) .validations(&[|x| REGEXES.port.is_match(x)]) @@ -204,7 +206,7 @@ impl XmrigProxy { } fn ip_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" IP ") + .description(" IP ") .max_ch(255) .help_msg(XMRIG_IP) .validations(&[|x| REGEXES.ipv4.is_match(x) || REGEXES.domain.is_match(x)]) @@ -212,14 +214,14 @@ impl XmrigProxy { } fn rig_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" RIG ID ") + .description(" RIG ID ") .max_ch(30) .help_msg(XMRIG_RIG) .build(ui, &mut self.rig) } fn api_ip_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" API IP ") + .description(" API IP ") .max_ch(255) .help_msg(XMRIG_API_IP) .validations(&[|x| REGEXES.ipv4.is_match(x) || REGEXES.domain.is_match(x)]) @@ -227,10 +229,17 @@ impl XmrigProxy { } fn api_port_field(&mut self, ui: &mut Ui) -> bool { StateTextEdit::new(ui) - .description(" API PORT ") + .description(" API PORT ") .max_ch(5) .help_msg(XMRIG_API_PORT) .validations(&[|x| REGEXES.port.is_match(x)]) .build(ui, &mut self.api_port) } + fn api_token_field(&mut self, ui: &mut Ui) -> bool { + StateTextEdit::new(ui) + .description(" API TOKEN ") + .max_ch(255) + .help_msg(XMRIG_API_TOKEN) + .build(ui, &mut self.token) + } } diff --git a/src/utils/constants.rs b/src/utils/constants.rs index a2a5a3c..8c56dda 100644 --- a/src/utils/constants.rs +++ b/src/utils/constants.rs @@ -508,6 +508,7 @@ pub const XMRIG_API_IP: &str = "Specify which IP to bind to for XMRig's HTTP API; If empty: [localhost/127.0.0.1]"; pub const XMRIG_API_PORT: &str = "Specify which port to bind to for XMRig's HTTP API; If empty: [18088]"; +pub const XMRIG_API_TOKEN: &str = "Specify the token to authenticate on the HTTP API"; pub const XMRIG_TLS: &str = "Enable SSL/TLS connections (needs pool support)"; pub const XMRIG_KEEPALIVE: &str = "Send keepalive packets to prevent timeout (needs pool support)"; pub const XMRIG_THREADS: &str = "Number of CPU threads to use for mining";