mirror of https://github.com/PurpleI2P/pyseeder
acetone
4 years ago
committed by
GitHub
5 changed files with 242 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<title>Access denied</title> |
||||||
|
<style media="screen"> |
||||||
|
* { |
||||||
|
box-sizing: border-box; |
||||||
|
font-size: 30px; |
||||||
|
font-family: monospace; |
||||||
|
margin: 20; |
||||||
|
padding: 20; |
||||||
|
background-color: black; |
||||||
|
color: red; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body><center> |
||||||
|
<p>The reseed is available for download from an I2P router only!<p> |
||||||
|
<img src="wild-putin.png"> |
||||||
|
</center></body> |
||||||
|
</html> |
@ -0,0 +1,15 @@ |
|||||||
|
limit_req_zone $binary_remote_addr zone=reseed:512k rate=10r/m; |
||||||
|
|
||||||
|
server { |
||||||
|
root /srv/pyseeder/output; |
||||||
|
listen [324:9de3:fea4:f6ac::ace]:7070; |
||||||
|
index seed.html; |
||||||
|
location /i2pseeds.su3 { |
||||||
|
limit_req zone=reseed burst=5; |
||||||
|
error_page 403 /err.html; |
||||||
|
if ($http_user_agent !~* "Wget/1.11.4" ) { return 403; } |
||||||
|
} |
||||||
|
location /acetone_at_mail.i2p.crt { |
||||||
|
limit_req zone=reseed; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> <meta http-equiv="Refresh" content="3600" /> |
||||||
|
<title>I2P Reseed. First in Yggdrasil.</title> |
||||||
|
<style media="screen"> |
||||||
|
* { |
||||||
|
font-family: monospace; |
||||||
|
background-color: black; |
||||||
|
color: white; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
<body><center> |
||||||
|
<p>Number of Yggdrasil routers in the I2P network.</p> |
||||||
|
<p style="color: gray">Data from the current reseed. Updated hourly.</p> |
||||||
|
<p style="font-size: 200px">13</p> |
||||||
|
</center></body> |
||||||
|
</html> |
After Width: | Height: | Size: 37 KiB |
@ -0,0 +1,186 @@ |
|||||||
|
#!/bin/bash |
||||||
|
# |
||||||
|
# The script finds routers with a Yggdrasil IPv6 |
||||||
|
# and mixes 30% of regular routers with them. |
||||||
|
# |
||||||
|
# If Yggdrasil < 25 then regular routers 25; |
||||||
|
# |
||||||
|
# Путь до папки netDb, которая будет скопирована |
||||||
|
netdb=/var/lib/i2pd/netDb |
||||||
|
# Путь до выходной папки |
||||||
|
outdb=/srv/pyseeder/transitoutput |
||||||
|
# |
||||||
|
### |
||||||
|
temp=/tmp/yggreseed |
||||||
|
success=/tmp/yggreseed.success |
||||||
|
padding=/tmp/yggreseed.padding |
||||||
|
minimum=25 # Минимальное количество роутеров с Ygg |
||||||
|
timestart=$(date '+%Y-%m-%d %H:%M:%S') |
||||||
|
### |
||||||
|
|
||||||
|
# Проверка рабочих директорий: |
||||||
|
echo -n $netdb... |
||||||
|
cd $netdb &> /dev/null |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "X" |
||||||
|
exit 1 |
||||||
|
else |
||||||
|
echo "OK" |
||||||
|
fi |
||||||
|
ls |
||||||
|
|
||||||
|
echo -n $outdb... |
||||||
|
cd $outdb &> /dev/null |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "X" |
||||||
|
exit 2 |
||||||
|
else |
||||||
|
echo "OK" |
||||||
|
fi |
||||||
|
ls |
||||||
|
|
||||||
|
# Очистка выходной директории |
||||||
|
echo "Clearing the output directory..." |
||||||
|
rm -r $outdb/* &> /dev/null |
||||||
|
|
||||||
|
maketemp () { # Создание временной папки первичной сортировки |
||||||
|
echo "Creating temp directory..." |
||||||
|
rm -r $temp &> /dev/null |
||||||
|
mkdir $temp &> /dev/null |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "Error. Exiting." |
||||||
|
exit 3 |
||||||
|
fi |
||||||
|
} |
||||||
|
maketemp |
||||||
|
|
||||||
|
copy () { # Копирование базы роутера в первичную временную папку |
||||||
|
echo "Copying the router base to the temp directory..." |
||||||
|
cp -r $netdb/* $temp/ &> /dev/null |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "Error. Exiting." |
||||||
|
exit 4 |
||||||
|
fi |
||||||
|
} |
||||||
|
copy |
||||||
|
|
||||||
|
# Main section |
||||||
|
|
||||||
|
echo "Finding the Yggdrasil routers:" |
||||||
|
cd $temp |
||||||
|
yggaddr=0 |
||||||
|
count=1 |
||||||
|
|
||||||
|
for((;;)); do # Поиск Yggdrasil-роутеров и их копирование в выходную директорию |
||||||
|
dir=$(ls -lh | head -n 2 | tail -n 1 | grep -o r.$) |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
break |
||||||
|
fi |
||||||
|
|
||||||
|
cd $dir |
||||||
|
for((;;)); do |
||||||
|
dat=$(ls -lh | head -n 2 | tail -n 1 | grep -E -w -o routerInfo.*.dat$) |
||||||
|
if [[ $? != 0 ]]; then # Если файлов в папке не осталось, выходим и удаляем ее |
||||||
|
cd $temp |
||||||
|
rmdir $dir |
||||||
|
break |
||||||
|
fi |
||||||
|
|
||||||
|
echo -n "[$count] " |
||||||
|
echo -n "$dat [" |
||||||
|
cat $dat | grep '=.[23]..:' &> /dev/null # Поиск host=200: или host=300: |
||||||
|
|
||||||
|
if [[ $? == 0 ]]; then # Успех, забираем |
||||||
|
echo "+]" |
||||||
|
let yggaddr++ |
||||||
|
mkdir $outdb/$dir &> /dev/null |
||||||
|
mv ./$dat $outdb/$dir |
||||||
|
echo $dat >> $success |
||||||
|
else # Не успех, удаляем |
||||||
|
echo ".]" |
||||||
|
rm ./$dat |
||||||
|
fi |
||||||
|
let count++ |
||||||
|
done |
||||||
|
done |
||||||
|
|
||||||
|
echo -e "\n================================================= YGGDRASIL *" |
||||||
|
cat $success |
||||||
|
rm $success |
||||||
|
echo -e "===========================================================" |
||||||
|
|
||||||
|
echo -e "Reseed building..." |
||||||
|
yggvolume=$(($yggaddr / 100 * 70)) # 70% ресида - Ygg-роутеры. |
||||||
|
echo -n "Need " |
||||||
|
if [[ $yggvolume < $minimum ]]; then # Если их меньше minimum, докладываем 25 роутеров обычных |
||||||
|
echo -n "25 " |
||||||
|
paddingcount=25 |
||||||
|
else |
||||||
|
paddingcount=$(($yggaddr / 100 * 30)) |
||||||
|
echo -n "$paddingcount " |
||||||
|
fi |
||||||
|
echo "regular routers" |
||||||
|
|
||||||
|
cd $temp |
||||||
|
maketemp |
||||||
|
copy |
||||||
|
echo -n "Padding status: " |
||||||
|
realpadding=0 |
||||||
|
for((i=0; $i < $paddingcount; i++)); do |
||||||
|
|
||||||
|
rand=$(( $RANDOM % 10 )) |
||||||
|
for((j=0;$j!=$rand;j++)); do |
||||||
|
cd $temp |
||||||
|
dir=$(ls -lh | head -n 2 | tail -n 1 | grep -o r.$) |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "Dir error! PADDING-RAND-FOR" |
||||||
|
exit 5 |
||||||
|
fi |
||||||
|
cd $dir |
||||||
|
dat=$(ls -lh | head -n 2 | tail -n 1 | grep -E -w -o routerInfo.*.dat$) |
||||||
|
if [[ $? != 0 ]]; then # Если файлов в папке не осталось, выходим и удаляем ее |
||||||
|
cd $temp |
||||||
|
rmdir $dir |
||||||
|
else |
||||||
|
rm ./$dat |
||||||
|
fi |
||||||
|
cd $temp |
||||||
|
done |
||||||
|
|
||||||
|
padselect () { # Дополнение ресида случайными роутерами |
||||||
|
cd $temp |
||||||
|
dir=$(ls -lh | head -n 2 | tail -n 1 | grep -o r.$) |
||||||
|
if [[ $? != 0 ]]; then |
||||||
|
echo "." |
||||||
|
padselect |
||||||
|
fi |
||||||
|
cd $dir |
||||||
|
dat=$(ls -lh | head -n 2 | tail -n 1 | grep -E -w -o routerInfo.*.dat$) |
||||||
|
if [[ $? != 0 ]]; then # Если файлов в папке не осталось, выходим и удаляем ее |
||||||
|
cd $temp |
||||||
|
rmdir $dir |
||||||
|
padselect |
||||||
|
fi |
||||||
|
} |
||||||
|
padselect |
||||||
|
|
||||||
|
mkdir $outdb/$dir &> /dev/null |
||||||
|
mv ./$dat $outdb/$dir |
||||||
|
echo $dat >> $padding |
||||||
|
let realpadding++ |
||||||
|
echo -n "*" |
||||||
|
done |
||||||
|
|
||||||
|
echo -e "\n=================================================== PADDING *" |
||||||
|
cat $padding |
||||||
|
rm $padding |
||||||
|
echo -e "===========================================================" |
||||||
|
echo -e "\nstarted: $timestart\nfinished: $(date '+%Y-%m-%d %H:%M:%S')" |
||||||
|
echo -e "total routers: $count" |
||||||
|
echo -e "reseed build: $(($yggaddr+$realpadding)) ($yggaddr/$realpadding)\n" |
||||||
|
echo -e "Yggdrasil I2P reseed creator (c) GPLv3, acetone, 2021\n" |
||||||
|
|
||||||
|
# Update web page |
||||||
|
|
||||||
|
sed -i "s/>[0-9]\{1,1000\}</>$yggaddr</" /srv/pyseeder/output/seed.html |
||||||
|
echo "Web page updated" |
Loading…
Reference in new issue