Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Created January 6, 2020 20:47
Show Gist options
  • Save pnkfelix/98a68a08aa7d0b4fff8b5e484121feb9 to your computer and use it in GitHub Desktop.
Save pnkfelix/98a68a08aa7d0b4fff8b5e484121feb9 to your computer and use it in GitHub Desktop.
diff --git a/src/main.rs b/src/main.rs
index 86512cd..52adfc2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -283,12 +283,13 @@ async fn run_server(addr: SocketAddr) {
}

async fn proxy(buf: &[u8]) -> Result<Vec<u8>> {
- let proxy = unsafe { &PROXY };
+ let proxy = unsafe { PROXY.as_slice() };

for addr in proxy.iter() {
let mut socket = UdpSocket::bind(("0.0.0.0", 0)).await?;

- let data: Result<Vec<u8>> = timeout(Duration::from_millis(unsafe { TIMEOUT }), async {
+ let timeout_val = unsafe { TIMEOUT };
+ let data: Result<Vec<u8>> = timeout(Duration::from_millis(timeout_val), async {
socket.send_to(&buf, addr).await?;
let mut res = [0; 512];
let len = socket.recv(&mut res).await?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment