Skip to content

Commit

Permalink
Replace udp module with external crate.
Browse files Browse the repository at this point in the history
  • Loading branch information
vikpe committed May 4, 2024
1 parent e113db3 commit 0a57a7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ description = "Get server addresses from QuakeWorld master servers."
keywords = ["quake", "quakeworld", "servers"]
repository = "https://github.com/vikpe/masterstat-rust"
authors = ["Viktor Persson <viktor.persson@arcsin.se>"]
version = "0.1.2"
version = "0.1.3"
edition = "2021"
license = "MIT"
include = [
"/benches/**",
"/Cargo.toml",
"/LICENSE",
"/README.md",
Expand All @@ -21,6 +20,7 @@ include = [
[dependencies]
anyhow = "1.0.82"
futures = "0.3.30"
tinyudp = "0.2.1"
tokio = { version = "1.37.0", features = ["rt", "sync"] }
zerocopy = "0.7.32"
zerocopy-derive = "0.7.32"
Expand Down
7 changes: 5 additions & 2 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use tokio::sync::Mutex;
use zerocopy::FromBytes;

use crate::server_address::{RawServerAddress, ServerAddress, RAW_ADDRESS_SIZE};
use crate::udp;

const SERVERS_COMMAND: [u8; 3] = [0x63, 0x0a, 0x00];
const SERVERS_RESPONSE_HEADER: [u8; 6] = [0xff, 0xff, 0xff, 0xff, 0x64, 0x0a];
Expand All @@ -29,7 +28,11 @@ pub fn server_addresses(
master_address: &str,
timeout: Option<Duration>,
) -> Result<Vec<ServerAddress>> {
let response = udp::send_and_receive(master_address, &SERVERS_COMMAND, timeout)?;
let options = tinyudp::ReadOptions {
timeout,
buffer_size: 16 * 1024, // 16 kb
};
let response = tinyudp::send_and_read(master_address, &SERVERS_COMMAND, &options)?;
let server_addresses = parse_servers_response(&response)?;
Ok(sorted_and_unique(&server_addresses))
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
mod command;
mod server_address;
mod udp;

pub use crate::command::server_addresses;
pub use crate::command::server_addresses_from_many;
Expand Down
36 changes: 0 additions & 36 deletions src/udp.rs

This file was deleted.

0 comments on commit 0a57a7f

Please sign in to comment.