fix proxy not disconnecting propperly
This commit is contained in:
parent
449ce0c0ba
commit
949c347569
3 changed files with 26 additions and 18 deletions
|
|
@ -76,12 +76,12 @@ async fn main() {
|
|||
tokio::select! {
|
||||
data = conn.recv() => {
|
||||
let Some(data) = data else {
|
||||
break;
|
||||
return;
|
||||
};
|
||||
|
||||
if let Err(e) = stream.send_buffer(&data[..]).await{
|
||||
error!("error sending data to backend: {}", e);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
},
|
||||
data = stream.read_buffer() => {
|
||||
|
|
@ -89,7 +89,7 @@ async fn main() {
|
|||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
error!("error reveiving data from backend: {}", e);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,12 +78,12 @@ async fn main() {
|
|||
tokio::select! {
|
||||
data = conn.recv() => {
|
||||
let Some(data) = data else {
|
||||
break;
|
||||
return;
|
||||
};
|
||||
|
||||
if let Err(e) = stream.send_buffer(&data[..]).await{
|
||||
error!("error sending data to backend: {}", e);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
},
|
||||
data = stream.read_buffer() => {
|
||||
|
|
@ -91,7 +91,7 @@ async fn main() {
|
|||
Ok(d) => d,
|
||||
Err(e) => {
|
||||
error!("error reveiving data from backend: {}", e);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,21 @@ impl<E: CryptoHandlerConnectionInstance> InternalConnection<E> {
|
|||
async fn send_raw_packet(&self, prudp_packet: &PRUDPV1Packet) {
|
||||
send_raw_prudp_to_sockaddr(&self.socket, self.socket_addr, prudp_packet).await;
|
||||
}
|
||||
|
||||
async fn delete_connection(&self){
|
||||
let Some(conns) = self.connections.upgrade() else {
|
||||
// this is fine as it implies the server has already quit, thus meaning that we dont
|
||||
// have to remove ourselves from the server
|
||||
return;
|
||||
};
|
||||
|
||||
let mut conns = conns.lock().await;
|
||||
|
||||
conns.remove(&self.socket_addr);
|
||||
|
||||
// the connection will now drop as soon as we leave this due to no longer having a permanent
|
||||
// reference
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExternalConnection {
|
||||
|
|
@ -172,6 +187,8 @@ pub(super) trait AnyInternalConnection:
|
|||
async fn close_connection(&mut self);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[async_trait]
|
||||
impl<T: CryptoHandlerConnectionInstance> AnyInternalConnection for InternalConnection<T> {
|
||||
async fn send_data_packet(&mut self, data: Vec<u8>) {
|
||||
|
|
@ -202,6 +219,7 @@ impl<T: CryptoHandlerConnectionInstance> AnyInternalConnection for InternalConne
|
|||
self.unacknowleged_packets.push((Instant::now(), packet));
|
||||
}
|
||||
|
||||
|
||||
async fn close_connection(&mut self) {
|
||||
// jon confirmed that this should be a safe way to dc a client
|
||||
|
||||
|
|
@ -228,18 +246,7 @@ impl<T: CryptoHandlerConnectionInstance> AnyInternalConnection for InternalConne
|
|||
|
||||
self.send_raw_packet(&packet).await;
|
||||
|
||||
let Some(conns) = self.connections.upgrade() else {
|
||||
// this is fine as it implies the server has already quit, thus meaning that we dont
|
||||
// have to remove ourselves from the server
|
||||
return;
|
||||
};
|
||||
|
||||
let mut conns = conns.lock().await;
|
||||
|
||||
conns.remove(&self.socket_addr);
|
||||
|
||||
// the connection will now drop as soon as we leave this due to no longer having a permanent
|
||||
// reference
|
||||
self.delete_connection().await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -583,6 +590,7 @@ impl<T: CryptoHandler> InternalSocket<T> {
|
|||
self.send_packet_unbuffered(address, &response).await;
|
||||
self.send_packet_unbuffered(address, &response).await;
|
||||
|
||||
conn.delete_connection().await;
|
||||
//self.internal_connections.lock().await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue