v2ray / v2ray-core

A platform for building proxies to bypass network restrictions.
https://www.v2ray.com/
MIT License
45.28k stars 8.94k forks source link

TCP over UDP #705

Closed BirkhoffLee closed 6 years ago

BirkhoffLee commented 6 years ago

提交 Issue 之前请先阅读 Issue 指引,然后回答下面的问题,谢谢。 Please read the instruction and answer the following questions before submitting your issue. Thank you.

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) What version of V2Ray are you using (If you deploy different version on server and client, please explicitly point out)?

V2Ray v2.47 (One for all) 20171109

2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 What's your scenario of using V2Ray? E.g., Watching YouTube videos in Chrome via Socks/VMess proxy.

I'm behind a highly-restricted firewall that drops all TCP packets but UDP packets.

Is it possible to implement a TCP over UDP feature to bypass this kind of firewall?

xiaokangwang commented 6 years ago

We have mKCP transport already, which transfer all data with UDP. You might wants to try mKCP first and evaluate if it can accomplish what you needed.

BirkhoffLee commented 6 years ago

I tried and it doesn't work. Any way to debug?

DarienRaymond commented 6 years ago

Just attach you V2Ray configs and logs (if any), and describe how is your environment set up.

BirkhoffLee commented 6 years ago

V2Ray server config.json:

{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 53,
    "protocol": "vmess",
    "settings": {
      "clients": [{
        "id": "xxxxxx",
        "level": 1,
        "alterId": 9487
      }]
    },
    "streamSettings": {
      "network": "kcp"
    },
    "detour": {
      "to": "vmess-detour"
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": {}
  },
  "inboundDetour": [{
      "protocol": "vmess",
      "port": "45000-45999",
      "tag": "vmess-detour",
      "settings": {},
      "allocate": {
        "strategy": "random",
        "concurrency": 5,
        "refresh": 5
      },
      "streamSettings": {
        "network": "kcp"
      }
    },
    {
      "protocol": "shadowsocks",
      "port": 19477,
      "settings": {
        "method": "aes-256-cfb",
        "password": "xxx",
        "udp": true,
        "level": 1
      }
    },
    {
      "protocol": "shadowsocks",
      "port": 19478,
      "settings": {
        "method": "aes-256-cfb",
        "password": "xxx",
        "udp": true,
        "level": 1
      }
    },
    {
      "protocol": "shadowsocks",
      "port": 53,
      "settings": {
        "method": "aes-256-cfb",
        "password": "xxx",
        "udp": true,
        "level": 1
      }
    }
  ],
  "outboundDetour": [{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [{
        "type": "field",
        "ip": [
          "0.0.0.0/8",
          "10.0.0.0/8",
          "100.64.0.0/10",
          "127.0.0.0/8",
          "169.254.0.0/16",
          "172.16.0.0/12",
          "192.0.0.0/24",
          "192.0.2.0/24",
          "192.168.0.0/16",
          "198.18.0.0/15",
          "198.51.100.0/24",
          "203.0.113.0/24",
          "::1/128",
          "fc00::/7",
          "fe80::/10"
        ],
        "outboundTag": "blocked"
      }]
    }
  }
}

V2Ray client config.json:

{
    "log": {
      "loglevel": "warning"
    },
    "inbound": {
      "listen": "127.0.0.1",
      "port": 1080,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": true,
        "ip": "127.0.0.1"
      }
    },
    "outbound": {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "xxx",
            "port": 53,
            "users": [
              {
                "id": "xxxxxx",
                "level": 1,
                "alterId": 9487
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "kcp"
      }
    },
    "outboundDetour": [
      {
        "protocol": "freedom",
        "settings": {},
        "tag": "direct"
      }
    ],
    "routing": {
      "strategy": "rules",
      "settings": {
        "rules": [
          {
            "type": "chinasites",
            "outboundTag": "direct"
          },
          {
            "type": "field",
            "ip": [
              "0.0.0.0/8",
              "10.0.0.0/8",
              "100.64.0.0/10",
              "127.0.0.0/8",
              "169.254.0.0/16",
              "172.16.0.0/12",
              "192.0.0.0/24",
              "192.0.2.0/24",
              "192.168.0.0/16",
              "198.18.0.0/15",
              "198.51.100.0/24",
              "203.0.113.0/24",
              "::1/128",
              "fc00::/7",
              "fe80::/10"
            ],
            "outboundTag": "direct"
          },
          {
            "type": "chinaip",
            "outboundTag": "direct"
          }
        ]
      }
    }
  }

I use Docker to deploy V2Ray, which shouldn't be a problem. The configuration above works perfectly when in a normal network, but fails when behind that "highly-restricted firewall".

ghost commented 6 years ago

建议文档给出几种不同的(比较全的)客户端+服务器配置文件,说明哪些可以精简,或者提供类似https://github.com/htfy96/v2ray-config-gen 的生成器之类的,大大降低学习成本。也减少作者回答问题。 不好意思发issue 就发到了这里 つ﹏⊂ @DarienRaymond

IbarakiKasen commented 6 years ago

According to your client config, traffic towards china sites are not going through the UDP proxy. If your "highly-restricted firewall" does block TCP traffic to china sites, you need to remove the following parts from your client config:

          {
            "type": "chinasites",
            "outboundTag": "direct"
          },
          {
            "type": "chinaip",
            "outboundTag": "direct"
          }
BirkhoffLee commented 6 years ago

@IbarakiKasen Thanks for helping out. Today I found out that the connection can actually be established to the v2ray server. But the speed is much too slow and unstable. I guess there are some restrictions on the firewall side that I didn't notice. Does anyone here have any hint on this, or having any debugging guide to the issue?

DarienRaymond commented 6 years ago

You may control the bandwidth of mKCP in kcpSettings. The slow speed you see may because mKCP is sending to much data (or too less) which triggers QoS on your firewall. Lower the bandwidth settings may lead to more stable connection speed.

DarienRaymond commented 6 years ago

Closing due to inactivity.