Browse Source

clippy issues

v0.1.x
ssrlive 3 years ago
parent
commit
61ed6d62c4
  1. 4
      .github/workflows/format-build.yml
  2. 2
      src/dns.rs
  3. 6
      src/virtdns.rs

4
.github/workflows/format-build.yml

@ -46,6 +46,10 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: rustfmt
run: |
rustc --version
cargo fmt --all -- --check
- run: rustup component add clippy - run: rustup component add clippy
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:

2
src/dns.rs

@ -88,7 +88,7 @@ pub fn extract_ipaddr_from_dns_message(message: &Message) -> Result<IpAddr, Stri
} }
pub fn extract_domain_from_dns_message(message: &Message) -> Result<String, String> { pub fn extract_domain_from_dns_message(message: &Message) -> Result<String, String> {
let query = message.queries().get(0).ok_or("DnsRequest no query body")?; let query = message.queries().first().ok_or("DnsRequest no query body")?;
let name = query.name().to_string(); let name = query.name().to_string();
Ok(name) Ok(name)
} }

6
src/virtdns.rs

@ -5,7 +5,7 @@ use hashlink::{linked_hash_map::RawEntryMut, LruCache};
use smoltcp::wire::Ipv4Cidr; use smoltcp::wire::Ipv4Cidr;
use std::{ use std::{
collections::HashMap, collections::HashMap,
convert::{TryFrom, TryInto}, convert::TryInto,
net::{IpAddr, Ipv4Addr, Ipv6Addr}, net::{IpAddr, Ipv4Addr, Ipv6Addr},
str::FromStr, str::FromStr,
time::{Duration, Instant}, time::{Duration, Instant},
@ -34,8 +34,8 @@ impl Default for VirtualDns {
Self { Self {
next_addr: start_addr.into(), next_addr: start_addr.into(),
name_to_ip: HashMap::default(), name_to_ip: HashMap::default(),
network_addr: IpAddr::try_from(cidr.network().address().into_address()).unwrap(), network_addr: IpAddr::from(cidr.network().address().into_address()),
broadcast_addr: IpAddr::try_from(cidr.broadcast().unwrap().into_address()).unwrap(), broadcast_addr: IpAddr::from(cidr.broadcast().unwrap().into_address()),
lru_cache: LruCache::new_unbounded(), lru_cache: LruCache::new_unbounded(),
} }
} }

Loading…
Cancel
Save