v2ray / v2ray-core

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

dokodemo-door 转发mkcp v4-v6 #951

Closed rufengsuixing closed 6 years ago

rufengsuixing commented 6 years ago

1) 你正在使用哪个版本的 V2Ray?(如果服务器和客户端使用了不同版本,请注明) 3.13 2) 你的使用场景是什么?比如使用 Chrome 通过 Socks/VMess 代理观看 YouTube 视频。 pc客户端v4----服务器1dokodemo-door转v6------服务器2 v6----------google 3) 你看到的不正常的现象是什么?(请描述具体现象,比如访问超时,TLS 证书错误等) 超时或者500 Internal Privoxy Error 4) 你期待看到的正确表现是怎样的? 中转正常使用 5) 请附上你的配置(提交 Issue 前请隐藏服务器端IP地址)。

服务器端配置:
    //服务器1
{
  "log" : {
    "loglevel": "warning",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbound": {
    "port": 41396,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "47cf0ddb-35bd-449d-8004-cacece60a2e6",
          "level": 1,
          "alterId": 64
        }
      ]
    }
  },
  "inboundDetour": [
    {
      "port": 6666,
      "protocol": "socks",
      "settings": {
        "auth": "password",
        "accounts": [
          {
            "user": "**user",
            "pass": "**password"
          }
        ],
      "udp": true,
      "ip": "127.0.0.1",
      "timeout": 0,
      "userLevel": 0,
      "tag":"cai"
      }
    },
    {
    "port": 1100,
    "listen": "127.0.0.1",
    "tag":"own",
    "protocol": "socks",
    "settings": {}
    },
    {
      "port": 10000,
      "listen": "0.0.0.0",
      "protocol": "dokodemo-door",
      "settings": {
        "port": 12580,
        "address": "服务器2 v6",
        "network": "tcp,udp"
      },
      "allocate": {
        "strategy": "always"
      }
    },
    {
      "port": 9000,
      "listen": "0.0.0.0",
      "protocol": "dokodemo-door",
      "settings": {
        "port": 18080,
        "address": "其他服务器",
        "network": "tcp,udp"
      },
      "allocate": {
        "strategy": "always"
      }
    },
    {
      "port": 9080,
      "listen": "0.0.0.0",
      "protocol": "dokodemo-door",
      "settings": {
        "port": 8080,
        "address": "其他服务器",
        "network": "tcp,udp"
      },
      "allocate": {
        "strategy": "always"
      }
    }
  ],
  "outbound": {
    "protocol": "vmess",
    "tag":"boom",
    "settings": {
      "vnext": [
        {
          "address": "服务器2 v6",
          "port": 12580,
          "users": [
            {
              "id": "7e678e33-5692-4dda-987b-cecdfc33d4fd",
              "alterId": 128,
              "security": "aes-128-gcm"
            }
          ]
        }
      ]
    },
    "streamSettings": {
      "network": "kcp",
      "security": "",
      "tcpSettings": null,
      "kcpSettings": {
        "mtu": 1350,
        "tti": 50,
        "uplinkCapacity": 20,
        "downlinkCapacity": 20,
        "congestion": true,
        "readBufferSize": 2,
        "writeBufferSize": 2,
        "header": {
          "type": "wechat-video"
        }
      }
    },
    "mux": {
      "enabled": true
    }
  },
  "outboundDetour": [
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "freedom",
      "settings": {
        "response": null
      },
      "tag": "direct"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "inboundTag": [
            "cai",
        "own"
          ],
          "outboundTag": "boom"
        },
        {
          "type": "field",
          "ip": [
            "0.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"
        },
        {
          "type": "field",
          "ip": "10.0.0.0/8",
          "outboundTag": "direct"
        }
      ]
    }
  }
}
//服务器2:
{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 443,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "7e678e33-5692-4dda-987b-cecdfc33d4fd",
          "level": 1,
          "alterId": 128
        }
      ]
    }
  },
  "inboundDetour": [
    {
      "port": 12580,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "7e678e33-5692-4dda-987b-cecdfc33d4fd",
            "level": 1,
            "alterId": 128
          }
        ]
      },
      "streamSettings": {
      "network": "kcp",
      "kcpSettings": {
        "uplinkCapacity":25,
        "downlinkCapacity":25,
        "congestion":true,
        "readBufferSize":20,
        "writeBufferSize":20,
        "header":{
          "type":"wechat-video"
        }
      }
    }
    }
  ],
  "outbound": {
    "protocol": "freedom",
    "settings": {}
  },
  "outboundDetour": [
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "vmess",
      "settings": {
      "vnext": [
        {
          "address": "服务器1 v6",
          "port": 41396,
          "users": [
            {
              "id": "47cf0ddb-35bd-449d-8004-cacece60a2e6",
              "alterId": 64,
              "security": "aes-128-cfb"
            }
          ]
        }
      ]
    },
      "tag": "back"
    }
  ],
  "routing": {
    "strategy": "rules",
    "settings": {
      "rules": [
        {
          "type": "field",
          "ip": [
            "0.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"
        },
        {
          "type": "field",
          "ip": [
            "10.0.0.0/8"
          ],
          "outboundTag": "back"
        }
      ]
    }
  }
}
客户端配置:
   {
  "log": {
    "access": "",
    "error": "",
    "loglevel": ""
  },
  "inbound": {
    "port": 1080,
    "listen": "0.0.0.0",
    "protocol": "socks",
    "settings": {
      "auth": "noauth",
      "udp": true,
      "ip": "127.0.0.1",
      "clients": null
    },
    "streamSettings": null
  },
  "outbound": {
    "tag": "agentout",
    "protocol": "vmess",
    "settings": {
      "vnext": [
        {
          "address": "服务器1v4",
          "port": 10000,
          "users": [
            {
              "id": "7e678e33-5692-4dda-987b-cecdfc33d4fd",
              "alterId": 128,
              "security": "aes-128-cfb"
            }
          ]
        }
      ],
      "servers": null
    },
    "streamSettings": {
      "network": "kcp",
      "security": "",
      "tcpSettings": null,
      "kcpSettings": {
        "mtu": 1350,
        "tti": 50,
        "uplinkCapacity": 20,
        "downlinkCapacity": 20,
        "congestion": true,
        "readBufferSize": 20,
        "writeBufferSize": 20,
        "header": {
          "type": "wechat-video",
          "request": null,
          "response": null
        }
      },
      "wsSettings": null
    },
    "mux": {
      "enabled": true
    }
  },
  "inboundDetour": null,
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {
        "response": null
      },
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockout"
    }
  ],
  "dns": {
    "servers": [
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "port": null,
          "outboundTag": "direct",
          "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"
          ],
          "domain": null
        }
      ]
    }
  }
}

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

