Skip to content

Commit

Permalink
Change to respond with an immediate Ok when receiving an `EchoReque…
Browse files Browse the repository at this point in the history
…st` (#42)
  • Loading branch information
kimhanbeom committed Jul 27, 2023
1 parent 7b86515 commit 92c1897
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ file is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and
this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Change to respond with an immediate `Ok` message when receiving an `EchoRequest`
message instead of calling the handler's function.

## [0.8.2] - 2023-06-15

### Added
Expand Down
15 changes: 1 addition & 14 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ pub trait Handler: Send {
return Err("not supported".to_string());
}

// This feature is supported for all daemons that use oinq.
async fn echo_request(&mut self) -> Result<(), String> {
return Ok(());
}

async fn trusted_user_agent_list(&mut self, _list: &[&str]) -> Result<(), String> {
return Err("not supported".to_string());
}
Expand Down Expand Up @@ -258,7 +253,7 @@ pub async fn handle<H: Handler>(
send_response(send, &mut buf, result).await?;
}
RequestCode::EchoRequest => {
send_response(send, &mut buf, handler.echo_request().await).await?;
send_response(send, &mut buf, Ok::<(), String>(())).await?;
}
RequestCode::TrustedUserAgentList => {
let user_agent_list = codec
Expand Down Expand Up @@ -331,7 +326,6 @@ mod tests {
internal_network_list: usize,
allow_list: usize,
block_list: usize,
echo_request_count: usize,
trusted_user_agents: usize,
}

Expand Down Expand Up @@ -377,11 +371,6 @@ mod tests {
Ok(())
}

async fn echo_request(&mut self) -> Result<(), String> {
self.echo_request_count += 1;
Ok(())
}

async fn trusted_user_agent_list(&mut self, list: &[&str]) -> Result<(), String> {
self.trusted_user_agents = list.len();
Ok(())
Expand Down Expand Up @@ -526,7 +515,6 @@ mod tests {
assert_eq!(handler.internal_network_list, 0);
assert_eq!(handler.allow_list, 0);
assert_eq!(handler.block_list, 0);
assert_eq!(handler.echo_request_count, 0);
assert_eq!(handler.trusted_user_agents, 0);
let res = super::handle(
&mut handler,
Expand All @@ -541,7 +529,6 @@ mod tests {
assert_eq!(handler.internal_network_list, 3);
assert_eq!(handler.allow_list, 2);
assert_eq!(handler.block_list, 1);
assert_eq!(handler.echo_request_count, 1);
assert_eq!(handler.trusted_user_agents, 4);

frame::recv_raw(&mut channel.client.recv, &mut buf)
Expand Down

0 comments on commit 92c1897

Please sign in to comment.