Skip to content

Instantly share code, notes, and snippets.

View phlinhng's full-sized avatar

phlinhng

  • Tsinghua University
  • Formosa
View GitHub Profile
@phlinhng
phlinhng / trojan.json
Last active June 19, 2021 06:49
将服务端的 trojan-go 与 v2ray-core 组合实现按目的地中转 ( 目前 trojan-go 作为 server 不支持前置代理,写开心的 )
{
"run_type": "server",
"local_addr": "127.0.0.1",
"local_port": 443,
"remote_addr": "1.1.1.1",
"remote_port": 80,
"log_level": 3,
"password": [
"your_awesome_password"
],
let github2jsdelivr = (_url) => {
regex = {"blob": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/,
"tree": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/};
if(_url.match(regex.tree)){
return _url.replace(regex.tree, "$1cdn.jsdelivr.net/gh/$2/$3@$4/$5");
}else if(_url.match(regex.blob)){
return _url.replace(regex.blob, "$1cdn.jsdelivr.net/gh/$2/$4@$4/$5");
}else{
return _url;
}
@phlinhng
phlinhng / cfworkers_reverse_proxy.js
Last active July 16, 2021 02:35
fw: universal reverse proxy template
// 需要反代的地址
const upstream = 'api.github.com'
// 反代地址的子路径
const upstreamPath = '/'
// 反代网站的移动端域名
const upstreamMobile = 'api.github.com'
// 是否使用 https
const useHttps = true
@phlinhng
phlinhng / trojan-go-quickstart.sh
Created May 31, 2020 17:56
trojan-go-quickstart.sh
#!/bin/sh
echo "Getting the latest version of trojan-go"
latest_version="$(curl -s "https://api.github.com/repos/p4gefau1t/trojan-go/releases" | jq '.[0].tag_name' --raw-output)"
echo "${latest_version}"
trojango_link="https://github.com/p4gefau1t/trojan-go/releases/download/${latest_version}/trojan-go-linux-amd64.zip"
mkdir -p "/usr/bin/trojan-go"
mkdir -p "/etc/trojan-go"
@phlinhng
phlinhng / soga.conf
Last active January 29, 2023 10:48
soga v2ray + nginx 反代
type=v2board # 必填这个
server_type=v2ray # 必填这个
api=webapi # webapi 或 db,表示 webapi 对接或数据库对接
# webapi 对接
webapi_url=https://www.yourdomain.com/ # webapi url,填写面板主页地址
webapi_key= # webapi key
node_id=1 # 节点id
soga_key= # 授权key,社区版无需填写,最多支持88用户,商业版无限制
@phlinhng
phlinhng / Caddyfile
Last active June 18, 2023 14:19
caddy 簡單反代谷歌學術
scholar.example.com {
timeouts 5m
proxy / https://scholar.google.com.hk {
except /robots.txt /usercontent
header_upstream X-Real-IP {remote}
header_upstream X-Forwarded-For {remote}
header_upstream User-Agent {>User-Agent}
# header_upstream X-Real-IP {>CF-Connecting-IP}
# header_upstream X-Forwarded-For {>CF-Connecting-IP}
header_upstream Accept-Language zh-HK
@phlinhng
phlinhng / cloudflare-ddns.sh
Last active September 5, 2023 19:46
Cloudflare DDNS Script
#!/bin/bash
zone_name=$1
record_name=$2
api_key=$3
current_ip=`curl -s https://api.ipify.org`
zone_id=`curl -s -X GET "https://api.cloudflare.com/client/v4/zones" \
-H "Authorization: Bearer ${api_key}" -H "Content-Type: application/json" \
| jq -r ".result | .[] | select(.name == \"${zone_name}\") | .id"`
@phlinhng
phlinhng / a-v2ray-wss-cdn-without-proxy.md
Last active October 13, 2023 19:59
v2ray wss不开cloudflare proxy套用cdn (让同一个域名既能直连也能通过cdn中转)

动机

在v2ray+ws+tls+web的情况下,不管cloudflare dns有没有开启云朵(proxy),都可以透过address填cf节点ip,ws头部host填域名的方式连接上v2Ray服务器。写这篇的目的是想测试在没有web的情况下使用同一招,让同一个域名既能直连也能通过cdn中转。

有web时的连接方法

地址: cloudflare.com (或1.1.1.1或任何cloudflare节点IP)
端口: web服务器的端口 (通常为443)
tls: 开
不安全连接: 不允许
混淆: websocket
@phlinhng
phlinhng / clash.yaml
Last active October 31, 2023 08:46
clash 1.0+ 配置模版
# HTTP, SOCKS5 混合端口
mixed-port: 7890
# 允许局域网的连接(可用来共享代理)
allow-lan: true
# 规则模式:Rule(规则) / Global(全局代理)/ Direct(全局直连)
mode: Rule
# 设置日志输出级别 (默认级别:info,级别越高日志输出量越大,越倾向于调试)