Xray-core: tls: bad record MAC

完整性要求

  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我搜索了issues,没有发现已提出的类似问题。

版本

1.8.11

描述

client -> server1 -(vless+tcp+reality)-> server2 -(vless+tcp+reality)-> server3

server1 xray 1.8.11 (normal) outbound1(vless+tcp+reality[to server3])->streamSettings(“dialerProxy”: “outbound2”,) outbound2(vless+tcp+reality[to server2])

server2 xray 1.8.11 (normal)

server3 xray 1.8.11 (error) app/proxyman/inbound: connection ends > proxy/vless/inbound: connection ends > proxy/vless/inbound: failed to transfer request payload > local error: tls: bad record MAC

重现方式

server1 - outbound
        {
            "tag": "out-server3",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                        "address": "server3",
                        "port": 443,
                        "users": [
                              ......
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                      ......
                },
                "sockopt": {
                    "dialerProxy": "out-server2",
                    "mark": 255
                }
            }
        },

        {
            "tag": "out-server2",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                        "address": "server2",
                        "port": 443,
                        "users": [
                              ......

                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                      ......
                },
                "sockopt": {
                    "mark": 255
                }
            }
        },
===============================

server2 - 
inbound:      {
            "tag": "in-reality",
            "protocol": "vless",
            "port": 443,
            "settings": {
                "clients": [
                      ......
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                      ......
                }
            }
        },

outbound : freedom

===============================
server3 - inbound
        {
            "tag": "in-reality",
            "protocol": "vless",
            "port": 443,
            "settings": {
                "clients": [
                      ......
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                      ......
                }
            }
        },

日志

server3 出現 error tls: bad record MAC

app/proxyman/inbound: connection ends > proxy/vless/inbound: connection ends > proxy/vless/inbound: failed to transfer request payload > local error: tls: bad record MAC

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

收到, 我会再留意情况, 谢谢

=====

原问题 client -> server1 -(vless+tcp+reality)-> server2 -(vless+tcp+reality)-> server3

补充 : client -(http/tproxy)-> server1 -(vless+tcp+reality)-> server2 -(vless+tcp+reality)-> server3

client : 有 android, ios, windows, ubuntu server1 : 有 Debian 12, ubuntu 22.04 server2 : ubuntu 22.04 server3 : ubuntu 22.04

=====

修改 client -(http/tproxy)-> server1 -(vless+tcp+reality)-> server2 -(vless+tls+grpc)-> server3

如修改 由: server2 -(vless+tcp+reality)-> server3 到: server2 -(vless+tls+grpc)-> server3

tls: bad record MAC 就不会再出现

=====

1.8.13 tls: bad record MAC 问题还存在, 但只会在一些情况出现, 但要详细测试才可给出 出现场景

我也遇到了在使用REALITY dialerProxy时会出现的问题,不确定是否与此问题同源。 反向代理bridge (VLESS TCP) 通过dailerProxy由Reality代理时,外部访问内部网络会出现断连(bridge设备REALITY outbound断连,触发原因未知,触发随机,推测是连接数多,通常在连续使用一段时间后出现),断连后经过20分钟左右会自动恢复连接。 在之前版本(XTLS VISION)并没有这个问题,应该是在 1.8.0之后出现的问题。 确定1.8.6至1.8.11版本均有此问题。

client bridge (outbound VLESS TCP) --dialerProxy (through outbound REALITY)--> server (inbound REALITY) ----> server portal (inbound VLESS TCP)

环境为旁路由(bridge设备)透明代理 bridge 配置如下


    "outbounds": [
        {
            "tag": "proxy",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                       ...
                    }
                ]
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                    "allowInsecure": false,
                    "fingerprint": "chrome",
                    "publicKey": "...",
                    "serverName": "...",
                    "shortId": "",
                    "show": false,
                    "spiderX": "/a"
                },
                "sockopt": {
                    "mark": 255
                }
            }
        },
        {
            "tag": "direct",
            "protocol": "freedom",
            "settings": {
                "domainStrategy": "UseIPv4v6"
            },
            "streamSettings": {
                "sockopt": {
                    "mark": 255
                }
            }
        },
        {
            "tag": "bridge-home1-in",
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                       ...
                    }
                ]
            },
            "streamSettings": {
                "sockopt": {
                    "dialerProxy": "proxy"
                }
            }
        }
    ],
    "reverse": {
        "bridges": [
            {
                "tag": "bridge-home1",
                "domain": "home1.reverse.com"
            }
        ]
    },
    "routing": {
        "domainMatcher": "mph",
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "inboundTag": [
                    "bridge-home1"
                ],
                "domain": [
                    "full:home1.reverse.com"
                ],
                "outboundTag": "bridge-home1-in"
            },
            {
                "type": "field",
                "inboundTag": [
                    "bridge-home1"
                ],
                "outboundTag": "direct"
            }
        ]
    }

portal 配置如下


    "inbounds": [
        {
            "tag": "realityin",
            "port": 443,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                       ...
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "tcp",
                "security": "reality",
                "realitySettings": {
                    "show": false,
                    "dest": "...:443",
                    "xver": 0,
                    "serverNames": [
                        "..."
                    ],
                    "privateKey": "...",
                    "shortIds": [
                        ""
                    ]
                }
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls",
                    "quic"
                ],
                "domainsExcluded": [
                    "courier.push.apple.com"
                ]
            }
        },
        {
            "tag": "home1-in",
            "listen": "MY_VPS_IP",
            "port": 20002,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                       ...
                    }
                ],
                "decryption": "none"
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls",
                    "quic"
                ],
                "domainsExcluded": [
                    "courier.push.apple.com"
                ]
            }
        }
    ],
    "reverse": {
        "portals": [
            {
                "tag": "portal-home1",
                "domain": "home1.reverse.com"
            }
        ]
    },
    "routing": {
        "domainMatcher": "mph",
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "inboundTag": [
                    "home1-in"
                ],
                "outboundTag": "portal-home1"
            }
            {
                "type": "field",
                "inboundTag": [
                    "realityin"
                ],
                "ip": [
                    "INTERNAL_SERVER_IP"
                ],
                "outboundTag": "portal-home1"
            }
        ]
    }

出现断连时bridge日志出现如下报错 Xray_log.txt

同时在断连期间,bridge 设备ping VPS 的 IP 正常 portal VPS 端无此 bridge 连接日志,其他设备(不经过此bridge设备)连接VPS REALITY inbound 正常。

测试最新1.8.13版本已无此问题。

@kingwilliam 麻烦再测一下 https://github.com/XTLS/Xray-core/actions/runs/9088697505

  1. 已测试 dialerProxy 运作正常
  2. 早前测试的inbound问题也没再出现.

我大体测了一下 感觉 xtls 协议用在客户端的链式代理其实非常好用 因为一般的链式是额外双层加密解密 而 xtls 可以做到连接头双层加密 后面跨两层裸奔 同时两个服务器都是端口转发 非常高效

对性能来说是这样,对“不想让观察者关联两个或多个连接”来说不合适,所以还是不适合 tor,虽然它就多加密几层还是能被关联

对于“不想让观察者关联两个或多个连接”的起夜级需求,我想了下还是只能空跑流量抹平时序特征,like https://github.com/v2ray/v2ray-core/issues/2526#issuecomment-783931231 ,比 hysteria 的 brutal 更激进,不过这样的强特征又不适合过墙了,有点难取舍,好在我没有搞回国流量 ghs 的需求