<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="https://xmix.one/feed/rss/">
<title>Hello World</title>
<link>https://xmix.one/</link>
<description>Your description here.</description>
<items>
<rdf:Seq>
<rdf:li resource="https://xmix.one/archives/73/"/>
<rdf:li resource="https://xmix.one/archives/45/"/>
<rdf:li resource="https://xmix.one/archives/88/"/>
<rdf:li resource="https://xmix.one/archives/135/"/>
<rdf:li resource="https://xmix.one/archives/134/"/>
<rdf:li resource="https://xmix.one/archives/132/"/>
<rdf:li resource="https://xmix.one/archives/131/"/>
<rdf:li resource="https://xmix.one/archives/130/"/>
<rdf:li resource="https://xmix.one/archives/129/"/>
<rdf:li resource="https://xmix.one/archives/128/"/>
<rdf:li resource="https://xmix.one/archives/127/"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="https://xmix.one/archives/73/">
<title>Debian 手动安装 LNMP</title>
<link>https://xmix.one/archives/73/</link>
<dc:date>2024-01-08T16:02:00+00:00</dc:date>
<description>一、环境准备1.更新软件源apt update2.UFW 防火墙放行网站服务端口ufw allow http
ufw allow https二、安装最新版 nginx因为 Debian 软件源中的 nginx 实在是太老了，这里选择通过 nginx 官方仓库安装。官方教程：https://nginx.org/en/linux_packages.html#instructions1.安装必备组件apt install -y curl gnupg2 ca-certificates lsb-release debian-archive-keyring2.导入官方 GPG 密钥（复制整块命令粘贴）curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg &gt;/dev/null3.验证下载的文件是否包含正确的密钥gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg输出应包含完整指纹，如下所示：pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid                      nginx signing key &lt;signing-key@nginx.com&gt;4.添加 nginx 官方仓库到 apt 软件源nginx 仓库分为 Mainline version（主线版）和 Stable version（稳定版）；Mainline version：可以理解为测试版，会持续修复 Bug 并包含最新的特性，因为持续的加入特性可能会导致新的 Bug。如果想体验最新的功能，例如 HTTP/3 实验性支持，建议使用该版本。Stable version：修复了关键性的 Bug，比较稳定，但是功能特性可能不是最新的，推荐用于生产环境。以下两个添加仓库的命令按需求选择其中之一就行了~添加 Mainline version（主线版）仓库echo &quot;deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx&quot; \
    | sudo tee /etc/apt/sources.list.d/nginx.list添加 Stable version（稳定版）仓库echo &quot;deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx&quot; \
    | sudo tee /etc/apt/sources.list.d/nginx.list5.设置存储库固定优先选择 nginx 官方仓库分发提供的包echo -e &quot;Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n&quot; \
    | sudo tee /etc/apt/preferences.d/99nginx6.更新软件源apt update7.安装 nginxapt install nginx -y8.运行nginxsystemctl start nginx9.查看 nginx 运行状态systemctl status nginx输出内容：● nginx.service - nginx - high performance web server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
     Active: active (running) since Sun 2023-10-22 04:24:44 CST; 17h ago
       Docs: https://nginx.org/en/docs/
    Process: 37688 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited,&gt;    Process: 38070 ExecReload=/bin/sh -c /bin/kill -s HUP $(/bin/cat /var/run/nginx&gt;   Main PID: 37689 (nginx)
      Tasks: 3 (limit: 1110)
     Memory: 229.6M
        CPU: 8.955s
     CGroup: /system.slice/nginx.service
             ├─37689 &quot;nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con&gt;
             ├─38077 &quot;nginx: worker process&quot;
             └─38078 &quot;nginx: worker process&quot;10.按 q 键取消查看运行状态11.通过浏览器访问主机，正常情况下应该会出现 nginx 欢迎页面12.nginx默认配置默认配置文件：/etc/nginx/conf.d/default.conf默认HTML页面：/usr/share/nginx/html三、nginx 初始化配置1.创建文件夹用于存放虚拟主机配置文件mkdir -p /etc/nginx/sites-available2.创建文件夹用于存放虚拟主机配置文件的软连接mkdir -p /etc/nginx/sites-enabled3.创建文件夹用于存放网站文件mkdir -p /www/wwwroot4.创建文件夹用于存放网站证书mkdir -p /www/cert5.创建文件夹用于存放网站日志mkdir -p /www/wwwlogs6.备份 nginx主配置文件mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak7.新建 nginx主配置文件nano /etc/nginx/nginx.conf插入以下代码：# 定义 nginx 运行用户
user www-data;
# pid 文件路径
pid /var/run/nginx.pid;
# 运行进程数（建议设置为等于 CPU 线程数）
worker_processes 2;
# 最大打开文件数
worker_rlimit_nofile 65535;

# 加载启用的模块
include /etc/nginx/modules-enabled/*.conf;

events {
    # Nginx 事件处理模型
    use epoll;
    # 同时接收多个新连接
    multi_accept on;
    # 单个进程允许的客户端最大连接数
    worker_connections 65535;
}

http {
    # 默认编码
    charset utf-8;
    # 开启文件的高效传输模式
    sendfile on;
    # 激活 TCP_CORK socket（阻塞住此头部数据，与之后的 sendfile 数据一同发送，优化吞吐性能）
    tcp_nopush on;
    # 小的数据包不等待直接传输
    tcp_nodelay on;
    # 保持链接超时设定（实现服务器与客户端之间的长连接，减少系统对TCP连接的建立和销毁的开销）
    keepalive_timeout 65;
    # 隐藏 Nginx 版本号
    server_tokens off;
    # 设定文件不存在的错误是否写入日志
    log_not_found off;
    # 哈希的最大值，影响散列表的冲突率，值越大消耗内存越多，但散列 key 的冲突率会降低。
    types_hash_max_size 2048;
    # 设置每个散列桶占用的内存大小
    types_hash_bucket_size 64;
    # 限制上传文件的大小
    client_max_body_size 256M;

    # MIME 媒体类型配置
    include mime.types;
    default_type application/octet-stream;

    # 日志配置
    # 全局访问日志文件
    access_log /var/log/nginx/access.log;
    # 全局错误日志文件和记录级别设定
    error_log /var/log/nginx/error.log warn;

    # 加载其他配置文件
    include /etc/nginx/conf.d/*.conf;

    # 加载启用的站点配置文件
    include /etc/nginx/sites-enabled/*;
}nginx.zip8.测试 nginx 配置文件nginx -t输出内容：nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful9.重新启动 nginxsystemctl restart nginx10.查看 nginx 运行状态systemctl status nginx11.按 q 键退出运行状态查看12.nginx 的安装至此已经完成，如果需要新建站点，可以按以下步骤操作（1）在 /etc/nginx/sites-available 目录创建配置文件示例命令：nano /etc/nginx/sites-available/test.conf（2）在 /etc/nginx/sites-enabled 目录创建配置文件的软链接以启用站点示例命令：ln -s /etc/nginx/sites-available/test.conf /etc/nginx/sites-enabled/test.conf（3）测试配置文件nginx -t（4）重新加载 nginxsystemctl reload nginx（5）关于 Gzip 功能不建议在 http {} 内直接添加 Gzip 的配置，如果在 http {} 内直接添加会应用到全部站点，部分站点可能并不需要开启 Gzip 压缩，正确的做法是在 Server {} 内添加 Gzip 的功能代码对单站点启用。代码如下：    # gzip 功能开关
    gzip on;
    # 启用应答头&quot;Vary: Accept-Encoding&quot;（声明数据经过了压缩处理）
    gzip_vary on;
    # 设定触发压缩的条件为无条件（做为反向代理的时候启用）
    gzip_proxied any;
    # gzip 压缩级别
    gzip_comp_level 6;
    # 设置需要压缩的MIME类型
    gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;四、安装并初始化 MariaDB 数据库1.安装 MariaDBDebian 11 默认存储库的 MariaDB 版本是 10.5apt install -y mariadb-server2.运行安全设置向导mysql_secure_installation3.安全设置向导中各个询问的选择Enter current password for root (enter for none):
输入 mysql 的 root 密码，默认没有，回车确认。

Switch to unix_socket authentication [Y/n]
切换到 unix 套接字身份验证？选择：否

Change the root password? [Y/n]
设置 root 密码？选择：是（自行设置密码）

Remove anonymous users? [Y/n]
删除匿名（空用户）用户？选择：是

Disallow root login remotely? [Y/n]
不允许远程root登录？选择：否

Remove test database and access to it? [Y/n]
删除 test 数据库？选择：是

Reload privilege tables now? [Y/n]
是否重新加载权限表使之生效？选择：是五、安装 PHP 及相关扩展模块PHP8.2篇1.导入 Ondřej Surý PHP 仓库的 GPG 签名密钥并添加软件源sudo apt install -y lsb-release ca-certificates apt-transport-https
echo &quot;deb https://packages.sury.org/php/ $(lsb_release -sc) main&quot; | sudo tee /etc/apt/sources.list.d/php.list2.更新系统的存储库索引并执行软件包更新wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
sudo apt update3.安装 PHP 8.2 及常用扩展模块apt install -y php8.2-{fpm,cli,common,mysql,curl,dom,exif,fileinfo,imagick,gd,mbstring,xml,zip,memcached,opcache,bcmath,intl,sqlite3}Debian 安装 PHP 会自动安装 Apache，但这里准备使用 nginx，所以需要安装 php-fpm ，这样就可以声明 PHP 将以 FPM 的方式运行，就不会安装 Apache 了。4.添加防止跨目录攻击配置sed -i &#039;s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/&#039; /etc/php/8.2/fpm/php.ini这条实际上是编辑 /etc/php/8.2/fpm/php.ini 文件，将 ;cgi.fix_pathinfo=1 内容替换为 cgi.fix_pathinfo=05.设置上传大小限制sed -i &#039;s/upload_max_filesize = 2M/upload_max_filesize = 512M/&#039; /etc/php/8.2/fpm/php.ini
sed -i &#039;s/post_max_size = 8M/post_max_size = 512M/&#039; /etc/php/8.2/fpm/php.ini7.重启 PHP并设置开机启动systemctl restart php8.2-fpm
systemctl enable php8.2-fpmPHP7.4篇1.导入 Ondřej Surý PHP 仓库的 GPG 签名密钥并添加软件源curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x2.更新系统的存储库索引并执行软件包更新apt update
apt dist-upgrade -y3.安装 PHP 7.4 及常用扩展模块apt install -y php7.4-{fpm,cli,common,mysql,curl,dom,exif,fileinfo,imagick,gd,mbstring,xml,zip,memcached,opcache,bcmath,iconv,intl,simplexml,sqlite3,xmlreader}Debian 安装 PHP 会自动安装 Apache，但这里准备使用 nginx，所以需要安装 php-fpm ，这样就可以声明 PHP 将以 FPM 的方式运行，就不会安装 Apache 了。4.添加防止跨目录攻击配置sed -i &#039;s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/&#039; /etc/php/7.4/fpm/php.ini这条实际上是编辑 /etc/php/7.4/fpm/php.ini 文件，将 ;cgi.fix_pathinfo=1 内容替换为 cgi.fix_pathinfo=05.设置上传大小限制sed -i &#039;s/upload_max_filesize = 2M/upload_max_filesize = 256M/&#039; /etc/php/7.4/fpm/php.ini
sed -i &#039;s/post_max_size = 8M/post_max_size = 256M/&#039; /etc/php/7.4/fpm/php.ini6.重启 PHP并设置开机启动systemctl restart php7.4-fpm
systemctl enable php7.4-fpmPHP测试1.创建目录用于存放测试PHP的页面mkdir -p /www/wwwroot/php-test2.新建 Vhost 配置文件，用于测试 PHPnano /etc/nginx/conf.d/php-test.conf写入代码：server {
    # 监听IPv4的80端口
    listen 80;
    # 绑定域名或IP
    server_name 192.168.1.123;
    # 网站根目录
    root /www/wwwroot/php-test;
    # 默认文档
    index index.php index.html index.htm;

    # 开启 PHP7.4-fpm 模式
    location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                # fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}3.测试 nginx 配置文件nginx -t4.重新加载 nginxsystemctl reload nginx5.创建 php 测试文件nano /www/wwwroot/php-test/phpinfo.php写入代码：&lt;?php 
    phpinfo( ); 
?&gt;6.在浏览器打开以下地址，如果看到经典的 phpinfo 页面则说明安装成功http://ip/phpinfo.php7.测试成功后，按顺序执行以下命令，删除测试站点及相关文件。（1）删除测试站点 nginx 配置文件rm /etc/nginx/conf.d/php-test.conf（2）删除测试站点工作目录rm -r /www/wwwroot/php-test（3）重新加载 nginxsystemctl reload nginx六、安装FFmpeg如果需要使用files.gallery的视频缩略图功能，需要安装ffmpegsudo apt install ffmpeg然后运行type -P ffmpeg得到ffmpeg的运行目录，填写在files.gallery的相应处，同时需要&#039;image_resize_cache&#039; =&gt; true七、MariaDB 数据库服务器性能优化（可选）1.编辑配置文件nano /etc/mysql/mariadb.conf.d/50-server.cnf2.根据需求在文件中修改/添加的各项配置nano 可以使用 Ctrl+W 组合键搜索内容【512MB 内存方案】
key_buffer_size = 32M
query_cache_size = 4M
tmp_table_size = 4M
innodb_buffer_pool_size = 8M
innodb_log_buffer_size = 4M
sort_buffer_size = 128K
read_buffer_size = 64K
read_rnd_buffer_size = 128K
join_buffer_size = 128K
thread_stack = 128K
thread_cache_size = 16
binlog_cache_size = 128K
table_open_cache = 32
max_connections = 384

【1GB 内存方案】
key_buffer_size = 64M
query_cache_size = 8M
tmp_table_size = 8M
innodb_buffer_pool_size = 16M
innodb_log_buffer_size = 8M
sort_buffer_size = 256K
read_buffer_size = 128K
read_rnd_buffer_size = 256K
join_buffer_size = 256K
thread_stack = 256K
thread_cache_size = 32
binlog_cache_size = 256K
table_open_cache = 64
max_connections = 512

【2GB 内存方案】
key_buffer_size = 128M
query_cache_size = 16M
tmp_table_size = 16M
innodb_buffer_pool_size = 32M
innodb_log_buffer_size = 16M
sort_buffer_size = 512K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
join_buffer_size = 512K
thread_stack = 512K
thread_cache_size = 64
binlog_cache_size = 512K
table_open_cache = 128
max_connections = 512

【4GB 内存方案】
key_buffer_size = 256M
query_cache_size = 32M
tmp_table_size = 32M
innodb_buffer_pool_size = 64M
innodb_log_buffer_size = 32M
sort_buffer_size = 1024K
read_buffer_size = 512K
read_rnd_buffer_size = 1024K
join_buffer_size = 1024K
thread_stack = 1024K
thread_cache_size = 128
binlog_cache_size = 1024K
table_open_cache = 256
max_connections = 5123.重启 MariaDB 数据库服务器systemctl restart mariadb.service4.进入 MariaDB 数据库控制命令行mariadb5.执行语句验证配置（输出结果以字节为单位）show variables like &#039;key_buffer_size&#039;;
show variables like &#039;query_cache_size&#039;;
show variables like &#039;tmp_table_size&#039;;
show variables like &#039;innodb_buffer_pool_size&#039;;
show variables like &#039;innodb_log_buffer_size&#039;;
show variables like &#039;sort_buffer_size&#039;;
show variables like &#039;read_buffer_size&#039;;
show variables like &#039;read_rnd_buffer_size&#039;;
show variables like &#039;join_buffer_size&#039;;
show variables like &#039;thread_stack&#039;;
show variables like &#039;thread_cache_size&#039;;
show variables like &#039;binlog_cache_size&#039;;
show variables like &#039;table_open_cache&#039;;
show variables like &#039;max_connections&#039;;6.退出 MariaDB 数据库控制命令行exit八、设置 PHP-FPM 的进程池为动态模式（可选）1.编辑 PHP-FPM 配置文件nano /etc/php/7.4/fpm/pool.d/www.conf2.修改运行模式为动态模式，并按需修改相关参数。（1）搜索 pm = 修改参数值为：dynamicpm = dynamic（2）搜索 pm.max_children = 修改参数值为：32pm.max_children = 32作用：控制静态方式下开启的PHP-FPM进程数量（3）搜索 pm.start_servers = 修改参数值为：16pm.start_servers = 16作用：控制动态方式下的起始PHP-FPM进程数量（4）搜索 pm.min_spare_servers = 修改参数值为：16pm.min_spare_servers = 16作用：控制动态方式下的最小PHP-FPM进程数量（5）搜索 pm.max_spare_servers = 修改参数值为：32pm.max_spare_servers = 32作用：控制动态方式下的最大PHP-FPM进程数量3.重启 PHPsystemctl restart php7.4-fpm九、安装 Memcached 服务端（可选）Memcached 是高性能内存键值数据存储器，可以为 WordPress 提供缓存功能。1.安装 Memcached 和必须的 CLI 命令行工具apt install -y memcached libmemcached-tools2.修改分配给 Memcached 的内存sed -i &#039;s/-m 64/-m 256/&#039; /etc/memcached.conf这条命令的作用是编辑 /etc/memcached.conf 文件，将 -m 64 内容替换为 -m 256。3.重启 Memcachedsystemctl restart memcached4.查看 Memcached 运行状态systemctl status memcached5.按 q 键退出运行状态查看十、修改 PHP Session 的存储引擎为 Memcached（可选）1.编辑 PHP 配置文件nano /etc/php/7.4/fpm/php.ini2.修改 Session 的存储引擎为 Memcached（1）搜索 session.save_handler ，修改参数值为：memcachedsession.save_handler = memcached（2）在下一行添加 session.save_path 的配置，参数值为 memcached 监听端口session.save_path = &quot;127.0.0.1:11211&quot;3.重启 PHPsystemctl restart php7.4-fpm至此，LEMP 环境已经完成安装~</description>
</item>
<item rdf:about="https://xmix.one/archives/45/">
<title>Docker 相关命令</title>
<link>https://xmix.one/archives/45/</link>
<dc:date>2022-05-22T13:26:00+00:00</dc:date>
<description>一、Docker安装CentOS 7、Debian、Ubuntucurl -sSL https://get.docker.com/ | sh官方文档提供了脚本安装的途径wget --no-check-certificate https://get.docker.com/ -O - | bash输入 docker -v 查看版本信息开机启动systemctl start docker
systemctl enable dockerDocker更新sudo apt update二、安装 docker-compose国外机：sudo curl -L &quot;https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)&quot; -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-compose国内机curl -L https://get.daocloud.io/docker/compose/releases/download/v2.18.1/docker-compose-`uname -s`-uname -m &gt; /usr/local/bin/docker-compose重要的步骤chmod +x /usr/local/bin/docker-compose使用docker-compose找到DOCKER项目的文件•上传 docker-compose.yml 文件运行docker compose up -d更新docker-composedocker compose pull &amp;&amp; docker compose down &amp;&amp; docker compose up -d &amp;&amp; docker image prune -f三、查看docker日志docker logs -f name设置 Docker 容器日志大小1.新建/etc/docker/daemon.json，若有就不用新建了。添加log-dirver和log-opts参数，样例如下：# vim /etc/docker/daemon.json

{
  &quot;log-driver&quot;:&quot;json-file&quot;,
  &quot;log-opts&quot;: {&quot;max-size&quot;:&quot;500m&quot;, &quot;max-file&quot;:&quot;3&quot;}
}max-size=500m，意味着一个容器日志大小上限是500M， max-file=3，意味着一个容器有三个日志，分别是id+.json、id+1.json、id+2.json。2.然后重启docker的守护线程命令如下：systemctl daemon-reload
systemctl restart docker【需要注意的是：设置的日志大小规则，只对新建的容器有效】四、修改docker容器内容一般用这个:docker exec -it 容器ID /bin/bashdocker exec -it 180144ea21cd /bin/bash但是很多docker封装的很鸡贼,得用这个:docker exec -it 180144ea21cd /bin/sh还有些更鸡贼,不给权限,禁区不是root,就用这个:docker exec -u 0 -it 180144ea21cd /bin/shexit退出docker编辑五、Docker 清理垃圾1 查看磁盘空间占用情况df -h查看 Docker 容器、镜像、卷等资源的占用情况docker system df清理指定镜像docker imagesdocker rmi 5457fb6ac112 01bbee84cc9c 4d81f08e4937清理所有废弃镜像与Build Cachedocker system prune -a多种 prune 命令来清理垃圾docker image prune # 清理镜像
docker container prune # 清理容器
docker volume prune # 清理卷
docker builder prune # 清理构建缓存六、删除镜像1.查询运行容器docker ps -a2.停止容器docker stop id
3.查询停止容器docker ps -n 54.启动容器docker start numid5.删除容器docker rm id
6.查询镜像docker images
7.删除镜像docker rmi id七、卸载清除 Dockerdpkgdpkg -l | grep docker　　通过dpkg列出docker相关的软件包卸载apt-get remove docker-ce-cli docker-ce
apt-get autoremove # 会自动卸载containerd.io等一干软件。</description>
</item>
<item rdf:about="https://xmix.one/archives/88/">
<title>VPS常用脚本汇编</title>
<link>https://xmix.one/archives/88/</link>
<dc:date>2024-10-31T08:29:00+00:00</dc:date>
<description>集成脚本nodequalitybash &lt;(curl -sL https://run.NodeQuality.com)bash &lt;(curl -sL https://sh.nodeseek.com)1、DD重装脚本史上最强脚本wget --no-check-certificate -qO InstallNET.sh &#039;https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh&#039; &amp;&amp; chmod a+x InstallNET.sh &amp;&amp; bash InstallNET.sh -debian 12 -pwd &#039;password&#039;萌咖大佬的脚本bash &lt;(wget --no-check-certificate -qO- &#039;https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh&#039;) -d 11 -v 64 -p 密码 -port 端口 -a -firmwarebeta.gs大佬的脚本wget --no-check-certificate -O NewReinstall.sh https://raw.githubusercontent.com/fcurrk/reinstall/master/NewReinstall.sh &amp;&amp; chmod a+x NewReinstall.sh &amp;&amp; bash NewReinstall.shDD windows（使用史上最强DD脚本）bash &lt;(curl -sSL https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh) -windows 10  -lang &quot;cn&quot;账户：Administrator
密码：Teddysun.com使用Windows徽标+R快捷键打开运行框，输入powershell运行，弹出powershell命名输入窗口，输入以下命令：irm https://get.activated.win | iex2、综合测试脚本bench.shwget -qO- bench.sh | bashLemonBenchwget -qO- https://raw.githubusercontent.com/LemonBench/LemonBench/main/LemonBench.sh | bash -s -- --fast融合怪bash &lt;(wget -qO- --no-check-certificate https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh)NodeBenchbash &lt;(curl -sL https://raw.githubusercontent.com/LloydAsp/NodeBench/main/NodeBench.sh)网络质量体检脚本(https://github.com/xykt/NetQuality)bash &lt;(curl -Ls Net.Check.Place)3、性能测试yabscurl -sL yabs.sh | bash跳过网络，测GB5curl -sL yabs.sh | bash -s -- -i5跳过网络和磁盘，测GB5curl -sL yabs.sh | bash -s -- -if5改测GB5不测GB6curl -sL yabs.sh | bash -s -- -5检查是否超售lsmod | grep virtio_balloon4、流媒体及IP质量测试最常用版本bash &lt;(curl -L -s check.unlock.media)原生检测脚本bash &lt;(curl -sL Media.Check.Place)准确度最高bash &lt;(curl -L -s https://github.com/1-stream/RegionRestrictionCheck/raw/main/check.sh)IP质量体检脚本bash &lt;(curl -sL IP.Check.Place)一键修改解锁DNSwget https://raw.githubusercontent.com/Jimmyzxk/DNS-Alice-Unlock/refs/heads/main/dns-unlock.sh &amp;&amp; bash dns-unlock.sh5、测速脚本Speedtestbash &lt;(curl -sL bash.icu/speedtest)Taierbash &lt;(curl -sL res.yserver.ink/taier.sh)hyperspeedbash &lt;(curl -Lso- https://bench.im/hyperspeed)全球测速curl -sL network-speed.xyz | bash6、回程测试bash &lt;(curl -Ls Check.Place) -N7、功能脚本添加SWAPwget https://www.moerats.com/usr/shell/swap.sh &amp;&amp; bash swap.shFail2banwget --no-check-certificate https://raw.githubusercontent.com/FunctionClub/Fail2ban/master/fail2ban.sh &amp;&amp; bash fail2ban.sh 2&gt;&amp;1 | tee fail2ban.log一键开启BBR，适用于较新的Debian、Ubuntuecho &quot;net.core.default_qdisc=fq&quot; &gt;&gt; /etc/sysctl.conf
echo &quot;net.ipv4.tcp_congestion_control=bbr&quot; &gt;&gt; /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
lsmod | grep bbr多功能BBR安装脚本wget -N --no-check-certificate &quot;https://gist.github.com/zeruns/a0ec603f20d1b86de6a774a8ba27588f/raw/4f9957ae23f5efb2bb7c57a198ae2cffebfb1c56/tcp.sh&quot; &amp;&amp; chmod +x tcp.sh &amp;&amp; ./tcp.sh锐速/BBRPLUS/BBR2/BBR3wget -O tcpx.sh &quot;https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh&quot; &amp;&amp; chmod +x tcpx.sh &amp;&amp; ./tcpx.shTCP窗口调优wget http://sh.nekoneko.cloud/tools.sh -O tools.sh &amp;&amp; bash tools.sh添加warpwget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh &amp;&amp; bash menu.sh [option] [lisence/url/token]25端口开放测试telnet smtp.aol.com 258、一键安装常用环境及软件dockercurl -sSL https://get.daocloud.io/docker | shPythoncurl -O https://raw.githubusercontent.com/lx969788249/lxspacepy/master/pyinstall.sh &amp;&amp; chmod +x pyinstall.sh &amp;&amp; ./pyinstall.shiperf3apt install iperf3realmbash &lt;(curl -L https://raw.githubusercontent.com/zhouh047/realm-oneclick-install/main/realm.sh) -igostwget --no-check-certificate -O gost.sh https://raw.githubusercontent.com/qqrrooty/EZgost/main/gost.sh &amp;&amp; chmod +x gost.sh &amp;&amp; ./gost.sh极光面板bash &lt;(curl -fsSL https://raw.githubusercontent.com/Aurora-Admin-Panel/deploy/main/install.sh)哪吒监控curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh  -o nezha.sh &amp;&amp; chmod +x nezha.sh &amp;&amp; sudo ./nezha.shWARPwget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh &amp;&amp; bash menu.shAria2wget -N git.io/aria2.sh &amp;&amp; chmod +x aria2.sh &amp;&amp; ./aria2.sh宝塔wget -O install.sh http://v7.hostcli.com/install/install-ubuntu_6.0.sh &amp;&amp; sudo bash install.shPVE虚拟化bash &lt;(wget -qO- --no-check-certificate https://raw.githubusercontent.com/oneclickvirt/pve/main/scripts/build_backend.sh)Argoxbash &lt;(wget -qO- https://raw.githubusercontent.com/fscarmen/argox/main/argox.sh)sing-box+订阅(https://github.com/fscarmen/sing-box)bash &lt;(wget -qO- https://raw.githubusercontent.com/fscarmen/sing-box/main/sing-box.sh)mack-a 8合1 sing-box(https://github.com/mack-a/v2ray-agent)wget -P /root -N --no-check-certificate &quot;https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh&quot; &amp;&amp; chmod 700 /root/install.sh &amp;&amp; /root/install.shygkkk sing-box(https://github.com/yonggekkk/sing-box-yg)bash &lt;(curl -Ls https://gitlab.com/rwkgyg/sing-box-yg/raw/main/sb.sh)223boy sing-box(https://233boy.com/sing-box/sing-box-script/）bash &lt;(wget -qO- -o- https://github.com/233boy/sing-box/raw/main/install.sh)安装3x-ui(https://github.com/MHSanaei/3x-ui)bash &lt;(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)9、综合功能脚本科技lionapt update -y  &amp;&amp; apt install -y curl
bash &lt;(curl -sL kejilion.sh)SKY-BOXwget -O box.sh https://raw.githubusercontent.com/BlueSkyXN/SKY-BOX/main/box.sh &amp;&amp; chmod +x box.sh &amp;&amp; clear &amp;&amp; ./box.shTG中文汉化https://t.me/setlanguage/classic-zh-cn</description>
</item>
<item rdf:about="https://xmix.one/archives/135/">
<title>Debian系统开机一条龙</title>
<link>https://xmix.one/archives/135/</link>
<dc:date>2026-04-07T14:08:09+00:00</dc:date>
<description>1、DD系统curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh &amp;&amp; bash reinstall.sh debian 12 --password 密码 --ssh-port 端口2、执行脚本：apt update &amp;&amp; apt install -y curl &amp;&amp; bash &lt;(curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/debian_setup.sh)代码审查：https://github.com/LucaLin233/Linux/blob/main/debian_setup.sh可选项1、禁用密码登录：sudo sed -i &#039;s/^#*PasswordAuthentication yes/PasswordAuthentication no/&#039; /etc/ssh/sshd_config &amp;&amp; sudo systemctl restart sshd如果是bin456789 DD的debian系统，请先运行：rm -rf /etc/ssh/sshd_config.d/01-permitrootlogin.conf2、更换内核：curl -fsSL &quot;https://keyserver.ubuntu.com/pks/lookup?op=get&amp;search=0xD38D7D1DA1349567ADED882D86F7D09EE734E623&quot; \
  | sudo gpg --dearmor -o /usr/share/keyrings/xanmod-archive-keyring.gpgecho &#039;deb [signed-by=/usr/share/keyrings/xanmod-archive-keyring.gpg] http://deb.xanmod.org releases main&#039; | sudo tee /etc/apt/sources.list.d/xanmod-release.listsudo apt update &amp;&amp; sudo apt install -y linux-xanmod-x64v33、开启Swap：sudo fallocate -l 1G /swapfile &amp;&amp; sudo chmod 600 /swapfile &amp;&amp; sudo mkswap /swapfile &amp;&amp; sudo swapon /swapfile &amp;&amp; echo &#039;/swapfile none swap sw 0 0&#039; | sudo tee -a /etc/fstab移除swap：sudo swapoff /swapfile &amp;&amp; sudo sed -i &#039;\#^/swapfile none swap sw 0 0#d&#039; /etc/fstab &amp;&amp; sudo rm /swapfile4、内核调优：查看状态:curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/kernel.sh | bash -s status恢复配置:curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/kernel.sh | bash -s restore优化无国内优化服务时:curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/kernel.sh | bash -s install -i优化国内优化服务器时:curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/kernel.sh | bash -s install -c交互版:curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/kernel.sh | bash -s install5、安装syncthingsudo mkdir -p /etc/apt/keyrings &amp;&amp; \
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg &amp;&amp; \
echo &quot;deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable-v2&quot; | sudo tee /etc/apt/sources.list.d/syncthing.list &amp;&amp; \
sudo apt update &amp;&amp; \
sudo apt install syncthing &amp;&amp; \
sudo systemctl enable syncthing@root.service &amp;&amp; \
sudo systemctl start syncthing@root.service6、路由追踪（可从一键部署脚本中选择安装）：curl -sL nxtrace.org/nt | bash7、修改系统dns：bash &lt;(curl -L -s https://raw.githubusercontent.com/1-stream/1stream-public-utils/main/dns-change.sh) 127.0.0.1 1.1.1.18、安装Cloudflare Tunnelsudo bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/cloudflare_tunnel.sh)&quot; -- install卸载：sudo bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/LucaLin233/Linux/refs/heads/main/tools/cloudflare_tunnel.sh)&quot; -- uninstall9、多功能脚本：wget -P /root -N --no-check-certificate &quot;https://raw.githubusercontent.com/jklolixxs/jms/main/jms.sh&quot; &amp;&amp; chmod 700 /root/jms.sh &amp;&amp; /root/jms.sh Bash10、流媒体解锁检测：bash &lt;(curl -L -s https://github.com/1-stream/RegionRestrictionCheck/raw/main/check.sh)11、修改语言为中文：apt update &amp;&amp; \
apt install -y locales &amp;&amp; \
sed -i &#039;s/^# *zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/&#039; /etc/locale.gen &amp;&amp; \
locale-gen &amp;&amp; \
update-locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-812、IP质量检测：bash &lt;(curl -sL IP.Check.Place)</description>
</item>
<item rdf:about="https://xmix.one/archives/134/">
<title>优秀的CF项目汇总</title>
<link>https://xmix.one/archives/134/</link>
<dc:date>2026-03-19T12:47:27+00:00</dc:date>
<description>1、CloudMail https://github.com/maillab/cloud-mail2、NodeWarden https://github.com/shuaiplus/nodewarden3、CloudFlare图床 https://github.com/hleov/CloudFlare-ImgBed4、Discord图床 https://github.com/katelya77/K-Vault5、Antigravity-TG-Big-Bro https://github.com/sunyuchentrx/Antigravity-TG-Big-Bro6、AddressGenerator https://github.com/jiangnan1224/AddressGenerator7、XUGOU https://github.com/zaunist/xugou8、cf-drop https://github.com/lyonbot/cf-drop9、剩余价值计算器 https://github.com/realnovicedev/vps_calculator_docker10、另一款剩余价值计算器https://github.com/verkyer/vps-jsq11、畅聊 https://github.com/Shannon-x/chitchatter12、CF-M365-Admin https://github.com/wang4386/CF-M365-Admin13、NodeCrypt https://github.com/shuaiplus/NodeCrypt14、Flare Stack Blog https://github.com/du2333/flare-stack-blog15、CF-Warden https://github.com/qaz741wsd856/warden-worker16、OSSshelf https://github.com/Zoroaaa/OSSshelf</description>
</item>
<item rdf:about="https://xmix.one/archives/132/">
<title>CF优选IP</title>
<link>https://xmix.one/archives/132/</link>
<dc:date>2026-02-23T11:23:00+00:00</dc:date>
<description>最前面优选IP网站https://ip.v2too.top/https://ip.v2too.top/api/nodeshttps://ipdb.030101.xyz/bestcfv4/https://ip.164746.xyz/https://stock.hostmonit.com/CloudFlareYeshttps://www.cnae.top/https://saas.sin.fan/cf.468123.xyzcf.090227.xyzcf.3666888.xyzcloudflare.182682.xyzcdn.31514926.xyz备注：这些优选的都是CF的边缘ip，其实还是CF的，不一定是优化的线路一、WIN普通版一键测试优选，并且把最快的IP解析到域名1.下载CloudflareSpeedTesthttps://github.com/XIU2/CloudflareSpeedTest2.创建脚本解压刚刚GitHub下载的文件，在解压的文件目录创建两个文件run_all.bat跟update_cf_dns.ps1run_all.bat的代码如下@echo off
:: 设置脚本输出的字符集为 UTF-8，以支持中文等字符
chcp 65001

:: 切换到当前批处理脚本所在的目录
cd /d &quot;%~dp0&quot;

:: 输出信息，提示正在删除 result.csv 文件
echo 正在删除 result.csv...
del /f /q &quot;result.csv&quot;

:: 启用延迟变量扩展（用于在同一行中使用变量）
setlocal enabledelayedexpansion

:: ================================
:: 获取当前小时数并判断是否为晚高峰时段
:: ================================
:: 1. 提取当前小时数（取第0到第2位）
set &quot;current_hour=%time:~0,2%&quot;

:: 2. 去除小时数前面的空格（防止 0-9 点时出现 &quot; 8&quot; 导致判断报错）
set &quot;current_hour=%current_hour: =%&quot;

:: 3. 设置晚高峰判断变量（默认设为 false）
set &quot;IS_PEAK=false&quot;

:: 4. 判断逻辑：如果是 20点 到 23点 (20, 21, 22, 23)
if %current_hour% geq 20 if %current_hour% lss 24 (
    set &quot;IS_PEAK=true&quot;
)

:: ================================
:: 根据是否是晚高峰时段，启动不同的 cfst.exe 测速命令
:: ================================
if &quot;%IS_PEAK%&quot;==&quot;true&quot; (
     :: 如果是晚高峰时段，执行更高频率、更高负载的测速任务
     start &quot;&quot; /b &quot;%~dp0cfst.exe&quot; -n 600 -t 8 -dn 10 -dt 15 -tp 443 -url https://speed.cloudflare.com/__down?bytes=200000000 -tl 200 -tll 40 -tlr 1 -p 10 -sl 1 -o &quot;%~dp0result.csv&quot;
) else (
     :: 如果不是晚高峰时段，执行较低频率的测速任务
     start &quot;&quot; /b &quot;%~dp0cfst.exe&quot; -n 600 -t 4 -dn 10 -dt 15 -tp 443 -url https://speed.cloudflare.com/__down?bytes=200000000 -tl 120 -tll 30 -tlr 0.5 -p 10 -sl 2 -o &quot;%~dp0result.csv&quot;
)

:: ================================
:: 启动 PowerShell 脚本（用于更新 Cloudflare DNS）
:: ================================
start powershell -NoProfile -ExecutionPolicy Bypass -File &quot;%~dp0update_cf_dns.ps1&quot;


REM 主窗口自动关闭
update_cf_dns.ps1代码如下，只需要修改配置里面的三个项# 循环监听 result.csv 文件
$csvFile = &quot;result.csv&quot;
Write-Host &quot;正在监听 result.csv 文件...&quot;

# 等待 cfst.exe 生成 result.csv 文件
while (-not (Test-Path $csvFile)) {
    Write-Host &quot;等待 result.csv 文件生成...&quot;
    Start-Sleep -Seconds 5
}

Write-Host &quot;检测到 result.csv，等待 10 秒后开始进行 DNS 更新...&quot;

# 等待 10 秒钟后再执行 DNS 更新
Start-Sleep -Seconds 10

Write-Host &quot;开始进行 DNS 更新...&quot;

# 在新的 CMD 窗口中启动 DNS 更新逻辑（例如 Cloudflare API 或任何 DNS 更新方法）
Start-Process cmd.exe -ArgumentList &quot;/K echo 正在开始 DNS 更新... &amp;&amp; REM 在这里添加你的 DNS 更新逻辑 &amp;&amp; pause&quot;

Write-Host &quot;DNS 更新已在新的 CMD 窗口中启动。&quot;


# ---------- 配置 ----------
$CF_API_TOKEN     = &quot;&quot;      # Cloudflare API Token，必须有 Zone.DNS:Edit 权限
$ZONE_ID      = &quot;&quot;           # Cloudflare Zone ID
$DNS_NAME     = &quot;&quot;           # 要更新的域名
$FILE_PATH    = Join-Path $PSScriptRoot &quot;result.csv&quot;
# --------------------------

Write-Host &quot;🚀 脚本开始执行...&quot;

# 读取 CSV 第一行真实 IP 和 下载速度
$csvLine = (Get-Content $FILE_PATH -Encoding UTF8 | Select-Object -Skip 1 | Select-Object -First 1)
$fields = $csvLine.Split(&quot;,&quot;)
$IP = $fields[0].Trim()
$DownloadSpeed = [float]$fields[5].Trim()

# 检查下载速度是否为 0
if ($DownloadSpeed -eq 0) {
    Write-Host &quot;❌ 下载速度为 0，跳过 DNS 更新&quot;
    exit 0
}

Write-Host &quot;📌 获取到 IP: $IP&quot;
Write-Host &quot;📌 下载速度: $DownloadSpeed MB/s&quot;

# 设置请求头
$Headers = @{
    Authorization = &quot;Bearer $CF_API_TOKEN&quot;
    &quot;Content-Type&quot; = &quot;application/json&quot;
}

# 获取 DNS 记录 ID
$Resp = Invoke-RestMethod -Uri &quot;https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?type=A&amp;name=$DNS_NAME&quot; -Method GET -Headers $Headers
if ($Resp.success -and $Resp.result.Count -gt 0) {
    $DNS_RECORD_ID = $Resp.result[0].id
    Write-Host &quot;📌 DNS记录ID: $DNS_RECORD_ID&quot;
} else {
    Write-Host &quot;❌ 获取 DNS 记录 ID 失败&quot;
    exit 1
}

# 构建 JSON Body（proxied = false，关闭小橙云）
$Body = @{
    type = &quot;A&quot;
    name = $DNS_NAME
    content = $IP
    ttl = 1
    proxied = $false
} | ConvertTo-Json -Compress

# 更新 DNS
$UpdateResp = Invoke-RestMethod -Uri &quot;https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$DNS_RECORD_ID&quot; -Method PATCH -Headers $Headers -Body $Body

Write-Host &quot;📌 Cloudflare 返回: $UpdateResp&quot;

if ($UpdateResp.success) {
    Write-Host &quot;✅ DNS记录更新成功: $DNS_NAME -&gt; $IP&quot;
} else {
    Write-Host &quot;❌ DNS更新失败&quot;
}二、WIN优化版优化功能：电脑上测试优选IP，解析最快的IP到cf域名，tg通知结果，上传结果到网页win的脚本代码# ========================== 全局参数配置 ==========================
# 程序相关
$cfstPath = &quot;.\cfst.exe&quot;  # cfst.exe 文件路径
$csvFile = &quot;.\result.csv&quot;  # CSV 文件路径

# api相关
$uploadUrl = &quot;https://xxx/api/upload&quot;  # 上传接口 URL
$authKey = &quot;&quot;  # 授权密钥

# 域名更新相关
$zoneId = &quot;&quot;  # Cloudflare Zone ID
$apiToken = &quot;&quot;  # Cloudflare API Token
$recordName = &quot;&quot;  # 要更新的 DNS 记录名称

# 测速相关
$url = &quot;&quot;  # 测速用的文件地址

# ========================== 删除旧的 CSV 文件 ==========================
Write-Host &quot;[INFO] 删除旧的 result.csv 文件...&quot;
if (Test-Path $csvFile) {
    Remove-Item $csvFile
}

# ========================== 开始测速 ==========================
Write-Host &quot;[INFO] 开始测速...&quot;

# 设置 cfst.exe 参数
$currentHour = (Get-Date).Hour

if ($currentHour -ge 19 -and $currentHour -lt 24) {
    # 晚高峰时段的参数
    $cfstArgs = &quot;-n 800 -t 8 -dn 10 -dt 10 -tp 443 -tl 300 -tlr 0.5 -sl 0.01 -p 10 -url $url -o result.csv&quot;
} else {
    # 平时的参数
    $cfstArgs = &quot;-n 800 -t 4 -dn 10 -dt 10 -tp 443 -tl 300 -tlr 0.5 -sl 0.01 -p 10 -url $url -o result.csv&quot;
}

# 在新的 PowerShell 窗口运行 cfst.exe
Start-Process powershell -ArgumentList &quot;-NoExit&quot;, &quot;-Command&quot;, &quot;&amp; &#039;$cfstPath&#039; $cfstArgs&quot;

# 等待 result.csv 文件生成
$timeout = 900  # 设置最大等待时间 15 分钟
$startTime = Get-Date
while (-not (Test-Path $csvFile)) {
    $elapsedTime = (Get-Date) - $startTime
    if ($elapsedTime.TotalSeconds -gt $timeout) {
        Write-Host &quot;[ERROR] 等待时间超过 15 分钟，未生成 result.csv 文件&quot;
        exit
    }
    Write-Host &quot;[INFO] 等待 result.csv 文件生成...&quot;
    Start-Sleep -Seconds 10
}

# ========================== 读取 CSV 文件 ==========================
Write-Host &quot;[INFO] 读取 result.csv 文件...&quot;
$csvContent = Import-Csv -Path $csvFile

# 选择最快的 IP
$bestIp = $csvContent | Sort-Object { [double]$_.&#039;下载速度(MB/s)&#039; } -Descending | Select-Object -First 1

if ($bestIp) {
    Write-Host &quot;[INFO] 选择的 IP: $($bestIp.&#039;IP 地址&#039;) SPEED: $($bestIp.&#039;下载速度(MB/s)&#039;)&quot;
} else {
    Write-Host &quot;[ERROR] 找不到有效的 IP 地址&quot;
    exit
}

# ========================== 更新 DNS 记录 ==========================
Write-Host &quot;[INFO] 准备更新 DNS，IP 地址: $($bestIp.&#039;IP 地址&#039;)&quot;
$recordUrl = &quot;https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName&quot;
$headers = @{
    &quot;Authorization&quot; = &quot;Bearer $apiToken&quot;
    &quot;Content-Type&quot;  = &quot;application/json&quot;
}

$response = Invoke-RestMethod -Uri $recordUrl -Headers $headers -Method Get

if ($response.success -and $response.result.Count -gt 0) {
    $recordId = $response.result[0].id

    # 更新 DNS 记录
    $updateUrl = &quot;https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$recordId&quot;
    $body = @{
        &quot;type&quot;    = &quot;A&quot;
        &quot;name&quot;    = $recordName
        &quot;content&quot; = $bestIp.&#039;IP 地址&#039;
        &quot;ttl&quot;     = 60
        &quot;proxied&quot; = $false
    } | ConvertTo-Json

    $updateResponse = Invoke-RestMethod -Uri $updateUrl -Headers $headers -Method Put -Body $body

    if ($updateResponse.success) {
        Write-Host &quot;[INFO] DNS 更新成功&quot;
    } else {
        Write-Host &quot;[ERROR] 更新 DNS 失败: $($updateResponse.errors)&quot;
    }
} else {
    Write-Host &quot;[ERROR] 获取 DNS 记录失败&quot;
    exit
}

# ========================== 上传结果到 Worker ==========================
Write-Host &quot;[INFO] 上传数据到 Worker...&quot;

$jsonArray = @()
foreach ($row in $csvContent) {
    $jsonArray += @{
        &quot;ip&quot;          = $row.&#039;IP 地址&#039;
        &quot;speed&quot;       = $row.&#039;下载速度(MB/s)&#039;
        &quot;latency&quot;     = $row.&#039;平均延迟&#039;
        &quot;packetLoss&quot;  = $row.&#039;丢包率&#039;
        &quot;region&quot;      = $row.&#039;地区码&#039;
        &quot;sent&quot;        = $row.&#039;已发送&#039;
        &quot;received&quot;    = $row.&#039;已接收&#039;
        &quot;time&quot;        = (Get-Date).ToString(&quot;yyyy-MM-dd HH:mm:ss&quot;)
    }
}

# 转换为 JSON 格式
$jsonBody = $jsonArray | ConvertTo-Json -Depth 4

try {
    $uploadResponse = Invoke-RestMethod -Uri $uploadUrl -Method Post -Headers @{
        &quot;Authorization&quot; = $authKey
        &quot;Content-Type&quot;  = &quot;application/json&quot;
    } -Body $jsonBody

    if ($uploadResponse.success) {
        Write-Host &quot;[INFO] 数据上传成功&quot;
    } else {
        Write-Host &quot;[ERROR] 数据上传失败: $($uploadResponse.errors)&quot;
    }
} catch {
    Write-Host &quot;[ERROR] 上传失败: $_&quot;
}

# 防止脚本结束，保持当前窗口打开
Write-Host &quot;[INFO] 脚本执行完成&quot;
Read-Host &quot;按任意键退出&quot;
后端是部署在cloudfalre的worker，需要绑定一个kv，kv命名是IP_KVtg通知的话，也还需要在变量里面添加变量名，TG_BOT_TOKEN tg机器人api，TG_CHAT_ID tg用户idAUTH_KEY 可选，用户上传接口验证的密钥CF的woker代码// ================= 配置 =================
const CONFIG = {
  // 节点地区映射
  REGION_MAP: {
    HKG: &quot;香港&quot;, KHH: &quot;高雄&quot;, NRT: &quot;东京&quot;, LAX: &quot;洛杉矶&quot;,
    SEA: &quot;西雅图&quot;, SJC: &quot;圣何塞&quot;, FRA: &quot;法兰克福&quot;,
    MAD: &quot;马德里&quot;, SIN: &quot;新加坡&quot;, CAN: &quot;广州&quot;, SHA: &quot;上海&quot;
  },
  MAX_NODES_DISPLAY: 10,             // Telegram 最多显示节点数量
  DATA_RETENTION_MS: 24 * 60 * 60 * 1000, // 节点数据保留 24 小时
  BAR_MAX_LEN: 5,                    // Telegram 条形图长度
  NODE_ACCESS_INTERVAL: 30 * 1000    // 节点接口访问最小间隔 30 秒
};

// ================= 获取北京时间 =================
const getBJTime = () =&gt; new Date(Date.now() + 8 * 3600 * 1000);

// ================= Telegram 消息生成函数（等宽条形图） =================
function generateTGMessageText(data) {
  if (!data || data.length === 0)
    return &quot;❌ Cloudflare 优选 IP\n\n暂无有效数据&quot;;

  // 1. 排序并取前 MAX_NODES_DISPLAY 条
  const sortedData = [...data]
    .map(i =&gt; ({ ip: String(i.ip), speed: parseFloat(i.speed) || 0 }))
    .sort((a, b) =&gt; b.speed - a.speed)
    .slice(0, CONFIG.MAX_NODES_DISPLAY);

  const maxSpeed = sortedData[0].speed;
  const barLen = CONFIG.BAR_MAX_LEN;

  // 2. 构建条形图行
  const nodeLines = sortedData.map(i =&gt; {
    const ratio = maxSpeed &gt; 0 ? i.speed / maxSpeed : 0;
    let fill = Math.round(ratio * barLen);
    if (fill &lt; 1) fill = 1;

    let block;
    if (ratio &gt; 0.7) block = &quot;█&quot;;       // 高速
    else if (ratio &gt; 0.3) block = &quot;▓&quot;;  // 中速
    else block = &quot;▒&quot;;                    // 低速

    const bar = block.repeat(fill).padEnd(barLen, &quot; &quot;);
    const ip = i.ip.padEnd(16, &quot; &quot;);
    const speed = i.speed.toFixed(2).padStart(6, &quot; &quot;);
    return `${ip}${bar} ${speed} MB/s`;
  }).join(&quot;\n&quot;);

  const fastest = sortedData[0];
  const slowest = sortedData[sortedData.length - 1];
  const timeStr = getBJTime().toISOString().replace(&quot;T&quot;, &quot; &quot;).substring(0, 16);

  // 3. 返回 Telegram 消息
  return `✅ Cloudflare 优选 IP 更新通知

⚡️ 最快： ${fastest.ip} - ${fastest.speed.toFixed(2)} MB/s
☁️ 最慢： ${slowest.ip} - ${slowest.speed.toFixed(2)} MB/s

🕙 更新时间： ${timeStr}
&lt;code&gt;
${nodeLines}
&lt;/code&gt;`;
}

// ================= HTML 页面渲染 =================
function renderHTML(list) {
  const updateTime = list.length &gt; 0 ? list[0].time : &quot;-&quot;;

  // 计算最大速度，用于条形图比例
  const maxSpeed = list.length &gt; 0 ? Math.max(...list.map(i =&gt; i.speed)) : 0;

  // 生成每个节点卡片 HTML
  const cards = list.sort((a, b) =&gt; b.speed - a.speed)
    .map((i, idx) =&gt; {
      const widthPct = maxSpeed &gt; 0 ? Math.round((i.speed / maxSpeed) * 100) : 0;
      return `
      &lt;div class=&quot;card&quot; onclick=&quot;copyToClipboard(&#039;${i.ip}&#039;)&quot;&gt;
        &lt;div class=&quot;card-header&quot;&gt;
          &lt;span class=&quot;rank&quot;&gt;#${idx + 1}&lt;/span&gt;
          &lt;span class=&quot;region&quot;&gt;${CONFIG.REGION_MAP[i.region] || i.region || &quot;Any&quot;}&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class=&quot;ip&quot;&gt;${i.ip}&lt;/div&gt;
        &lt;div class=&quot;speed&quot;&gt;${i.speed} MB/s&lt;/div&gt;
        &lt;div class=&quot;latency&quot;&gt;${i.latency} ms&lt;/div&gt;
        &lt;div class=&quot;card-footer&quot;&gt;点击复制 IP&lt;/div&gt;
      &lt;/div&gt;`;
    }).join(&quot;&quot;);

  return `&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;zh-CN&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
&lt;title&gt;Cloudflare 优选 IP&lt;/title&gt;
&lt;style&gt;
  :root {
    --primary-color: #4caf50;
    --secondary-color: #f3f6f9;
    --card-bg: #ffffff;
    --text-color: #333;
    --muted-color: #888;
    --highlight-color: #f3f8fb;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  }

  * { box-sizing: border-box; }
  body {
    margin: 0;
    padding: 20px;
    font-family: &#039;Segoe UI&#039;, Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(145deg, #e0f7fa, #ffffff);
    color: var(--text-color);
  }
  .container { max-width: 1200px; margin: 0 auto; }
  .header { text-align: center; margin-bottom: 40px; }
  .header h1 { font-size: 2rem; color: var(--primary-color); }
  .header p { font-size: 0.9rem; color: var(--muted-color); }

  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

  /* 卡片样式 */
  .card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .card:hover { transform: translateY(-5px); box-shadow: var(--hover-shadow); }

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }
  .rank {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--primary-color);
    background: var(--highlight-color);
    padding: 6px 12px;
    border-radius: 20px;
  }
  .region {
    font-size: 0.8rem;
    color: #1e40af;
    background: #e0e7ff;
    padding: 6px 12px;
    border-radius: 12px;
  }

  .ip {
    font-family: &#039;Courier New&#039;, Courier, monospace;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 14px;
  }

  .speed {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin: 12px 0;
  }

  .latency {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--muted-color);
    text-align: center;
  }

  .card-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted-color);
    margin-top: 14px;
  }

  #toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  #toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
  }
