From b79d68d3aefde568998096b605768140f1588f5d Mon Sep 17 00:00:00 2001 From: Chiara Seim Date: Thu, 24 Aug 2023 14:02:15 -0700 Subject: [PATCH 1/2] Feature flags for ops integration test, enable logging for namespaces to checkin, change ops url for integration test --- integration_tests/Cargo.toml | 4 ++-- integration_tests/src/config.rs | 4 ++-- rita_client/src/heartbeat/mod.rs | 4 ++-- rita_client/src/operator_update/mod.rs | 2 +- rita_client/src/rita_loop/mod.rs | 2 +- rita_exit/src/operator_update/mod.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 4f8e11f89..64873e091 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -16,9 +16,9 @@ althea_kernel_interface = { path = "../althea_kernel_interface", features = ["in althea_types = { path = "../althea_types" } clu = { path = "../clu" } settings = { path = "../settings" } -rita_client = { path = "../rita_client"} +rita_client = { path = "../rita_client", features = ["dev_env"]} rita_common = { path = "../rita_common", features = ["integration_test"]} -rita_exit = { path = "../rita_exit"} +rita_exit = { path = "../rita_exit", features = ["dev_env"]} ctrlc = {version = "3.2.1", features = ["termination"]} diesel = { version = "1.4", features = ["postgres", "r2d2"] } diesel_migrations = { version = "1.4", features = ["postgres"] } diff --git a/integration_tests/src/config.rs b/integration_tests/src/config.rs index 8104203ea..2ddbd6a65 100644 --- a/integration_tests/src/config.rs +++ b/integration_tests/src/config.rs @@ -53,7 +53,7 @@ pub fn generate_rita_config_file(path: String) -> Result<(), KernelInterfaceErro let log = " [log]\n - enabled = false\n" + enabled = true\n" .to_string(); lines.push(log); @@ -153,7 +153,7 @@ pub fn generate_exit_config_file(path: String) -> Result<(), KernelInterfaceErro let log = " [log]\n - enabled = false\n" + enabled = true\n" .to_string(); lines.push(log); diff --git a/rita_client/src/heartbeat/mod.rs b/rita_client/src/heartbeat/mod.rs index 6d558a49a..dd0f3d0f7 100644 --- a/rita_client/src/heartbeat/mod.rs +++ b/rita_client/src/heartbeat/mod.rs @@ -125,8 +125,8 @@ pub fn send_heartbeat_loop() { fn send_udp_heartbeat() { let heartbeat_url: &str; if cfg!(feature = "dev_env") { - heartbeat_url = "0.0.0.0:33333"; - info!("We are using localhost heartbeart url"); + heartbeat_url = "7.7.7.7:33333"; + info!("We are using dev env heartbeart url"); } else if cfg!(feature = "operator_debug") { heartbeat_url = "192.168.10.2:33333"; info!("We are setting operator debug heartbeart url"); diff --git a/rita_client/src/operator_update/mod.rs b/rita_client/src/operator_update/mod.rs index 4c2b05a14..749206d4a 100644 --- a/rita_client/src/operator_update/mod.rs +++ b/rita_client/src/operator_update/mod.rs @@ -67,7 +67,7 @@ pub async fn operator_update( ) -> Result { let url: &str; if cfg!(feature = "dev_env") { - url = "http://0.0.0.0:8080/checkin"; + url = "http://7.7.7.7:8080/checkin"; } else if cfg!(feature = "operator_debug") { url = "http://192.168.10.2:8080/checkin"; } else { diff --git a/rita_client/src/rita_loop/mod.rs b/rita_client/src/rita_loop/mod.rs index 47b21c84e..8c467c0b6 100644 --- a/rita_client/src/rita_loop/mod.rs +++ b/rita_client/src/rita_loop/mod.rs @@ -212,7 +212,7 @@ pub fn start_antenna_forwarder(settings: RitaClientSettings) { if metrics_permitted() { let url: &str; if cfg!(feature = "dev_env") { - url = "0.0.0.0:33300"; + url = "7.7.7.7:33300"; } else if cfg!(feature = "operator_debug") { url = "192.168.10.2:33334"; } else { diff --git a/rita_exit/src/operator_update/mod.rs b/rita_exit/src/operator_update/mod.rs index 09ebbd373..1b96c1bd9 100644 --- a/rita_exit/src/operator_update/mod.rs +++ b/rita_exit/src/operator_update/mod.rs @@ -37,7 +37,7 @@ pub const OPERATOR_UPDATE_TIMEOUT: Duration = Duration::from_secs(4); pub async fn operator_update(rita_started: Instant) { let url: &str; if cfg!(feature = "dev_env") { - url = "http://0.0.0.0:8080/exitcheckin"; + url = "http://7.7.7.7:8080/exitcheckin"; } else if cfg!(feature = "operator_debug") { url = "http://192.168.10.2:8080/exitcheckin"; } else { From 2b2f70111cba59f5e1e7659d5674d9f262650583 Mon Sep 17 00:00:00 2001 From: Justin Kilpatrick Date: Tue, 5 Sep 2023 14:12:29 -0400 Subject: [PATCH 2/2] Fix: Insert router ip instead of exit dns ip in /etc/config/dhcp This patch fixes a bug where the incorrect server would be included in /etc/config/dhcp. /etc/resolv.conf is for the router itself and is used by the local dhcp server to forward requests, but clients should be given the router ip (whatever that may be) for their own requests. --- rita_client/src/rita_loop/mod.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/rita_client/src/rita_loop/mod.rs b/rita_client/src/rita_loop/mod.rs index 8c467c0b6..70e39b957 100644 --- a/rita_client/src/rita_loop/mod.rs +++ b/rita_client/src/rita_loop/mod.rs @@ -28,9 +28,7 @@ use std::io::BufRead; use std::io::BufReader; use std::io::Read; use std::io::Seek; - use std::net::IpAddr; -use std::net::Ipv4Addr; use std::path::Path; use std::sync::Arc; use std::sync::RwLock; @@ -330,7 +328,7 @@ fn manage_babeld_logs() { /// as a dns resolver pub fn update_dns_conf() { let resolv_path = "/etc/resolv.conf"; - let updated_config = "nameserver 172.168.0.254\nnameserver 8.8.8.8\nnameserver 1.0.0.1\nnameserver 74.82.42.42\nnameserver 149.112.112.10\nnameserver 64.6.65.6" + let updated_config = "nameserver 172.168.0.254\nnameserver 1.0.0.1\nnameserver 8.8.8.8\nnameserver 74.82.42.42\nnameserver 149.112.112.10\nnameserver 64.6.65.6" .to_string(); // read line by line instead match File::open(resolv_path) { @@ -362,24 +360,28 @@ pub fn update_dns_conf() { // not every device will take this dns server and use it, but many do, and some use it exclusively so it has to be correct const DHCP_DNS_LIST_KEY: &str = "dhcp.@dnsmasq[0].server"; - const EXIT_INTERNAL_IP: Ipv4Addr = Ipv4Addr::new(172, 168, 0, 254); + const LAN_IP_KEY: &str = "network.lan.ipaddr"; // this config value is the list of servers dnsmasq uses for resolving client requests // if it does not start with the exit internal nameserver add it. An empty value is acceptable // since dnsmasq simply uses resolv.conf servers which we update above in that case. - match parse_list_to_ip(KI.get_uci_var(DHCP_DNS_LIST_KEY)) { - Ok(dns_server_list) => { + match ( + parse_list_to_ip(KI.get_uci_var(DHCP_DNS_LIST_KEY)), + maybe_parse_ip(KI.get_uci_var(LAN_IP_KEY)), + ) { + (Ok(dns_server_list), Ok(router_internal_ip)) => { // an empty list uses the system resolver, this is acceptable since we just set the system resolver to // point at the exit internal ip above if let Some(first_server_list_entry) = dns_server_list.get(0) { - if *first_server_list_entry != EXIT_INTERNAL_IP { + if *first_server_list_entry != router_internal_ip { let mut dns_server_list = dns_server_list; - dns_server_list.insert(0, EXIT_INTERNAL_IP.into()); + dns_server_list.insert(0, router_internal_ip); overwrite_dns_server_and_restart_dhcp(DHCP_DNS_LIST_KEY, dns_server_list) } } } - Err(e) => error!("Failed to get dns server list? {:?}", e), + (Err(e), _) => error!("Failed to get dns server list? {:?}", e), + (_, Err(e)) => error!("Failed to get router internal ip {:?}", e), } } } @@ -435,3 +437,12 @@ pub fn update_system_time() { } } } + +fn maybe_parse_ip( + input: Result, +) -> Result { + match input { + Ok(s) => Ok(s.parse()?), + Err(e) => Err(e), + } +}