Skip to content

Commit

Permalink
Merge branch 'master' into christianborst/althea-jsonrpc-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr authored Sep 6, 2023
2 parents 8f4a20a + 2b2f701 commit 0561f6f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
4 changes: 2 additions & 2 deletions integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions rita_client/src/heartbeat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion rita_client/src/operator_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub async fn operator_update(
) -> Result<u64, ()> {
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 {
Expand Down
31 changes: 21 additions & 10 deletions rita_client/src/rita_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -212,7 +210,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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
}
}
}
Expand Down Expand Up @@ -435,3 +437,12 @@ pub fn update_system_time() {
}
}
}

fn maybe_parse_ip(
input: Result<String, KernelInterfaceError>,
) -> Result<IpAddr, KernelInterfaceError> {
match input {
Ok(s) => Ok(s.parse()?),
Err(e) => Err(e),
}
}
2 changes: 1 addition & 1 deletion rita_exit/src/operator_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0561f6f

Please sign in to comment.