Skip to content

Commit 960204a

Browse files
committed
release: 0.23.4
2 parents c814635 + c508918 commit 960204a

10 files changed

Lines changed: 282 additions & 115 deletions

File tree

CREDITS.md

Lines changed: 103 additions & 43 deletions
Large diffs are not rendered by default.

adbyss/Cargo.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "adbyss"
3-
version = "0.23.3"
3+
version = "0.23.4"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"
@@ -91,9 +91,9 @@ items = [
9191
[dependencies]
9292
argyle = "0.15.*"
9393
dactyl = "0.13.*"
94-
fyi_msg = "2.5.*"
94+
fyi_msg = "2.6.*"
9595
regex = "1.12.*"
96-
toml = "=1.0.*"
96+
toml = "=1.1.*"
9797
trimothy = "0.9.*"
9898
utc2k = "0.19.*"
9999
write_atomic = "0.7.*"
@@ -102,16 +102,15 @@ write_atomic = "0.7.*"
102102
path = "../adbyss_psl"
103103
features = [ "serde" ]
104104

105-
[dependencies.minreq]
106-
version = "2.14.*"
107-
default-features = false
108-
features = [ "https" ]
109-
110105
[dependencies.nix]
111106
version = "0.31.*"
112107
default-features = false
113108
features = [ "user" ]
114109

110+
[dependencies.reqwest]
111+
version = "0.13.*"
112+
features = [ "blocking", "gzip" ]
113+
115114
[dependencies.serde]
116115
version = "1.0.*"
117116
features = [ "derive" ]

adbyss/src/main.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757

5858
mod err;
59+
mod net;
5960
mod settings;
6061
mod source;
6162
mod write;
@@ -161,7 +162,7 @@ fn main__() -> Result<(), AdbyssError> {
161162
}
162163

163164
// Make sure we're online if any sources other than our own are enabled.
164-
if settings.needs_internet() { check_internet()?; }
165+
if settings.needs_internet() { net::check_internet()?; }
165166

166167
// Just print the domains.
167168
if flags.contains(Flags::Show) {
@@ -200,41 +201,6 @@ fn main__() -> Result<(), AdbyssError> {
200201
Ok(())
201202
}
202203

203-
/// # Check Internet.
204-
///
205-
/// This method attempts to check for an internet connection by trying to reach
206-
/// Github (which is serving one of the lists Adbyss needs anyway). It will
207-
/// give it ten tries, with ten seconds in between each try, returning an
208-
/// error if nothing has been reached after that.
209-
///
210-
/// ## Errors
211-
///
212-
/// If the site can't be reached, an error will be returned.
213-
fn check_internet() -> Result<(), AdbyssError> {
214-
use std::{
215-
thread::sleep,
216-
time::Duration,
217-
};
218-
219-
let mut tries: u8 = 0;
220-
loop {
221-
// Are you there?
222-
let res = minreq::head("https://github.com/")
223-
.with_header("user-agent", "Mozilla/5.0")
224-
.with_timeout(15)
225-
.send();
226-
227-
if res.is_ok_and(|r| r.status_code == 200) { return Ok(()); }
228-
229-
// Out of tries?
230-
if tries == 9 { return Err(AdbyssError::NoInternet); }
231-
232-
// Wait and try again.
233-
tries += 1;
234-
sleep(Duration::from_secs(10));
235-
}
236-
}
237-
238204
/// # Require Root.
239205
///
240206
/// This will restart the command with root privileges if necessary, or fail

adbyss/src/net.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*!
2+
# Adbyss: Networking.
3+
*/
4+
5+
use crate::AdbyssError;
6+
use reqwest::{
7+
blocking::{
8+
Client,
9+
ClientBuilder,
10+
},
11+
StatusCode,
12+
};
13+
use std::{
14+
sync::OnceLock,
15+
thread::sleep,
16+
time::Duration,
17+
};
18+
19+
/// # HTTP Client.
20+
static CLIENT: OnceLock<Option<Client>> = OnceLock::new();
21+
22+
23+
24+
/// # Check Internet.
25+
///
26+
/// This method attempts to check for an internet connection by trying to reach
27+
/// Github (which is serving one of the lists Adbyss needs anyway). It will
28+
/// give it ten tries, with ten seconds in between each try, returning an
29+
/// error if nothing has been reached after that.
30+
///
31+
/// ## Errors
32+
///
33+
/// If the site can't be reached, an error will be returned.
34+
pub(super) fn check_internet() -> Result<(), AdbyssError> {
35+
let mut tries: u8 = 0;
36+
loop {
37+
// Are you there?
38+
let res = client()
39+
.ok_or(AdbyssError::NoInternet)?
40+
.head("https://github.com/")
41+
.send();
42+
43+
if res.is_ok_and(|r| matches!(r.status(), StatusCode::OK)) { return Ok(()); }
44+
45+
// Out of tries?
46+
if tries == 9 { return Err(AdbyssError::NoInternet); }
47+
48+
// Wait and try again.
49+
tries += 1;
50+
sleep(Duration::from_secs(10));
51+
}
52+
}
53+
54+
#[must_use]
55+
/// # Initialize HTTP Client.
56+
pub(super) fn client() -> Option<&'static Client> {
57+
CLIENT.get_or_init(||
58+
ClientBuilder::new()
59+
.user_agent("Mozilla/5.0")
60+
.gzip(true)
61+
.build()
62+
.ok()
63+
)
64+
.as_ref()
65+
}

adbyss/src/source.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,19 @@ impl Source {
121121
/// content, so the extra complexity is worth it.
122122
fn download_source(kind: Source) -> Result<String, AdbyssError> {
123123
if
124-
let Ok(res) = minreq::get(kind.url())
125-
.with_header("user-agent", "Mozilla/5.0")
126-
.with_timeout(15)
127-
.send() &&
128-
(200..=399).contains(&res.status_code) &&
129-
let Ok(out) = res.as_str()
124+
let Some(client) = crate::net::client() &&
125+
let Ok(res) = client.get(kind.url()).send()
130126
{
131-
Ok(out.to_owned())
127+
let status = res.status();
128+
if
129+
(status.is_success() || status.is_redirection()) &&
130+
let Ok(out) = res.text()
131+
{
132+
return Ok(out);
133+
}
132134
}
133-
else { Err(AdbyssError::SourceFetch(kind)) }
135+
136+
Err(AdbyssError::SourceFetch(kind))
134137
}
135138

136139
/// # Read From Cache.

adbyss_psl/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33

44

5+
## [0.23.4](https://github.com/Blobfolio/adbyss/releases/tag/v0.23.4) - 2026-04-16
6+
7+
### Changed
8+
9+
* Update suffix database
10+
11+
12+
513
## [0.23.3](https://github.com/Blobfolio/adbyss/releases/tag/v0.23.3) - 2026-03-05
614

715
### Changed

adbyss_psl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "adbyss_psl"
3-
version = "0.23.3"
3+
version = "0.23.4"
44
license = "WTFPL"
55
authors = ["Josh Stoik <josh@blobfolio.com>"]
66
edition = "2024"

0 commit comments

Comments
 (0)