Hysteria outbound without `settings.address` panics with nil pointer dereference at the first dial; `-test` passes

Aperta Adatta ai principianti
#7,557 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Leggi infra/conf/hysteria.go:24-27, dove la configurazione del client Hysteria crea il server a partire da settings.address, e verifica come viene testata la convalida della configurazione. Inizia eseguendo la riproduzione segnalata xray run -test -c cfg.json con la configurazione fornita. Il risultato atteso è che l’assenza di un indirizzo venga rifiutata con un errore di configurazione prima che il primo tentativo di connessione possa causare un panic.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Integrity requirements

  • I read the issue template.
  • I confirm I read the documentation and did not pile up options.
  • Complete configs and logs are provided below.
  • I searched issues and found no similar ones.
  • Reproduced on the latest release.

Description

Version: Xray 26.11.9 (Xray, Penetrates Everything.) 676eaf6 (go1.27.3 linux/amd64), the v26.11.9 release Xray-linux-64.zip (sha256 b651f7e1d9966ee2c1b1ee1bf8b52c72771824d3065dce96bbc8bcc19ed95f82). The panic site is also unchanged on main at 919d0ae (2026-11-30).

infra/conf/hysteria.go:24-27 builds ClientConfig.Server from c.Address.Build() with no check that an address was given. The core starts and xray run -test prints Configuration OK, then the first connection through the outbound panics in transport/internet/tls/config.go:496 (WithDestination, nil destination). The loaded config is not valid, but nothing says so before the process dies.

Reproduction Method

Save the client config below as cfg.json.

xray run -test -c cfg.json   # then: xray run -c cfg.json, and in another shell: curl -x socks5h://127.0.0.1:10808 http://example.com/

Expected result: xray run -test fails with a config error (hysteria: address is empty or similar); no panic at dial.

Client config


{
  "log": {
    "loglevel": "warning"
  },
  "outbounds": [
    {
      "protocol": "hysteria",
      "settings": {
        "version": 2
      },
      "streamSettings": {
        "network": "hysteria",
        "security": "tls",
        "tlsSettings": {
          "serverName": "example.com",
          "alpn": [
            "h3"
          ]
        },
        "hysteriaSettings": {
          "version": 2,
          "auth": "x"
        }
      }
    }
  ],
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 10808,
      "protocol": "socks",
      "settings": {
        "udp": false
      }
    }
  ]
}

Server config

Not needed: the client config panics on its own.

Client log

Full output of the panicking process (ends with the exit code):


Xray 26.11.9 (Xray, Penetrates Everything.) 676eaf6 (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
[Info] infra/conf/serial: Reading config: &{Name:../cfg/hyst.json Format:json}
Configuration OK.
exit=0

Xray 26.11.9 (Xray, Penetrates Everything.) 676eaf6 (go1.27.3 linux/amd64)
A unified platform for anti-censorship.
[Info] infra/conf/serial: Reading config: &{Name:/tmp/repro/cfg/hyst.json Format:json}
[Warning] core: Xray 26.11.9 started
from tcp:127.0.0.1:58286 accepted tcp:127.0.0.1:20001
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xca24a5]

goroutine 27 [running]:
github.com/xtls/xray-core/transport/internet/tls.WithDestination.func1(0x18afcdeb25a0)
github.com/xtls/xray-core/transport/internet/tls/config.go:496 +0x25
github.com/xtls/xray-core/transport/internet/tls.(*Config).GetTLSConfig(0x18afcdbdd760, {0x18afcdd272c0, 0x1, 0x0?})
github.com/xtls/xray-core/transport/internet/tls/config.go:408 +0x538
github.com/xtls/xray-core/transport/internet/hysteria.Dial({0x24c9158, 0x18afcddc2480}, {{0x0?, 0x0?}, 0x0?, 0x0?}, 0x18afcdbd1030)
github.com/xtls/xray-core/transport/internet/hysteria/dialer.go:358 +0x371
github.com/xtls/xray-core/transport/internet.Dial({0x24c9158, 0x18afcddc2480}, {{0x0?, 0x0?}, 0x0?, 0x2?}, 0x18afcdbd1030?)
github.com/xtls/xray-core/transport/internet/dialer.go:63 +0x168
github.com/xtls/xray-core/app/proxyman/outbound.(*Handler).Dial(0x18afcddbcd00, {0x24c9158?, 0x18afcddc2480?}, {{0x0?, 0x0?}, 0x0?, 0x0?})
github.com/xtls/xray-core/app/proxyman/outbound/handler.go:275 +0x11d
github.com/xtls/xray-core/proxy/hysteria.(*Client).Process(0x18afcdd7c990, {0x24c9158, 0x18afcddc2450}, 0x18afcdcea280, {0x24c7308, 0x18afcddbcd00})
github.com/xtls/xray-core/proxy/hysteria/client.go:63 +0x21c
github.com/xtls/xray-core/app/proxyman/outbound.(*Handler).Dispatch(0x18afcddbcd00, {0x24c9158, 0x18afcddc2450}, 0x18afcdcea280)
github.com/xtls/xray-core/app/proxyman/outbound/handler.go:239 +0x98a
github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).routedDispatch(0x18afcdd7fea0, {0x24c9158, 0x18afcddc2450}, 0x18afcdcea280, {{0x24c9628, 0x18afcdb38244}, 0x4e21, 0x2})
github.com/xtls/xray-core/app/dispatcher/default.go:507 +0xc52
github.com/xtls/xray-core/app/dispatcher.(*DefaultDispatcher).DispatchLink(0x18afcdd7fea0, {0x24c9158, 0x18afcddc2450}, {{0x24c9628?, 0x18afcdb38244?}, 0xd008?, 0x18af?}, 0x18afcdcea280)
github.com/xtls/xray-core/app/dispatcher/default.go:344 +0x506
github.com/xtls/xray-core/common/mux.(*Server).DispatchLink(0x20?, {0x24c9158?, 0x18afcddc2450?}, {{0x24c9628?, 0x18afcdb38244?}, 0xa1a0?, 0x18af?}, 0x2?)
github.com/xtls/xray-core/common/mux/server.go:64 +0xda
github.com/xtls/xray-core/proxy/socks.(*Server).processTCP(0x18afcddc26c0, {0x24c9158, 0x18afcddc2240}, {0x73b3c67c1e00, 0x18afcdd100b8}, {0x24ca4f0, 0x18afcdb48e00}, {0x18afcdb38178, 0x1, 0x1})
github.com/xtls/xray-core/proxy/socks/server.go:157 +0xf4b
github.com/xtls/xray-core/proxy/socks.(*Server).Process(0x18afcddc26c0, {0x24c9158, 0x18afcddc2240}, 0x2, {0x73b3c67c1e00, 0x18afcdd100b8}, {0x24ca4f0, 0x18afcdb48e00})
github.com/xtls/xray-core/proxy/socks/server.go:91 +0x2a5
github.com/xtls/xray-core/app/proxyman/inbound.(*tcpWorker).callback(0x18afcddc8000, {0x73b3c67c1e00, 0x18afcdd100b8})
github.com/xtls/xray-core/app/proxyman/inbound/worker.go:123 +0xde3
created by github.com/xtls/xray-core/app/proxyman/inbound.(*tcpWorker).Start.func1 in goroutine 26
github.com/xtls/xray-core/app/proxyman/inbound/worker.go:142 +0x86
exit=2

Server log

Not applicable.

Lingua principale
Go
Stelle
43.3k
Fork
6.2k
Merge medio
2g 11h
PR unite (30g)
55

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di XTLS/Xray-core

Tutte le issue di XTLS/Xray-core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.