【自作】 プログラミング 【してみた】
8d8c9070 :
Anonymous
2010-09-10 13:10
暇ぶっこいてたらシェルスクリプトなP2Pっぽい何かができてた。
-- p2p.cgi --
#!/bin/sh
client=wget
gossip="./gossip.sh"
args="$1"
target=`echo $1 | cut -f1 -d"&"`
remote=`echo $1 | cut -f2 -d"&"`
node=`echo $remote | cut -f3 -d/`
if [ ! -f nodelist/$node ]; then
echo -n "" > nodelist/$node
fi
echo "text/plain"
echo ""
if [ -f $target ]; then
echo "1"
else
echo "0"
$client -O $target $remote/$target
$gossip $target &
fi
-- gossip.sh --
#!/bin/sh
ls nodelist > nodelist.txt
local="
http://localhost:8080
"
target="$1"
max=5
count=0
shuf nodelist.txt | while read node; do
result=`wget -O- "
http://$node/p2p.cgi?$target&$local
"`
if [ -z $result ]; then
rm nodelist/$node
else
count=`expr $count + $result`
fi
if [ $count -gt $max ]; then
exit
fi
done
ちゃんとやるにはハッシュチェックとかファイル名じゃなくてハッシュ値を使うとかしないと危険だな~。
Powered by
shinGETsu
.
Amazonのアソシエイトとして、新月サンプルゲートウェイは適格販売により収入を得ています。
[ad] 「私、能力は平均値でって言ったよね!」Blu-ray BOX
[ad] アンダーニンジャ
[ad] 機動武闘伝Gガンダム 石破天驚 Blu-ray Box
[ad] トップガン マーヴェリック
[ad] 劇場版ハイスクール・フリート