&lt;/style&gt;
&lt;script&gt;
  // 复制 IP 并显示 Toast 提示
  function copyToClipboard(text) {
    navigator.clipboard.writeText(text).then(() =&gt; {
      const toast = document.getElementById(&quot;toast&quot;);
      toast.classList.add(&quot;show&quot;);
      setTimeout(() =&gt; toast.classList.remove(&quot;show&quot;), 1800);
    });
  }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;container&quot;&gt;
  &lt;div class=&quot;header&quot;&gt;
    &lt;h1&gt;Cloudflare 优选 IP&lt;/h1&gt;
    &lt;p&gt;最后更新 · ${updateTime}&lt;/p&gt;
  &lt;/div&gt;
  &lt;div class=&quot;grid&quot;&gt;
    ${cards || &#039;&lt;div style=&quot;grid-column: 1/-1; text-align:center; color:#9ca3af; padding:60px;&quot;&gt;暂无数据&lt;/div&gt;&#039;}
  &lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;toast&quot;&gt;IP 已复制&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;`;
}

// ================= Worker 主逻辑 =================
export default {
  async fetch(request, env) {
    const { pathname } = new URL(request.url);

    // ---------- 上传测速数据接口 ---------- 
    if (pathname === &quot;/api/upload&quot; &amp;&amp; request.method === &quot;POST&quot;) {
      try {
        const auth = request.headers.get(&quot;Authorization&quot;);
        if (env.AUTH_KEY &amp;&amp; auth !== env.AUTH_KEY)
          return new Response(&quot;Unauthorized&quot;, { status: 401 });

        const rawData = await request.json();
        if (!Array.isArray(rawData)) throw new Error(&quot;Invalid format&quot;);

        const now = getBJTime().toISOString();
        const cleanData = rawData.map(i =&gt; ({
          ip: i.ip, speed: i.speed, latency: i.latency, region: i.region, time: now.replace(&quot;T&quot;, &quot; &quot;).substring(0, 16)
        }));

        // 每次上传的数据都完全覆盖之前的数据
        await env.SPEED_TEST_KV.put(&quot;speed_test_data&quot;, JSON.stringify(cleanData));

        // 发送 Telegram 消息
        await Promise.allSettled([
          fetch(`https://api.telegram.org/bot${env.TG_BOT_TOKEN}/sendMessage`, {
            method: &quot;POST&quot;,
            headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },
            body: JSON.stringify({
              chat_id: env.TG_CHAT_ID,
              text: generateTGMessageText(cleanData),
              parse_mode: &quot;HTML&quot;,
              disable_notification: true
            })
          }),
        ]);

        return new Response(JSON.stringify({ success: true }), {
          headers: { &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot; }
        });

      } catch (e) {
        return new Response(JSON.stringify({ error: e.message }), {
          status: 400,
          headers: { &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot; }
        });
      }
    }

    // ---------- 获取节点数据接口 ---------- 
    if (pathname === &quot;/api/nodes&quot;) {
      const nowTs = Date.now();
      const clientIP = request.headers.get(&quot;CF-Connecting-IP&quot;) || &quot;unknown&quot;;

      const rawAccess = await env.SPEED_TEST_KV.get(&quot;nodes_access_map&quot;);
      let accessMap = rawAccess ? JSON.parse(rawAccess) : {};

      // 删除过期访问记录
      for (let ip in accessMap)
        if (nowTs - accessMap[ip] &gt; CONFIG.NODE_ACCESS_INTERVAL) delete accessMap[ip];

      // 检查访问频率
      if (accessMap[clientIP])
        return new Response(JSON.stringify({ success: false, message: &quot;请30秒后再请求&quot; }), {
          headers: { &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot; }
        });

      // 更新访问时间
      accessMap[clientIP] = nowTs;
      await env.SPEED_TEST_KV.put(&quot;nodes_access_map&quot;, JSON.stringify(accessMap));

      // 获取 24 小时内有效节点数据
      const raw = await env.SPEED_TEST_KV.get(&quot;speed_test_data&quot;);
      let list = raw ? JSON.parse(raw) : [];
      list = list.filter(i =&gt; nowTs - new Date(i.time).getTime() &lt; CONFIG.DATA_RETENTION_MS);

      return new Response(JSON.stringify({ success: true, data: list }), {
        headers: { &quot;Content-Type&quot;: &quot;application/json; charset=utf-8&quot; }
      });
    }

    // ---------- 网页端展示 ---------- 
    if (pathname === &quot;/&quot;) {
      const raw = await env.SPEED_TEST_KV.get(&quot;speed_test_data&quot;) || &quot;[]&quot;;
      return new Response(renderHTML(JSON.parse(raw)), {
        headers: { &quot;Content-Type&quot;: &quot;text/html; charset=UTF-8&quot; }
      });
    }

    // ---------- 404 ---------- 
    return new Response(&quot;Not Found&quot;, { status: 404 });
  }
};
三、Linux版1.官方安装说明# 如果是第一次使用，则建议创建新文件夹（后续更新时，跳过该步骤）
mkdir cfst

