v2ray / v2ray-core

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

mKCP 无法建立连接 #1263

Closed dalifooder closed 6 years ago

dalifooder commented 6 years ago

Please skip to the English section below if you don't write Chinese.

中文: 提交 Issue 之前请先阅读 Issue 指引,然后回答下面的问题,谢谢。 除非特殊情况,请完整填写所有问题。不按模板发的 issue 将直接被关闭。

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) 服务器和客户端都是最新版3.39 2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 VPS上配置有2个服务:v2ray的服务端,OpenVPN的服务端,其中OpenVPN的服务端侦听端口不对外开放(listen on 127.0.0.1). a)建立一条socks/vmess链路用来日常翻墙 b)建立一条socks/vmess链路用来转发OpenVPN流量 以前使用任意门协议直接做过OpenVPN的端口映射,那时OpenVPN的侦听端口是对外开放的,后来使用VPN有过长时间的几次大流量下载,被GFW检测到ban掉了VPS的IP,所以现在想把OpenVPN的端口隐藏掉。 3) 你看到的不正常的现象是什么?(请描述具体现象,比如访问超时,TLS 证书错误等) 配置使用mKCP传输无法建立连接,改为默认的TCP传输可以正常达成a使用场景,但是b场景仍然失败。具体表现为:选择使用mKCP传输时,客户端报错“failed to read response header > EOF”,服务器端没有连接信息显示。 4) 你期待看到的正确表现是怎样的? 能正常达成a和b两个使用需求。 5) 请附上你的配置(提交 Issue 前请隐藏服务器端IP地址)。

