Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Created January 6, 2020 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnkfelix/4bdef50d0538fee8f6e0cbc4379f6074 to your computer and use it in GitHub Desktop.
Save pnkfelix/4bdef50d0538fee8f6e0cbc4379f6074 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