# 进入文件夹（后续更新，只需要从这里重复下面的下载、解压命令即可）
cd cfst

# 下载 CFST 压缩包（自行根据需求替换 URL 中 [版本号] 和 [文件名]）
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_amd64.tar.gz
# 如果你是在国内网络环境中下载，那么请使用下面这几个镜像加速之一：
# wget -N https://ghfast.top/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_arm64.tar.gz
# wget -N https://wget.la/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_arm64.tar.gz
# wget -N https://ghproxy.net/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_arm64.tar.gz
# wget -N https://gh-proxy.com/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_arm64.tar.gz
# wget -N https://hk.gh-proxy.com/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.3.4/cfst_linux_arm64.tar.gz
# 如果下载失败的话，尝试删除 -N 参数（如果是为了更新，则记得提前删除旧压缩包 rm cfst_linux_amd64.tar.gz ）

# 解压（不需要删除旧文件，会直接覆盖，自行根据需求替换 文件名）
tar -zxf cfst_linux_amd64.tar.gz

# 赋予执行权限
chmod +x cfst

# 运行（不带参数）
./cfst

# 运行（带参数示例）
./cfst -tl 200 -dn 20在解压的文件里面，新建一个sh文件run_cf_ddns.sh需要修改的内容都在配置信息里面API_TOKEN # Cloudflare API Token，必须有 Zone.DNS:Edit 权限
ZONE_ID # Cloudflare Zone ID
RECORD_NAME # 要更新的域名记得给文件添加可执行权限，chmod 777 run_cf_ddns.sh，然后运行看看效果./run_cf_ddns.sh#!/bin/bash

