博文

不用自己的域名和服务器搭博客的好处就是不怕异常流量

图片
去年10月和最近两天,我的博客都有异常的流量访问。 不用自己的域名和服务器搭博客的好处是,随便这些流量怎么跑,对大公司(Google)来说,都是小意思。对我自己来说,属于完全不用花精力去思考。

用双引号" 在shell脚本中包住$()调用 解决sed命令报错问题

图片
问题 在  Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容  的过程中,发生一件奇怪的事情。 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para1) 正常执行,但下面这个就报错 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para) GitHub上面的文件内容分别为: sed-E-para1: s#(http.*github[^/]*/)#https://github.crazypeace.workers.dev/\1#g sed-E-para : s#(curl.*\.sh)([^/])#\1 | sed -E "$(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para)" \2#g; s#(http.*github[^/]*/)#https://github.crazypeace.workers.dev/\1#g 在TG上问了一圈之后, fscarmen https://t.me/fscarmen2  给出了解决方案,用双引用把 $() 调用包起来。 解决方案 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E " $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para) "

sed不支持非贪婪匹配 改用perl

问题 之前   Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容 实践: bash <(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh   | sed -E "$(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para )" ) 发现这个处理方法并不完美。 用grep github把涉及修改的地方输出一下。 curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh   | sed -E "$(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para )" | grep github 发现,.sh 的部分, bash <(curl -L https://github.crazypeace.workers.dev/ https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh | sed -E "$(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para)" ) --version 4.45.2 只在前面加了 github proxy,后面调用 GitHub 资源的部分并没有处理。 分析 查了一下资料发现,sed只有贪婪匹配,所以改用 perl 实操 perl用来做正则替换的参数为 -pe,里面同样支持sed语法的s命令 如 p

GitHub Proxy 支持 api.github.com

图片
在使用GitHub Proxy代理 warp 脚本时,发现在调用api.github.com时报错。 经查, gh-proxy 没有加入对api.github.com的支持 https://github.com/hunshcn/gh-proxy/issues/44 那么就自己加一下吧。 修改内容很简单,前面部分,过滤格式增加一行 const exp7 = /^(?:https?:\/\/)?api\.github\.com\/.+?\/.+?\/.*$/i 后面部分,判断格式的地方加一个 || path.search(exp7) === 0  ====== 完 Github:  https://github.com/crazypeace/gh-proxy ====== 实例 bash <(curl  https://github.crazypeace.workers.dev/ https://raw.githubusercontent.com/P3TERX/warp.sh/main/warp.sh   | perl -pe "$(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para )" ) 4

在IPv6 only FreeVPSvc VPS访问GitHub一键脚本失败的时候,用GitHub Proxy解决问题

图片
原理: Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容 sed不支持非贪婪匹配 改用perl 网页工具 https://crazypeace.github.io/gh-proxy/ https://ghproxy.crazypeace.workers.dev/ 使用演示 实例: 极简一键脚本 搭V2Ray 修改前 bash <(curl -L  https://github.com/crazypeace/v2ray_wss/raw/main/install.sh ) 修改后 bash <(curl -L  https://ghproxy.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh   | perl -pe "$(curl -L  https://ghproxy.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para )" ) 一键WARP开IPv4入站 修改前 bash <(curl -L  https://raw.githubusercontent.com/P3TERX/warp.sh/main/warp.sh ) 4 修改后 bash <(curl -L  https://ghproxy.crazypeace.workers.dev/ https://raw.githubusercontent.com/P3TERX/warp.sh/main/warp.sh   | perl -pe "$(curl -L  https://ghproxy.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para )" ) 4

Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容

图片
问题 Free.vps.vc 访问GitHub资源出错 --update sed不支持非贪婪匹配 改用perl 修改后 bash <(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh   | perl -pe "$(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para )" ) 解决思路 用 GitHub Proxy 代理 source:  https://github.com/hunshcn/gh-proxy 要么fork一份脚本,自己修改添加gh-proxy,如下文教程 如何设置自定义gh-proxy参数使用我的warp脚本 要么就把脚本下载到本地,然后修改脚本。有手搓和sed命令替换两条路。 手搓方法 1. 自己搭 或者 使用现成的 GitHub Proxy . 以  https://github.crazypeace.workers.dev/  为例 2. 在你的 GitHub 资源 url 的前面加上 GitHub Proxy 的 url  如: bash <(curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh) 修改为 bash <(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh) 3. 如果你的资源是一个脚本,而这个脚本里面访问了GitHub资源 3.1 那么你可以先 wget 下来 wget  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/v2ray_wss/raw/main/install.sh 这里下载下来的是文件名是 install.sh

sed 命令中的 / 可以用任意字符替换 特别地当处理网址相关问题时

官方说明: The  /  characters may be uniformly replaced by any other single character within any given  s  command. The  /  character (or whatever other character is used in its stead) can appear in the  regexp  or  replacement  only if it is preceded by a  \  character. 来源: https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command 如: sed -E 's#(http.*github[^/]*/)#https://github.crazypeace.workers.dev/\1#g' 和 sed -E 's/(http.*github[^/]*\/)/https:\/\/github.crazypeace.workers.dev\/\1/g' 等同。

The Hot3 in Last 30 Days

无服务器 自建短链服务 Url-Shorten-Worker 完整的部署教程

ClouDNS .asia免费域名 托管到CloudFlare开CDN白嫖Websocket WS通道翻墙 / desec.io