服务器端配置:
{
   "log":{
    "access":"",//  "access":"/var/log/v2ray/access.log",
    "error":"", // "error":"/var/log/v2ray/error.log",
      "loglevel":"debug"
   },
   "dns":{
      "servers":[
         "8.8.8.8",
         "8.8.4.4"
      ]
   },
   "inbound":{
      "port":12345,
      "protocol":"vmess",
      "tag":"vpn_in",
      "settings":{

         "clients":[
            {
               "id":"45ec2625-8f96-449e-94dc-16a4b70a9092",
               "level":1,
               "alterId":32,
               "email":"vpn_line@v2ray.com"
            }
         ],
         "detour":{
            "to":"dynamicPort"
         }
      },
      "streamSettings":{
         "network":"mkcp",
         "kcpSettings":{

         }
      },
      "disableInsecureEncryption":true
   },
   "inboundDetour":[
      {
         "protocol":"vmess",
         "port":"10000-20000",
         "tag":"dynamicPort",
         "settings":{
            "default":{
               "level":1,
               "alterId":32
            }
         },
         "allocate":{
            "strategy":"random",
            "concurrency":3,
            "refresh":2
         }
      },
      {
         "port":5062,
         "protocol":"vmess",
         "tag":"socks_in",
         "settings":{

            "clients":[
               {
                  "id":"0b87fb80-0d44-412c-ac1c-0a1e078a04df",
                  "level":0,
                  "alterId":32,
                  "email":"socks_line@v2ray.com"
               }
            ],
            "streamSettings":{
               "network":"mkcp",
               "kcpSettings":{

               }
            },
            "disableInsecureEncryption":true
         }
      }
   ],
   "routing":{
      "strategy":"rules",
      "settings":{
         "rules":[
            {
        "type": "field",
        "inboundTag":["vpn_in"],
               "outboundTag":"vpn_out"
            },
            {
            "type": "field",
            "inboundTag":["socks_in"],
               "outboundTag":"socks_out"
            }
         ]
      }
   },
   "outbound":{
      "protocol":"freedom",
      "tag":"vpn_out",
      "settings":{
         "redirect":"127.0.0.1:1194"
      }
   },
   "outboundDetour":[
      {
         "protocol":"freedom",
         "settings":{

         },
         "tag":"socks_out"
      }
   ],
   "transport":{
      "tcpSettings":{

      },
      "kcpSettings":{
         "mtu":1350,
         "tti":20,
         "uplinkCapacity":20,
         "downlinkCapacity":20,
         "congestion":true,
         "readBufferSize":2,
         "writeBufferSize":2,
         "header":{
            "type":"srtp"
         }
      },
      "wsSettings":{

      },
      "httpSettings":{

      },
      "dsSettings":{

      }
   }
}
客户端配置:
{
   "log":{
      "access":"/var/log/v2ray/access.log",
      "error":"/var/log/v2ray/error.log",
      "loglevel":"debug"
   },
   "dns":{
      "servers":[
         "8.8.8.8",
         "8.8.4.4"
      ]
   },
   "routing":{
      "strategy":"rules",
      "settings":{
         "domainStrategy":"IPIfNonMatch",
         "rules":[
            {
               "type":"chinaip",
               "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":"field",
               "inboundTag":[
                  "socks_in"
               ],
               "outboundTag":"socks_out"
            },
            {
                "type":"field",
                "inboundTag":[
                    "vpn_in"
                ],
                "outboundTag":"vpn_out"
            }
         ]
      }
   },
   "inbound":{
      "protocol":"socks",
      "port":1112,
      "tag":"vpn_in",
      "settings":{
         "auth":"noauth",
         "udp":true,
         "ip":"192.168.1.41"
      }
   },
   "inboundDetour":[
      {
         "port":1080,
         "tag":"socks_in",
         "protocol":"socks",
         "settings":{
            "auth":"noauth"
         }
      }
   ],
   "outbound":{
      "protocol":"vmess",
      "tag":"vpn_out",
      "settings":{
         "vnext":[
            {
               "address":"**********",
               "port":12345,
               "users":[
                  {
                     "id":"45ec2625-8f96-449e-94dc-16a4b70a9092",
                     "alterId":32,
                     "security":"auto"
                  }
               ]
            }
         ]
      },
      "mux":{
         "enabled":false//true
      },
      "streamSettings":{
         "network":"mkcp",
         "kcpSettings":{

         }
      }
   },
   "outboundDetour":[
      {
         "protocol":"vmess",
         "tag":"socks_out",
         "settings":{
            "vnext":[
               {
                  "address":"**********",
                  "port":5062,
                  "users":[
                     {
                        "id":"0b87fb80-0d44-412c-ac1c-0a1e078a04df",
                        "alterId":32,
                        "security":"auto"
                     }
                  ]
               }
            ]
         },
         "mux":{
            "enabled":false
         },
         "streamSettings":{
            "network":"mkcp",
            "kcpSettings":{

            }
         }
      },
      {
         "protocol":"freedom",
         "settings":{},
         "tag":"direct"
      }
   ],
   "transport":{
      "tcpSettings":{

      },
      "kcpSettings":{
         "mtu":1350,
         "tti":20,
         "uplinkCapacity":20,
         "downlinkCapacity":20,
         "congestion":true,
         "readBufferSize":2,
         "writeBufferSize":2,
         "header":{
            "type":"wechat-video"
         }
      },
      "wsSettings":{

      },
      "httpSettings":{

      },
      "dsSettings":{

      }
   }
}

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

