博文

Xray x25519 密钥对、linux中的base64、golang中的base64.RawURLEncoding

图片
玩了一下 Xray 上面的 Reality, 对其中生成 x2519 密钥对的过程感兴趣,拿到源码一看,还可以用 -i 参数带私钥进去计算公钥。 大概瞄了一下源码,哦,私钥是个Base64字符串。 放Google随便搜了一下,得到了这个: head -c 32 /dev/random | base64 生成的结果比如: Fi/Ho3QZbkPwR4OwqUVSE5lEZag4wIX80tZ2VNr0edA= 拿着这个喂给 xray x25519 -i 却老是报错,比如: illegal base64 data at input byte 2 拿着linux生成的base64字符串与xray x25519生成的公私钥字符串对比一下发现,xray x25519不认识'/'字符,而且生成的公私钥里面有'-'和'_' 再去查了一下资料,这才知道: Golang的base64.RawURLEncoding和Linux系统中的Base64在某些方面是有区别的,下面分别介绍: 1. 编码字符集不同。base64.RawURLEncoding 按照RFC 4648中URL和文件名安全型Base64编码标准,使用的字符集不包含加号(+)和斜杠(/),而是使用减号(-)和下划线(_)进行二进制数据的编码,这样可以避免数据在进行URL或文件名传递时出现冲突和问题。而Linux系统中的Base64编码标准是标准的Base64编码标准,使用的字符集包含加号(+)和斜杠(/)。 2. 解码方法不同。base64.RawURLEncoding 和标准Base64编码的解码方法有所不同。这是因为在进行URL参数编码时,我们通常会使用多种方法对特殊字符进行转义,这些特殊字符会在URL传输期间发生错误。因此,base64.RawURLEncoding在解码时不支持使用标准Base64编码字符集中的加号(+)和斜杠(/),而是使用减号(-)和下划线(_)作为替代字符。 总之,base64.RawURLEncoding适用于一些二进制数据需要进行URL或文件命名处理的场景,可以避免数据在传输时出现问题。而Linux系统中的标准Base64编码适用于其他场景,最常用于网络应用程序或进行数据等加密传输的场景。 在Linux中,可以通过使用 base64 命令来进

用指定版本commit的233脚本v3.67进行本地安装

图片
233脚本有了大更新,对于各种Linux环境的适配还没有旧版本做得那么好。有些朋友怀念旧版本。那么我们可以用指定版本 (比如 v3.67) 的233脚本进行本地安装。

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

图片
去年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 -fsSL https://github.crazypeace.workers.dev/ https://raw.githubusercontent.com/P3TERX/warp.sh/main/warp.sh | perl -pe 's#(curl.*?\.sh)([^/])#\1 | perl -pe "\$(curl -L https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para)" \2#g; s#(http.*?github[^/]*/)#https://github.crazypeace.workers.dev/\1#g' ) 4

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

原理: Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容 sed不支持非贪婪匹配 改用perl 如果看了下面的实例还学不会,欢迎留言附上你的一键脚本。 实例: 极简一键脚本 搭V2Ray 修改前 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   | perl -pe "$(curl -L  https://github.crazypeace.workers.dev/ https://github.com/crazypeace/gh-proxy/raw/master/perl-pe-para )" ) 一键WARP开IPv4入站 修改前 bash <(curl  https://raw.githubusercontent.com/P3TERX/warp.sh/main/warp.sh ) 4 修改后 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

此博客中的热门博文