455 current 2025-06-28 04:47:33 25.05.20250424.f771eb4 6.12.24 *

This commit is contained in:
2025-06-28 04:48:04 -04:00
parent 37b4e716a4
commit b6c057e70a
5 changed files with 60 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
OP=${1:-}; DOMAIN=${2:-}
[[ $OP =~ ^(on|off)$ && -n $DOMAIN ]] || {
echo "usage: dnsblock on|off <domain>"; exit 1; }
FILE="/var/lib/dnsmasq/conf.d/block-$DOMAIN.conf"
if [[ $OP == on ]]; then
sudo tee "$FILE" >/dev/null <<EOF
address=/${DOMAIN}/0.0.0.0
address=/${DOMAIN}/::
EOF
else
sudo rm -f "$FILE"
fi

19
home/scripts/dns/dnsblock.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
OP=${1:-}; DOMAIN=${2:-}
[[ $OP =~ ^(on|off)$ && -n $DOMAIN ]] || {
echo "usage: dnsblock on|off <domain>"; exit 1; }
FILE="/var/lib/dnsmasq/conf.d/block-$DOMAIN.conf"
if [[ $OP == on ]]; then
sudo tee "$FILE" >/dev/null <<EOF
address=/${DOMAIN}/0.0.0.0
address=/${DOMAIN}/::
EOF
else
sudo rm -f "$FILE"
fi
sudo systemctl restart dnsmasq
# sudo systemctl reload dnsmasq

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
websites=("www.reddit.com" "reddit.com" "www.youtube.com" "youtube.com" "www.instagram.com" "instagram.com" "www.facebook.com" "facebook.com" "www.craigslist.org" "craigslist.org" "www.ebay.com" "ebay.com" "www.monkeytype.com" "monkeytype.com" "www.typeracer.com" "typeracer.com" "www.twitter.com" "twitter.com" "www.linkedin.com" "linkedin.com" "tinder.com")
for website in ${websites[@]}; do
grep -v "$website" /etc/hosts > "$tempHosts"
mv "$tempHosts" /etc/hosts
done

View File

@@ -12,12 +12,23 @@
"127.0.0.1" = ["localhost"];
};
networkmanager.enable = true;
networkmanager = {
enable = true;
# dispatcherScripts = [
# {
# source = ./blockers.sh;
# type = "basic";
# }
# ];
};
# interfaces = {
# enp0s31f6 = {};
# wlp4s0 = {};
# };
# ensures wireless is wlan0, eth is eth0;
# predictable interfaces is kinda sussy innit?
usePredictableInterfaceNames = false;
};
}

View File

@@ -1,8 +1,13 @@
{
config,
pkgs,
lib,
...
}: {
system.activationScripts.dnsmasqConfd = lib.stringAfter ["var"] ''
mkdir -p /var/lib/dnsmasq/conf.d
'';
services.dnsmasq = {
enable = true;
resolveLocalQueries = true;