海运的博客

此内容被密码保护

发布时间:April 4, 2021 // 分类: // No Comments

请输入密码访问

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));

使用Tampermonkey油猴脚本自动抢购斯巴达spartanhost vps

发布时间:March 1, 2021 // 分类: // 3 Comments

最近斯巴达vps比较火,一机难求,写了个js脚本用于抢购,效果还不错,推荐使用chrome浏览器,安装Tampermonkey扩展使用。

// ==UserScript==
// @name         自动抢购买vps
// @namespace    https://www.haiyun.me
// @version      0.1
// @description  buy spartanhost vps
// @author       www.haiyun.me
// @match        https://billing.spartanhost.net/cart.php?a=*
// @grant        none
// ==/UserScript==

(function() {
    var forcedReload = false;
    var time = 500; 
    var url = document.URL;
    var hostname = "www.haiyun.me";
    var customfield = "website";
    if (document.title == '502 Bad Gateway') {
        setTimeout(function() {
            window.location.reload(forcedReload);
        }, time);
    } else if (document.title == '504 Gateway Time-out') {
        setTimeout(function() {
            window.location.reload(forcedReload);
        }, time);
    } else if (document.title == '503 Service Temporarily Unavailable') {
        setTimeout(function() {
            window.location.reload(forcedReload);
        }, time);
    } else if (document.title == '500 Internal Server Error') {
        setTimeout(function() {
            window.location.reload(forcedReload);
        }, time);
    } else if (document.getElementsByTagName('h1')[0].innerHTML == '无法访问此网站') {
        setTimeout(function() {
            window.location.reload(forcedReload);
        }, time);
    }

    if (url.indexOf("https://billing.spartanhost.net/cart.php?a=add") != -1) {
        var str = document.getElementById("order-boxes").innerHTML;
        if (str.indexOf("Out of Stock") != -1) {
            setTimeout(function() {
                window.location.reload(forcedReload);
            }, time);
        }
    } else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=confproduct") != -1) {
        document.getElementById("inputHostname").value = hostname;
        var element = document.querySelector('input[name^="customfield"]');
        element.value = customfield;
        document.getElementById("btnCompleteProductConfig").click();
    } else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=view") != -1) {
        document.getElementById("checkout").click();
    } else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=checkout") != -1) {
        document.getElementById("iCheck-accepttos").click();
        document.getElementById("btnCompleteOrder").click();
    }
})();

windows10添加多ip地址及指定出口ip

发布时间:February 24, 2021 // 分类: // No Comments

查看网卡名称及编号:

netsh int ipv4 show int

查看当前ip地址:

netsh int ipv4 show ipadd level=verbose

开启dhcp和静态ip共存:

netsh int ipv4 set int "Ethernet0" dhcpstaticipcoexistence=enabled

添加ip地址,skipassource设置是否使用此ip为出口源ip,默认新添加的ip为出口ip:

netsh int ipv4 add add "Ethernet0" 192.168.1.22/24 skipassource=true

已添加的ip修改skipassource参数:

Get-NetIPAddress 192.168.1.22 | Set-NetIPAddress -SkipAsSource $True
Set-NetIPAddress -IPAddress "192.168.1.22" -InterfaceAlias "Ethernet0" -SkipAsSource $false

多网卡可修改路由及网卡metric跃点数指定优先网络出口:

netsh int ipv4 show rou
netsh int ipv4 set int "Ethernet0" metric=2
netsh int ipv4 set rou 0.0.0.0/0 "Ethernet0" 192.168.1.1 metric=100
route change 0.0.0.0 mask 0.0.0.0 192.168.1.1 metric 100 if 4

n1盒子连接手机4G无线热点做k2p宽带pppoe备份线路并切换

发布时间:February 24, 2021 // 分类:N1,K2P // No Comments

k2p主路由地址:192.168.1.1
n1盒子地址:192.168.1.2
k2p添加低优先级默认路由走n1,此路由只有pppoe断开后才有效:

ip rou add default via 192.168.1.2 dev br-lan metric 1000

n1盒子用netplan配置无线网络默认路由和无线热点的路由优先级,默认情况下走k2p主路由,当路由器pppoe不能连接时打开手机无线热点则自动走手机4g网络连接。

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
            - 192.168.1.2/24
            dhcp4: false
            dhcp6: true
            accept-ra: true
            #gateway4: 192.168.1.1
            routes:
                - to: 0.0.0.0/0
                  via: 192.168.1.1
                  metric: 1000
            nameservers:
                addresses:
                - 192.168.1.1
                search: []

    wifis:
      wlan0:
        dhcp4: yes
        dhcp6: no
        dhcp4-overrides:
            route-metric: 600
        access-points:
            "Phone-ssid":
                password: "www.haiyun.me"

n1盒子开启snat及网络转发:

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1
分类
最新文章
最近回复
  • crowjin: 你确定这能过滤??不是所有请求都返回空地址::?
  • : linux系统上单个网卡多条宽带拨号获取公网IP,外网可以访问这些IP,有偿! Q:25299...
  • 硅谷少年: 非常有用,感谢分享
  • spartan2: https://dashboard.hcaptcha.com/welcome_accessib...
  • 海运: 应该能,在购买页面先手工跳过cf机器验证,后续一定时间内不更换ip应该不会再次验证。
  • spartan: 大佬斯巴达开启了CF的机器识别验证,请问插件能自动跳过吗? 另外这个脚本有没有简单使用说明,新...
  • vincent: 膜拜大佬
  • 海运: proxy-header或proxy_protocol
  • liangjw: 如果是 内部调用 或者 中间存在 代理 而上一个代理又在内网 ,那怎么处理来自代理私有IP?
  • chainofhonor: 感谢,用dnsmasq设置自动判断BIOS和UEFI成功了
归档