logo NodeSeekbeta

做了一个基于域前置的反代hf/github访问小工具,请大伙看看

当时假期看到bypass-GFW-SNI这个项目就想着自己也写一个学习一下,所以就有了这个项目

YASRP - https://github.com/Illusion2-1/YASRP

组件 技术 关键决策依据
传输协议栈 .NET Core 8 1. 原生HTTP/2与TLS 1.3无缝衔接能力 2. SocketsHttpHandler提供底层TCP连接精准控制 3. 跨平台兼容性满足实验规模化部署需求
请求代理引擎 Kestrel + Middleware 1. 并发能力 2. 基于流水线架构动态注入ConnectCallback
DNS设施 DoH + Local LRU Cache 1. 规避基于UDP的传统DNS劫持问题 2. 利用公共DoH服务实现解析结果校验 3. 缓存预加载机制降低首次查询延迟
TLS策略 SNI重写 + 证书卸载 1. 在握手阶段动态注入TargetHost的伪装逻辑 2. 允许绕过中间设备SNI过滤规则

找补

因为已经有很多成熟的像steamcommunity302或者watt toolkit这样的工具了,所以写这个项目主要还是学习为主,写出了个控制台小工具,不期待能用在生产环境上;

编写的过程中也确实学到了很多,也能有幸向Steamcommunity302的作者Dogfight360请教技术。

目前支持Linux,Windows还未测试过,workflow也没有提供Windows的可执行程序。

但是最后因为一开始就是抱着学习技术的心态去写的,也不知道要写什么了,希望能得到大伙都宝贵意见~

场景

主要是用在大陆鸡上的,对我自己而言经常要拉一些hf和github的资源,直接拉肯定是拉不下来的,我又懒得总是去找镜像;有这个工具就可以直接访问了

使用示例

从Workflow下载最新的可执行文件,赋予执行权限并运行

sudo apt-get install -y aspnetcore-runtime-8.0 #安装.net runtime
chmod +x YASRP
sudo ./YASRP
#绑定443端口普遍需要root,如果不想使用root,可以用sudo setcap cap_net_bind_service=+ep YASRP

接着用curl或wget,例如下载hf的模型:

curl --resolve huggingface.co:443:127.0.0.1 -L -k https://huggingface.co/BlinkDL/rwkv-5-music/resolve/main/RWKV-5-MIDI-560M-v1-20230902-ctx4096.pth --output RWKV-5-MIDI-560M-v1-20230902-ctx4096.pth

原本打算还做写hosts解析和安装证书的功能,但是既然已经放完假了,就还没写