# ================= 配置信息 =================
# Cloudflare API Token，必须有 Zone.DNS:Edit 权限
API_TOKEN=&quot;&quot;
# Cloudflare Zone ID
ZONE_ID=&quot;&quot;
# 要更新的域名
RECORD_NAME=&quot;&quot;
# 测速url
SPEED_URL=&quot;&quot;

# ================= cfst 参数 =================
# 定义平时参数
CFST_PARAMS_DAY=&quot;-n 600 -t 4 -dn 10 -dt 15 -tp 443 -url $SPEED_URL -tl 120 -tll 40 -tlr 0.5 -p 10 -sl 1 -o result.csv&quot;
# 定义晚高峰参数
CFST_PARAMS_PEAK=&quot;-n 600 -t 6 -dn 10 -dt 15 -tp 443 -url $SPEED_URL -tl 200 -tll 40 -tlr 1 -p 10 -sl 1 -o result.csv&quot;

# 根据当前时间判断使用哪一套参数
current_hour=$(date +%H)
if [ &quot;$current_hour&quot; -ge 20 ] &amp;&amp; [ &quot;$current_hour&quot; -lt 24 ]; then
    CFST_PARAMS=&quot;$CFST_PARAMS_PEAK&quot;  # 晚高峰使用晚高峰参数
