Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed May 15, 2024
1 parent bac6710 commit 224c0b9
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion etc/smartdns/smartdns.conf
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ log-level info
# specific cname to domain
# cname /domain/target

# enalbe DNS64 feature
# enable DNS64 feature
# dns64 [ip/subnet]
# dns64 64:ff9b::/96

Expand Down
6 changes: 3 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl App {

middleware_builder = middleware_builder.with(AddressMiddleware);

if cfg.resolv_hostanme() {
if cfg.resolv_hostname() {
middleware_builder = middleware_builder.with(DnsHostsMiddleware::new());
}

Expand Down Expand Up @@ -179,7 +179,7 @@ impl App {
let nftsets = cfg.valid_nftsets();
if !nftsets.is_empty() {
let nft = Nft::new();
if nft.avaliable() {
if nft.available() {
let mut success = true;
for i in nftsets {
if let Err(err) = match i {
Expand All @@ -197,7 +197,7 @@ impl App {
middleware_builder.with(DnsNftsetMiddleware::new(nft));
}
} else {
log::warn!("nft is not avaliable, skipped.",);
log::warn!("nft is not available, skipped.",);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/config/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub trait IListenerConfig {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct UdpListenerConfig {
/// listen adress
/// listen address
#[serde(with = "serde_str")]
pub listen: ListenerAddress,
/// listen port
Expand All @@ -64,7 +64,7 @@ impl Default for UdpListenerConfig {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TcpListenerConfig {
/// listen adress
/// listen address
#[serde(with = "serde_str")]
pub listen: ListenerAddress,
/// listen port
Expand All @@ -79,7 +79,7 @@ pub struct TcpListenerConfig {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TlsListenerConfig {
/// listen adress
/// listen address
#[serde(with = "serde_str")]
pub listen: ListenerAddress,
/// listen port
Expand All @@ -97,7 +97,7 @@ pub struct TlsListenerConfig {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct HttpsListenerConfig {
/// listen adress
/// listen address
#[serde(with = "serde_str")]
pub listen: ListenerAddress,
/// listen port
Expand All @@ -115,7 +115,7 @@ pub struct HttpsListenerConfig {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct QuicListenerConfig {
/// listen adress
/// listen address
#[serde(with = "serde_str")]
pub listen: ListenerAddress,
/// listen port
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct Config {
/// ```
/// user [username]
///
/// exmaple:
/// example:
/// user nobody
/// ```
pub user: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/config/parser/domain_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ impl NomParser for DomainRule {
map(options::parse_no_value(tag("no-cache")), |v| {
rule.no_cache = Some(v);
}),
map(options::unkown_options, |(n, v)| {
log::warn!("domain rule: unkown options {}={:?}", n, v)
map(options::unknown_options, |(n, v)| {
log::warn!("domain rule: unknown options {}={:?}", n, v)
}),
));

Expand Down
8 changes: 4 additions & 4 deletions src/config/parser/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn parse_no_value<'a, O, E: nom::error::ParseError<&'a str>, N: nom::Parser<
value(true, preceded(take_while_m_n(1, 2, |c| c == '-'), name))
}

pub fn unkown_value(input: &str) -> IResult<&str, &str> {
pub fn unknown_value(input: &str) -> IResult<&str, &str> {
preceded(
alt((tag("="), recognize(pair(opt(char(':')), space1)))),
recognize(pair(
Expand All @@ -50,14 +50,14 @@ pub fn unkown_value(input: &str) -> IResult<&str, &str> {
)(input)
}

pub fn unkown_options(input: &str) -> IResult<&str, (&str, Option<&str>)> {
pub fn unknown_options(input: &str) -> IResult<&str, (&str, Option<&str>)> {
let key = any_name;
let value = unkown_value;
let value = unknown_value;
pair(key, opt(value))(input)
}

pub fn parse(input: &str) -> IResult<&str, Options<'_>> {
let (input, options) = separated_list0(space1, unkown_options)(input)?;
let (input, options) = separated_list0(space1, unknown_options)(input)?;

Ok((input, options))
}
Expand Down
5 changes: 4 additions & 1 deletion src/dns_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ impl DnsClientBuilder {
.filter(|info| {
info.bootstrap_dns && {
if info.server.ip().is_none() {
warn!("bootstrap-dns must use ip addess, {:?}", info.server.host());
warn!(
"bootstrap-dns must use ip address, {:?}",
info.server.host()
);
false
} else {
true
Expand Down
6 changes: 3 additions & 3 deletions src/dns_conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl RuntimeConfig {
.filter(|p| p.exists())
.map(RuntimeConfig::load_from_file)
.next()
.expect("No configuation file found.")
.expect("No configuration file found.")
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ impl RuntimeConfig {

/// whether resolv local hostname to ip address
#[inline]
pub fn resolv_hostanme(&self) -> bool {
pub fn resolv_hostname(&self) -> bool {
self.resolv_hostname.unwrap_or(self.hosts_file.is_some())
}

Expand Down Expand Up @@ -586,7 +586,7 @@ impl RuntimeConfigBuilder {
&cfg.nftsets,
);

// set nameserver group for bootstraping
// set nameserver group for bootstrapping
for server in cfg.nameservers.iter_mut() {
if server.server.ip().is_none() {
let host = server.server.host().to_string();
Expand Down
10 changes: 5 additions & 5 deletions src/dns_mw_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,21 +368,21 @@ impl Middleware<DnsContext, DnsRequest, DnsResponse, DnsError> for DnsCacheMiddl
}

struct DomainPrefetchingNotify {
notity: Arc<Notify>,
notify: Arc<Notify>,
tick: RwLock<Instant>,
}

impl DomainPrefetchingNotify {
pub fn new() -> Self {
Self {
notity: Default::default(),
notify: Default::default(),
tick: RwLock::new(Instant::now()),
}
}

async fn notify_after(&self, duration: Duration) {
if duration.is_zero() {
self.notity.notify_one()
self.notify.notify_one()
} else {
let now = Instant::now();
let tick = *(self.tick.read().await);
Expand All @@ -397,7 +397,7 @@ impl DomainPrefetchingNotify {

*self.tick.write().await.deref_mut() = next_tick;
debug!("Domain prefetch check will be performed in {:?}.", duration);
let notify = self.notity.clone();
let notify = self.notify.clone();
tokio::spawn(async move {
sleep(duration).await;
notify.notify_one();
Expand All @@ -410,7 +410,7 @@ impl Deref for DomainPrefetchingNotify {
type Target = Notify;

fn deref(&self) -> &Self::Target {
self.notity.as_ref()
self.notify.as_ref()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/dns_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl DomainRuleMap {
};

for name in names {
// overide
// override
*(name_rule_map.entry(name).or_default()) += rule.config.clone();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Error {
LoadCertificateFailed(PathBuf, String),
#[error("loading certificate key {0} failed, due to: {1}")]
LoadCertificateKeyFailed(PathBuf, String),
#[error("could not register {0} listener on addresss {1}, due to {2}")]
#[error("could not register {0} listener on address {1}, due to {2}")]
RegisterListenerFailed(&'static str, SocketAddr, String),
/// An underlying IO error occurred
#[error("io error: {0}")]
Expand Down
10 changes: 5 additions & 5 deletions src/ffi/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const B_NAME: &str = "nft";
#[derive(Debug)]
pub struct Nft {
path: PathBuf,
avaliable: bool,
available: bool,
}

impl Nft {
pub fn new() -> Self {
let mut nft = Self {
path: B_NAME.into(),
avaliable: false,
available: false,
};

use which::{which, which_in_global};
Expand All @@ -22,13 +22,13 @@ impl Nft {
}) {
nft.path = path;
}
nft.avaliable = nft.list_tables().is_ok();
nft.available = nft.list_tables().is_ok();

nft
}

pub fn avaliable(&self) -> bool {
self.avaliable
pub fn available(&self) -> bool {
self.available
}

pub fn add_ipv4_set(&self, family: &'static str, table: &str, name: &str) -> io::Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/infra/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ mod icmp {
// enable by running: `sudo setcap CAP_NET_RAW+eip /path/to/program`
Type::RAW
} else {
panic!("unpriviledged ping is disabled, please enable by setting `net.ipv4.ping_group_range` or setting `CAP_NET_RAW`")
panic!("unprivileged ping is disabled, please enable by setting `net.ipv4.ping_group_range` or setting `CAP_NET_RAW`")
}
} else if #[cfg(any(target_os = "macos"))] {
// MacOS seems enable UNPRIVILEGED_ICMP by default.
Expand Down
4 changes: 2 additions & 2 deletions src/server/legacy/dns_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl RequestHandler for DnsServerHandler {
dns_response.answers(),
dns_response.name_servers(),
Box::new(None.into_iter()),
dns_response.additionals(),
dns_response.additional(),
);

let result =
Expand Down Expand Up @@ -309,7 +309,7 @@ impl From<&Request> for crate::dns::DnsRequest {
queries: vec![value.query().original().clone()],
answers: value.answers().into_iter().cloned().collect(),
name_servers: value.name_servers().into_iter().cloned().collect(),
additionals: value.additionals().into_iter().cloned().collect(),
additional: value.additional().into_iter().cloned().collect(),
sig0: value.sig0().into_iter().cloned().collect(),
edns: value.edns().cloned(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ mod net {
bind_type: &str,
) -> T {
func(sock_addr, bind_device, bind_type).unwrap_or_else(|err| {
panic!("cound not bind to {bind_type}: {sock_addr}, {err}");
panic!("could not bind to {bind_type}: {sock_addr}, {err}");
})
}

Expand Down
8 changes: 4 additions & 4 deletions src/service/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ impl From<&str> for InstallContentOrPath {

#[derive(Debug, PartialEq, Eq)]
pub enum InstallStrategy {
Overide,
Override,
Backup,
Preserve,
}

impl Default for InstallStrategy {
#[inline]
fn default() -> Self {
Self::Overide
Self::Override
}
}

Expand Down Expand Up @@ -389,7 +389,7 @@ impl Installer {
InstallStrategy::Preserve => {
dest_path.append_extension("default");
}
InstallStrategy::Overide => (),
InstallStrategy::Override => (),
}
}

Expand Down Expand Up @@ -433,7 +433,7 @@ impl Installer {
}
};
} else {
// directry
// directory
if install_item.is_directory() && !install_item.path.exists() {
fs::create_dir_all(install_item.path.as_path())?;
}
Expand Down

0 comments on commit 224c0b9

Please sign in to comment.