zhu327/scripts

cloudflare备注

Closed this issue · 1 comments

可以中转了,客户端配置 "security": "tls","port": 443,就可以成功中转,不会被gfw干扰。

@k79e

下面是客户端配置示例:

{
  "inbounds": [
    {
      "port": 1080,
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth"
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "xxx.xxx.workers.dev",
            "port": 443,
            "users": [
              {
                "id": "xxxxxx-xxxxx-xxxx-xxx-e651e5f02e7d",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings":{
          "wsSettings":{
              "path":"",
              "headers":{}
          },
          "network":"ws",
          "security": "tls"
      }
    }
  ]
}

下面是服务端配置示例:

{
  "inbounds": [{
      "port": 80,
      "protocol": "vmess",
      "settings": {
        "clients": [{
          "id": "xxxxx-xxxx-48bc-9871-e651e5f02e7d",
          "alterId": 64
        }]
      },
      "streamSettings":{
          "wsSettings":{
              "path":"",
              "headers":{}
          },
          "network":"ws",
          "security": "none"
      }
    }
  ],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  }]
}

cloudflare worker 代码:

addEventListener(
  'fetch',event => {
     let url=new URL(event.request.url);
     url.hostname='34.34.34.23.xip.io';
     if(url.protocol == 'https:') {
        url.protocol='http:'
     }
     let request=new Request(url,event.request);
     if(request.headers.has("Origin")) {
       request.headers.delete("Origin");
     }
     event.respondWith(
          fetch(request)
    )
  }
)
url.hostname='34.34.34.23.xip.io'; 

这一行可以使用 http://xip.io/ 这个网站的功能,使ip变成域名

if(url.protocol == 'https:') {
        url.protocol='http:'
     }

这一段是把wss协议转成ws协议,因为vps上的v2ray是运行在80端口,使用没有加密的ws协议。

Originally posted by @mapic91 in v2ray/v2ray-core#2333 (comment)

k79e commented

真不知道fetch能不能限制tls版本. 有时候遇见奇怪问题都不知道咋回事 可能跟这个有关 也可能不是.