Skip to content

Commit

Permalink
clippy/cargo: resolve build errors and warnings
Browse files Browse the repository at this point in the history
This commit resolves all errors and warnings that surfaced
after upgrading from rustc v1.60 to v1.68.2.

Signed-off-by: Erdem Meydanli <[email protected]>
  • Loading branch information
meerd committed Apr 9, 2024
1 parent cfa679e commit b78b6c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 0 additions & 2 deletions samples/command_executer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[allow(non_local_definitions)]

pub mod command_parser;
pub mod protocol_helpers;
pub mod utils;
Expand Down
9 changes: 3 additions & 6 deletions vsock_proxy/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dns_lookup::lookup_host;
use idna::domain_to_ascii;
use std::net::IpAddr;

use crate::{IpAddrType, VsockProxyResult, DnsResolveResult};
use crate::{DnsResolveResult, IpAddrType, VsockProxyResult};

/// Resolve a DNS name (IDNA format) into multiple IP addresses (v4 or v6)
pub fn resolve(addr: &str, ip_addr_type: IpAddrType) -> VsockProxyResult<Vec<IpAddr>> {
Expand Down Expand Up @@ -55,8 +55,5 @@ pub fn resolve_single(addr: &str, ip_addr_type: IpAddrType) -> VsockProxyResult<
let ip = *addrs.first().ok_or("No IP address found")?;
let ttl = 60; // IMPORTANT TODO: Obtain this value dynamically

Ok(DnsResolveResult {
ip,
ttl
})
}
Ok(DnsResolveResult { ip, ttl })
}
8 changes: 4 additions & 4 deletions vsock_proxy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

pub mod proxy;
pub mod dns;
pub mod proxy;

use std::net::IpAddr;

Expand All @@ -13,15 +13,15 @@ pub enum IpAddrType {
/// Only allows IP6 addresses
IPAddrV6Only,
/// Allows both IP4 and IP6 addresses
IPAddrMixed
IPAddrMixed,
}

pub struct DnsResolveResult {
///Resolved address
pub ip: IpAddr,
///DNS TTL value
pub ttl: u32
pub ttl: u32,
}

/// The most common result type provided by VsockProxy operations.
pub type VsockProxyResult<T> = Result<T, String>;
pub type VsockProxyResult<T> = Result<T, String>;
9 changes: 6 additions & 3 deletions vsock_proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use clap::{App, AppSettings, Arg};
use env_logger::init;
use log::info;

use vsock_proxy::{proxy::{check_allowlist, Proxy}, IpAddrType, VsockProxyResult};
use vsock_proxy::{
proxy::{check_allowlist, Proxy},
IpAddrType, VsockProxyResult,
};

fn main() -> VsockProxyResult<()> {
init();
Expand Down Expand Up @@ -77,7 +80,7 @@ fn main() -> VsockProxyResult<()> {

let ipv4_only = matches.is_present("ipv4");
let ipv6_only = matches.is_present("ipv6");
let ip_addr_type : IpAddrType = match (ipv4_only, ipv6_only) {
let ip_addr_type: IpAddrType = match (ipv4_only, ipv6_only) {
(true, false) => IpAddrType::IPAddrV4Only,
(false, true) => IpAddrType::IPAddrV6Only,
_ => IpAddrType::IPAddrMixed,
Expand Down Expand Up @@ -119,7 +122,7 @@ fn main() -> VsockProxyResult<()> {
remote_host,
remote_port,
num_workers,
ip_addr_type
ip_addr_type,
)
.map_err(|err| format!("Could not create proxy: {}", err))?;

Expand Down

0 comments on commit b78b6c4

Please sign in to comment.