服务器端错误日志:
    // 在这里附上服务器端日志
//服务器1  error log 
2018/03/12 13:41:30 [Warning] Core: V2Ray v3.13 started
//服务器2 error log (美国时区)
2018/03/12 05:13:04 [Warning] [625986290] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 05:16:51 [Warning] [3328401012] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 05:18:51 [Warning] [3752742076] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 05:31:17 [Warning] Core: V2Ray v3.13 started
2018/03/12 05:46:36 [Warning] Core: V2Ray v3.13 started
2018/03/12 05:46:52 [Warning] [555150939] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 05:47:03 [Warning] [1828477398] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 06:37:24 [Warning] [4044660932] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 06:48:36 [Warning] [1595443871] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
2018/03/12 06:58:38 [Warning] [1064215365] App|Proxyman|Inbound: connection ends > Proxy|VMess|Inbound: unable to set read deadline > Transport|Internet|mKCP: Connection closed.
客户端错误日志:
    // 在这里附上客户端日志
2018/03/12 15:00:30 [Warning] Core: V2Ray v3.13 started

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

    // 在这里附上服务器端日志
//服务器1  access log 空 
//服务器2 access log  (美国时区)
2018/03/12 06:49:39 [服务器2 ipv6]:41202 accepted tcp:v1.mux.cool:0
2018/03/12 06:49:55 [服务器2 ipv6]:34156 accepted tcp:v1.mux.cool:0
2018/03/12 06:51:26 [服务器1 ipv6]:58291 accepted tcp:v1.mux.cool:0
2018/03/12 06:51:26 [服务器2 ipv6]:37496 accepted tcp:v1.mux.cool:0
2018/03/12 06:52:00 [服务器2 ipv6]:34498 accepted tcp:v1.mux.cool:0
2018/03/12 06:52:40 [服务器2 ipv6]:51909 accepted tcp:v1.mux.cool:0
2018/03/12 06:53:19 [服务器2 ipv6]:62680 accepted tcp:v1.mux.cool:0
2018/03/12 06:54:00 [服务器2 ipv6]:19803 accepted tcp:v1.mux.cool:0
2018/03/12 06:54:22 [服务器2 ipv6]:18554 accepted tcp:v1.mux.cool:0
2018/03/12 06:54:42 [服务器2 ipv6]:37577 accepted tcp:v1.mux.cool:0
2018/03/12 06:54:43 [服务器2 ipv6]:44043 accepted tcp:v1.mux.cool:0
2018/03/12 06:55:23 [服务器2 ipv6]:13083 accepted tcp:v1.mux.cool:0
2018/03/12 06:56:03 [服务器2 ipv6]:34813 accepted tcp:v1.mux.cool:0
2018/03/12 06:56:19 [服务器2 ipv6]:35067 accepted tcp:v1.mux.cool:0
2018/03/12 06:57:58 [服务器2 ipv6]:51325 accepted tcp:v1.mux.cool:0

8) 其它相关的配置文件(如 Nginx)和相关日志。

请预览一下你填的内容再提交。

rufengsuixing commented 6 years ago

直接连没有问题,但是中转会出问题

rufengsuixing commented 6 years ago

经过中转和客户端抓包,发现可能是转发的时候dokodemo-door进行了udp包的合并 中转抓出的包数量较少,包的最大体积较大,分布大小较为松散 客户端抓出来的包,包的最大体积较小,分布大小集中,所以综上我觉得是udp的合并有问题,可能不兼容kcp

rufengsuixing commented 6 years ago

使用了ip6tabels 进行ipv6的包的dnat和snat转发,连接仍然失败,摸不到头脑,可能是kcp有关于地址的校验

5high commented 6 years ago

参考issue 819 https://github.com/v2ray/v2ray-core/issues/819

rufengsuixing commented 6 years ago

升到3.20,在所有链路上关掉mux正常了