v2ray / v2ray-core

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

V2ray同时使用WS/mkcp时无法使用动态端口 #634

Closed chnliupu closed 6 years ago

chnliupu commented 6 years ago

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

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) 2.41

2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 转发网络数据

3) 你看到的不正常的现象是什么?

2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9987: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9129: use of closed network connection] > Retry: all retry attempts failed`

类似的错误有上千行 通过主监听端口能上网,无法使用动态端口,通过iptraf看到的数据全部通过主监听端口传输

4) 你期待看到的正确表现是怎样的? 数据能通过所分配的动态端口段

5) 请附上你的配置文件(提交 Issue 前请隐藏服务器端IP地址)。

Server Configuration File(服务器端配置文件):
    {
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 8040,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "",
          "level": 1,
          "alterId": 64
        }
      ]
    },
    "streamSettings":{
      "network":"kcp"
    },
    "detour":{
      "to":"kcp_dynamic_port"
    }
  },
  "inboundDetour": [
    {
      "port": 9500,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "",
            "level": 1,
            "alterId": 64
          }
        ]
      },
      "streamSettings":{
        "network":"ws"
      },
      "detour":{
        "to":"tcp_dynamic_port"
      }
    },
    {
      "protocol": "vmess",
      "port": "9000-9449",  
      "tag": "kcp_dynamic_port", 
      "settings": {},
      "allocate": {            
        "strategy": "random",  
        "concurrency": 2,      
        "refresh": 5   
      }
    },
    {
      "protocol": "vmess",
      "port": "9501-10000",
      "tag": "tcp_dynamic_port",
      "settings": {},
      "allocate": {
        "strategy": "random",
        "concurrency": 2,
        "refresh": 5
      }
    }
  ],
  "outbound": {
    "protocol": "freedom",
    "settings": {}
  },
  "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"
        }
      ]
    }
  },
  "transport":{
    "tcpSettings": {
      "connectionReuse": true
    },
    "kcpSettings": {
      "mtu": 1350,
      "tti": 20,
      "uplinkCapacity": 5,
      "downlinkCapacity": 100,
      "congestion": false,
      "readBufferSize": 1,
      "writeBufferSize": 1,
      "header": {
        "type": "wechat-video"
      }
    }
  }
}
Client Configuration File(客户端配置文件):
    {
  "log": {
    "loglevel": "warning"
  },
  "inbound": {
    "port": 1080,
    "listen": "127.0.0.1",
    "protocol": "socks",
    "settings": {
      "auth": "noauth",
      "udp": false,
      "ip": "127.0.0.1"
    }
  },
  "outbound": {
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "",
          "port": 8040,
          "users": [
            {
              "id": "",
              "alterId": 64
            }
          ]
        }
      ]
    },
    "streamSettings":{
      "network":"kcp",
      "kcpSettings": {
        "mtu": 1350,
        "tti": 20,
        "uplinkCapacity": 5,
        "downlinkCapacity": 100,
        "congestion": false,
        "readBufferSize": 1,
        "writeBufferSize": 1,
        "header": {
          "type": "wechat-video"
        }
      }
    }
  },
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    }
  ],
  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "port": "1-52",
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "port": "54-79",
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "port": "81-442",
          "outboundTag": "direct"
        },
        {
          "type": "field",
          "port": "444-65535",
          "outboundTag": "direct"
        },
        {
          "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"
        }
      ]
    }
  }
}

6) 请附上出错时软件输出的日志。在 Linux 中,日志通常在 /var/log/v2ray/error.log 文件中。

Server Log File(服务器端日志):
    2017/10/22 02:18:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9871: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:18:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9251: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9002: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9943: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9987: use of closed network connection] > Retry: all retry attempts failed
2017/10/22 02:23:53 [Warning]Transport|Internet|TCP: failed to accepted raw connections > Retry: [accept tcp [::]:9129: use of closed network connection] > Retry: all retry attempts failed

十二小时内类似错误上千条

Client Log File(客户端日志):
2017/10/22 10:18:37 [Debug]App|Proxyman|Inbound: creating tcp worker on 127.0.0.1:1080
2017/10/22 10:18:37 [Info]Transport|Internet|TCP: listening TCP on 127.0.0.1:1080
2017/10/22 10:18:37 [Warning]Core: V2Ray started

备注:iptables

-A INPUT -p tcp -m tcp --dport 8001:8039 -j ACCEPT
-A INPUT -p udp -m udp --dport 8040 -j ACCEPT
-A INPUT -p udp -m udp --dport 9000:10000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 9000:10000 -j ACCEPT

VPS服务商防火墙端口已开放 系统debian 8

chnliupu commented 6 years ago

20171022105356 20171022105431

chnliupu commented 6 years ago

detour写错位置了,修改之后mkcp可动态端口,ws不可以,错误信息为 unexpected EOF

DarienRaymond commented 6 years ago

你的 kcp_dynamic_port 和 tcp_dynamic_port 没有指定 streamSettings 为 kcp 或 ws,默认情况下是用 tcp 传输的,所以连接不上。