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

build(rust): Move cargo dependencies into root Cargo.toml #64

Merged
merged 1 commit into from
Apr 29, 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
164 changes: 161 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,164 @@
[workspace]
members = ["crates/dyndns"]
resolver = "2"

members = [
"crates/dyndns",
]
[workspace.package]
rust-version = "1.76"
edition = "2021"
license = "MIT"

[workspace.dependencies]
chrono = { version = "0.4", default-features = false, features = [
"alloc",
"serde",
"clock",
] }
clap = { version = "4", features = ["cargo", "derive"] }
color-eyre = "0.6"
figment = { version = "0.10", features = ["env", "toml", "test"] }
figment_file_provider_adapter = "0.1"
humantime = "2"
humantime-serde = "1"
itertools = "0.12"
native-tls = { version = "0.2", features = ["vendored"] }
once_cell = "1"
reqwest = { version = "0.12", features = ["blocking", "json"] }
secrecy = { version = "0.8", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
serde_with = "3"
signal-hook = { version = "0.3", features = ["extended-siginfo"] }
tailsome = "1"
tracing = "0.1"
tracing-log = "0.2"
tracing-subscriber = "0.3"
trust-dns-resolver = "0.23"

# Stats feature dependencies
cfg-if = "1"
diesel = { version = "2", features = ["sqlite", "chrono"]}
diesel_migrations = { version = "2", features = ["sqlite"]}
directories = "5"
libsqlite3-sys = { version = "0.28", features = ["bundled"]}

# Web server dependencies
aide = { version = "0.13", features = [
"redoc",
"axum",
"axum-extra",
"macros",
] }
axum = { version = "0.7" }
axum-jsonschema = { version = "0.8", features = [
"aide",
] }
axum-macros = { version = "0.4" }
futures-util = { version = "0.3" }
http = { version = "1" }
hyper = { version = "1" }
hyper-util = { version = "0" }
mime_guess = { version = "2" }
rust-embed = { version = "8", features = ["debug-embed"]}
schemars = { version = "0.8", features = ["chrono"] }
tower = { version = "0.4", features = ["full"] }
tower-http = { version = "0.5", features = ["full"] }
tokio = { version = "1", features = ["full"] }

# workspace.build-dependencies (not actually a valid key, so needs to be part of
# regular dependencies)
# Keep anyhow, because vergen depends on it.
anyhow = "1"
vergen = { version = "8", features = [
"build",
"cargo",
"git",
"gitcl",
"rustc",
"si",
] }

# workspace.dev-dependencies (not actually a valid key, so needs to be part of
# regular dependencies)
tempfile = "3"

# An opinionated list of extra clippy lints. Can be overridden where necessary.
# Taken from
# https://github.com/EmbarkStudios/rust-ecosystem/blob/542740e462f7ebf246e0b7170b3fb77cf6c68ec7/lints.rs
# but converted to new 1.74+ Cargo.toml syntax.
# See https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-lints-section

[workspace.lints.rust]
unsafe_code = "deny"
future_incompatible = "warn"
nonstandard_style = "warn"
rust_2018_idioms = "warn"

[workspace.lints.clippy]
all = "warn"
await_holding_lock = "warn"
char_lit_as_u8 = "warn"
checked_conversions = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
doc_markdown = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
fallible_impl_from = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
from_iter_instead_of_collect = "warn"
if_let_mutex = "warn"
implicit_clone = "warn"
imprecise_flops = "warn"
inefficient_to_string = "warn"
invalid_upcast_comparisons = "warn"
large_digit_groups = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
let_unit_value = "warn"
linkedlist = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_ok_or = "warn"
map_err_ignore = "warn"
map_flatten = "warn"
map_unwrap_or = "warn"
match_on_vec_items = "warn"
match_same_arms = "warn"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
mem_forget = "warn"
mismatched_target_os = "warn"
missing_enforced_import_renames = "warn"
mut_mut = "warn"
mutex_integer = "warn"
needless_borrow = "warn"
needless_continue = "warn"
needless_for_each = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
ptr_as_ptr = "warn"
rc_mutex = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_functions_in_if_condition = "warn"
semicolon_if_nothing_returned = "warn"
single_match_else = "warn"
string_add_assign = "warn"
string_add = "warn"
string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
unimplemented = "warn"
unnested_or_patterns = "warn"
unused_self = "warn"
useless_transmute = "warn"
verbose_file_reads = "warn"
zero_sized_map_values = "warn"
92 changes: 48 additions & 44 deletions crates/dyndns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
name = "digitalocean-dyndns"
version = "0.6.0"
edition = "2021"
license.workspace = true
rust-version.workspace = true
description = "Dynamic DNS using DigitalOcean's DNS API"
readme = "README.md"
repository = "https://github.com/alcroito/digitalocean-dyndns"
license = "MIT"
keywords = ["dyndns", "digitalocean"]
publish = false
build = "build.rs"
Expand Down Expand Up @@ -41,66 +42,66 @@ web = [
]

[dependencies]
chrono = { version = "0.4", default-features = false, features = [
chrono = { workspace = true, default-features = false, features = [
"alloc",
"serde",
"clock",
] }
clap = { version = "4", features = ["cargo", "derive"] }
color-eyre = "0.6"
figment = { version = "0.10", features = ["env", "toml", "test"] }
figment_file_provider_adapter = "0.1"
humantime = "2"
humantime-serde = "1"
itertools = "0.12"
native-tls = { version = "0.2", features = ["vendored"] }
once_cell = "1"
reqwest = { version = "0.12", features = ["blocking", "json"] }
secrecy = { version = "0.8", features = ["serde"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
serde_with = "3"
signal-hook = { version = "0.3", features = ["extended-siginfo"] }
tailsome = "1"
tracing = "0.1"
tracing-log = "0.2"
tracing-subscriber = "0.3"
trust-dns-resolver = "0.23"
clap = { workspace = true, features = ["cargo", "derive"] }
color-eyre.workspace = true
figment = { workspace = true, features = ["env", "toml", "test"] }
figment_file_provider_adapter.workspace = true
humantime.workspace = true
humantime-serde.workspace = true
itertools.workspace = true
native-tls = { workspace = true, features = ["vendored"] }
once_cell.workspace = true
reqwest = { workspace = true, features = ["blocking", "json"] }
secrecy = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive", "rc"] }
serde_json.workspace = true
serde_with.workspace = true
signal-hook = { workspace = true, features = ["extended-siginfo"] }
tailsome.workspace = true
tracing.workspace = true
tracing-log.workspace = true
tracing-subscriber.workspace = true
trust-dns-resolver.workspace = true

# Stats feature dependencies
cfg-if = "1"
diesel = { version = "2", features = ["sqlite", "chrono"], optional = true }
diesel_migrations = { version = "2", features = ["sqlite"], optional = true }
directories = "5"
libsqlite3-sys = { version = "0.28", features = ["bundled"], optional = true }
cfg-if.workspace = true
diesel = { workspace = true, features = ["sqlite", "chrono"], optional = true }
diesel_migrations = { workspace = true, features = ["sqlite"], optional = true }
directories.workspace = true
libsqlite3-sys = { workspace = true, features = ["bundled"], optional = true }

# Web server dependencies
aide = { version = "0.13", optional = true, features = [
aide = { workspace = true, optional = true, features = [
"redoc",
"axum",
"axum-extra",
"macros",
] }
axum = { version = "0.7", optional = true }
axum-jsonschema = { version = "0.8", optional = true, features = [
axum = { workspace = true, optional = true }
axum-jsonschema = { workspace = true, optional = true, features = [
"aide",
] }
axum-macros = { version = "0.4", optional = true }
futures-util = { version = "0.3", optional = true }
http = { version = "1", optional = true }
hyper = { version = "1", optional = true }
hyper-util = { version = "0", optional = true }
mime_guess = { version = "2", optional = true }
rust-embed = { version = "8", features = ["debug-embed"], optional = true }
schemars = { version = "0.8", optional = true, features = ["chrono"] }
tower = { version = "0.4", features = ["full"], optional = true }
tower-http = { version = "0.5", features = ["full"], optional = true }
tokio = { version = "1", features = ["full"], optional = true }
axum-macros = { workspace = true, optional = true }
futures-util = { workspace = true, optional = true }
http = { workspace = true, optional = true }
hyper = { workspace = true, optional = true }
hyper-util = { workspace = true, optional = true }
mime_guess = { workspace = true, optional = true }
rust-embed = { workspace = true, features = ["debug-embed"], optional = true }
schemars = { workspace = true, optional = true, features = ["chrono"] }
tower = { workspace = true, features = ["full"], optional = true }
tower-http = { workspace = true, features = ["full"], optional = true }
tokio = { workspace = true, features = ["full"], optional = true }

[build-dependencies]
# Keep anyhow, because vergen depends on it.
anyhow = "1"
vergen = { version = "8", features = [
anyhow.workspace = true
vergen = { workspace = true, features = [
"build",
"cargo",
"git",
Expand All @@ -110,4 +111,7 @@ vergen = { version = "8", features = [
] }

[dev-dependencies]
tempfile = "3"
tempfile.workspace = true

[lints]
workspace = true
15 changes: 7 additions & 8 deletions crates/dyndns/src/config/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ where
impl<'de> Visitor<'de> for LogLevelVisitor {
type Value = tracing::Level;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str("a number between 0 and 3 or one of the following strings: error, warn, info, debug, trace")
}

Expand All @@ -160,7 +160,6 @@ where
let level = match value {
0 => tracing::Level::INFO,
1 => tracing::Level::DEBUG,
2 => tracing::Level::TRACE,
_ => tracing::Level::TRACE,
};
Ok(level)
Expand All @@ -170,9 +169,11 @@ where
where
E: de::Error,
{
value.parse::<tracing::Level>().map_err(|_| {
let msg = "error parsing log level: expected one of \"error\", \"warn\", \
\"info\", \"debug\", \"trace\"";
value.parse::<tracing::Level>().map_err(|e| {
let msg = format!(
"error parsing log level: expected one of \"error\", \"warn\", \
\"info\", \"debug\", \"trace\": {e}"
);
E::custom(msg)
})
}
Expand All @@ -190,11 +191,9 @@ where
S: serde::Serializer,
{
let level_u8 = match *level {
tracing::Level::INFO => 0,
tracing::Level::INFO | tracing::Level::WARN | tracing::Level::ERROR => 0,
tracing::Level::DEBUG => 1,
tracing::Level::TRACE => 2,
tracing::Level::ERROR => 0,
tracing::Level::WARN => 0,
};
serializer.serialize_u8(level_u8)
}
2 changes: 1 addition & 1 deletion crates/dyndns/src/db/crud/domain_records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn get_domain_records(conn: &mut SqliteConnection) -> Result<Vec<DomainRecor

pub fn create_domain_record(
conn: &mut SqliteConnection,
new_domain_record: &NewDomainRecord,
new_domain_record: &NewDomainRecord<'_, '_>,
) -> Result<Option<DomainRecord>> {
use super::super::schema::domain_records;
let domain_record =
Expand Down
2 changes: 1 addition & 1 deletion crates/dyndns/src/domain_record_api/digital_ocean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl DomainRecordApi for DigitalOceanApi {

impl Drop for DigitalOceanApi {
fn drop(&mut self) {
trace!("DigitalOceanApi object destroyed")
trace!("DigitalOceanApi object destroyed");
}
}

Expand Down
5 changes: 3 additions & 2 deletions crates/dyndns/src/ip_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use trust_dns_resolver::Resolver;
use crate::types::{DisplayIpAddrV4AndV6Pretty, IpAddrV4AndV6};

/// IP addresses for OpenDNS Public DNS
/// https://en.wikipedia.org/wiki/OpenDNS
/// [https://en.wikipedia.org/wiki/OpenDNS](https://en.wikipedia.org/wiki/OpenDNS)
const OPEN_DNS_IPS: &[IpAddr] = &[
IpAddr::V4(Ipv4Addr::new(208, 67, 222, 222)),
IpAddr::V4(Ipv4Addr::new(208, 67, 220, 220)),
Expand All @@ -26,7 +26,8 @@ pub struct DnsIpFetcher {}

impl PublicIpFetcher for DnsIpFetcher {
/// Fetch public IP of current machine by querying the OpenDNS myip resolver
/// See https://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-a-shell-script/81699#81699
/// See
/// [Stack Overflow](https://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-a-shell-script/81699#81699)
fn fetch_public_ips(&self, lookup_ipv4: bool, lookup_ipv6: bool) -> Result<IpAddrV4AndV6> {
info!("Fetching public IP using OpenDNS");
let hostname_to_lookup = "myip.opendns.com.";
Expand Down
2 changes: 1 addition & 1 deletion crates/dyndns/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn setup_early_logger() -> Result<()> {
.init();
TRACING_FILTER_RELOAD_HANDLE
.set(reload_handle)
.map_err(|_| eyre!("Could not save tracing filter reload handle"))
.map_err(|e| eyre!("Could not save tracing filter reload handle {e:?}"))
}

pub fn setup_logger(log_level: &tracing::Level) -> Result<()> {
Expand Down
Loading
Loading