mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
feat: 问就是封包
This commit is contained in:
@@ -262,7 +262,7 @@ export async function startNodeRelay(
|
||||
},
|
||||
end: () => sock.end(),
|
||||
}
|
||||
sock.on('data', data =>
|
||||
sock.on('data', (data: Buffer) =>
|
||||
handleData(adapter, st, data, wsUrl, authHeader, wsAuthHeader),
|
||||
)
|
||||
sock.on('close', () => cleanupConn(states.get(sock)))
|
||||
@@ -381,7 +381,7 @@ function openTunnel(
|
||||
// responds with its own "HTTP/1.1 200" over the tunnel; we just pipe it.
|
||||
const head =
|
||||
`${connectLine}\r\n` + `Proxy-Authorization: ${authHeader}\r\n` + `\r\n`
|
||||
ws.send(encodeChunk(Buffer.from(head, 'utf8')))
|
||||
ws.send(encodeChunk(new Uint8Array(Buffer.from(head, 'utf8'))) as any)
|
||||
// Flush anything that arrived while the WS handshake was in flight —
|
||||
// trailing bytes from the CONNECT packet and any data() callbacks that
|
||||
// fired before onopen.
|
||||
@@ -429,15 +429,15 @@ function openTunnel(
|
||||
|
||||
function sendKeepalive(ws: WebSocketLike): void {
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(encodeChunk(new Uint8Array(0)))
|
||||
ws.send(encodeChunk(new Uint8Array(0)) as any)
|
||||
}
|
||||
}
|
||||
|
||||
function forwardToWs(ws: WebSocketLike, data: Buffer): void {
|
||||
if (ws.readyState !== WebSocket.OPEN) return
|
||||
for (let off = 0; off < data.length; off += MAX_CHUNK_BYTES) {
|
||||
const slice = data.subarray(off, off + MAX_CHUNK_BYTES)
|
||||
ws.send(encodeChunk(slice))
|
||||
const slice = new Uint8Array(data.subarray(off, off + MAX_CHUNK_BYTES))
|
||||
ws.send(encodeChunk(slice) as any)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user