Skip to content

Commit

Permalink
Add logging to proxy server
Browse files Browse the repository at this point in the history
  • Loading branch information
r-n-o committed Jun 24, 2024
1 parent dd2bf25 commit 595349d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/qos_net/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl Proxy {

impl server::RequestProcessor for Proxy {
fn process(&mut self, req_bytes: Vec<u8>) -> Vec<u8> {
println!("Proxy processing request");
if req_bytes.len() > MAX_ENCODED_MSG_LEN {
return ProxyMsg::ProxyError(QosNetError::OversizedPayload)
.try_to_vec()
Expand All @@ -203,32 +204,41 @@ impl server::RequestProcessor for Proxy {
let resp = match ProxyMsg::try_from_slice(&req_bytes) {
Ok(req) => match req {
ProxyMsg::StatusRequest => {
println!("Proxy processing StatusRequest");
ProxyMsg::StatusResponse(self.connections.len())
}
ProxyMsg::ConnectByNameRequest {
hostname,
port,
dns_resolvers,
dns_port,
} => self.connect_by_name(
hostname,
port,
dns_resolvers,
dns_port,
),
} => {
println!("Proxy connecting to {hostname}:{port}");
self.connect_by_name(
hostname,
port,
dns_resolvers,
dns_port,
)
},
ProxyMsg::ConnectByIpRequest { ip, port } => {
println!("Proxy connecting to {ip}:{port}");
self.connect_by_ip(ip, port)
}
ProxyMsg::CloseRequest { connection_id } => {
println!("Proxy closing connection {connection_id}");
self.close(connection_id)
}
ProxyMsg::ReadRequest { connection_id, size } => {
println!("Proxy reading {size} bytes from connection {connection_id}");
self.read(connection_id, size)
}
ProxyMsg::WriteRequest { connection_id, data } => {
println!("Proxy writing to connection {connection_id}");
self.write(connection_id, data)
}
ProxyMsg::FlushRequest { connection_id } => {
println!("Proxy flushing connection {connection_id}");
self.flush(connection_id)
}
ProxyMsg::ProxyError(_) => {
Expand Down

0 comments on commit 595349d

Please sign in to comment.