海运的博客

pt torrent种子自动辅种相似度计算

发布时间:March 5, 2021 // 分类:PT // No Comments

torrent解析类使用https://github.com/Rhilip/Bencode,打补丁支持获取种子hash信息。

--- Bencode.php.1       2021-02-24 07:30:41.677067125 +0800
+++ Bencode.php 2021-03-05 17:52:23.803081067 +0800
@@ -26,6 +26,9 @@
  */
 class Bencode
 {
+    public function info_hash($data, $info_hash) {
+      return sha1(substr($data, $info_hash['pos'], $info_hash['length']));
+    }
     /**
      * Decode bencoded data from string
      *
@@ -46,7 +49,15 @@
             $return = [];
             while ($data[$pos] !== 'e') {
                 $key = self::decode($data, $pos);
+                if (!strcmp($key, "info")) {
+                //if ($key === "info") {
+                  $return['info_hash']['pos'] = $pos;
+                }
                 $value = self::decode($data, $pos);
+                if (!strcmp($key, "info")) {
+                //if ($key === "info") {
+                  $return['info_hash']['length'] = ($pos - $return['info_hash']['pos']);
+                }
                 if ($key === null || $value === null) {
                     break;
                 }
@@ -125,6 +136,9 @@
             $return = '';
             $check = -1;
             $list = true;
+            if (isset($data['info_hash'])) {
+              unset($data['info_hash']);
+            }
             foreach ($data as $key => $value) {
                 if ($key !== ++$check) {
                     $list = false;

解析种子torrent所包含的文件名称信息,将名称和文件大小组合排序并计算sha,sha相同则2个种子内容一样可自动辅种。

<?php
require_once './Bencode.php';
require_once './ParseErrorException.php';
$bencode = new Bencode(); 
$str = file_get_contents($filename);
$s = $bencode->decode($str);

if (isset($s['info']["files"])) {
  foreach ($s['info']["files"] as $v) {
    $length = $v["length"];
    $file = end($v["path"]);
    $save[] = $length.$file;
  }
} else {
  $length = $s['info']["length"];
  $file = $s['info']["name"];
  $save[] = $length.$file;
}
if (isset($s["encoding"])) {
  $coding = $s["encoding"];
} else {
  $coding = mb_detect_encoding(implode('', $save), ['UTF-8', 'GB18030', 'GBK', 'GB2312', 'ISO-8859-1']);
  echo 'detect encoding: '.$coding.PHP_EOL;
}
if (!$coding) {
  $coding = 'UTF-8';
}
if ($coding != "UTF-8") {
  foreach ($save as $k => $v) {
    $save[$k] = mb_convert_encoding($v, "UTF-8", $coding);
  }
}
sort($save);
$sha1 = sha1(implode('', $save));

ubuntu18.04编译使用transmission2.92/2.94/3.0跳过校验

发布时间:November 16, 2018 // 分类:PT // No Comments

安装编译环境及transmission依赖:

apt-get install ca-certificates libcurl4-openssl-dev libssl-dev pkg-config build-essential checkinstall libevent-dev intltool libtool zlib1g-dev

下载编译transmission:

wget http://archive.ubuntu.com/ubuntu/pool/main/t/transmission/transmission_2.92.orig.tar.gz
tar zxvf transmission_2.92.orig.tar.gz 
cd transmission-2.92
wget http://archive.ubuntu.com/ubuntu/pool/main/t/transmission/transmission_2.92-3ubuntu2.debian.tar.xz
tar Jxvf transmission_2.92-3ubuntu2.debian.tar.xz 
#打openssl补丁,不然编译失败
patch -p 1 < debian/patches/f91cf5ad8c677b61ceb0bf5877b87f9e93256dd7.patch 
#patch -p 1 < debian/patches/8c8386a7f3f482a9c917f51d28e0042e55f56b3e.patch 
#patch -p 1 < debian/patches/transmission-fix-dns-rebinding-vuln.patch 
#transmission跳过校验patch
wget https://github.com/superlukia/transmission-2.92_skiphashcheck/commit/56e327d1dacb5b3453954b76a6d0edd30edb7a34.patch
patch -p 1 < 56e327d1dacb5b3453954b76a6d0edd30edb7a34.patch
./configure 
make 
#替换已安装的transmission-daemon
mv /usr/bin/transmission-daemon /usr/bin/transmission-daemon.bak
cp daemon/transmission-daemon /usr/bin/transmission-daemon

2.94:

apt-get source transmission-daemon
#tar zxf transmission_2.94.orig.tar.gz transmission-2.94/
cd transmission-2.94/
wget https://github.com/blackyau/Transmission_SkipHashChek/commit/0a18e4dffc7002eb80abe39ae8c8c8aec1205967.patch
git apply 0a18e4dffc7002eb80abe39ae8c8c8aec1205967.patch
./autogen.sh
make

3.0:

apt install git ca-certificates libcurl4-openssl-dev libssl-dev pkg-config build-essential checkinstall libevent-dev intltool libtool zlib1g-dev libglib2.0-dev libsystemd-dev
git clone https://github.com/transmission/transmission
cd transmission/
git checkout 3.00
git submodule update --init
git clone https://github.com/TonyRL/docker-transmission-skip-hash-check.git
patch -p0 < docker-transmission-skip-hash-check/patches/001-skip-hash-checking.patch 
patch -p0 < docker-transmission-skip-hash-check/patches/002-fdlimit.patch 
patch -p0 < docker-transmission-skip-hash-check/patches/003-random-announce.patch 
./autogen.sh --prefix=/usr/local/transmission --with-systemd 
make && make install

如果编译时没安装libsystemd依赖,需修改下systemd服务,不然通过systemctl启动transmission会卡住。

cat /etc/systemd/system/multi-user.target.wants/transmission-daemon.service
[Unit]
Description=Transmission BitTorrent Daemon
After=network.target

[Service]
User=debian-transmission
#Type=notify
Type=simple
ExecStart=/usr/bin/transmission-daemon -f --log-error -g /var/lib/transmission-daemon/.config/transmission-daemon/
ExecStop=/bin/kill -s STOP $MAINPID
ExecReload=/bin/kill -s HUP $MAINPID

[Install]
WantedBy=multi-user.target

在WEB界面添加种子后校验时右键点击种子Ask tracker for more peers即可跳过校验。
另类方法:
https://www.jianshu.com/p/ab2df4282e59
参考:
https://github.com/superlukia/transmission-2.92_skiphashcheck
https://blog.csdn.net/Sardkit/article/details/79911925

php使用deluge

发布时间:October 10, 2018 // 分类:PT // No Comments

使用https://github.com/kaysond/deluge-php 提供的类,简单使用:

$host = "192.168.168.5:8112";
$password = "deluge";
$d = new deluge($host, $password);
//返回只包含当前状态Downloading中的
$filter = array('state' => "Downloading");
//返回指定的这此参数的值
$params = array('name', 'hash', 'max_upload_speed', 'eta');
$list = $d->getTorrentsStatus($filter, $params, '');
var_dump($list);
$url = 'https://www.haiyun.me/deluge.torrent';
$options = array('max_upload_speed' => 100, 'max_download_speed' => 100);
$res = $d->addTorrentUrl($url, $options, '');
var_dump($res);

参考:
https://media.readthedocs.org/pdf/deluge/develop/deluge.pdf

ubuntu18.04编译安装deluge

发布时间:October 10, 2018 // 分类:PT // No Comments

安装编译环境及libtorrent依赖:

apt-get install build-essential checkinstall pkg-config automake libtool git
apt-get install libboost-system-dev libboost-python-dev libboost-chrono-dev libboost-random-dev libssl-dev

使用最新版libtorrent:

wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_1_10/libtorrent-rasterbar-1.1.10.tar.gz
tar zxvf libtorrent-rasterbar-1.1.10.tar.gz 
cd libtorrent-rasterbar-1.1.10/
./configure --prefix=/usr/local/libtorrent --enable-python-binding --with-libiconv
make clean && make -j$(nproc) && make install
echo '/usr/local/libtorrent/lib' > /etc/ld.so.conf.d/libtorrent-x86_64.conf 
ldconfig
export PYTHONPATH=$PYTHONPATH:/usr/local/libtorrent/lib/python2.7/site-packages/
echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/libtorrent/lib/python2.7/site-packages/' >> ~/.bashrc

查看python能否调用libtorrent:

python -c "import libtorrent; print libtorrent.version"

安装deluge依赖:

apt-get install python python-twisted python-openssl python-setuptools intltool python-xdg python-chardet geoip-database python-libtorrent python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako 

安装deluge:

wget http://download.deluge-torrent.org/source/deluge-1.3.15.tar.gz
tar -xzvf deluge-1.3.15.tar.gz
cd deluge-1.3.15
mkdir -p /usr/local/deluge/lib/python2.7/site-packages/
export PYTHONPATH=$PYTHONPATH:/usr/local/deluge/lib/python2.7/site-packages/
echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/deluge/lib/python2.7/site-packages/' >> ~/.bashrc
python setup.py build
python setup.py install --prefix /usr/local/deluge
export PATH=$PATH:/usr/local/deluge/bin/
echo 'export PATH=$PATH:/usr/local/deluge/bin/' >> ~/.bashrc

使用libtorrent1.0.11版本:

git clone https://github.com/arvidn/libtorrent.git
cd libtorrent
git checkout origin/RC_1_0
./autotool.sh
./configure --prefix=/usr/local/libtorrent --enable-python-binding --with-libiconv
make clean && make -j$(nproc) && make install

ubuntu编译安装qbittorrent:https://www.haiyun.me/archives/1253.html
centos7编译安装deluge:https://www.haiyun.me/archives/1240.html
参考:
https://dev.deluge-torrent.org/wiki/Building/libtorrent
https://dev.deluge-torrent.org/wiki/Installing/Source

ubuntu18.04编译qbittorrent4.13和libtorrent1.0.11

发布时间:October 5, 2018 // 分类:PT // No Comments

qbittorrent4在使用libtorrent最新版本1.1.9版本时有诸多问题,编译使用1.0.11稳定版本试试。
安装编译环境及libtorrent依赖:

apt-get install build-essential pkg-config automake libtool git
apt-get install libboost-dev libboost-system-dev libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev

编译libtorrent:

git clone https://github.com/arvidn/libtorrent.git
#之前系统版本可直接下载源码使用,18.04需修改include/libtorrent/export.hpp替换boost/config/为boost/config/detail/
#https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_0_11/libtorrent-rasterbar-1.0.11.tar.gz
cd libtorrent
git checkout origin/RC_1_0
./autotool.sh
./configure --prefix=/usr/local/libtorrent CXXFLAGS=-std=c++11
make clean && make -j$(nproc)
make install
echo '/usr/local/libtorrent/lib' > /etc/ld.so.conf.d/libtorrent-x86_64.conf 
ldconfig
export CPLUS_INCLUDE_PATH=/usr/local/libtorrent/include/
export PKG_CONFIG_PATH=/usr/local/libtorrent/lib/pkgconfig/

安装qbittorrent依赖及编译:

apt-get install qtbase5-dev qttools5-dev-tools libqt5svg5-dev zlib1g-dev
wget https://github.com/qbittorrent/qBittorrent/archive/release-4.1.3.tar.gz
tar zxvf release-4.1.3.tar.gz 
cd qBittorrent-release-4.1.3/
./configure --prefix=/usr/local/qbittorrent --disable-gui
make clean && make -j$(nproc)
make install
export PATH=$PATH:/usr/local/qbittorrent/bin/
echo 'export PATH=$PATH:/usr/local/qbittorrent/bin/' >> ~/.bashrc
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...