mirror of
https://gitea.farpn.net/w1cdn/mwtchahrd.git
synced 2025-12-10 06:28:02 -06:00
Compare commits
23 Commits
spothole
...
ca858bc038
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca858bc038 | ||
|
|
fd641c1ca1 | ||
|
|
05a6bb18b0 | ||
|
|
85521543c6 | ||
|
|
6bbfa66c4f | ||
|
|
d95cf3e368 | ||
|
|
20fda492a5 | ||
|
|
97e955156d | ||
|
|
c60723b0a5 | ||
|
|
780c4b5884 | ||
|
|
07c57e85a8 | ||
|
|
875da10174 | ||
|
|
7ce55f020b | ||
|
|
21499a93d9 | ||
|
|
268a79acda | ||
|
|
ad5f2ccd0d | ||
|
|
8af43a54bb | ||
|
|
d20188e152 | ||
|
|
b6b627ef65 | ||
|
|
863657f61f | ||
|
|
f1d0f6dc31 | ||
|
|
d353b1b055 | ||
|
|
f452e72ef9 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,7 +6,7 @@ target/
|
|||||||
|
|
||||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
Cargo.lock
|
#Cargo.lock
|
||||||
|
|
||||||
#Cross config
|
#Cross config
|
||||||
Cross.toml
|
Cross.toml
|
||||||
|
|||||||
1882
Cargo.lock
generated
Normal file
1882
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,21 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mwtchahrd"
|
name = "mwtchahrd"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Chris, N6CTA <mail@n6cta.com>"]
|
authors = ["Chris, N6CTA <mail@n6cta.com>", "Matt, W1CDN <admin@w1cdn.net>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
|
openssl-sys = "0.9.111"
|
||||||
|
openssl = { version = "0.10", features = ["vendored"] }
|
||||||
|
rand = "0.9.2"
|
||||||
|
regex = "1.12.2"
|
||||||
reqwest = { version = "0.12.24", features = ["json", "blocking"] }
|
reqwest = { version = "0.12.24", features = ["json", "blocking"] }
|
||||||
serde_json = "1.0.145"
|
serde_json = "1.0.145"
|
||||||
socket2 = "0.5"
|
socket2 = "0.5"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
|
|
||||||
|
|||||||
11
Cross.toml
11
Cross.toml
@@ -1,11 +0,0 @@
|
|||||||
[target.aarch64-unknown-linux-gnu]
|
|
||||||
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge@sha256:168fa652629cedcd9549e85258be8f83fa008625b187c004d6ea439cf16f6a41"
|
|
||||||
|
|
||||||
[target.x86_64-unknown-linux-gnu]
|
|
||||||
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:edge@sha256:3542b427c3f7d0d2976d7add025c5ba997499411f408b3b26803ccc70fc431da"
|
|
||||||
|
|
||||||
[target.armv7-unknown-linux-gnueabihf]
|
|
||||||
image = "ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:edge@sha256:3e1def581eb9c9f11cfff85745802f2de5cf9cdeeb5a8495048f393a0993b99b"
|
|
||||||
|
|
||||||
[target.arm-unknown-linux-gnueabihf]
|
|
||||||
image = "ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:edge@sha256:28e7aaae8301506f4f1b3394c8bc23f958d1717043e06f816045e7b8df57e173"
|
|
||||||
13
README.md
13
README.md
@@ -74,6 +74,15 @@ mwtchahrd -i <IP> -p <PORT> [-c <CHANNEL>] [-d] [-u]
|
|||||||
|
|
||||||
- `-f, --freq <FREQ>`
|
- `-f, --freq <FREQ>`
|
||||||
Spotting frequency [default: 14105000].
|
Spotting frequency [default: 14105000].
|
||||||
|
|
||||||
|
- `-y, --my-lat <MY_LAT>`
|
||||||
|
Spotter latitude, DD.dddd.
|
||||||
|
|
||||||
|
- `-x, --my-lon <MY_LON>`
|
||||||
|
Spotter longitude, DD.dddd.
|
||||||
|
|
||||||
|
- `-t, --filter <CALL-SSID,CALL-SSID,...>`
|
||||||
|
Filter out spots from these callsign-UUID combinations (self spots, for example), comma-separated. This is not regex, just full matches.
|
||||||
|
|
||||||
- `-h, --help`
|
- `-h, --help`
|
||||||
Print help.
|
Print help.
|
||||||
@@ -109,10 +118,10 @@ mwtchahrd -i 127.0.0.1 -p 8000 -u
|
|||||||
|
|
||||||
### Spotting to [Spothole.app](https://spothole.app) API
|
### Spotting to [Spothole.app](https://spothole.app) API
|
||||||
|
|
||||||
Sends only UI frames and mode is hardcoded as `PKT`. Spot from callsign `W1CDN` and report fixed frequency 14.105 MHz:
|
Sends only UI frames and mode is hardcoded as `PKT`. Spot from callsign `W1CDN` and report fixed frequency 14.105 MHz. Report your location as spotter and don't spot your own beacons.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mwtchahrd --ip 192.168.0.6 --port 8000 --spotter W1CDN --spothole --freq 14105000
|
mwtchahrd --ip 192.168.0.6 --port 8000 --spotter W1CDN --spothole --freq 14105000 --my-lat 47.01 --my-lon -97.01 --filter W1CDN-1,W1CDN-7
|
||||||
```
|
```
|
||||||
|
|
||||||
## Code Overview
|
## Code Overview
|
||||||
|
|||||||
7
auto-build-release.sh
Executable file
7
auto-build-release.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
echo "Building release for multiple targets";
|
||||||
|
cargo build --release;
|
||||||
|
cross build --release --target=aarch64-unknown-linux-gnu;
|
||||||
|
cross build --release --target=x86_64-unknown-linux-gnu;
|
||||||
|
cross build --release --target=armv7-unknown-linux-gnueabihf;
|
||||||
|
cross build --release --target=arm-unknown-linux-gnueabihf;
|
||||||
|
cross build --release --target=x86_64-pc-windows-gnu;
|
||||||
7
auto-build.sh
Executable file
7
auto-build.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
echo "Building dev for multiple targets";
|
||||||
|
cargo build;
|
||||||
|
cross build --target=aarch64-unknown-linux-gnu;
|
||||||
|
cross build --target=x86_64-unknown-linux-gnu;
|
||||||
|
cross build --target=armv7-unknown-linux-gnueabihf;
|
||||||
|
cross build --target=arm-unknown-linux-gnueabihf;
|
||||||
|
cross build --target=x86_64-pc-windows-gnu;
|
||||||
229
src/main.rs
229
src/main.rs
@@ -10,8 +10,11 @@ use std::thread::sleep;
|
|||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
use std::net::UdpSocket;
|
use std::net::UdpSocket;
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use serde_json::json;
|
use serde_json::{json};
|
||||||
use reqwest;
|
use reqwest;
|
||||||
|
use regex::Regex;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
|
||||||
/// Validate that the provided port string can be parsed into a u16 and is nonzero.
|
/// Validate that the provided port string can be parsed into a u16 and is nonzero.
|
||||||
fn validate_port(port: &str) -> Result<u16, String> {
|
fn validate_port(port: &str) -> Result<u16, String> {
|
||||||
@@ -62,7 +65,7 @@ struct Cli {
|
|||||||
|
|
||||||
/// Spotter callsign (e.g. W1CDN)
|
/// Spotter callsign (e.g. W1CDN)
|
||||||
#[arg(short = 's', long)]
|
#[arg(short = 's', long)]
|
||||||
spotter: Option<String>,
|
my_call: Option<String>,
|
||||||
|
|
||||||
/// Spot UI frames to a Spothole server
|
/// Spot UI frames to a Spothole server
|
||||||
#[arg(short = 'o', long, default_value_t = false)]
|
#[arg(short = 'o', long, default_value_t = false)]
|
||||||
@@ -76,6 +79,18 @@ struct Cli {
|
|||||||
#[arg(short = 'f', long, default_value_t = 14105000)]
|
#[arg(short = 'f', long, default_value_t = 14105000)]
|
||||||
freq: u32,
|
freq: u32,
|
||||||
|
|
||||||
|
/// Spotter latitude DD.dddd
|
||||||
|
#[arg(short = 'y', long, allow_negative_numbers = true)]
|
||||||
|
my_lat: Option<f64>,
|
||||||
|
|
||||||
|
/// Spotter longitude DD.dddd
|
||||||
|
#[arg(short = 'x', long, allow_negative_numbers = true)]
|
||||||
|
my_lon: Option<f64>,
|
||||||
|
|
||||||
|
/// Filter out spots from these callsign-UUID combinations (self spots, for example), comma-separated
|
||||||
|
#[arg(short = 't', long, value_delimiter = ',', num_args = 1..,)]
|
||||||
|
filter: Vec<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a byte slice into a hex-dump string for debugging purposes.
|
/// Convert a byte slice into a hex-dump string for debugging purposes.
|
||||||
@@ -367,7 +382,7 @@ impl BufferManager {
|
|||||||
/// - Filters out frames destined for "NODES" and frames with an XID payload.
|
/// - Filters out frames destined for "NODES" and frames with an XID payload.
|
||||||
/// - Optionally filters to only UI frames if requested.
|
/// - Optionally filters to only UI frames if requested.
|
||||||
/// - Buffers multi-line frames and prints a formatted session line.
|
/// - Buffers multi-line frames and prints a formatted session line.
|
||||||
fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager, loc_store: &mut HashMap<String, Vec<String>>) {
|
||||||
let hdr = &frame.header;
|
let hdr = &frame.header;
|
||||||
// Process only frames on the specified channel.
|
// Process only frames on the specified channel.
|
||||||
if hdr.port != cli.channel as i32 {
|
if hdr.port != cli.channel as i32 {
|
||||||
@@ -376,9 +391,27 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
let source = hdr.callfrom_str();
|
let source = hdr.callfrom_str();
|
||||||
let basic_destination = hdr.callto_str();
|
let basic_destination = hdr.callto_str();
|
||||||
let timestamp = Local::now().format("%H:%M:%S").to_string();
|
let timestamp = Local::now().format("%H:%M:%S").to_string();
|
||||||
let spotter = &cli.spotter;
|
let my_call = &cli.my_call;
|
||||||
let freq = &cli.freq;
|
let freq = &cli.freq;
|
||||||
//let spothole_alt = &cli.spothole_alt;
|
let my_lat = &cli.my_lat;
|
||||||
|
let my_lon = &cli.my_lon;
|
||||||
|
|
||||||
|
// Split callsign and SSID if there are both
|
||||||
|
let (source_call, source_ssid): (&String, Option<&String>) = if source.contains("-") {
|
||||||
|
let re_source = Regex::new(r"(?P<call>.*)-(?P<ssid>[\d])").unwrap();
|
||||||
|
// Break captures into named values
|
||||||
|
let callssid = re_source.captures(&source).unwrap();
|
||||||
|
|
||||||
|
(&callssid["call"].to_string(), Some(&callssid["ssid"].to_string()))
|
||||||
|
// Otherwise there is just the call and no SSID
|
||||||
|
} else {
|
||||||
|
(&source, None)
|
||||||
|
//(&source, &String::new())
|
||||||
|
};
|
||||||
|
//println!("{:?}",(source_call, source_ssid));
|
||||||
|
|
||||||
|
|
||||||
|
//println!("{} - {}", source_call, source_ssid);
|
||||||
|
|
||||||
// If user provides an alternate Spothole URL, use that one
|
// If user provides an alternate Spothole URL, use that one
|
||||||
let spothole_url = match &cli.spothole_alt {
|
let spothole_url = match &cli.spothole_alt {
|
||||||
@@ -421,53 +454,6 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
if cli.ui_only && summary != "UI" {
|
if cli.ui_only && summary != "UI" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Spothole is enabled
|
|
||||||
if summary == "UI" && cli.spothole {
|
|
||||||
// curl --request POST --header "Content-Type: application/json"
|
|
||||||
// --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,
|
|
||||||
"de_call": &spotter,
|
|
||||||
"freq": &freq,
|
|
||||||
"comment": &text,
|
|
||||||
"mode": "PKT",
|
|
||||||
"mode_type": "DATA",
|
|
||||||
"mode_source": "SPOT",
|
|
||||||
"time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
|
||||||
});
|
|
||||||
let client = reqwest::blocking::Client::new();
|
|
||||||
let res = client.post(spothole_url)
|
|
||||||
.json(&packet)
|
|
||||||
.send();
|
|
||||||
println!("res = {res:?}");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send UDP
|
|
||||||
if cli.uport != 55555 {
|
|
||||||
let uaddr = format!("{}:{}", cli.uip, cli.uport);
|
|
||||||
let socket = UdpSocket::bind("0.0.0.0:0");
|
|
||||||
|
|
||||||
let packet = json!({
|
|
||||||
"final_destination": &final_destination,
|
|
||||||
"source": &source,
|
|
||||||
"spotter": &spotter,
|
|
||||||
"summary": &summary,
|
|
||||||
"text": &text,
|
|
||||||
"freq": &freq,
|
|
||||||
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
|
||||||
"type": "data"
|
|
||||||
});
|
|
||||||
let _ = socket.expect("REASON").send_to(packet.to_string().as_bytes(), uaddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In non-debug mode, print the session line and any additional lines.
|
// In non-debug mode, print the session line and any additional lines.
|
||||||
if !cli.debug {
|
if !cli.debug {
|
||||||
@@ -478,6 +464,139 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract location from APRS format
|
||||||
|
let (lat, lon) = aprs_loc(&text);
|
||||||
|
|
||||||
|
// Store the location
|
||||||
|
// Only update location store if there is a real location
|
||||||
|
if lat > -9999.0_f64 && lon > -9999.0_f64 {
|
||||||
|
let loc = vec![lat.to_string(), lon.to_string()];
|
||||||
|
loc_store.insert(source.clone(), loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up a stored location
|
||||||
|
// If it doesn't exist, set to empty
|
||||||
|
let stored_loc = match loc_store.get(&source) {
|
||||||
|
Some(loc_value) => loc_value,
|
||||||
|
None => &vec!["".to_string(), "".to_string()],
|
||||||
|
};
|
||||||
|
|
||||||
|
// Only send good locations on
|
||||||
|
let json_lat = stored_loc[0].clone() ;
|
||||||
|
let json_lon = stored_loc[1].clone() ;
|
||||||
|
|
||||||
|
//println!("Stored location: {} {}", stored_loc[0].clone(), stored_loc[1].clone());
|
||||||
|
|
||||||
|
// If Spothole is enabled and this is a UI frame and the source is not filtered
|
||||||
|
if summary == "UI" && cli.spothole && !cli.filter.contains(&source){
|
||||||
|
// POST JSON
|
||||||
|
let packet = json!({
|
||||||
|
"dx_call": &source_call,
|
||||||
|
"dx_ssid": &source_ssid,
|
||||||
|
"de_call": &my_call,
|
||||||
|
"de_latitude": &my_lat,
|
||||||
|
"de_longitude": &my_lon,
|
||||||
|
"freq": &freq,
|
||||||
|
"comment": &text,
|
||||||
|
"dx_latitude": &json_lat,
|
||||||
|
"dx_longitude": &json_lon,
|
||||||
|
"mode": "PKT",
|
||||||
|
"mode_type": "DATA",
|
||||||
|
"mode_source": "SPOT",
|
||||||
|
"time": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
|
});
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
let res = client.post(spothole_url)
|
||||||
|
.json(&packet)
|
||||||
|
.send();
|
||||||
|
println!("sent to {} = {}", spothole_url, packet);
|
||||||
|
println!("res = {res:?}");
|
||||||
|
// If it's filtered, send a note about that
|
||||||
|
} else if summary == "UI" && cli.spothole && cli.filter.contains(&source) {
|
||||||
|
println!("Filter {:?} applied, not spotted", cli.filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send UDP
|
||||||
|
if cli.uport != 55555 {
|
||||||
|
let uaddr = format!("{}:{}", cli.uip, cli.uport);
|
||||||
|
let socket = UdpSocket::bind("0.0.0.0:0");
|
||||||
|
|
||||||
|
let packet = json!({
|
||||||
|
"final_destination": &final_destination,
|
||||||
|
"source": &source,
|
||||||
|
"spotter": &my_call,
|
||||||
|
"spotter_latitude": &my_lat,
|
||||||
|
"spotter_longitude": &my_lon,
|
||||||
|
"summary": &summary,
|
||||||
|
"text": &text,
|
||||||
|
"dx_latitude": &json_lat,
|
||||||
|
"dx_longitude": &json_lon,
|
||||||
|
"freq": &freq,
|
||||||
|
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
|
"type": "data"
|
||||||
|
});
|
||||||
|
let _ = socket.expect("REASON").send_to(packet.to_string().as_bytes(), uaddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn aprs_loc(packet: &str) -> (f64, f64) {
|
||||||
|
// Capture different pieces of the location string
|
||||||
|
let re_loc = Regex::new(r"(?P<latd>\d{2})(?P<latm>[\d ]{2}\.[\d ]{2})(?P<ns>[nsNS])/(?P<lond>\d{3})(?P<lonm>[\d ]{2}\.[\d ]{2})(?P<ew>[ewEW])").unwrap();
|
||||||
|
|
||||||
|
// Check for 3rd party traffic, which may include location
|
||||||
|
let re_3p = Regex::new(r"(?<tcpip>TCPIP)").unwrap();
|
||||||
|
let mut loc3p: bool = false;
|
||||||
|
if re_3p.is_match(&packet) {
|
||||||
|
loc3p = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only proceed if there were captures
|
||||||
|
match re_loc.captures(&packet) {
|
||||||
|
Some(_caps) => {
|
||||||
|
|
||||||
|
// Break captures into named values
|
||||||
|
let loc = re_loc.captures(&packet).unwrap();
|
||||||
|
|
||||||
|
// Initiate randomness for ambiguity..
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
// Convert to decimal degrees. If ambiguity spaces are included (see APRS spec), replace them with random digits.
|
||||||
|
let mut lat_dec: f64 = &loc["latd"].trim().parse().expect("Expects a number!") + (&loc["latm"].replace(" ", &rng.random_range(0..9).to_string()).trim().parse().expect("Expects a number!") / 60.0);
|
||||||
|
// If south, make negative
|
||||||
|
if &loc["ns"] == "S" {
|
||||||
|
lat_dec = lat_dec * -1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO if there are spaces in loc["latm"], the same spaces need to be in loc["lonm"] for proper ambiguity according to APRS spec
|
||||||
|
|
||||||
|
let mut lon_dec: f64 = &loc["lond"].trim().parse().expect("Expects a number!") + (&loc["lonm"].replace(" ", &rng.random_range(0..9).to_string()).trim().parse().expect("Expects a number!") / 60.0);
|
||||||
|
// If west, make negative
|
||||||
|
if &loc["ew"] == "W" {
|
||||||
|
lon_dec = lon_dec * -1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
// String to paste into map for testing
|
||||||
|
//println!("{}, {}", lat_dec, lon_dec);
|
||||||
|
|
||||||
|
// But if after all that, it's a 3rd-party location, toss it
|
||||||
|
// This is the only capture group we ID by numberf
|
||||||
|
if loc3p == true {
|
||||||
|
(lat_dec, lon_dec) = (-9999.0_f64, -9999.0_f64);
|
||||||
|
println!("Dropping location, looks like 3rd party");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
(lat_dec, lon_dec)
|
||||||
|
|
||||||
|
}
|
||||||
|
// Otherwise if there were no captures, return bad data
|
||||||
|
None => {
|
||||||
|
// The regex did not match. Deal with it here!
|
||||||
|
(-9999.0_f64, -9999.0_f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Main entry point:
|
/// Main entry point:
|
||||||
@@ -491,6 +610,10 @@ fn main() -> Result<()> {
|
|||||||
let uaddr = format!("{}:{}", cli.uip, cli.uport);
|
let uaddr = format!("{}:{}", cli.uip, cli.uport);
|
||||||
let reconnect_delay_ms = 5000;
|
let reconnect_delay_ms = 5000;
|
||||||
|
|
||||||
|
// Set up the location store
|
||||||
|
//let mut loc_store = HashMap:: new();
|
||||||
|
let mut loc_store: HashMap<String, Vec<String>> = HashMap::new();
|
||||||
|
|
||||||
if cli.uport != 55555 {
|
if cli.uport != 55555 {
|
||||||
// Bind the client socket to any available address and port
|
// Bind the client socket to any available address and port
|
||||||
let socket = UdpSocket::bind("0.0.0.0:0")?;
|
let socket = UdpSocket::bind("0.0.0.0:0")?;
|
||||||
@@ -538,7 +661,7 @@ fn main() -> Result<()> {
|
|||||||
while buffer.len() >= 36 {
|
while buffer.len() >= 36 {
|
||||||
match parse_frame(&buffer, cli.debug) {
|
match parse_frame(&buffer, cli.debug) {
|
||||||
Ok((consumed, frame)) => {
|
Ok((consumed, frame)) => {
|
||||||
handle_frame(&frame, &cli, &mut buffers);
|
handle_frame(&frame, &cli, &mut buffers, &mut loc_store);
|
||||||
// Remove the processed frame from the buffer.
|
// Remove the processed frame from the buffer.
|
||||||
buffer.drain(0..consumed);
|
buffer.drain(0..consumed);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user