Skip to content

Instantly share code, notes, and snippets.

View phlinhng's full-sized avatar

phlinhng

  • Tsinghua University
  • Formosa
View GitHub Profile
@phlinhng
phlinhng / a-trojan-with-nginx-stream-module.md
Last active March 28, 2024 13:39
Trojan + NGINX 多網站共存

利用 NGINX 的 Stream 模塊 sni_preread 功能,可以做到讓 Trojan 和其他網站在同一台機器上共享 443 端口。

@phlinhng
phlinhng / a-clash-tproxy-gateway.md
Last active March 27, 2024 22:07
Clash as transparent proxy gateway via TPROXY

Notes

  1. If your local network use public IP ranges instead of private ones, make sure to add respecive RETURN rules to iptables to prevent looping issue
  2. Set clash as DHCP's only DNS server to allow domain-based filter (shunting) rules work
  3. Use lsof -i udp:53 to check if clash's DNS module work fine, otherwise you may have to kill systemd-resolved and any other processes occupying the UDP 53 port
  4. The given scripts will NOT hangle the traffic of gateway itself since it is not recommend to do so. If you want to redirect the egress traffic of the gateway, the following material may be useful

Reference

@phlinhng
phlinhng / wgcf-tutorial.md
Last active March 1, 2024 13:44
WGCF 筆記

1. 更換內核至 5.6 以上版本

Debian / Ubuntu 系可直接運行以下指令,安裝 xanmod-edge 內核後重啟。此內核安裝完後會自動啟用 BBR,無需手動配置。

echo 'deb http://deb.xanmod.org releases main' | tee /etc/apt/sources.list.d/xanmod-kernel.list
wget -qO - https://dl.xanmod.org/gpg.key | apt-key --keyring /etc/apt/trusted.gpg.d/xanmod-kernel.gpg add -
apt update && apt upgrade -y && apt install linux-xanmod-edge -y

2. 安裝 wireguard-tools 與 resolvconf

apt install wireguard-tools resolvconf -y
@phlinhng
phlinhng / v2ray-unblock-netflix.md
Last active February 22, 2024 07:33
利用 v2ray-core / xray-core 的任意門協議解鎖流媒體

V2Ray 白話文教學介紹了如何利用 V2Ray 的路由功能將特定網站(例如 Netflix)的流量經過 Shadowsocks 轉到另一台機器上,達成解鎖流媒體的方法。 事實上,可以利用 V2Ray 的任意門協議直接將流量轉發到落地機上,進一步減少使用代理協議產生的開銷,以下為做法。

假設不能看奈飛的機器為 VPS A,可以看奈飛的機器為 VPS B。

基本配置

  • VPS A: 開兩個 freedom outbound,一個給 80 端口,一個給 443 端口,並配置對應的路由規則
  • VPS B: 開兩個 dokodemo-door inbound,一個給 80 端口,一個給 443 端口,兩個 inbound 都要設置 sniffing,並配置對應的路由規則

VPS A 設置

{
  "outbounds": [
@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,级别越高日志输出量越大,越倾向于调试)
@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 / 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 / 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 / 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 / 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"