Skip to content

Instantly share code, notes, and snippets.

View Ghost-chu's full-sized avatar

Ghost_chu Ghost-chu

View GitHub Profile
@NotNull
public SlidingWindowDynamicSpeedLimiter tweakSpeedLimiterBySlidingWindow(@Nullable String downloader, @NotNull DownloaderSpeedLimiter currentSetting,
long thresholdBytes, long minSpeedBytesPerSecond, long maxSpeedBytesPerSecond) throws Exception {
SlidingWindowDynamicSpeedLimiter slidingWindowDynamicSpeedLimiter = new SlidingWindowDynamicSpeedLimiter();
slidingWindowDynamicSpeedLimiter.setThreshold(thresholdBytes);
slidingWindowDynamicSpeedLimiter.setMaxSpeed(maxSpeedBytesPerSecond);
slidingWindowDynamicSpeedLimiter.setMinSpeed(minSpeedBytesPerSecond);
// 假设滑动窗口为24小时
long windowSizeMillis = 24 * 60 * 60 * 1000; // 24小时(毫秒)
slidingWindowDynamicSpeedLimiter.setWindowSizeMillis(windowSizeMillis);
@Ghost-chu
Ghost-chu / 1. 提示
Last active February 5, 2025 12:49
archives.mcbbs.co spider
我正在使用 Java 23 编写爬虫,爬虫目标地址是:
https://archives.mcbbs.co/read.php?tid=<TID>
TID 是从 1 开始的整数,上不封顶
当链接有效时,返回 200 状态码,并包含网页内容。此时你需要将整个页面存储到工作目录下的 archive 目录中的 <TID>.html 文件。
特别注意的是,即使链接无效,也会返回 200 状态码,但内容固定为字符串 “
文件不存在”。
除此以外,我还要求并发爬取,但爬取速度不能超过 20req/s,并且 UserAgent 必须为:mcbbs-archives-indexer (@Ghost-chu [2908803755], speed 20req per seconds)
同时将所有有效链接存储到 archives/links.txt,一行一个
@Ghost-chu
Ghost-chu / overdownload.sql
Last active December 19, 2024 23:03
Complex SQL
WITH LatestSnapshots AS (
SELECT DISTINCT ON (s.torrent, s.peer_ip, s.user_application)
s.id,
s.torrent,
s.peer_ip,
s.user_application,
s.to_peer_traffic,
s.last_time_seen
FROM
public.peer_history s
package com.ghostchu.peerbanhelper.downloader.impl.bitcomet.crypto;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import javax.crypto.Mac;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayOutputStream;
## @NAME IPV6 ::1 Transmission 2.94 恶意多拨
## @AUTHOR PBH-BTN Community
## @CACHEABLE true
## @VERSION 1.0
## @THREADSAFE true
if(isBlank(peer.clientName)) {
return false; ## 下载器必须提供 ClientName
}
## @NAME Gopeed 全随机检查
## @AUTHOR PBH-BTN Community
## @CACHEABLE true
## @VERSION 1.1
## @THREADSAFE true
if(isBlank(peer.clientName) || isBlank(peer.peerId)) {
return false; ## 二元组任意为空都不能继续检查,需要下载器支持
}
## 全部转换为小写
@Ghost-chu
Ghost-chu / gopeed-random-peerid.av
Last active August 7, 2024 16:54
gopeed-random-peerid.av
## @NAME Gopeed 全随机检查
## @AUTHOR PBH-BTN Community
## @CACHEABLE true
## @VERSION 1.0
## @THREADSAFE true
if(isBlank(peer.clientName) || isBlank(peer.peerId)) {
return false; ## 二元组任意为空都不能继续检查,需要下载器支持
}
## 全部转换为小写
@Ghost-chu
Ghost-chu / cfw-no-ipv6-route.md
Created April 4, 2023 16:07
阻止 Clash for Windows 路由 IPv6 流量

切换到 “Profile” 选项卡,在对应配置文件上右键选择 “Parsers”,然后 “Edit Parsers”,添加下面的规则:

parsers:
  - url: "<订阅URL>"
    yaml:
      prepend-rules:
        - IP-CIDR,::/0,DIRECT
@Ghost-chu
Ghost-chu / qb-ban-vampire.py
Created October 9, 2022 03:41 — forked from Sg4Dylan/qb-ban-vampire.py
qBittorrent block vampire peers. qBittorrent 屏蔽吸血客户端.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: Sg4Dylan -- <sg4dylan#gmail.com>
# Licence: GPLv3
import requests
import re
import json
import time
@Ghost-chu
Ghost-chu / 关键词去重.java
Last active December 17, 2021 14:53
do.txt输入ok.txt输出
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {