FranzKafkaYu / x-ui

Lightweight Xray panel with multi-protocol and multi-user on the same port,supports English language and Telegram bot. Easy to use and easy to manage.
GNU General Public License v3.0
8.01k stars 1.63k forks source link

Vless回落失败 #166

Closed venkate123 closed 2 years ago

venkate123 commented 2 years ago

Welcome

Description of the problem,screencshot would be good

直接安装Xray可以回落,使用X-UI回落失败 Xray Config.json如下

{
  "inbounds": [{
    "port": 59149,
    "protocol": "vless",
    "settings": {
      "clients": [
        {
          "id": "XXX",
          "flow": "xtls-rprx-direct",
          "level": 0
        }
      ],
      "decryption": "none",
      "fallbacks": [
          {
              "alpn": "http/1.1",
              "dest": 80
          },
          {
              "alpn": "h2",
              "dest": 443
          }
      ]
    },
    "streamSettings": {
        "network": "tcp",
        "security": "xtls",
        "xtlsSettings": {
            "serverName": "XXX",
            "alpn": ["http/1.1", "h2"],
            "certificates": [
                {
                    "certificateFile": "/root/dockerAPP/npm/letsencrypt/live/npm-1/fullchain.pem",
                    "keyFile": "/root/dockerAPP/npm/letsencrypt/live/npm-1/privkey.pem"
                }
            ]
        }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }]
}

X-UI生成的config.json如下:

{
  "log": null,
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "hybrid",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:cn",
          "geoip:private"
        ],
        "outboundTag": "blockedByIp",
        "type": "field"
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all",
          "geosite:cn"
        ],
        "outboundTag": "blockedByDomain"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "dns": {
    "hosts": {
      "dns.google": [
        "8.8.8.8",
        "8.8.4.4"
      ],
      "dns.pub": "119.29.29.29",
      "dns.alidns.com": "223.5.5.5"
    },
    "servers": [
      {
        "address": "https://1.1.1.1/dns-query",
        "domains": [
          "geosite:geolocation-!cn",
          "geosite:google@cn"
        ],
        "expectIPs": [
          "geoip:!cn"
        ]
      },
      "1.1.1.1",
      {
        "address": "localhost",
        "skipFallback": true
      }
    ],
    "queryStrategy": "UseIP"
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "streamSettings": null,
      "tag": "api",
      "sniffing": null
    },
    {
      "listen": null,
      "port": 9000,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "82d7f544-c034-4b14-fcc9-9a962651321d",
            "email": "5t2Q.love@xray.com",
            "flow": "xtls-rprx-direct"
          }
        ],
        "decryption": "none",
        "fallbacks": [
          {
            "name": "",
            "alpn": "http/1.1",
            "path": "",
            "dest": "80",
            "xver": 0
          },
          {
            "name": "",
            "alpn": "h2",
            "path": "",
            "dest": "443",
            "xver": 0
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "xtls",
        "xtlsSettings": {
          "serverName": "XXX",
          "certificates": [
            {
              "certificateFile": "/root/dockerAPP/npm/letsencrypt/live/npm-1/fullchain.pem",
              "keyFile": "/root/dockerAPP/npm/letsencrypt/live/npm-1/privkey.pem"
            }
          ]
        },
        "tcpSettings": {
          "header": {
            "type": "none"
          }
        }
      },
      "tag": "inbound-9000",
      "sniffing": {
        "enabled": false,
        "destOverride": [
          "http",
          "tls"
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blocked"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByIp"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByDomain"
    }
  ],
  "transport": null,
  "policy": {
    "levels": {
      "0": {
        "handshake": 4,
        "connIdle": 300,
        "uplinkOnly": 2,
        "downlinkOnly": 5,
        "statsUserUplink": false,
        "statsUserDownlink": false,
        "bufferSize": 4
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
  "stats": {},
  "reverse": null,
  "fakeDns": null
}

Version of x-ui

```console $ x-ui version # Paste output here ```

x-ui log or xray log

```console # paste log here ```
venkate123 commented 2 years ago

我发现回落失败的原因可能是"streamSettings"中缺少"alpn": ["http/1.1", "h2"],因为Xray中xtls默认只支持"h2",而我的nginx设置只支持“http/1.1“,建议在xtls增加该字段设置。参考此处

FranzKafkaYu commented 2 years ago

我发现回落失败的原因可能是"streamSettings"中缺少"alpn": ["http/1.1", "h2"],因为Xray中xtls默认只支持"h2",而我的nginx设置只支持“http/1.1“,建议在xtls增加该字段设置。参考此处

奇怪的是这个其实是有默认值的,默认值即为["http/1.1", "h2"],参考文档,为何没有生效需要提交给core确认,当然也可以考虑再x-ui内增加该字段配置,此项待定

venkate123 commented 2 years ago

我上面贴的这个链接里面有讨论,有开发者说是文档写错了,默认就是为空或“h2“,并没有"http/1.1"。而且你贴的这个中文文档中默认值是[ "h2", "http/1.1"],前后顺序代表优先级,经我测试,这个优先级也是有点bug的,在我的环境里,当"h2"在前面时,"http/1.1"完全不生效,仍然回落失败,必须指定为["http/1.1", "h2"]或"http/1.1"。因此希望当选择xtls时增加该字段的设置。

venkate123 commented 2 years ago

我发现回落失败的原因可能是"streamSettings"中缺少"alpn": ["http/1.1", "h2"],因为Xray中xtls默认只支持"h2",而我的nginx设置只支持“http/1.1“,建议在xtls增加该字段设置。参考此处

奇怪的是这个其实是有默认值的,默认值即为["http/1.1", "h2"],参考文档,为何没有生效需要提交给core确认,当然也可以考虑再x-ui内增加该字段配置,此项待定

@FranzKafkaYu 请问有计划加该设置项吗?如果可以的话,也希望对Vmess的ws协议添加“ acceptProxyProtocol”设置项,如此处所示。感谢!

FranzKafkaYu commented 2 years ago

@venkate123 可尝试最新版本。

venkate123 commented 2 years ago

@venkate123 可尝试最新版本。

@FranzKafkaYu 谢谢!回落可以工作了!不过vmess回落还是不行,不知道为什么。除此之外,新添的这两个设置项,修改后不能立刻生效,必须要重启xray才会在config.json中看到。

venkate123 commented 2 years ago

我搞错了,不用重启就可以生效,就是要等几秒钟。

FranzKafkaYu commented 2 years ago

我搞错了,不用重启就可以生效,就是要等几秒钟。

这是正常情况。

venkate123 commented 2 years ago

我搞错了,不用重启就可以生效,就是要等几秒钟。

这是正常情况。

vmess回落也成功了,之前回落里面没有设置"xver=1",现在的回落功能完全可用了!

再提一个建议呢:能否增加一个高级配置文本框,允许自己往里面写json文本,然后后端如果解析成功,就用该json的键值对覆盖自动生成的config.json键值对,相当于给每个inbound增加自定义的“xray配置模板”。如果实现,像我这样对于“ acceptProxyProtocol”设置的特殊需求,或者其他无法预知的特别需求,完全可以通过自定义json来实现。逻辑就是:面板上只放基础设置项实现基本功能,避免界面繁杂,通过自定义json实现xray的特殊功能,合起来就是完全体的xray。

venkate123 commented 2 years ago

我搞错了,不用重启就可以生效,就是要等几秒钟。

这是正常情况。

vmess回落也成功了,之前回落里面没有设置"xver=1",现在的回落功能完全可用了!

再提一个建议呢:能否增加一个高级配置文本框,允许自己往里面写json文本,然后后端如果解析成功,就用该json的键值对覆盖自动生成的config.json键值对,相当于给每个inbound增加自定义的“xray配置模板”。如果实现,像我这样对于“ acceptProxyProtocol”设置的特殊需求,或者其他无法预知的特别需求,完全可以通过自定义json来实现。逻辑就是:面板上只放基础设置项实现基本功能,避免界面繁杂,通过自定义json实现xray的特殊功能,合起来就是完全体的xray。

我想代码实现逻辑就是:把”xray配置模板“的前后端代码copy 过来,后端解析的json只对该inbound生效即可,应该不算复杂?