惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
博客园_首页
美团技术团队
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
J
Java Code Geeks
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
雷峰网
雷峰网
爱范儿
爱范儿

LanYunのBlog

优化macOS Dock栏的显示与隐藏 解决macOS全屏模式下某些情况显示原始鼠标指针的问题 Yarn从Classic迁移到Modern nginx自编译 用santa对二进制进行监控和授权 ESXI 8.0安装黑群晖DSM 7.x openwrt编译过程记录 编译monero For macOS ARM 自建busuanzi不蒜子平台统计平台 浅记博客更新日志 (机翻)Kubo配置文件 修改brew services中服务的启动参数 技术杂记📝 解决Surge模块不能同步问题 为Arch Linux配置邮件服务 自编译NutClient-ESXI,更改邮件逻辑 解决ESXI和群晖使用SSH密钥登录问题 为J4125软路由ESXI中群晖提供UPS服务 在arch linux上搭建rustdesk server 解决虚拟机扩容中GPT PMBR大小不符问题 优雅地为macOS提供python多版本的支持 修复root路径下文件权限问题 解决macOS 14上利用Whisky运行steam时有关问题 在macOS中用PhpStorm配置Xdebug调试 利用CloudFlare Workers快速自建一个IP获取器 如何自动续期证书? 从0开始速配VPS用于网站等 搭建一个基于ChatGPT的QQ机器人(Yunzai-Bot) For Mac 010 Editor For Mac 13.0.1 Crack 破解 关于部署Cloudflare Zero Trust遇到的问题浅记录📝
搭建Tuic V5
LanYun · 2023-07-06 · via LanYunのBlog

前言

本文内容基于开源项目 tuic 精巧的TUICed 0-RTT代理协议,以cloudflare作为域名解析服务,surge作为代理端.

你需要至少有:

  • VPS
  • 域名

点开发布链接可以看到最新版,建议以最新版为准,可替换本文中出现的链接.

搭建

配置

首先更新软件源,并创建tuic文件夹

1
2
3
apt update -y
apt -y install wget
mkdir /opt/tuic && cd /opt/tuic

获取服务端程序并赋予权限

name -a命令查看linux架构

GNUmusl是两种不同的C库(C standard library)实现,下面用musl库,因为它具有更小的内存占用和更快的启动时间.

amd
1
2
wget https://github.com/EAimTY/tuic/releases/download/tuic-server-1.0.0/tuic-server-1.0.0-x86_64-unknown-linux-musl -O /opt/tuic/tuic-server
chmod +x /opt/tuic/tuic-server
arm
1
2
wget https://github.com/EAimTY/tuic/releases/download/tuic-server-1.0.0/tuic-server-1.0.0-aarch64-unknown-linux-musl -O /opt/tuic/tuic-server
chmod +x /opt/tuic/tuic-server

接下来建立服务端配置

1
2
cat /proc/sys/kernel/random/uuid 
vim /opt/tuic/config.json

稍微分别翻译一部分意思吧,详细完整请看配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 用于监听的套接字地址,默认443,如果端口被占用可以换成其他,建议用其他的端口,另外tuic暂不支持回落
// 用户列表,包含用户UUID和密码
// 证书文件的路径
// 私钥文件的路径
// 可选。拥堵控制算法,可用选项:
// "cubic", "new_reno", "bbr"
// 默认:"cubic" ,个人推荐 "bbr"
// 可选。应用层协议的协商
// 默认为空(无ALPN)
// 可选。如果服务器应该为中继IPv6 UDP数据包创建单独的UDP套接字
// 默认:true
// 可选。在服务器端启用0-RTT QUIC连接握手。
// 这对性能影响不大,因为该协议是完全复用的。
// 警告:强烈建议禁用该功能,因为它容易受到重放攻击。参见https://blog.cloudflare.com/even-faster-connection-establishment-with-quic-0-rtt-resumption/#attack-of-the-clones
// 默认值:false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"server": "[::]:443",
"users": {
"00000000-0000-0000-0000-000000000000": "PASSWORD_0"
},
"certificate": "/opt/tuic/fullchain.pem",
"private_key": "/opt/tuic/privkey.pem",
"congestion_control": "bbr",
"alpn": ["h3", "spdy/3.1"],
"udp_relay_ipv6": true,
"zero_rtt_handshake": false,
"auth_timeout": "3s",
"max_idle_time": "10s",
"max_external_packet_size": 1500,
"gc_interval": "3s",
"gc_lifetime": "15s",
"log_level": "warn"
}

创建systemd

1
vim /lib/systemd/system/tuic.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=Delicately-TUICed high-performance proxy built on top of the QUIC protocol
Documentation=https://github.com/EAimTY/tuic
After=network.target

[Service]
User=root
WorkingDirectory=/opt/tuic
ExecStart=/opt/tuic/tuic-server -c config.json
Restart=on-failure
RestartPreventExitStatus=1
RestartSec=5

[Install]
WantedBy=multi-user.target
1
2
3
systemctl daemon-reload 
systemctl enable --now tuic.service
systemctl status tuic.service

证书

申请证书

本博客有用开源工具 acme.sh 通过DNS来自动化证书续期的教程.本文这里用另外一个开源工具 certbot

先去域名解析网站将xx.xxx.xx域名解析到你这个VPS的IP上.

下面示例并不是DNS验证,而是通过80端口验证(standalone插件)

example@gmail.com 换成你的邮箱 xx.xxx.xx 换成你的域名

1
2
3
4
5
6
7
apt -y install certbot 
certbot certonly \
--standalone \
--agree-tos \
--no-eff-email \
--email example@gmail.com \
-d xx.xxx.xx

通过systemd timer定时更新证书

1
2
systemctl enable --now certbot.timer 
systemctl status certbot.timer
1
2
3

ln -s -v /etc/letsencrypt/live/vless3.lanyundev.com/fullchain.pem /opt/tuic/fullchain.pem
ln -s -v /etc/letsencrypt/live/vless3.lanyundev.com/privkey.pem /opt/tuic/privkey.pem

添加bash脚本用于续订证书后自动重启tuic

1
vim /etc/letsencrypt/renewal-hooks/post/tuic.sh
1
2
3
#!/bin/bash

systemctl restart tuic.service
1
chmod +x /etc/letsencrypt/renewal-hooks/post/tuic.sh

额外记录一下:

证书sha256指纹获取:

1
openssl x509 -noout -fingerprint -sha256 -inform pem -in /opt/tuic/fullchain.pem

简单用法

1
2
3
4
5
6
7
8
9
10

certbot certificates

certbot renew --manual --preferred-challenges dns --manual-auth-hook "/脚本目录/au.sh python txy add" --manual-cleanup-hook "/脚本目录/au.sh python txy clean"


1 1 */1 * * root certbot-auto renew --manual --preferred-challenges dns --deploy-hook "service nginx -s reload" --manual-auth-hook "/脚本目录/au.sh php aly add" --manual-cleanup-hook "/脚本目录/au.sh php aly clean"

sudo certbot revoke --cert-name example.com
sudo certbot revoke --cert-path /etc/letsencrypt/live/example.com/cert.pem

后续有机会更新吧,

  • WeChat

    WeChat

  • AliPay

    AliPay


相关推荐

cover

cover