Add RDP debug logging and enable guacd debug level
- docker-compose: override guacd command with -L debug flag so FreeRDP errors are visible in `docker logs mremotify-guacd-1` - rdp.ts: log RDP host/user, arg names, ready instruction, proxy-mode entry, and any error/disconnect instructions from guacd Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -128,6 +128,8 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
fastify.log.info({ host: conn.host, port: conn.port, user: conn.username }, 'RDP: starting guacd handshake');
|
||||
|
||||
try {
|
||||
// 1. Select protocol
|
||||
guacd.write(buildInstruction('select', conn.protocol));
|
||||
@@ -135,6 +137,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
|
||||
// 2. Read args list from guacd
|
||||
const argsInstruction = await readInstruction(guacd, tcpBuf);
|
||||
const argNames = argsInstruction.slice(1);
|
||||
fastify.log.info({ argNames }, 'RDP: guacd args list received');
|
||||
|
||||
const decryptedPassword = conn.encryptedPassword ? decrypt(conn.encryptedPassword) : '';
|
||||
|
||||
@@ -162,6 +165,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
|
||||
|
||||
// 4. Read ready instruction
|
||||
const readyInstruction = await readInstruction(guacd, tcpBuf);
|
||||
fastify.log.info({ readyInstruction }, 'RDP: guacd ready instruction received');
|
||||
if (readyInstruction[0] !== 'ready') {
|
||||
throw new Error(`guacd handshake failed: expected 'ready', got '${readyInstruction[0]}'`);
|
||||
}
|
||||
@@ -185,12 +189,22 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
fastify.log.info({ uuid: readyInstruction[1] }, 'RDP: entering proxy mode');
|
||||
|
||||
// --- Proxy mode ---
|
||||
guacd.on('data', (data: Buffer) => {
|
||||
if (socket.readyState === WebSocket.OPEN) socket.send(data.toString('utf8'));
|
||||
const text = data.toString('utf8');
|
||||
// Log the first message from guacd (usually an error or first instruction)
|
||||
if (text.startsWith('5.error') || text.startsWith('10.disconnect')) {
|
||||
fastify.log.warn({ guacdMsg: text.substring(0, 200) }, 'RDP: guacd sent error/disconnect');
|
||||
}
|
||||
if (socket.readyState === WebSocket.OPEN) socket.send(text);
|
||||
});
|
||||
|
||||
guacd.on('end', () => socket.close());
|
||||
guacd.on('end', () => {
|
||||
fastify.log.info('RDP: guacd TCP connection ended');
|
||||
socket.close();
|
||||
});
|
||||
guacd.on('error', (err) => {
|
||||
fastify.log.warn({ err }, 'guacd socket error');
|
||||
socket.close(1011, err.message);
|
||||
|
||||
@@ -19,6 +19,8 @@ services:
|
||||
guacd:
|
||||
image: guacamole/guacd:1.5.4
|
||||
restart: unless-stopped
|
||||
# -L debug gives full FreeRDP error detail in `docker logs mremotify-guacd-1`
|
||||
command: ["/bin/sh", "-c", "/usr/local/sbin/guacd -b 0.0.0.0 -l 4822 -f -L debug"]
|
||||
networks:
|
||||
- internal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user