Updated copyright year to 2023 and added replace-string.sh script

This commit is contained in:
Tomkoid 2023-01-02 11:16:14 +01:00
parent 183a875f59
commit 122463a048
No known key found for this signature in database
GPG key ID: D4403E79602EE85B
31 changed files with 67 additions and 39 deletions

View file

@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
adblocker
Copyright (C) 2022 Tomkoid
Copyright (C) 2023 Tomkoid
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) 2022 Tomkoid
<program> Copyright (C) 2023 Tomkoid
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

13
replace-string.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Usage:
# ./replace-string.sh.sh <from> <to>
if [ "$1" == "" ] || [ "$2" == "" ]
then
echo "error: Not enough arguments."
echo "usage: ./replace-string.sh <from> <to>"
exit
fi
find ./ -iname "*.rs" -type f -exec sed -i "s/$1/$2/g" {} \;

View file

@ -1,7 +1,7 @@
// allowed_exit_functions.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// android/apply.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// android/checks.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// android/list.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// android/mod.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// arguments.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// colors.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// copy.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// handle_permissions.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// initialize_colors.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// initialize_dirs.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// main.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -43,6 +43,7 @@ mod signal_handling;
mod sync;
pub mod write;
pub mod tor;
pub mod error;
#[cfg(target_family = "windows")]
mod windows;
@ -198,14 +199,22 @@ fn main() {
let time = std::time::SystemTime::now();
sync(repo, &args);
let error = sync(repo, &args);
println!(
"{}took {}ms{}",
colors.bold_green,
time.elapsed().expect("counting elapsed time").as_millis(),
colors.reset
)
if !error {
println!(
"{}took {}ms{}",
colors.bold_green,
time.elapsed().expect("counting elapsed time").as_millis(),
colors.reset
)
} else {
println!(
"{}error{}",
colors.bold_red,
colors.reset
);
}
}
let changed = local_hosts_output != read_file_to_string(&local_hosts).unwrap();

View file

@ -1,7 +1,7 @@
// messages.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// presets/mod.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// presets/preset.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// read.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// repos.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/init.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/mod.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/networkmanger.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/openrc.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/runit.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/openrc.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// services/systemd.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// signal_handling.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// sync.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::Args;
use crate::error::check_http_error;
use crate::tor::if_onion_link;
use crate::{
get_data_dir, initialize_colors::initialize_colors, read::read_file_to_string,
@ -24,7 +25,8 @@ use crate::{
};
use std::{path::Path, process::exit};
pub fn sync(repo: &str, args: &Args) {
// Returns true if error
pub fn sync(repo: &str, args: &Args) -> bool {
let colors = initialize_colors();
let mut client = reqwest::blocking::ClientBuilder::new();
@ -76,6 +78,8 @@ pub fn sync(repo: &str, args: &Args) {
}
};
let error = check_http_error(&response);
if Path::new(&local_hosts).exists() {
write_to_file(
&local_hosts,
@ -84,4 +88,6 @@ pub fn sync(repo: &str, args: &Args) {
} else {
write_to_file(&local_hosts, response);
}
error
}

View file

@ -1,7 +1,7 @@
// tor.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// windows.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
// write.rs
//
// Simple cross-platform and system-wide CLI adblocker
// Copyright (C) 2022 Tomáš Zierl
// Copyright (C) 2023 Tomáš Zierl
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by