Bug: json.Marshal error ignored in hysteria2 realm_server SSE event stream
not following template
## Description
In `protocol/hysteria2/realm_server.go:383`, the error from `json.Marshal` is silently ignored:
```go
data, _ := json.Marshal(ev.data)
fmt.Fprintf(w, "event: %s\ndata: %s\n\n", ev.kind, data)
```
## Impact
If `ev.data` contains values that cannot be serialized by `encoding/json` (e.g., channels, functions, complex numbers, or cyclic data structures), the marshal will silently return an empty byte slice or incomplete JSON. The SSE stream will then send malformed data, and the client will receive corrupted or empty events with no indication of the error.
## Location
`protocol/hysteria2/realm_server.go:383`
## Suggested Fix
At minimum, log the error and skip the event:
```go
data, err := json.Marshal(ev.data)
if err != nil {
return
}
fmt.Fprintf(w, "event: %s\ndata: %s\n\n", ev.kind, data)
```
0 条评论