clippy issues

This commit is contained in:
ssrlive 2024-01-01 14:40:50 +08:00
parent 0edd07479d
commit 61ed6d62c4
3 changed files with 8 additions and 4 deletions

View file

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

View file

@ -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> {
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();
Ok(name)
}

View file

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