Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interleave dns providers #224

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
doylemark marked this conversation as resolved.
Show resolved Hide resolved
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-control-plane-image-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- name: Parse semver from cargo.toml
id: get-version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-data-plane-binary-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- name: Parse semver from cargo.toml
id: get-version
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-control-plane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-data-plane.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: "standard-cache"
Expand All @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: "standard-cache"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-shared-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: "standard-cache"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/vsock-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: "vsock-proxy"
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- uses: Swatinem/rust-cache@v2
with:
shared-key: "vsock-proxy"
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- name: Compile proxy
run: cargo build -p vsock-proxy --release
- name: Upload proxy
Expand All @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: 1.79.0
- name: Publish vsock-proxy
run: cargo publish -p vsock-proxy
env:
Expand Down
17 changes: 9 additions & 8 deletions control-plane/src/dnsproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ use tokio::net::UdpSocket;
const DNS_SERVER_OVERRIDE_KEY: &str = "EV_CONTROL_PLANE_DNS_SERVER";

lazy_static::lazy_static! {
pub static ref CLOUDFLARE_DNS_SERVERS: Vec<IpAddr> = vec![IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), IpAddr::V4(Ipv4Addr::new(1, 0, 0, 1))];
pub static ref GOOGLE_DNS_SERVERS: Vec<IpAddr> = vec![IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), IpAddr::V4(Ipv4Addr::new(8, 8, 4, 4))];
pub static ref OPEN_DNS_SERVERS: Vec<IpAddr> = vec![IpAddr::V4(Ipv4Addr::new(208, 67, 222, 222)), IpAddr::V4(Ipv4Addr::new(208, 67, 220, 220))];
pub static ref DNS_SERVERS: Vec<IpAddr> = vec![
IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), // Cloudflare Primary
IpAddr::V4(Ipv4Addr::new(8, 8, 8, 8)), // Google Primary
IpAddr::V4(Ipv4Addr::new(208, 67, 222, 222)), // OpenDNS Primary
IpAddr::V4(Ipv4Addr::new(1, 0, 0, 1)), // Cloudflare Secondary
IpAddr::V4(Ipv4Addr::new(8, 8, 4, 4)), // Google Secondary
IpAddr::V4(Ipv4Addr::new(208, 67, 220, 220)) // OpenDNS Secondary
];
}

pub fn read_dns_server_ips_from_env_var() -> Option<Vec<IpAddr>> {
Expand All @@ -32,11 +37,7 @@ pub struct DnsProxy {
impl std::default::Default for DnsProxy {
fn default() -> Self {
Self {
dns_server_ips: [
CLOUDFLARE_DNS_SERVERS.as_slice(),
GOOGLE_DNS_SERVERS.as_slice(),
]
.concat(),
dns_server_ips: DNS_SERVERS.clone(),
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions control-plane/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,8 @@ async fn main() -> Result<()> {
{
listen_for_shutdown_signal();
let mut health_check_server = health::HealthCheckServer::new().await?;
let parsed_ip = control_plane::dnsproxy::read_dns_server_ips_from_env_var().unwrap_or(
[
control_plane::dnsproxy::CLOUDFLARE_DNS_SERVERS.as_slice(),
control_plane::dnsproxy::GOOGLE_DNS_SERVERS.as_slice(),
]
.concat(),
);
let parsed_ip = control_plane::dnsproxy::read_dns_server_ips_from_env_var()
.unwrap_or_else(|| control_plane::dnsproxy::DNS_SERVERS.clone());

let dns_proxy_server = control_plane::dnsproxy::DnsProxy::new(parsed_ip);
let (
Expand Down
19 changes: 10 additions & 9 deletions data-plane/src/dns/enclavedns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ impl EnclaveDnsProxy {

loop {
let mut buffer = [0; 512];
let (amt, src) = shared_socket.recv_from(&mut buffer).await?;
let buf = Bytes::copy_from_slice(&buffer[..amt]);
let dispatch_result =
timeout(dns_dispatch_timeout, dns_lookup_sender.send((buf, src))).await;
if let Ok((amt, src)) = shared_socket.recv_from(&mut buffer).await {
let buf = Bytes::copy_from_slice(&buffer[..amt]);
let dispatch_result =
timeout(dns_dispatch_timeout, dns_lookup_sender.send((buf, src))).await;

match dispatch_result {
Ok(Err(e)) => log::error!("Error dispatching DNS request: {e:?}"),
Err(e) => log::error!("Timeout dispatching DNS request: {e:?}"),
_ => {}
};
match dispatch_result {
Ok(Err(e)) => log::error!("Error dispatching DNS request: {e:?}"),
Err(e) => log::error!("Timeout dispatching DNS request: {e:?}"),
_ => {}
};
}
}
}
}
Expand Down
Loading