File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 11[package ]
22name = " adbyss"
3- version = " 0.23.3 "
3+ version = " 0.23.4 "
44license = " WTFPL"
55authors = [" Josh Stoik <josh@blobfolio.com>" ]
66edition = " 2024"
@@ -91,9 +91,9 @@ items = [
9191[dependencies ]
9292argyle = " 0.15.*"
9393dactyl = " 0.13.*"
94- fyi_msg = " 2.5 .*"
94+ fyi_msg = " 2.6 .*"
9595regex = " 1.12.*"
96- toml = " =1.0 .*"
96+ toml = " =1.1 .*"
9797trimothy = " 0.9.*"
9898utc2k = " 0.19.*"
9999write_atomic = " 0.7.*"
@@ -102,16 +102,15 @@ write_atomic = "0.7.*"
102102path = " ../adbyss_psl"
103103features = [ " serde" ]
104104
105- [dependencies .minreq ]
106- version = " 2.14.*"
107- default-features = false
108- features = [ " https" ]
109-
110105[dependencies .nix ]
111106version = " 0.31.*"
112107default-features = false
113108features = [ " user" ]
114109
110+ [dependencies .reqwest ]
111+ version = " 0.13.*"
112+ features = [ " blocking" , " gzip" ]
113+
115114[dependencies .serde ]
116115version = " 1.0.*"
117116features = [ " derive" ]
Original file line number Diff line number Diff line change 5656
5757
5858mod err;
59+ mod net;
5960mod settings;
6061mod source;
6162mod 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -121,16 +121,19 @@ impl Source {
121121/// content, so the extra complexity is worth it.
122122fn 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.
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 11[package ]
22name = " adbyss_psl"
3- version = " 0.23.3 "
3+ version = " 0.23.4 "
44license = " WTFPL"
55authors = [" Josh Stoik <josh@blobfolio.com>" ]
66edition = " 2024"
You can’t perform that action at this time.
0 commit comments