mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 20:30:58 -05:00
Compare commits
6 Commits
076ab5036a
...
cc7e8882d4
Author | SHA1 | Date | |
---|---|---|---|
|
cc7e8882d4 | ||
|
b011f63d44 | ||
|
38db24ef8c | ||
|
a68b3fc723 | ||
|
888ab25280 | ||
|
f3e6745b58 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.env
|
.env
|
||||||
|
ips.txt
|
||||||
# Yarn stuff
|
# Yarn stuff
|
||||||
.yarn
|
.yarn
|
||||||
# TypeScript stuff
|
# TypeScript stuff
|
||||||
|
@ -130,7 +130,7 @@ export async function requestServerData(client:TClient, server:IServer):Promise<
|
|||||||
if (data.status === 200 ?? 204) return data;
|
if (data.status === 200 ?? 204) return data;
|
||||||
else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`)
|
else if (data.status === 404) Logger.console('log', loggingPrefix, `(${i+1}/${maxRetries}) ${server.serverName} responded with an error (404), API is disabled or mismatched code`)
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
Logger.console('log', loggingPrefix, `Couldn't get the data for ${server.serverName}: ${err.message}`);
|
Logger.console('log', loggingPrefix, `Couldn't get data for ${server.serverName}: ${err.message}`);
|
||||||
}
|
}
|
||||||
await new Promise(resolve=>setTimeout(resolve, 500))
|
await new Promise(resolve=>setTimeout(resolve, 500))
|
||||||
}
|
}
|
||||||
|
31
ufwReject.sh
Executable file
31
ufwReject.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "Please run this script as root or sudo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Store the IP addresses in a file
|
||||||
|
IP_ADDRESSES_STORE="ips.txt"
|
||||||
|
|
||||||
|
# Scan the kernel log for IP addresses and store them in a file
|
||||||
|
dmesg | grep 'SRC=' | awk -F'SRC=' '{ print $2 }' | awk '{ print $1 }' | sort | uniq | head -n 5000 > "$IP_ADDRESSES_STORE"
|
||||||
|
|
||||||
|
# Initialize a counter for new IPs
|
||||||
|
new_ips=0
|
||||||
|
|
||||||
|
# Populate the UFW reject rule with the IP addresses collected from the kernel log
|
||||||
|
while IFS= read -r ip
|
||||||
|
do
|
||||||
|
# Check if the IP is already in the UFW rules
|
||||||
|
if ! ufw status | grep -q "$ip"
|
||||||
|
then
|
||||||
|
ufw reject from $ip
|
||||||
|
# Increment the counter
|
||||||
|
((new_ips++))
|
||||||
|
fi
|
||||||
|
done < "$IP_ADDRESSES_STORE"
|
||||||
|
|
||||||
|
echo "Done populating UFW reject rule"
|
||||||
|
echo "$new_ips IP addresses were added"
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user