76

使用 Cloudflare WARP 作为 V2Ray/Shadowsocks 出站(落地)连接

 2 years ago
source link: https://iecho.cc/2023/03/27/apply-cloudflare-warp-for-v2ray-shadowsocks-outbound-connections/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用 Cloudflare WARP 作为 V2Ray/Shadowsocks 出站(落地)连接

使用 Cloudflare WARP 作为 V2Ray/Shadowsocks 出站(落地)连接

2023-03-27 15:10:37

#网络

#Cloudflare

OpenAI is not available in your country

ChatGPT 最近很火,但不幸地是 OpenAI 屏蔽了中国地区和常见数据中心 IP 来源。这意味着,如果你在国内,想要使用 ChatGPT,除了需要一张外币信用卡/借记卡,还需要一个可以访问 OpenAI 的代理 IP。WARP 是 Cloudflare 提供的免费 VPN 服务,基于 WireGuard 协议,VPN 对端为启用了 anycast 的 Cloudflare CDN。WARP 的 IP 不在一些服务商的黑名单内,所以可以借助 WARP 来正常访问 ChatGPT 和 OpenAI 相关接口,以及其他流媒体服务(以解锁本地内容的版权限制),比如 Netflix、Hulu、Disney+。

一般来说我们无法在中国境内使用 WARP,但可以使用自有的境外 VPS 将代理流量路由至 WARP。基本思路是:将 WireGuard 的 Cloudflare WARP “转换”为 Socks5 协议,作为 V2Ray/Shadowsocks 的出站连接。

WARP 提供了官方的 Linux Client,内置了 proxy mode,可以将 WARP 转换为 Socks5 代理。但这个 Socks5 代理只能 bind 在 localhost,对于跑在 docker 里的 V2Ray/Shadowsocks 来说,无法直接使用。我们可以使用 socatrinetd 建立一条本地的端口转发,具体过程略。

# 注册设备
warp-cli register
# 替换为自己的 license key
warp-cli set-license <LICENSE>
# 切换到 proxy mode
warp-cli set-mode proxy
# 修改 socks5 端口,默认 40000
warp-cli set-proxy-port <PORT>
# 启动
warp-cli connect

Shadowsocks 并不能像 V2Ray 那样 chaining,而 V2Ray 本身支持 Shadowsocks 协议,所以只需将 Shadowsocks 配置为 inbound object 即可,无需单独运行一个实例。

入站部分配置如下:

"inbounds": [
// Shadowsocks inbound
{
"protocol": "shadowsocks",
"port": 8388,
"settings": {
"method":"aes-256-gcm",
"password":"password",
"network": "tcp,udp"
}
},
// V2Ray inbound
{
"port": 8389,
"protocol": "vmess",
"settings": {
"clients": []
},
"tag": "in-0",
"streamSettings": {
"network": "tcp",
"security": "auto",
"tcpSettings": {}
}
}
]

V2Ray 默认使用第一条 outbound 作为出站路由,因此无需打 tag 也可正常使用。出站部分配置如下:

 "outbounds": [
{
"protocol": "socks",
"settings": {
"servers": [
{
// 建议修改为固定的网卡 IP
"address": "<宿主机 IP>",
"port": 40000
}
]
}
},
{
"tag": "direct",
"protocol": "freedom",
"settings": {}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {}
}
],

至此配置完成,拓扑如下:

Client <-- SS/V2Ray --> VPS <-- WARP --> Cloudflare Edge <--> Internet

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK