Skip to content

加载 server.json 作为服务端配置时 panic #5273

@halohsu

Description

@halohsu

完整性要求

  • 我读完了 issue 模板中的所有注释,确保填写符合要求。
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
  • 我搜索了 issues, 没有发现已提出的类似问题。
  • 问题在 Release 最新的版本上可以成功复现

描述

操作系统 : Ubuntu Jammy(AMD64)
软件版本 : Xray 25.10.15 (Xray, Penetrates Everything.) b69a376 (go1.25.3 linux/amd64)

重现方式

xray run -c server.json

客户端配置

暂无

服务端配置

{
  "version": {   // 限制版本, 要求每次更新 xray 二进制都需要更新 version.max 字段
    "min": "25.10.15",
    "max": "25.10.15"
  },
  "log": {   // 记录详细的日志
    "access": "/var/log/xray/access.log",
    "error": "/var/log/xray/error.log",
    "loglevel": "warning",
    "dnsLog": false,
    "maskAddress": ""
  },
  "dns": {
    "servers": [
      "https+local://1.1.1.1/dns-query",  // 优先使用 1.1.1.1 进行 DNS 查询
      "localhost"                         // 降级使用本地 DNS
    ]
  },
  "routing": {},   // 允许来自客户端的请求全部通过代理服务器
  "policy": {
    "levels": {
      "0": {
        "handshake": 5,
        "connIdle": 200,
        "uplinkOnly": 2,
        "downlinkOnly": 5,
        "statsUserUplink": true,  // 允许用户级别的统计信息
        "statsUserDownlink": true,
        "statsUserOnline": true,
        "bufferSize": 1024
      }
    },
    "system": {
      "statsInboundUplink": true,    // 允许统计信息
      "statsInboundDownlink": true,  // 允许统计信息
      "statsOutboundUplink": true,   // 允许统计信息
      "statsOutboundDownlink": true  // 允许统计信息
    }
  },
  "inbounds": [
    {
      "port": 7443,
      "protocol": "vless",
      "settings": {
        "clients": [
          {
            "id": "c191d145-496f-45c2-bbf3-bba83b157086",
            "flow": "xtls-rprx-vision",
            "level": 0,
            "email": "a@outlook.com"
          },
          {
            "id": "c191d145-496f-45c2-bbf3-bba83b157086",
            "flow": "xtls-rprx-vision",
            "level": 0,
            "email": "b@outlook.com"
          }
        ],
        "decryption": "none",  // 保持为 None, 使用 streamSettings.security 进行加密
        "fallbacks": [
          {
            "dest": 80
          }
        ]
      },
      "streamSettings": {
        "network": "xhttp",    // XHTTP 适用于经过公网(带有网络审查的)环境, 基于 HTTP/2.0 协议
        "security": "reality",
        "realitySettings": {   // Reality 比 TLS 的安全性更高, 配置方式也和 TLS 一致
          "show": false,
          "target": "myexample.com:443",
          "xver": 0,
          "serverNames": [
            "myexample.com"
          ],
          "privateKey": "kIZNuu73qH_1so4iQl0-9b6u8jvjRaWqJWPQ98J2dmI",   // xray x25519生成
          "minClientVer": "", // 不限制 TLS 版本
          "maxClientVer": "", // 不限制 TLS 版本
          "maxTimeDiff": 0,   // 不限制客户端与服务端的时间差
          "shortIds": [
            "0253aa9be89748771b35d1f10169786f",
            "f9e55da7bff41b3f4eaaf8c9f3348ab2",
            "b21fe54c0cff55858a16fdf9d0fbb2c2",
            "f6d196f076c7501809408c15af6e964b"
          ],
          "mldsa65Seed": "",  // 自动生成
          "limitFallbackUpload": {
            "afterBytes": 0,
            "bytesPerSec": 0,
            "burstBytesPerSec": 0
          },
          "limitFallbackDownload": {
            "afterBytes": 0,
            "bytesPerSec": 0,
            "burstBytesPerSec": 0
          },
          "fingerprint": "chrome",  // 伪装为 Chrome 浏览器的指纹
          "serverName": "",         // 留空, 自动从 serverNames 中选择
          "password": "dVKTqiDR5TXG9gV1Wk57WAATLsTlxSTqxiQS7HTP8lI",  // 验证客户端合法性
          "shortId": "",            // 留空, 自动从 shortIds 中选择
          "mldsa65Verify": "",
          "spiderX": ""             // 不启用爬虫伪装
        }
      }
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom"
    },
    {
      "tag": "block",
      "protocol": "blackhole"
    }
  ],
  "transport": {},
  "stats": {},
  "reverse": {},
  "fakedns": {},
  "metrics": {
    "tag": "Metrics",
    "listen": "127.0.0.1:11111"
  },
  "observatory": {
    "subjectSelector": ["outbound"],
    "probeUrl": "https://www.google.com/generate_204",
    "probeInterval": "10s",
    "enableConcurrency": false
  }
}

客户端日志

暂无

服务端日志

Xray 25.10.15 (Xray, Penetrates Everything.) b69a376 (go1.25.3 linux/amd64)
A unified platform for anti-censorship.
panic: runtime error: index out of range [8] with length 8

goroutine 1 [running]:
encoding/hex.Decode({0xc0002f64e0?, 0xc00016ae60?, 0x20?}, {0xc00016ace0?, 0xc0001689f0?, 0x2b?})
encoding/hex/hex.go:101 +0x125
github.com/xtls/xray-core/infra/conf.(*REALITYConfig).Build(0xc000239380)
github.com/xtls/xray-core/infra/conf/transport_internet.go:632 +0x265c
github.com/xtls/xray-core/infra/conf.(*StreamConfig).Build(0xc0001cb600)
github.com/xtls/xray-core/infra/conf/transport_internet.go:984 +0x659
github.com/xtls/xray-core/infra/conf.(*InboundDetourConfig).Build(0xc000187960)
github.com/xtls/xray-core/infra/conf/xray.go:165 +0x56f
github.com/xtls/xray-core/infra/conf.(*Config).Build(0xc000294780)
github.com/xtls/xray-core/infra/conf/xray.go:585 +0x1836
github.com/xtls/xray-core/infra/conf/serial.BuildConfig({0xc000120500?, 0xc00014bec0?, 0xc000187bf0?})
github.com/xtls/xray-core/infra/conf/serial/builder.go:52 +0x2a
github.com/xtls/xray-core/core.LoadConfig({0x16b81ed, 0x4}, {0x143bee0?, 0xc00014bec0?})
github.com/xtls/xray-core/core/config.go:146 +0x56e
main.startXray()
github.com/xtls/xray-core/main/run.go:223 +0x15c
main.executeRun(0x247b7c0?, {0xc0001180a0?, 0x800c000187f20?, 0x7fbaff17a0c8?})
github.com/xtls/xray-core/main/run.go:78 +0x130
github.com/xtls/xray-core/main/commands/base.Execute()
github.com/xtls/xray-core/main/commands/base/execute.go:64 +0x6bf
main.main()
github.com/xtls/xray-core/main/main.go:22 +0x1a5
root@a:~#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions