(stream quic.Stream, done chan<- error)
| 262 | } |
| 263 | |
| 264 | func handleControlStream(stream quic.Stream, done chan<- error) { |
| 265 | defer stream.Close() |
| 266 | shared.LogNetwork("Control stream established") |
| 267 | |
| 268 | for { |
| 269 | opcode, nonce, err := shared.ReadControlMessage(stream) |
| 270 | if err != nil { |
| 271 | // EOF is expected when client disconnects - treat as normal shutdown |
| 272 | if err == io.EOF || errors.Is(err, io.EOF) { |
| 273 | shared.LogNetwork("Control stream EOF - client disconnected normally") |
| 274 | done <- nil |
| 275 | return |
| 276 | } |
| 277 | shared.LogError("Failed to read control message", err) |
| 278 | // Signal completion on control stream error |
| 279 | done <- err |
| 280 | return |
| 281 | } |
| 282 | |
| 283 | switch opcode { |
| 284 | case shared.OpPing: |
| 285 | // Respond with pong |
| 286 | if err := shared.WritePong(stream, nonce); err != nil { |
| 287 | shared.LogError("Failed to send pong", err) |
| 288 | return |
| 289 | } |
| 290 | |
| 291 | case shared.OpShutdown: |
| 292 | shared.LogNetwork("Received shutdown signal, exiting immediately") |
| 293 | done <- nil |
| 294 | return |
| 295 | |
| 296 | default: |
| 297 | shared.LogErrorf("Unknown control opcode: %02x", opcode) |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func handleSOCKS5Stream(stream quic.Stream) { |
| 303 | defer stream.Close() |
no test coverage detected