Skip to content

Commit

Permalink
GH-651: Automatic Retries for the URLs in case of DNS Resolve Failure (
Browse files Browse the repository at this point in the history
…#326)

* GH-651: we identified the appropriate place for the new logic

* GH-651: added in a missing Zero hop test

* GH-651: add todos for this card

* GH-651: repaired current tests

* GH-651: Added IBCDHelperReal factory

* GH-651: worked on test: handle_dns_resolve_failure_sent_request_retry

* GH-651: Before master merge

* GH-651: Repaired master meage

* GH-651: Testing is working but stil failing

* GH-651: Test is now working

* GH-651: Added some more Cassertions

* GH-651: Test is now working as expected

* GH-651: Added new macro: type_id

* GH-651: Fixed RouteQueryMessage stop condition

* GH-651: started work on stop_on_message

* GH-651: Finished stop_on_message

* GH-651: Added retiring stream key code to test

* GH-651: Working on improving request_route_and_transmit

* GH-651: Changes from Dev meeting

* GH-651: Fixed a test for error log case

* GH-651: Fixed all tests

* GH-651: Added a todo

* GH-651: Removed dns_failure_retries after exhausting its retry count

* GH-651: Added function dns_failure_retries_left

* GH-651: Refactored handle_dns_resolve_failure function

* GH-651: Remove return from request_route_and_transmit

* GH-651: Formatting

* GH-651: renamed stream_shutdown_sub to dispatcher_sub

* GH-651: more renaming

* GH-651: created send_dns_failure_response_to_the_browser function

* GH-651: Updated dns_resolution_failure_response message

* GH-651: Added todo

* GH-651: Added a new message DnsRetryResultMessage under ProxyServer

* GH-651: implement Ok result for DnsRetryResultMessage

* GH-651: Fixed some tests

* GH-651: Refactored resolve_message

* GH-651: Fixed test resolve_message_handles_mailbox_error_from_neighborhood

* GH-651: Refactored proxy_server/mod.rs

* GH-651: Removed AddRouteMessage

* GH-651: Renamed DnsRetryResultMessage to RouteResultMessage

* GH-651: Added TODOs for next session

* GH-651: Added new struct Hostname

* GH-651: Add new test new_http_request_creates_new_entry_inside_dns_retries_hashmap

* GH-651: complete test new_http_request_creates_new_entry_inside_dns_retries_hashmap

* GH-651: Fixed todos and added a new test

* GH-651: Added test proxy_server_receives_failed_dns_then_a_successful_cores_package

* GH-651: Remove test proxy_server_receives_failed_dns_then_a_successful_cores_package

* GH-651: Ceanup - tests passing

* GH-651: Fixed test dns_resolution_failure_no_longer_blacklists_exit_node_for_all_hosts

* GH-651: Added test dns_resolution_failure_automatic_retries_works

* Added new test dns_resolution_failure_with_real_nodes

* GH-651: Working on test: dns_resolution_failure_with_real_nodes_route_error

* GH-651: Test dns_resolution_failure_with_real_nodes_route_error is working

* GH-651: Added new enum MessageTypeLite with test

* GH-651: added new function: wait_for_specific_package

* GH-651: added new function: make_package_for_client

* GH-651: Refactoring / cleanup

* GH-651: fixed routes for function make_package_for_client

* GH-651: Removed test: dns_resolution_failure_automatic_retries_works

* GH-651: fixing test dns_resolution_failure_no_longer_blacklists_exit_node_for_all_hosts

* GH-651: working on dns_resolution_failure_no_longer_blacklists_exit_node_for_all_hosts

* GH-651: Finished test: dns_resolution_failure_no_longer_blacklists_exit_node_for_all_hosts

* GH-651: added new logs RouteResultMessage handler

* GH-651: Added new test: route_result_message_handler_panics_when_dns_retries_hashmap_doesnt_contain_a_stream_key

* GH-651: Formatting

* GH-651: Removed warnings

* GH-651: ci-matrix multinode_integration_test DEBUG

* GH-651: Increased timeouts

* GH-651: Increased Node count for test dns_resolution_failure_with_real_nodes

* GH-651: Increase timeout for test dns_resolution_failure_with_real_nodes

* GH-651: changed timeout for test dns_resolution_failure_with_real_nodes

* GH-651: added removal of DNS retry entry on a successful client responce & clean up

* GH-651: test clean up

* GH-651: More clean up

* GH-651: Finished self review

* GH651: added modity_config closure to construct_neighborhood

* GH-651: formatting

* GH-651: Working on review 1

* GH-651: More work completed for review 1

* GH651: Completed more items form review 1

* GH651: Completed more items form review 1

* GH651: Completed more items form review 1

* GH651: Completed more items form review 1

* GH-651: Clean up of peer_actors.proxy_server

* GH-651 Formatting

* GH651: Improved TryTransmitToHopperArgs::New

* GH-651: added new test new_http_request_creates_new_exhausted_entry_inside_dns_retries_hashmap_zero_hop

* GH-651: Simple Renaming

* GH-651: Added condition to test: handle_dns_resolve_failure_sends_message_to_neighborhood

* GH-651: Fixed System new name

* GH-651: Removed zsh text

* GH-651: Merged in Master

* GH-651: doubious test fixed

* GH-651: Removed test proxy_server_applies_late_wallet_information

* GH-651: Added new test fn dns_resolution_failure_for_wildcard_ip_with_real_nodes

* GH-651: Added new test wildcard_ip_resolves_in_dns_failure

* GH-651: Sends DnsResolveFailure_0v1 for DNS failure & wildcard IP

* GH-651: fixed test dns_resolution_failure_for_wildcard_ip_with_real_nodes

* GH-651: Ignoring test actual_server_drop

* GH-651: IP wildcard filter added with test

---------

Co-authored-by: Bert <Bert@Bert.com>
Co-authored-by: utkarshg6 <utkarshabhinav.torres@gmail.com>
Co-authored-by: Bert <65427484+bertllll@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 19, 2024
1 parent d529207 commit 99b68bf
Show file tree
Hide file tree
Showing 18 changed files with 2,046 additions and 513 deletions.
30 changes: 29 additions & 1 deletion multinode_integration_tests/src/masq_mock_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use node_lib::sub_lib::cryptde::{encodex, CryptDE};
use node_lib::sub_lib::cryptde_null::CryptDENull;
use node_lib::sub_lib::cryptde_real::CryptDEReal;
use node_lib::sub_lib::framer::Framer;
use node_lib::sub_lib::hopper::{IncipientCoresPackage, MessageType};
use node_lib::sub_lib::hopper::{
ExpiredCoresPackage, IncipientCoresPackage, MessageType, MessageTypeLite,
};
use node_lib::sub_lib::neighborhood::{GossipFailure_0v1, RatePack, DEFAULT_RATE_PACK};
use node_lib::sub_lib::node_addr::NodeAddr;
use node_lib::sub_lib::route::Route;
Expand Down Expand Up @@ -394,6 +396,32 @@ impl MASQMockNode {
Ok((socket_from, socket_to, live_cores_package))
}

pub fn wait_for_specific_package(
&self,
message_type_lite: MessageTypeLite,
immediate_neighbor: SocketAddr,
) -> Option<ExpiredCoresPackage<MessageType>> {
let public_key = self.main_public_key();
let cryptde = CryptDENull::from(public_key, TEST_DEFAULT_MULTINODE_CHAIN);
loop {
if let Ok((_, _, live_cores_package)) =
self.wait_for_package(&JsonMasquerader::new(), Duration::from_secs(2))
{
let (_, intended_exit_public_key) =
CryptDENull::extract_key_pair(public_key.len(), &live_cores_package.payload);
assert_eq!(&intended_exit_public_key, public_key);
let expired_cores_package = live_cores_package
.to_expired(immediate_neighbor, &cryptde, &cryptde)
.unwrap();
if message_type_lite == expired_cores_package.payload.clone().into() {
return Some(expired_cores_package);
}
} else {
return None;
}
}
}

pub fn wait_for_gossip(&self, timeout: Duration) -> Option<(Gossip_0v1, IpAddr)> {
let masquerader = JsonMasquerader::new();
match self.wait_for_package(&masquerader, timeout) {
Expand Down
33 changes: 20 additions & 13 deletions multinode_integration_tests/src/neighborhood_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::masq_mock_node::MASQMockNode;
use crate::masq_node::MASQNode;
use crate::masq_node_cluster::MASQNodeCluster;
use crate::masq_real_node::MASQRealNode;
use crate::masq_real_node::{make_consuming_wallet_info, NodeStartupConfigBuilder};
use crate::masq_real_node::{MASQRealNode, NodeStartupConfig};
use crate::multinode_gossip::{Standard, StandardBuilder};
use node_lib::neighborhood::gossip::Gossip_0v1;
use node_lib::neighborhood::gossip_producer::{GossipProducer, GossipProducerReal};
Expand Down Expand Up @@ -51,25 +51,28 @@ use std::time::Duration;
/// * `HashMap<PublicKey, MASQMockNode>` The mock Nodes corresponding to other NodeRecords in `model_db`. They
/// will have the same public keys as the `model_db` NodeRecords they
/// represent, but different NodeAddrs.
pub fn construct_neighborhood(
pub fn construct_neighborhood<F>(
cluster: &mut MASQNodeCluster,
model_db: NeighborhoodDatabase,
additional_keys_to_mock: Vec<&PublicKey>,
modify_config: F,
) -> (
NeighborhoodDatabase,
MASQRealNode,
HashMap<PublicKey, MASQMockNode>,
) {
let real_node = cluster.start_real_node(
NodeStartupConfigBuilder::standard()
.fake_public_key(model_db.root().public_key())
.consuming_wallet_info(make_consuming_wallet_info(
model_db.root().public_key().to_string().as_str(),
))
.rate_pack(model_db.root().inner.rate_pack)
.chain(cluster.chain)
.build(),
);
)
where
F: FnOnce(NodeStartupConfigBuilder) -> NodeStartupConfig,
{
let config_builder = NodeStartupConfigBuilder::standard()
.fake_public_key(model_db.root().public_key())
.consuming_wallet_info(make_consuming_wallet_info(
model_db.root().public_key().to_string().as_str(),
))
.rate_pack(model_db.root().inner.rate_pack)
.chain(cluster.chain);
let config = modify_config(config_builder);
let real_node = cluster.start_real_node(config);
let (mock_node_map, adjacent_mock_node_keys) =
make_mock_node_map(cluster, &model_db, &real_node, additional_keys_to_mock);
let modified_nodes = make_modified_node_records(model_db, &mock_node_map);
Expand All @@ -82,6 +85,10 @@ pub fn construct_neighborhood(
(modified_db, real_node, mock_node_map)
}

pub fn do_not_modify_config() -> impl FnOnce(NodeStartupConfigBuilder) -> NodeStartupConfig {
|builder: NodeStartupConfigBuilder| builder.build()
}

fn make_mock_node_map(
cluster: &mut MASQNodeCluster,
model_db: &NeighborhoodDatabase,
Expand Down
Loading

0 comments on commit 99b68bf

Please sign in to comment.