12
  • 我来试试

  • @Illusion2-1 #2 比如我要在国内服务器下这个应该怎么写

    https://github.com/zhboner/realm/releases/download/v2.7.0/realm-x86_64-unknown-linux-gnu.tar.gz
    
  • @tansel #3
    试试

    curl -L -k --resolve github.com:443:127.0.0.1 --resolve objects.githubusercontent.com:443:127.0.0.1 https://github.com/zhboner/realm/releases/download/v2.7.0/realm-x86_64-unknown-linux-gnu.tar.gz -o realm-x86_64-unknown-linux-gnu.tar.gz
    
  • chmod +x YASRP
    sudo ./YASRP
    

    我是从github上直接下的源码,是需要自己编译才能有YASRP可执行文件?

  • 好耶感谢

  • 学习了

  • [12:23:24] [THREAD-1/INFO] [Program]: Started.
    [12:23:24] [THREAD-1/WARN] [AppConfiguration]: Config file not found at /root/linux-x64/config.yaml, creating default configuration
    [12:23:24] [THREAD-1/INFO] [AppConfiguration]: Configuration saved successfully
    [12:23:24] [THREAD-1/INFO] [CertManager]: Initializing certificate manager...
    [12:23:24] [THREAD-1/INFO] [CertManager]: No existing root certificate found.
    [12:23:24] [THREAD-1/INFO] [CertManager]: Generating new root certificate with validity 2025-03-06 to 2035-03-06
    [12:23:24] [THREAD-1/INFO] [DefaultCertificateProvider]: Generating root certificate with CN=YASRP
    [12:23:26] [THREAD-1/INFO] [DefaultCertificateProvider]: Root certificate generated successfully.
    [12:23:26] [THREAD-1/INFO] [UnixCertificateStore]: Stored certificate at: ./Yasrp Root.pfx
    [12:23:26] [THREAD-1/INFO] [CertManager]: Root certificate 'Yasrp Root' generated and stored successfully
    [12:23:26] [THREAD-1/INFO] [CertManager]: Certificate manager initialized successfully
    [12:23:26] [THREAD-1/INFO] [DnsCacheService]: DNS cache initialized. Loaded 0 entries from persistence
    [12:23:26] [THREAD-1/INFO] [ProxyServer]: ProxyServer initialized with configuration.
    [12:23:26] [THREAD-1/INFO] [ProxyServer]: Starting Kestrel server...
    [12:23:26] [THREAD-1/INFO] [CertManager]: No valid certificate available, generating new site certificate...
    [12:23:26] [THREAD-1/INFO] [CertManager]: Generating new site certificate for domains: steamcommunity.com, www.steamcommunity.com, store.steampowered.com, store.akamai.steamstatic.com, google.com, www.google.com, huggingface.co, www.huggingface.co, datasets-server.huggingface.co, cdn-thumbnails.huggingface.co, transformer.huggingface.co, transformers.huggingface.co, cdn-avatars.huggingface.co, cdn-lfs-us-1.huggingface.co, cdn-uploads.huggingface.co, cdn-lfs-eu-1.huggingface.co, convai.huggingface.co, cdn-lfs.huggingface.co, cdn.huggingface.co, cdn-datasets.huggingface.co, discuss.huggingface.co, status.huggingface.co, ui.endpoints.huggingface.co, store.huggingface.co, dell.huggingface.co, neuralconvo.huggingface.co, home.huggingface.co, api-inference.huggingface.co, thumbnails.huggingface.co, ui.autotrain.huggingface.co, github.com, www.github.com, gist.github.com, api.github.com, codeload.github.com, support.github.com, raw.githubusercontent.com, raw.github.com, camo.githubusercontent.com, cloud.githubusercontent.com, avatars.githubusercontent.com, avatars0.githubusercontent.com, avatars1.githubusercontent.com, avatars2.githubusercontent.com, avatars3.githubusercontent.com, user-images.githubusercontent.com, private-user-images.githubusercontent.com, github-releases.githubusercontent.com, analytics.githubassets.com, desktop.githubusercontent.com, lab.github.com, assets-cdn.github.com, www.github.io, pages.github.com, resources.github.com, developer.github.com, partner.github.com, desktop.github.com, guides.github.com, github-releases.githubusercontent.com, objects.githubusercontent.com
    [12:23:26] [THREAD-1/INFO] [DefaultCertificateProvider]: Generating site certificate...
    [12:23:27] [THREAD-1/INFO] [DefaultCertificateProvider]: Site certificate generated and saved to /root/linux-x64/SiteCert.pfx
    [12:23:27] [THREAD-1/INFO] [ProxyServer]: Performing DNS warmup...
    [12:23:27] [THREAD-1/INFO] [ProxyServer]: Kestrel server started successfully.
    info: Microsoft.Hosting.Lifetime[0]
          Application started. Press Ctrl+C to shut down.
    info: Microsoft.Hosting.Lifetime[0]
          Hosting environment: Production
    info: Microsoft.Hosting.Lifetime[0]
          Content root path: /root/linux-x64
    [12:23:30] [THREAD-12/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:32] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:34] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:34] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for steamcommunity.com
    [12:23:34] [THREAD-9/WARN] [DoHResolver]: Primary DoH server failed: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:23:36] [THREAD-9/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:38] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:40] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:40] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for steamcommunity.com
    [12:23:40] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://9.9.9.9/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:23:42] [THREAD-12/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:45] [THREAD-12/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:47] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:47] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for steamcommunity.com
    [12:23:47] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://1.1.1.1/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:23:49] [THREAD-12/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:51] [THREAD-12/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:53] [THREAD-12/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:53] [THREAD-12/ERROR] [DoHClient]: DoH query failed after 3 attempts for steamcommunity.com
    [12:23:53] [THREAD-12/WARN] [DoHResolver]: Fallback DoH server failed: https://101.101.101.101/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:23:55] [THREAD-7/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:57] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:59] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:23:59] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for steamcommunity.com
    [12:23:59] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://208.67.222.222/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:23:59] [THREAD-7/INFO] [DnsCacheService]: Adding cache entry for steamcommunity.com with 1 IPs
    [12:23:59] [THREAD-7/INFO] [FilteringStrategies]: Starting IP filtering for domain: steamcommunity.com
    [12:23:59] [THREAD-9/INFO] [FilteringStrategies]: Skipping filtering for steamcommunity.com - less than 2 IP addresses available
    [12:24:01] [THREAD-9/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:04] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:06] [THREAD-7/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:06] [THREAD-7/ERROR] [DoHClient]: DoH query failed after 3 attempts for www.steamcommunity.com
    [12:24:06] [THREAD-7/WARN] [DoHResolver]: Primary DoH server failed: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:24:08] [THREAD-9/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:10] [THREAD-12/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:12] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:12] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for www.steamcommunity.com
    [12:24:12] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://9.9.9.9/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:24:14] [THREAD-7/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:16] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:18] [THREAD-12/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:18] [THREAD-12/ERROR] [DoHClient]: DoH query failed after 3 attempts for www.steamcommunity.com
    [12:24:18] [THREAD-12/WARN] [DoHResolver]: Fallback DoH server failed: https://1.1.1.1/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:24:20] [THREAD-7/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:22] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:25] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:25] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for www.steamcommunity.com
    [12:24:25] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://101.101.101.101/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    [12:24:27] [THREAD-12/WARN] [DoHClient]: Attempt 1 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:29] [THREAD-7/WARN] [DoHClient]: Attempt 2 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:31] [THREAD-9/WARN] [DoHClient]: Attempt 3 failed: The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.
    [12:24:31] [THREAD-9/ERROR] [DoHClient]: DoH query failed after 3 attempts for www.steamcommunity.com
    [12:24:31] [THREAD-9/WARN] [DoHResolver]: Fallback DoH server failed: https://208.67.222.222/dns-query, Error: All retry attempts failed (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.) (The request was canceled due to the configured HttpClient.Timeout of 2 seconds elapsing.)
    
  • 这要修改哪里,dns配置文件吗

12

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有72267位seeker

🎉欢迎新用户🎉