服务器端错误日志:
N/A
客户端错误日志:
2018/09/12 15:34:06 [Debug] App|Log: Logger started
2018/09/12 15:34:06 [Warning] Core: V2Ray v3.39 started
2018/09/12 15:36:55 [Info] [3698931668] Proxy|Socks: TCP Connect request to tcp:www.google.com:80
2018/09/12 15:36:55 [Info] [3698931668] App|Dispatcher: taking detour [socks_out] for [tcp:www.google.com:80]
2018/09/12 15:36:55 [Info] Transport|Internet|mKCP: dialing mKCP to udp:************:5062
2018/09/12 15:36:55 [Info] Transport|Internet|mKCP: #18427 creating connection to ************:5062
2018/09/12 15:36:55 [Info] [3698931668] Proxy|VMess|Outbound: tunneling request to tcp:www.google.com:80 via tcp:************:5062
2018/09/12 15:37:25 [Debug] Transport|Internet|mKCP: #18427 entering state 1 at 30000
2018/09/12 15:37:25 [Info] Transport|Internet|mKCP: #18427 closing connection to ************:5062
2018/09/12 15:37:25 [Info] [3698931668] App|Proxyman|Outbound: failed to process outbound traffic > Proxy|VMess|Outbound: connection ends > Proxy|VMess|Outbound: failed to read header > Proxy|VMess|Encoding: failed to read response header > EOF
2018/09/12 15:37:25 [Info] [3698931668] App|Proxyman|Inbound: connection ends > Proxy|Socks: connection ends > Proxy|Socks: failed to transport all TCP response > io: read/write on closed pipe
2018/09/12 15:37:40 [Debug] Transport|Internet|mKCP: #18427 entering state 3 at 45001
2018/09/12 15:37:45 [Debug] Transport|Internet|mKCP: #18427 sending terminating cmd.
2018/09/12 15:37:50 [Debug] Transport|Internet|mKCP: #18427 sending terminating cmd.
2018/09/12 15:37:50 [Debug] Transport|Internet|mKCP: #18427 entering state 5 at 55101
2018/09/12 15:37:50 [Info] Transport|Internet|mKCP: #18427 terminating connection to ************:5062

7) 请附上访问日志。在 Linux 中,日志通常在 /var/log/v2ray/access.log 文件中。

N/A

另外,使用的是搬瓦工的KVM架构机器,应该没有防火墙限制UDP流量。

dalifooder commented 6 years ago

b使用场景log更新: 当使用OpenVPN客户端尝试连接v2ray客户端的socks端口时,客户端log报错为:“failed to parse UDP request > Proxy|Socks: discarding fragmented payload.”,v2ray服务器端仍然没有log显示。 v2ray客户端详细log:


2018/09/13 12:34:06 [Info] [4069484067] Proxy|Socks: client UDP connection from udp:192.168.1.42:50337
2018/09/13 12:34:06 [Info] [4069484067] Proxy|Socks: failed to parse UDP request > Proxy|Socks: discarding fragmented payload.
2018/09/13 12:34:09 [Info] [4069484067] Proxy|Socks: failed to parse UDP request > Proxy|Socks: discarding fragmented payload.
2018/09/13 12:34:14 [Info] [4069484067] Proxy|Socks: failed to parse UDP request > Proxy|Socks: discarding fragmented payload.
2018/09/13 12:34:22 [Info] [4069484067] Proxy|Socks: failed to parse UDP request > Proxy|Socks: discarding fragmented payload.
2018/09/13 12:34:37 [Info] [4069484067] Proxy|Socks: failed to parse UDP request > Proxy|Socks: discarding fragmented payload.
2018/09/13 12:34:54 [Info] App|Proxyman|Inbound: connection ends > EOF

OpenVPN客户端log:

Thu Sep 13 09:38:47 2018 SIGUSR1[soft,tls-error] received, process restarting
Thu Sep 13 09:38:47 2018 MANAGEMENT: >STATE:1536856727,RECONNECTING,tls-error,,,,,
Thu Sep 13 09:38:47 2018 Restart pause, 300 second(s)
Thu Sep 13 09:43:47 2018 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.1.41:1112
Thu Sep 13 09:43:47 2018 Socket Buffers: R=[65536->65536] S=[65536->65536]
Thu Sep 13 09:43:47 2018 UDP link local: (not bound)
Thu Sep 13 09:43:47 2018 UDP link remote: [AF_INET]192.168.1,41:1112
Thu Sep 13 09:43:47 2018 MANAGEMENT: >STATE:1536857027,WAIT,,,,,,
Thu Sep 13 09:44:47 2018 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Thu Sep 13 09:44:47 2018 TLS Error: TLS handshake failed
VictoriaRaymond commented 6 years ago
dalifooder commented 6 years ago

改正上面指出的错误后,现在a场景已经正常了,十分感谢。 但是b场景仍然报错,报错详情见上一楼,这个问题该如何解决?