1
0
forked from n6cta/baecun

4 Commits
v0.1.0 ... udp

Author SHA1 Message Date
mattbk
c96a0116c7 Send simple UDP stuff. 2025-09-27 10:03:59 -05:00
fe425d839a Update README.md 2025-03-01 09:35:15 +00:00
309fd239f9 etc 2025-03-01 01:00:18 -08:00
0e5ef84203 Fixed readme formatting errors 2025-03-01 00:58:41 -08:00
2 changed files with 21 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# baecun
baecun is a Rust-based command-line tool that constructs and sends specially formatted frames to an AGWPE server over TCP. It supports unproto frames with and without digipeaters and provides some validation for IP addresses, ports, callsigns, and channel numbers. This tool was written as an exercise to both learn and be able to teach the building blocks of both rust idomatic programming and writing a simple unproto AGWPE TX client.
baecun is a Rust-based command-line tool that constructs and sends specially formatted frames to an AGWPE server over TCP. It supports unproto frames with and without digipeaters and provides some validation for IP addresses, ports, callsigns, and channel numbers. This tool was written as an exercise to both learn and be able to teach the building blocks of both Rust idomatic programming and writing a simple unproto AGWPE TX client.
## Features
@@ -24,7 +24,7 @@ Sends the constructed frame to the AGWPE server over a TCP connection.
## Prerequisites
- Rusthttps://www.rust-lang.org/tools/install (version 1.XX or later)
- Rust https://www.rust-lang.org/tools/install (version 1.XX or later)
- Cargo package manager (included with Rust)
## Installation
@@ -49,14 +49,14 @@ The compiled executable will be located in the `target/release` directory.
Run the executable with the required arguments:
```bash
baecun -i <IP_ADDRESS> -p -f <FROM_CALL> -t <TO_CALL> -m \"<MESSAGE>\" [OPTIONS]
baecun -i <IP_ADDRESS> -p -f <FROM_CALL> -t <TO_CALL> -m <MESSAGE> [OPTIONS]
```
### Command-Line Arguments
- `-i, ip <IP_ADDRESS>`
The IP address of the AGWPE server.
Example: `192.168.1.100`
Example: `127.0.0.1`
- `-p, port `
The port number of the AGWPE server (must be greater than 0).

View File

@@ -1,6 +1,7 @@
use clap::{Parser, ArgGroup};
use std::io::{self, Read, Write};
use std::net::{IpAddr, TcpStream};
use std::net::UdpSocket;
/// Validate IP address.
fn validate_ip(ip: &str) -> Result<IpAddr, String> {
@@ -108,8 +109,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
// Send the frame.
send_frame(&frame, &cli.ip.to_string(), cli.port)?;
//send_frame(&frame, &cli.ip.to_string(), cli.port)?;
//Ok(())
// Bind a UDP socket to an address; here, "0.0.0.0:0" finds a free port automatically
let socket = UdpSocket::bind("0.0.0.0:0")?;
// Define the target address and port
let target_address = "report.pskreporter.info:14739";
// Send the message
socket.send_to(&frame, target_address)?;
println!("Message sent successfully.");
Ok(())
}
/// Build 'M' frame (unproto without digipeaters).
@@ -175,3 +189,4 @@ fn send_frame(frame: &[u8], host: &str, port: u16) -> io::Result<()> {
stream.write_all(frame)?;
Ok(())
}