Skip to content

Commit

Permalink
release: 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Sep 5, 2024
2 parents 25b5bb9 + 1841489 commit db4428e
Show file tree
Hide file tree
Showing 17 changed files with 504 additions and 265 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/msrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,4 @@ jobs:
- name: MSRV
run: |
cargo msrv --path adbyss verify
cargo msrv --path adbyss_core verify
cargo msrv --path adbyss_psl verify -- cargo check --all-features
39 changes: 20 additions & 19 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Project Dependencies
Package: adbyss
Version: 0.12.0
Generated: 2024-08-09 05:10:46 UTC
Version: 0.13.0
Generated: 2024-09-05 20:03:14 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [adbyss_core](https://github.com/Blobfolio/adbyss) | 0.12.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.12.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [adbyss_core](https://github.com/Blobfolio/adbyss) | 0.13.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.13.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [aho-corasick](https://github.com/BurntSushi/aho-corasick) | 1.1.3 | [Andrew Gallant](mailto:[email protected]) | MIT or Unlicense |
| [argyle](https://github.com/Blobfolio/argyle) | 0.7.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [anyhow](https://github.com/dtolnay/anyhow) | 1.0.86 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crossbeam-deque](https://github.com/crossbeam-rs/crossbeam) | 0.8.5 | | Apache-2.0 or MIT |
| [crossbeam-epoch](https://github.com/crossbeam-rs/crossbeam) | 0.9.18 | | Apache-2.0 or MIT |
| [crossbeam-utils](https://github.com/crossbeam-rs/crossbeam) | 0.8.20 | | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [displaydoc](https://github.com/yaahc/displaydoc) | 0.2.5 | [Jane Lusby](mailto:[email protected]) | Apache-2.0 or MIT |
| [either](https://github.com/rayon-rs/either) | 1.13.0 | bluss | Apache-2.0 or MIT |
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.0 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.13.6 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.1 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [getrandom](https://github.com/rust-random/getrandom) | 0.2.15 | The Rand Project Developers | Apache-2.0 or MIT |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.14.5 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
| [icu_collections](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
Expand All @@ -33,16 +34,17 @@
| [icu_provider](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
| [icu_provider_macros](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
| [idna](https://github.com/servo/rust-url/) | 1.0.2 | The rust-url developers | Apache-2.0 or MIT |
| [indexmap](https://github.com/indexmap-rs/indexmap) | 2.3.0 | | Apache-2.0 or MIT |
| [indexmap](https://github.com/indexmap-rs/indexmap) | 2.5.0 | | Apache-2.0 or MIT |
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [libc](https://github.com/rust-lang/libc) | 0.2.155 | The Rust Project Developers | Apache-2.0 or MIT |
| [libc](https://github.com/rust-lang/libc) | 0.2.158 | The Rust Project Developers | Apache-2.0 or MIT |
| [libyml](https://github.com/sebastienrousseau/libyml) | 0.0.5 | LibYML Contributors | MIT |
| [litemap](https://github.com/unicode-org/icu4x) | 0.7.3 | The ICU4X Project Developers | Unicode-3.0 |
| [log](https://github.com/rust-lang/log) | 0.4.22 | The Rust Project Developers | Apache-2.0 or MIT |
| [memchr](https://github.com/BurntSushi/memchr) | 2.7.4 | [Andrew Gallant](mailto:[email protected]) and bluss | MIT or Unlicense |
| [minreq](https://github.com/neonmoe/minreq) | 2.12.0 | [Jens Pitkanen](mailto:[email protected]) | ISC |
| [once_cell](https://github.com/matklad/once_cell) | 1.19.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.86 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [quote](https://github.com/dtolnay/quote) | 1.0.36 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [rayon](https://github.com/rayon-rs/rayon) | 1.10.0 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [rayon-core](https://github.com/rayon-rs/rayon) | 1.12.1 | [Niko Matsakis](mailto:[email protected]) and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
| [regex](https://github.com/rust-lang/regex) | 1.10.6 | The Rust Project Developers and [Andrew Gallant](mailto:[email protected]) | Apache-2.0 or MIT |
Expand All @@ -53,25 +55,24 @@
| [rustls-webpki](https://github.com/rustls/webpki) | 0.101.7 | | ISC |
| [ryu](https://github.com/dtolnay/ryu) | 1.0.18 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or BSL-1.0 |
| [sct](https://github.com/rustls/sct.rs) | 0.7.1 | [Joseph Birr-Pixton](mailto:[email protected]) | Apache-2.0, ISC, or MIT |
| [serde](https://github.com/serde-rs/serde) | 1.0.205 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.205 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_yaml](https://github.com/dtolnay/serde-yaml) | 0.9.34+deprecated | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde](https://github.com/serde-rs/serde) | 1.0.209 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.209 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_yml](https://github.com/sebastienrousseau/serde_yml) | 0.0.12 | Serde YML Contributors | Apache-2.0 or MIT |
| [smallvec](https://github.com/servo/rust-smallvec) | 1.13.2 | The Servo Project Developers | Apache-2.0 or MIT |
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:[email protected]) | Apache-2.0 or MIT |
| [syn](https://github.com/dtolnay/syn) | 2.0.72 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [syn](https://github.com/dtolnay/syn) | 2.0.77 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [synstructure](https://github.com/mystor/synstructure) | 0.13.1 | [Nika Layzell](mailto:[email protected]) | MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.12.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [tinystr](https://github.com/unicode-org/icu4x) | 0.7.6 | The ICU4X Project Developers | Unicode-3.0 |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [unicode-ident](https://github.com/dtolnay/unicode-ident) | 1.0.12 | [David Tolnay](mailto:[email protected]) | Apache-2.0 AND Unicode-DFS-2016 or MIT |
| [unsafe-libyaml](https://github.com/dtolnay/unsafe-libyaml) | 0.2.11 | [David Tolnay](mailto:[email protected]) | MIT |
| [untrusted](https://github.com/briansmith/untrusted) | 0.9.0 | [Brian Smith](mailto:[email protected]) | ISC |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.9.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.9.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [utf16_iter](https://github.com/hsivonen/utf16_iter) | 1.0.5 | [Henri Sivonen](mailto:[email protected]) | Apache-2.0 or MIT |
| [utf8_iter](https://github.com/hsivonen/utf8_iter) | 1.0.4 | [Henri Sivonen](mailto:[email protected]) | Apache-2.0 or MIT |
| [webpki-roots](https://github.com/rustls/webpki-roots) | 0.25.4 | | MPL-2.0 |
| [write16](https://github.com/hsivonen/write16) | 1.0.0 | | Apache-2.0 or MIT |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [writeable](https://github.com/unicode-org/icu4x) | 0.5.5 | The ICU4X Project Developers | Unicode-3.0 |
| [yoke](https://github.com/unicode-org/icu4x) | 0.7.4 | [Manish Goregaokar](mailto:[email protected]) | Unicode-3.0 |
| [yoke-derive](https://github.com/unicode-org/icu4x) | 0.7.4 | [Manish Goregaokar](mailto:[email protected]) | Unicode-3.0 |
Expand Down
9 changes: 4 additions & 5 deletions adbyss/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[package]
name = "adbyss"
version = "0.12.0"
version = "0.13.0"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.80"
description = "Adbyss is a DNS blacklist manager for Linux."
repository = "https://github.com/Blobfolio/adbyss"
publish = false
Expand Down Expand Up @@ -90,11 +89,11 @@ items = [
]

[dependencies]
argyle = "0.7.2"
argyle = "0.8.*"
dactyl = "0.7.*"
fyi_msg = "0.13.*"
fyi_msg = "0.14.*"
libc = "0.2.*"
serde_yaml = "0.9.*"
serde_yml = "=0.0.12"

[dependencies.adbyss_core]
path = "../adbyss_core"
Expand Down
45 changes: 35 additions & 10 deletions adbyss/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,55 @@
# `Adbyss`
*/

#![deny(unsafe_code)]
#![deny(
clippy::allow_attributes_without_reason,
clippy::correctness,
unreachable_pub,
unsafe_code,
)]

#![warn(
clippy::filetype_is_file,
clippy::integer_division,
clippy::needless_borrow,
clippy::complexity,
clippy::nursery,
clippy::pedantic,
clippy::perf,
clippy::suboptimal_flops,
clippy::style,
clippy::allow_attributes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::filetype_is_file,
clippy::format_push_string,
clippy::get_unwrap,
clippy::impl_trait_in_params,
clippy::lossy_float_literal,
clippy::missing_assert_message,
clippy::missing_docs_in_private_items,
clippy::needless_raw_strings,
clippy::panic_in_result_fn,
clippy::pub_without_shorthand,
clippy::rest_pat_in_fully_bound_structs,
clippy::semicolon_inside_block,
clippy::str_to_string,
clippy::string_to_string,
clippy::todo,
clippy::undocumented_unsafe_blocks,
clippy::unneeded_field_pattern,
clippy::unseparated_literal_suffix,
clippy::unwrap_in_result,
macro_use_extern_crate,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
)]

#![allow(clippy::redundant_pub_crate)]
#![expect(clippy::redundant_pub_crate, reason = "Unresolvable.")]



Expand Down Expand Up @@ -214,19 +238,20 @@ Additional global settings are stored in /etc/adbyss.yaml.
));
}

#[allow(unsafe_code)]
#[expect(unsafe_code, reason = "For root.")]
/// # Require Root.
///
/// This will restart the command with root privileges if necessary, or fail
/// if that doesn't work.
fn require_root() -> Result<(), AdbyssError> {
// See what privileges we have.
// Safety: we have to trust libc knows how to fetch the user and group!
let (uid, e_uid) = unsafe { (libc::getuid(), libc::geteuid()) };

// We're already root.
if uid == 0 && e_uid == 0 { Ok(()) }
// We just need to SETUID.
else if e_uid == 0 {
// Safety: again we have to trust this works correctly.
unsafe { libc::setuid(0); }
Ok(())
}
Expand Down
14 changes: 12 additions & 2 deletions adbyss/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,48 @@ use std::path::PathBuf;



#[allow(clippy::struct_excessive_bools)] // This is coming from Yaml.
#[expect(clippy::struct_excessive_bools, reason = "The fields mirror our YAML config.")]
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize)]
/// # Settings.
pub(super) struct Settings {
#[serde(default = "Settings::config")]
/// # Hosts File Path.
hostfile: PathBuf,

#[serde(default = "default_true")]
/// # Backup Original Hosts?
backup: bool,

#[serde(default = "default_false")]
/// # Join Hosts by TLD?
compact: bool,

#[serde(default = "default_true")]
/// # Use Adaway Sources?
source_adaway: bool,

#[serde(default = "default_true")]
/// # Use Adbyss Sources?
source_adbyss: bool,

#[serde(default = "default_true")]
/// # Use Steven Black Sources?
source_stevenblack: bool,

#[serde(default = "default_true")]
/// # Use Yoyo Sources?
source_yoyo: bool,

#[serde(default = "Vec::new")]
/// # Domains to Exclude.
exclude: Vec<String>,

#[serde(default = "Vec::new")]
/// # Patterns to Exclude.
regexclude: Vec<String>,

#[serde(default = "Vec::new")]
/// # Domains to Include.
include: Vec<String>,
}

Expand Down Expand Up @@ -77,7 +87,7 @@ impl TryFrom<PathBuf> for Settings {
std::fs::canonicalize(&path)
.and_then(std::fs::read_to_string)
.ok()
.and_then(|x| serde_yaml::from_str::<Self>(&x).ok())
.and_then(|x| serde_yml::from_str::<Self>(&x).ok())
.ok_or_else(|| AdbyssError::Config(Box::from(path)))
}
}
Expand Down
7 changes: 3 additions & 4 deletions adbyss_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[package]
name = "adbyss_core"
version = "0.12.0"
version = "0.13.0"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.80"
description = "Library for Adbyss."
repository = "https://github.com/Blobfolio/adbyss"
publish = false

[dependencies]
argyle = "0.7.*"
argyle = "0.8.*"
dactyl = "0.7.*"
fyi_msg = "0.13.*"
fyi_msg = "0.14.*"
rayon = "1.10.*"
regex = "1.10.*"
utc2k = "0.9.*"
Expand Down
24 changes: 21 additions & 3 deletions adbyss_core/src/hosts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ const END_WATERMARK: &str = "## End of Adbyss Rules ##";
/// This is used to match the boundary between the custom hostfile entries and
/// Adbyss' contributions.
enum Watermark {
/// # No Match Yet.
Zero,

/// # Matched ### Opening.
One,

/// # Matched ADBYSS title.
Two,

/// # Matched ### Closing.
Three,
}

Expand Down Expand Up @@ -105,11 +112,22 @@ impl Watermark {
/// Results are cumulative, so if you plan on doing this more than once with
/// different setups, instantiate a new object.
pub struct Shitlist {
/// # Hosts File Path.
hostfile: PathBuf,

/// # Flags.
flags: u8,

/// # Domains to Exclude.
exclude: HashSet<Domain>,

/// # Patterns to Exclude.
regexclude: Option<RegexSet>,

/// # Found Entries.
found: HashSet<Domain>,

/// # File Contents.
out: Vec<u8>,
}

Expand Down Expand Up @@ -656,7 +674,7 @@ impl Shitlist {
found
}

#[allow(clippy::type_complexity)] // This is it.
#[expect(clippy::type_complexity, reason = "It is what it is.")]
/// # Strip Ignores: Static Filter
///
/// Because this filter could run 60K times or more, it is worth taking
Expand All @@ -673,12 +691,12 @@ impl Shitlist {
// Both, optimized static.
(Some(re), Ordering::Equal) => {
let re = re.clone();
let val = self.exclude.iter().next().unwrap().clone();
let val = self.exclude.iter().next()?.clone();
Some(Box::new(move |x| x == &&val || re.is_match(x)))
},
// Optimized static.
(None, Ordering::Equal) => {
let val = self.exclude.iter().next().unwrap().clone();
let val = self.exclude.iter().next()?.clone();
Some(Box::new(move |x| x == &&val))
},
// Both, many statics.
Expand Down
Loading

0 comments on commit db4428e

Please sign in to comment.