fix(handler): encode AddOutbound payload as proto to avoid xray nil-deref #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/addoutbound-proto-encoding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
xray 26.3.27 panics with nil-pointer dereference at
app/proxyman/outbound/handler.go:104((*TypedMessage).GetInstance(0x0)) on everyAddOutboundcall from panel hot-reload. 29 panic occurrences observed on prod RU nodes in 24h; cascade outbounds never materialize → cascade TCP=0 across all 16 RU nodes.Root cause:
handler.service.ts:addOutboundwas passing raw xray JSON ({tag, protocol, settings, streamSettings}) straight toxtlsApi.handler.rawClient.addOutboundviaoutbound: obj as never. nice-grpc serializes by proto field name; xray JSON's fields don't match theOutboundHandlerConfigproto (which expectssenderSettings: TypedMessage,proxySettings: TypedMessage). Onlytagended up on the wire → server-sideProxySettingswas nil → panic.Fix
New
src/modules/handler/converters/outbound-json-to-proto.tsconverts xray JSON →OutboundHandlerConfigproto:@bufbuild/protobuf/wireBinaryWriterfor transports xtls-sdk does NOT ship: grpc/reality/tcp/tls/splithttp/websocket. Reality client logic mirrors xray-coreinfra/confv26.3.27.handler.service.ts: bothaddOutboundandsyncOutboundsnow convert before grpc; conversion errors in sync become per-outbound error strings instead of whole-batch aborts.Scope
Covered now (everything cascade + existing inbound types need):
Not implemented (rejects with clear error): kcp/mkcp, httpupgrade, hysteria. TCP
header_settings(HTTP/1.1 obfuscation) silently ignored — none of our inbounds use it. Pinned to xray-core v26.3.27 field numbers (matches DockerfileXRAY_CORE_VERSION).Verification
npm installclean, no lockfile driftnpm run buildexits 0, no TS errorsnpm test— 21/21 pass vianode:testthrough ts-nodeTest plan post-merge
Pre-fix: 0. Expected post-fix: ≥1 per RU node.
4. Check xray.err.log on RU nodes for new
AddOutboundpanics — should be zero.Backup tag:
pre-merge-addoutbound-proto-{TS}onorigin/main.Co-Authored-By: Пятница 🤖 pyatnitsa@openclaw