-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoban.sh
58 lines (51 loc) · 1.15 KB
/
autoban.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
SYS_CLI="/usr/local/bin/syscoin-cli -conf=/home/syscoin/.syscoin/syscoin.conf -datadir=/home/syscoin/.syscoin"
BANNED="/Satoshi:4.0.1/,/Satoshi:4.0.2/,/Satoshi:4.0.3/,/Satoshi:4.0.0/"
$SYS_CLI getpeerinfo | awk -F":" -v banned="$BANNED" -v syscli="$SYS_CLI" -- '
BEGIN {
split(banned,BAN,",");
}
/\"id\"*/ {
id=substr($2,2,length($2)-2);ID[id]=id;
}
/^....\"addr\"/ {
if (substr($2,3,1)=="[") {
sadr = substr($0,index($0,":"));
start = index(sadr,"[");
end = index(sadr,"]");
IP[id]=substr(sadr,start,end-3);
} else {
IP[id]=substr($2,3);
}
}
/\"subver\"*/ {
s=length($1)+4;
VER[id]=substr($0,s,(length($0)-s-1));
}
END {
for (id in ID) {
for (banned in BAN) {
if(VER[id]==BAN[banned]) {
system(syscli" setban "IP[id]" add");
}
}
}
}'
stop_syscoind(){
echo "Stopping"
sudo service syscoind stop
clear
}
start_syscoind(){
echo "Starting Syscoin"
sudo service syscoind start # start the service
sudo systemctl enable syscoind # enable at boot
clear
}
remove_geth(){
echo "Removing Geth"
rm -rf /home/syscoin/.syscoin/geth
}
stop_syscoind
remove_geth
start_syscoind