mirror of
				https://gitea.farpn.net/w1cdn/mwtchahrd.git
				synced 2025-11-04 05:46:36 -06:00 
			
		
		
		
	Use alternative spothole URL if desired.
This commit is contained in:
		
							
								
								
									
										20
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -35,7 +35,7 @@ struct Cli {
 | 
			
		||||
    /// AGWPE server IP address (e.g. 127.0.0.1)
 | 
			
		||||
    #[arg(short = 'i', long)]
 | 
			
		||||
    ip: std::net::IpAddr,
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    /// AGWPE server TCP port (e.g. 8000)
 | 
			
		||||
    #[arg(short = 'p', long, value_parser = validate_port)]
 | 
			
		||||
    port: u16,
 | 
			
		||||
@@ -64,10 +64,14 @@ struct Cli {
 | 
			
		||||
    #[arg(short = 's', long)]
 | 
			
		||||
    spotter: Option<String>,
 | 
			
		||||
    
 | 
			
		||||
    /// Spot UI frames to Spothole
 | 
			
		||||
    /// Spot UI frames to a Spothole server
 | 
			
		||||
    #[arg(short = 'o', long, default_value_t = false)]
 | 
			
		||||
    spothole: bool,
 | 
			
		||||
    
 | 
			
		||||
    /// Provide a different URL than https://spothole.app/api/v1/spot
 | 
			
		||||
    #[arg(short = 'O', long)]
 | 
			
		||||
    spothole_alt: Option<String>,
 | 
			
		||||
    
 | 
			
		||||
    /// Spotting frequency
 | 
			
		||||
    #[arg(short = 'f', long, default_value_t = 14105000)]
 | 
			
		||||
    freq: u32,
 | 
			
		||||
@@ -374,6 +378,13 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
 | 
			
		||||
    let timestamp = Local::now().format("%H:%M:%S").to_string();
 | 
			
		||||
    let spotter = &cli.spotter;
 | 
			
		||||
    let freq = &cli.freq;
 | 
			
		||||
    //let spothole_alt = &cli.spothole_alt;
 | 
			
		||||
    
 | 
			
		||||
    // If user provides an alternate Spothole URL, use that one
 | 
			
		||||
    let spothole_url = match &cli.spothole_alt {
 | 
			
		||||
        Some(spothole_alt) => spothole_alt,
 | 
			
		||||
        None => &"https://spothole.app/api/v1/spot".to_string(),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // Filter and compute the text from the payload only once.
 | 
			
		||||
    let text = filter_text(&frame.payload);
 | 
			
		||||
@@ -417,6 +428,9 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
 | 
			
		||||
        //  --data '{"dx_call":"M0TRT","time":1760019539, "freq":14200000, 
 | 
			
		||||
        //  "comment":"Test spot please ignore", "de_call":"M0TRT"}' https://spothole.app/api/v1/spot
 | 
			
		||||
        
 | 
			
		||||
        println!("spothole_url: {}", spothole_url);
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        // POST JSON
 | 
			
		||||
        let packet = json!({
 | 
			
		||||
            "dx_call": &source,
 | 
			
		||||
@@ -429,7 +443,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
 | 
			
		||||
            "time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
 | 
			
		||||
        });
 | 
			
		||||
        let client = reqwest::blocking::Client::new();
 | 
			
		||||
        let res = client.post("https://spothole.app/api/v1/spot")
 | 
			
		||||
        let res = client.post(spothole_url)
 | 
			
		||||
            .json(&packet)
 | 
			
		||||
            .send();
 | 
			
		||||
        println!("res = {res:?}");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user