Skip to content

Commit 0c5bab3

Browse files
committed
refactor: [#681] udp return errors instead of panicking
1 parent 340e9e0 commit 0c5bab3

File tree

5 files changed

+189
-174
lines changed

5 files changed

+189
-174
lines changed

http_trackers.sh

-29
This file was deleted.

src/console/clients/udp/checker.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Client {
6464
let binding_address = local_bind_to.parse().context("binding local address")?;
6565

6666
debug!("Binding to: {local_bind_to}");
67-
let udp_client = UdpClient::bind(&local_bind_to).await;
67+
let udp_client = UdpClient::bind(&local_bind_to).await?;
6868

6969
let bound_to = udp_client.socket.local_addr().context("bound local address")?;
7070
debug!("Bound to: {bound_to}");
@@ -88,7 +88,7 @@ impl Client {
8888

8989
match &self.udp_tracker_client {
9090
Some(client) => {
91-
client.udp_client.connect(&tracker_socket_addr.to_string()).await;
91+
client.udp_client.connect(&tracker_socket_addr.to_string()).await?;
9292
self.remote_socket = Some(*tracker_socket_addr);
9393
Ok(())
9494
}
@@ -116,9 +116,9 @@ impl Client {
116116

117117
match &self.udp_tracker_client {
118118
Some(client) => {
119-
client.send(connect_request.into()).await;
119+
client.send(connect_request.into()).await?;
120120

121-
let response = client.receive().await;
121+
let response = client.receive().await?;
122122

123123
debug!("connection request response:\n{response:#?}");
124124

@@ -163,9 +163,9 @@ impl Client {
163163

164164
match &self.udp_tracker_client {
165165
Some(client) => {
166-
client.send(announce_request.into()).await;
166+
client.send(announce_request.into()).await?;
167167

168-
let response = client.receive().await;
168+
let response = client.receive().await?;
169169

170170
debug!("announce request response:\n{response:#?}");
171171

@@ -200,9 +200,9 @@ impl Client {
200200

201201
match &self.udp_tracker_client {
202202
Some(client) => {
203-
client.send(scrape_request.into()).await;
203+
client.send(scrape_request.into()).await?;
204204

205-
let response = client.receive().await;
205+
let response = client.receive().await?;
206206

207207
debug!("scrape request response:\n{response:#?}");
208208

0 commit comments

Comments
 (0)