Set full ntfy url in config instead of just topic

This commit is contained in:
Simon Fondrie-Teitler
2025-08-06 13:07:08 -04:00
parent 481f02f81f
commit 1c08708bc4
5 changed files with 24 additions and 30 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ pub struct Config {
pub ui_level: u8,
pub colorblind_mode: bool,
pub key_input_mode: u8,
pub ntfy_topic: Option<String>,
pub ntfy_url: Option<String>,
pub analyzers: AnalyzerConfig,
}
@@ -31,7 +31,7 @@ impl Default for Config {
colorblind_mode: false,
key_input_mode: 0,
analyzers: AnalyzerConfig::default(),
ntfy_topic: None,
ntfy_url: None,
}
}
}
+2 -2
View File
@@ -17,7 +17,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use crate::config::{parse_args, parse_config};
use crate::diag::run_diag_read_thread;
use crate::error::RayhunterError;
use crate::notifications::{run_notification_worker, NotificationService};
use crate::notifications::{NotificationService, run_notification_worker};
use crate::pcap::get_pcap;
use crate::qmdl_store::RecordingStore;
use crate::server::{ServerState, get_config, get_qmdl, get_zip, serve_static, set_config};
@@ -220,7 +220,7 @@ async fn run_with_config(
let mut maybe_ui_shutdown_tx = None;
let mut maybe_key_input_shutdown_tx = None;
let notification_service = NotificationService::new(config.ntfy_topic.clone());
let notification_service = NotificationService::new(config.ntfy_url.clone());
if !config.debug_mode {
let (ui_shutdown_tx, ui_shutdown_rx) = oneshot::channel();
+9 -16
View File
@@ -8,8 +8,6 @@ use log::error;
use tokio::sync::mpsc::{self, error::TryRecvError};
use tokio_util::task::TaskTracker;
static NTFY_BASE_URL: &str = "https://ntfy.sh/";
pub struct Notification {
message_type: String,
message: String,
@@ -35,19 +33,15 @@ struct NotificationStatus {
}
pub struct NotificationService {
channel_name: Option<String>,
url: Option<String>,
tx: mpsc::Sender<Notification>,
rx: mpsc::Receiver<Notification>,
}
impl NotificationService {
pub fn new(channel_name: Option<String>) -> Self {
pub fn new(url: Option<String>) -> Self {
let (tx, rx) = mpsc::channel(10);
Self {
channel_name,
tx,
rx,
}
Self { url, tx, rx }
}
pub fn new_handler(&self) -> mpsc::Sender<Notification> {
@@ -81,12 +75,11 @@ pub fn run_notification_worker(
failed_since_last_success: 0,
});
// Ignore if we're in the debounce period
if let Some(debounce) = notification.debounce {
if let Some(last_sent) = status.last_sent {
if last_sent.elapsed() < debounce {
continue;
}
}
if let Some(debounce) = notification.debounce
&& let Some(last_sent) = status.last_sent
&& last_sent.elapsed() < debounce
{
continue;
}
status.message = notification.message;
status.needs_sending = true;
@@ -117,7 +110,7 @@ pub fn run_notification_worker(
}
match http_client
.post(format!("{NTFY_BASE_URL}{channel_name}"))
.post(&url)
.body(notification.message.clone())
.send()
.await
@@ -112,16 +112,17 @@
</div>
<div>
<label for="ntfy_topic" class="block text-sm font-medium text-gray-700 mb-1">
ntfy Topic
</label>
<input
id="ntfy_topic"
bind:value={config.ntfy_topic}
<label for="ntfy_url" class="block text-sm font-medium text-gray-700 mb-1">
ntfy URL for Sending Notifications
</label>
<input
id="ntfy_url"
type="url"
bind:value={config.ntfy_url}
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-rayhunter-blue"
>
/>
</div>
<div class="space-y-3">
<div class="flex items-center">
<input
+2 -2
View File
@@ -22,8 +22,8 @@ ui_level = 1
# 1 = double-tapping the power button starts/stops recordings
key_input_mode = 0
# If set, attempts to send a notification to the ntify topic when a new warning is triggered
# ntfy_topic =
# If set, attempts to send a notification to the url when a new warning is triggered
# ntfy_url =
# Analyzer Configuration
# Enable/disable specific IMSI catcher detection heuristics