else
    CFST_PARAMS=&quot;$CFST_PARAMS_DAY&quot;   # 非高峰期使用平时参数
fi

echo &quot;使用 cfst 参数: $CFST_PARAMS&quot;
# ============================================

# ================= 防止重复运行逻辑 =================
LOCK_FILE=&quot;/tmp/cfst_ddns_update.lock&quot;
LOCK_TIMEOUT=900  # 15分钟超时

# 使用文件描述符 200 绑定锁文件
exec 200&gt;&quot;$LOCK_FILE&quot;

# 尝试获取排他锁 (-n 表示非阻塞，如果失败立即返回)
if ! flock -n 200; then
    echo &quot;--- [$(date &#039;+%Y-%m-%d %H:%M:%S&#039;)] 错误: 另一个脚本实例正在运行，本次任务跳过 ---&quot;
    exit 0
fi

# 设置超时控制：超过15分钟自动解除锁并停止脚本
{
    sleep &quot;$LOCK_TIMEOUT&quot; &amp;&amp; echo &quot;--- [$(date &#039;+%Y-%m-%d %H:%M:%S&#039;)] 错误: 超过 15 分钟未完成任务，自动解锁并退出 ---&quot; &amp;&amp; flock -u 200 &amp;&amp; exit 1
} &amp;

# 脚本的主要任务处理
echo &quot;--- [$(date &#039;+%Y-%m-%d %H:%M:%S&#039;)] 正在执行任务 ---&quot;
# 任务代码...

# 脚本任务完成后解除锁
flock -u 200
echo &quot;--- [$(date &#039;+%Y-%m-%d %H:%M:%S&#039;)] 任务完成，已释放锁 ---&quot;
# ===================================================

# 获取脚本所在绝对路径
BASE_DIR=$(cd &quot;$(dirname &quot;$0&quot;)&quot;; pwd)
cd &quot;$BASE_DIR&quot; || exit 1
RESULT_FILE=&quot;$BASE_DIR/result.csv&quot;

echo &quot;--- 任务开始: $(date &#039;+%Y-%m-%d %H:%M:%S&#039;) ---&quot;

# 1. 环境清理
[ -f &quot;$RESULT_FILE&quot; ] &amp;&amp; rm -f &quot;$RESULT_FILE&quot;

# 2. 执行测速
if [ -f &quot;./cfst&quot; ]; then
    echo &quot;[步骤1/4] 正在运行 cfst 测速...&quot;
    chmod +x ./cfst
    ./cfst $CFST_PARAMS
else
    echo &quot;错误: 目录下未找到 cfst 执行文件&quot;
    exit 1
fi

# 3. 结果校验与提取
if [ ! -s &quot;$RESULT_FILE&quot; ]; then
    echo &quot;错误: 测速失败，未生成有效的 result.csv&quot;
    exit 1
fi

READ_DATA=$(awk -F, &#039;NR==2 {print $1,$6}&#039; &quot;$RESULT_FILE&quot;)
read -r IP SPEED &lt;&lt;&lt; &quot;$READ_DATA&quot;

CHECK_RESULT=$(echo &quot;$SPEED&quot; | awk &#039;{if($1 &lt;= 0.01) print &quot;stop&quot;; else print &quot;go&quot;}&#039;)

if [ &quot;$CHECK_RESULT&quot; == &quot;stop&quot; ] || [ -z &quot;$IP&quot; ]; then
    echo &quot;停止更新: 速度过低 ($SPEED MB/s) 或未获取到 IP。&quot;
    exit 0
fi

echo &quot;[步骤2/4] 测速通过！最优 IP: $IP, 速度: $SPEED MB/s&quot;

# 4. 更新 Cloudflare
echo &quot;[步骤3/4] 正在获取 Record ID...&quot;
RECORD_INFO=$(curl -s -X GET &quot;https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?name=$RECORD_NAME&quot; \
     -H &quot;Authorization: Bearer $API_TOKEN&quot; \
     -H &quot;Content-Type: application/json&quot;)

RECORD_ID=$(echo &quot;$RECORD_INFO&quot; | sed -n &#039;s/.*&quot;id&quot;:&quot;\([^&quot;]*\)&quot;.*/\1/p&#039; | head -n 1)

if [ -z &quot;$RECORD_ID&quot; ] || [ ${#RECORD_ID} -lt 10 ]; then
    echo &quot;错误: 无法获取 Record ID。&quot;
    exit 1
fi

echo &quot;[步骤4/4] 正在同步 DNS 记录...&quot;
UPDATE_RES=$(curl -s -X PUT &quot;https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID&quot; \
     -H &quot;Authorization: Bearer $API_TOKEN&quot; \
     -H &quot;Content-Type: application/json&quot; \
     --data &quot;{\&quot;type\&quot;:\&quot;A\&quot;,\&quot;name\&quot;:\&quot;$RECORD_NAME\&quot;,\&quot;content\&quot;:\&quot;$IP\&quot;,\&quot;ttl\&quot;:60,\&quot;proxied\&quot;:false}&quot;)

if [[ &quot;$UPDATE_RES&quot; == *&quot;\&quot;success\&quot;:true&quot;* ]]; then
    echo &quot;==========================================&quot;
    echo &quot;  更新成功！ IP: $IP&quot;
    echo &quot;==========================================&quot;
else
    echo &quot;更新失败！&quot;
    echo &quot;$UPDATE_RES&quot;
    exit 1
fi

echo &quot;--- 任务结束: $(date &#039;+%Y-%m-%d %H:%M:%S&#039;) ---&quot;
</description>
</item>
<item rdf:about="https://xmix.one/archives/131/">
<title>Linux部署yt-dtl，下载Youtube</title>
<link>https://xmix.one/archives/131/</link>
<dc:date>2026-02-19T07:57:00+00:00</dc:date>
<description>一、安装 yt-dlp（推荐官方二进制方式）下载最新版sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp赋予执行权限sudo chmod a+rx /usr/local/bin/yt-dlp测试yt-dlp --version如果能显示版本号，说明安装成功。二、安装 ffmpeg（必须）用于合并视频音频：sudo apt update
sudo apt install ffmpeg -y测试：ffmpeg -version三、下载命令yt-dlp -f &quot;bestvideo+bestaudio/best&quot; \
--merge-output-format mp4 \
URL
</description>
</item>
<item rdf:about="https://xmix.one/archives/130/">
<title>部署 WireGuard 实现NAS安全组网</title>
<link>https://xmix.one/archives/130/</link>
<dc:date>2026-02-08T08:27:00+00:00</dc:date>
<description>1. 前期准备DDNS 解析：解析一个域名到你的公网 IP。客户端准备：手机/PC 端下载安装 WireGuard。密码处理（关键）：准备好你的明文密码。访问 bcrypt.online 生成 Hash 串。转义处理：在 Docker Compose 中 $ 是变量符，必须将 Hash 串中所有的 $ 替换为 $$。2. Docker 部署在NAS中新建目录 /vol1/1000/app/wireguard，创建 docker-compose.yml。配置要点：替换 WG_HOST 为你的域名。替换 PASSWORD_HASH 为刚才生成的 Hash。WG_DEFAULT_ADDRESS 建议修改为非家庭常用网段（如 10.8.0.x），避免路由冲突。services:
  wg-easy:
    image: ghcr.io/wg-easy/wg-easy
    container_name: wg-easy
    environment:
      - WG_HOST=你的公网域名或公网IP
      - PASSWORD_HASH=管理后台密码 (Bcrypt Hash)，注意 Docker Compose 中 $ 需写成 $$
      
      # 网络配置
      - WG_PORT=51820
      - WG_DEFAULT_ADDRESS=10.8.0.x
      - WG_DEFAULT_DNS=223.5.5.5, 223.6.6.6
      - WG_ALLOWED_IPS=0.0.0.0/0, ::/0
      - WG_MTU=1420
      
    volumes:
      - ./config:/etc/wireguard
    ports:
      - &quot;51820:51820/udp&quot; # 隧道通信
      - &quot;51821:51821/tcp&quot; # Web 管理面板
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1启动容器后，访问 http://NAS_IP:51821/ 进入后台（密码为 Hash 前的明文）。3. 端口转发进入主路由后台，添加端口映射：外部端口：51820内部端口：51820协议：UDP (注意：WireGuard 仅使用 UDP)4. 客户端连接在 Web 后台点击 New Client，命名（如 iPhone）。打开手机 WireGuard App，扫描屏幕上的二维码。断开手机 WiFi，使用 5G 流量测试。开启连接，尝试访问 NAS 内网 IP。5. 为什么选择 WireGuard？安全性：隐形防御端口映射 (5666)：像家门临街，虽然有锁，但小偷知道门在哪，随时能尝试撬锁或利用漏洞（如 fnOS 事件）。WireGuard (51820)：在攻击者眼中是“丢包”的黑洞。没有正确的私钥，服务器对任何扫描都不予回应。坏人连门都找不到，无从下手。功能性：全屋互联端口映射：要在墙上凿无数个洞。想用 NAS 凿一个，想看监控又凿一个。想用局域网打印机？没映射就无法访问。WireGuard：直接把你要到了客厅。连上 VPN 等同于设备物理接入了家庭 WiFi。NAS、路由器后台、PC 远程桌面、打印机，想连谁连谁。维护性：收敛入口传统方式：维护多个端口，需确保每个服务的 Auth 都足够强壮。WireGuard：只需守住这唯一的入口。只要隧道安全，内网所有弱密码设备皆安全。</description>
</item>
<item rdf:about="https://xmix.one/archives/129/">
<title>Typecho整文件夹迁移后的权限调整</title>
<link>https://xmix.one/archives/129/</link>
<dc:date>2026-02-07T16:31:27+00:00</dc:date>
<description>对于采用SQLITE的Typecho，在对整个文件夹先压缩再上传的迁移，迁移后会出现访问500错误。其主要原因是*.db 的属主是 root:root，而 PHP-FPM 是 www-data 在跑，因此需要重新调整权限。1. 把 usr 目录和数据库交给 www-datachown -R www-data:www-data /www/wwwroot/xxx.xxx/usr2. 给 usr 目录写权限（SQLite 需要）chmod 775 /www/wwwroot/xxx.xxx/usr3. 确保数据库文件可写chmod 664 /www/wwwroot/xxx.xxx/usr/xmix.db</description>
</item>
<item rdf:about="https://xmix.one/archives/128/">
<title>Linux迁移Docker到数据盘</title>
<link>https://xmix.one/archives/128/</link>
<dc:date>2026-02-03T11:53:00+00:00</dc:date>
<description>1、 确认 Docker 完全没在运行sudo systemctl stop docker.socket
sudo systemctl stop docker
sudo systemctl stop containerd2、 创建 Docker 数据目录mkdir -p /data/docker给权限（推荐）：chown -R root:root /data/docker
chmod 711 /data/docker3、 指定 Docker 使用 /data/docker创建或编辑配置文件：nano /etc/docker/daemon.json写入 完整内容（如果文件原来不存在，直接粘贴即可）：{
  &quot;data-root&quot;: &quot;/data/docker&quot;
}保存退出。4、将 containerd 数据迁移到 /data/docker/containerd：sudo mv /var/lib/containerd /data/docker/containerd5、修改 containerd 配置（通常 /etc/containerd/config.toml）：root = &quot;/data/docker/containerd&quot;
state = &quot;/data/docker/containerd/state&quot;6、启动 Dockersystemctl daemon-reexec
systemctl start containerd
systemctl start docker7、验证是否生效（关键一步）docker info | grep &quot;Docker Root Dir&quot;
ls /data/docker_new/containerd/io.containerd.content.v1.content
ls /data/docker_new/containerd/io.containerd.snapshotter.v1.overlayfs</description>
</item>
<item rdf:about="https://xmix.one/archives/127/">
<title>使用CF Workers 优选反代 EMBY</title>
<link>https://xmix.one/archives/127/</link>
<dc:date>2026-01-19T13:03:00+00:00</dc:date>
<description>前期准备:CloudFLare账号托管在Cloudflare上面的域名注意事项:同一个反代建议不要给很多人用，否则流量过大可能违反CF的政策导致被封号。建议小范围自用。第一步: 部署代码首先打开Cloudflare面板，在左侧菜单找到 Workers 和 Pages，点击 创建应用程序，模板选Hello word 开始新建一个Worker。点击 编辑代码，将原有的代码全部删除，粘贴以下代码。注意：粘贴后，请务必修改代码顶部的 target 这一行，填入你自己想要反代的Emby服务器地址和端口。const myConfig = {
 target: &#039;https://你的emby地址:端口号&#039;,
 enableCors: true
};

export default {
 async fetch(req, env, ctx) {
  const u = new URL(req.url);
  const t = new URL(myConfig.target);
  u.protocol = t.protocol;
  u.hostname = t.hostname;
  u.port = t.port;
  const h = new Headers(req.headers);
  h.set(&#039;Host&#039;, t.hostname);
  if (h.has(&#039;Referer&#039;)) h.set(&#039;Referer&#039;, myConfig.target);
  if (h.has(&#039;Origin&#039;)) h.set(&#039;Origin&#039;, myConfig.target);
  const r = new Request(u.toString(), {
   method: req.method,
   headers: h,
   body: req.body,
   redirect: &#039;follow&#039;
  });
  try {
   const res = await fetch(r);
   const rh = new Headers(res.headers);
   if (myConfig.enableCors) {
    rh.set(&#039;Access-Control-Allow-Origin&#039;, &#039;*&#039;);
    rh.set(&#039;Access-Control-Allow-Methods&#039;, &#039;GET,POST,PUT,PATCH,DELETE,OPTIONS&#039;);
    rh.set(&#039;Access-Control-Allow-Headers&#039;, &#039;*&#039;);
   }
   return new Response(res.body, {
    status: res.status,
    statusText: res.statusText,
    headers: rh
   });
  } catch (err) {
   return new Response(err.message, { status: 502 });
  }
 }
};点击右上角的 部署 (Deploy) 按钮保存。第二步: 域名CNAME优选打开你托管在Cloudflare的域名管理页面，进入 DNS 记录。添加一条 CNAME 记录:名称: 填写你想要的前缀(例如 emby)目标: 填写一个优选域名。务必关闭 "小黄云"优选域名可以在这里选:https://cf.090227.xyz/第三步: 配置路由在你的域名管理页面左侧菜单栏，点击 Workers 路由 (Workers Routes)。点击 添加路由。路由一栏输入: 添加记录的名称.你的域名/*例如: emby.你的域名.com/*注意!!!  一定要带上/*Worker 一栏选择你第一步创建的那个Worker。点击保存。本教程的优选域名方式也可以用于其它功能的workers,反代代码也可以用于emby服务器以外的网站,想要个性化的功能可以让AI帮你写代码结束:现在打开你在DNS设置的那个域名(例如 https://emby.你的域名.com)，应该就可以直接访问你的Emby了，并且走的是优选线路。补充:反代需要使用国内dns解析,否则可能连不上,如果你有同时使用代理软件,请自行添加规则,把你自己的域名走直连,并且DNS要用国内的补充:在播放器上,服务器端口可以不填(默认443),也可以填443、2053、2083、2087、2096、8443使用其它端口也许可以在晚高峰提升速度(我不确定). 本方式搭建的反代,使用hills的可以直接在它的服务器线路中添加进阶:如果你有多个Emby服务器，想要通过同一个优选域名访问（例如用 /server1 访问第一台，/server2 访问第二台），懒得每个服务器都开一个workers, 可以使用下面的代码。操作方法:将Worker中的代码全部替换为以下内容，并修改顶部的配置区域。const mapCfg = {
 paths: {
  &quot;/server1&quot;: &quot;https://你的第一台emby地址:端口&quot;,
  &quot;/server2&quot;: &quot;https://你的第二台emby地址:端口&quot;
 },
 main: &quot;https://你的默认emby地址:端口&quot;,
 cors: true
};

export default {
 async fetch(req, env, ctx) {
  const rawUrl = new URL(req.url);
  let target = mapCfg.main;
  let prefix = &quot;&quot;;
   
  for (const key in mapCfg.paths) {
   if (rawUrl.pathname.startsWith(key)) {
    target = mapCfg.paths[key];
    prefix = key;
    break;
   }
  }

  let cleanPath = rawUrl.pathname;
  if (prefix) {
   cleanPath = cleanPath.replace(prefix, &#039;&#039;);
   if (cleanPath === &#039;&#039; || !cleanPath.startsWith(&#039;/&#039;)) {
    cleanPath = &#039;/&#039; + cleanPath;
   }
  }

  const tUrl = new URL(target);
  const finalUrl = new URL(cleanPath + rawUrl.search, tUrl);
   
  const h = new Headers(req.headers);
  h.set(&#039;Host&#039;, tUrl.host);
   
  if (h.has(&#039;Referer&#039;)) h.set(&#039;Referer&#039;, target);
  if (h.has(&#039;Origin&#039;)) h.set(&#039;Origin&#039;, target);

  const newReq = new Request(finalUrl.toString(), {
   method: req.method,
   headers: h,
   body: req.body,
   redirect: &#039;follow&#039;
  });

  try {
   const res = await fetch(newReq);
   const resH = new Headers(res.headers);
    
   if (mapCfg.cors) {
    resH.set(&#039;Access-Control-Allow-Origin&#039;, &#039;*&#039;);
    resH.set(&#039;Access-Control-Allow-Methods&#039;, &#039;GET, POST, PUT, PATCH, DELETE, OPTIONS&#039;);
    resH.set(&#039;Access-Control-Allow-Headers&#039;, &#039;*&#039;);
   }

   return new Response(res.body, {
    status: res.status,
    statusText: res.statusText,
    headers: resH
   });
  } catch (err) {
   return new Response(err.message, { status: 502 });
  }
 }
};使用说明:修改 paths 中的内容，左边是路径前缀，右边是对应的服务器地址。修改 main 中的地址，这是直接访问域名（不带前缀）时连接的默认服务器。在Emby客户端填入地址时：访问默认服务器填: https://emby.你的域名.com访问其他服务器填: https://emby.你的域名.com/server1 (对应代码里设置的前缀)</description>
</item>
</rdf:RDF>