Skip to content

Conversation

@xiaokangwang
Copy link
Contributor

@xiaokangwang xiaokangwang commented Oct 27, 2023

This is a reduced version of WebSocket transport that does not require actually implementing/using Websocket protocol itself. It sends http upgrade header to WebSocket and then use the upgraded http1.1 connection directly, cutting unnecessary overhead and protocol complexity of WebSocket.

This design is inspired by https://www.usenix.org/conference/foci20/presentation/frolov and based on WebTunnel Implementation.

Server Config Example, when hide behind nginx that deals with tls:

{
  "log": {
    "error": {
      "level": "Debug",
      "type": "Console"
    },
    "access": {
      "type": "None"
    }
  },
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ],
  "inbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "users": [
          "1234"
        ]
      },
      "listen": "127.0.0.1",
      "port": 1234,
      "streamSettings": {
        "transport": "httpupgrade",
        "transportSettings": {
          "host": "XXXX",
          "path": "XXXX"
        }
      }
    }
  ]
}

Client Config Example:

{
  "log": {
    "error": {
      "level": "Debug",
      "type": "Console"
    },
    "access": {
      "type": "None"
    }
  },
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "port": 443,
        "uuid": "XXXX",
        "address": "XXXX"
      },
      "streamSettings": {
        "transport": "httpupgrade",
        "transportSettings": {
          "host": "XXXX",
          "path": "XXXX"
        },
        "security": "tls",
        "securitySettings": {
          "serverName": "XXXX",
          "allowInsecure": false,
          "nextProtocol": [
            "http/1.1"
          ]
        }
      }
    }
  ],
  "inbounds": [
    {
      "protocol": "socks",
      "settings": {
        "udpEnabled": true,
        "address": "127.0.0.1",
        "packetEncoding": "Packet"
      },
      "port": 1080
    }
  ]
}

@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 16.66667% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.69%. Comparing base (cb84b28) to head (1eefcd3).
⚠️ Report is 309 commits behind head on master.

Files with missing lines Patch % Lines
transport/internet/httpupgrade/hub.go 4.08% 47 Missing ⚠️
transport/internet/httpupgrade/config.pb.go 30.76% 43 Missing and 2 partials ⚠️
transport/internet/httpupgrade/dialer.go 6.66% 28 Missing ⚠️
transport/internet/httpupgrade/httpupgrade.go 25.00% 2 Missing and 1 partial ⚠️
transport/internet/httpupgrade/errors.generated.go 0.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2727      +/-   ##
==========================================
- Coverage   37.79%   37.69%   -0.11%     
==========================================
  Files         654      659       +5     
  Lines       38723    38873     +150     
==========================================
+ Hits        14636    14653      +17     
- Misses      22477    22604     +127     
- Partials     1610     1616       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xiaokangwang xiaokangwang merged commit 1eefcd3 into v2fly:master Oct 27, 2023
@freedmanop
Copy link

freedmanop commented Jan 16, 2024

客户端照你的写法不能用,可以说详细一点吗

@DDCHlsq
Copy link

DDCHlsq commented Mar 8, 2024

实测能用,延迟比 gRPC 传输略高,比 ws 低,但是速度是 gRPC 的 3 倍(GIA线路,本地千兆测试),

@CrazyBoyFeng
Copy link

@freedmanop 我估计你是用 v4 的模式载入的配置文件。httpupgrade 目前只提供了 v5 格式的配置接入:

./v2ray run -c config.json -format jsonv5

@HappyLife-page
Copy link

@freedmanop 我估计你是用 v4 的模式载入的配置文件。httpupgrade 目前只提供了 v5 格式的配置接入:

./v2ray run -c config.json -format jsonv5

请问这个,配置路由不生效呢
我两个写法都不起作用,想限制大陆访问的
写法1:
"outbounds": [
{
"tag": "direct",
"protocol": "freedom"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"strategy": "rules",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
},
{
"type": "field",
"domain": [
"geosite:cn"
],
"outboundTag": "block"
},
{
"type": "field",
"ip": [
"geoip:cn"
],
"outboundTag": "block"
}
]
}

写法2:
"outbounds": [
{
"protocol": "freedom"
}
],
"outboundDetour": [
{
"protocol": "blackhole",
"tag": "blocked"
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"domain": [
"geosite:cn"
],
"outboundTag": "blocked",
"type": "field"
},
{
"ip": [
"geoip:cn"
],
"outboundTag": "blocked",
"type": "field"
}
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants