mirror of
				https://gitea.farpn.net/w1cdn/mwtchahrd.git
				synced 2025-11-04 05:46:36 -06:00 
			
		
		
		
	Make simple GET request from Spothole.
This commit is contained in:
		
							
								
								
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -11,6 +11,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
 | 
			
		||||
use std::net::UdpSocket;
 | 
			
		||||
use std::net::Ipv4Addr;
 | 
			
		||||
use serde_json::json;
 | 
			
		||||
use reqwest;
 | 
			
		||||
 | 
			
		||||
/// Validate that the provided port string can be parsed into a u16 and is nonzero.
 | 
			
		||||
fn validate_port(port: &str) -> Result<u16, String> {
 | 
			
		||||
@@ -62,6 +63,11 @@ struct Cli {
 | 
			
		||||
    /// Spotter callsign (e.g. W1CDN)
 | 
			
		||||
    #[arg(short = 's', long)]
 | 
			
		||||
    spotter: Option<String>,
 | 
			
		||||
    
 | 
			
		||||
    /// Spot UI frames to Spothole
 | 
			
		||||
    #[arg(short = 'o', long, default_value_t = false)]
 | 
			
		||||
    spothole: bool,
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Convert a byte slice into a hex-dump string for debugging purposes.
 | 
			
		||||
@@ -399,6 +405,12 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
 | 
			
		||||
    if cli.ui_only && summary != "UI" {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // If Spothole is enabled
 | 
			
		||||
    if summary == "UI" && cli.spothole {
 | 
			
		||||
        let body = reqwest::blocking::get("https://spothole.app/api/v1/spots?limit=1");
 | 
			
		||||
        println!("body = {body:?}");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Send UDP
 | 
			
		||||
    if cli.uport != 55555 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user