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:
deadRabbit
2026-02-22 14:06:08 +01:00
parent 6494ecf698
commit 3b3a667b96
2 changed files with 18 additions and 2 deletions

View File

@@ -128,6 +128,8 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
return; return;
} }
fastify.log.info({ host: conn.host, port: conn.port, user: conn.username }, 'RDP: starting guacd handshake');
try { try {
// 1. Select protocol // 1. Select protocol
guacd.write(buildInstruction('select', conn.protocol)); guacd.write(buildInstruction('select', conn.protocol));
@@ -135,6 +137,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
// 2. Read args list from guacd // 2. Read args list from guacd
const argsInstruction = await readInstruction(guacd, tcpBuf); const argsInstruction = await readInstruction(guacd, tcpBuf);
const argNames = argsInstruction.slice(1); const argNames = argsInstruction.slice(1);
fastify.log.info({ argNames }, 'RDP: guacd args list received');
const decryptedPassword = conn.encryptedPassword ? decrypt(conn.encryptedPassword) : ''; const decryptedPassword = conn.encryptedPassword ? decrypt(conn.encryptedPassword) : '';
@@ -162,6 +165,7 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
// 4. Read ready instruction // 4. Read ready instruction
const readyInstruction = await readInstruction(guacd, tcpBuf); const readyInstruction = await readInstruction(guacd, tcpBuf);
fastify.log.info({ readyInstruction }, 'RDP: guacd ready instruction received');
if (readyInstruction[0] !== 'ready') { if (readyInstruction[0] !== 'ready') {
throw new Error(`guacd handshake failed: expected 'ready', got '${readyInstruction[0]}'`); throw new Error(`guacd handshake failed: expected 'ready', got '${readyInstruction[0]}'`);
} }
@@ -185,12 +189,22 @@ export async function rdpWebsocket(fastify: FastifyInstance) {
return; return;
} }
fastify.log.info({ uuid: readyInstruction[1] }, 'RDP: entering proxy mode');
// --- Proxy mode --- // --- Proxy mode ---
guacd.on('data', (data: Buffer) => { 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) => { guacd.on('error', (err) => {
fastify.log.warn({ err }, 'guacd socket error'); fastify.log.warn({ err }, 'guacd socket error');
socket.close(1011, err.message); socket.close(1011, err.message);

View File

@@ -19,6 +19,8 @@ services:
guacd: guacd:
image: guacamole/guacd:1.5.4 image: guacamole/guacd:1.5.4
restart: unless-stopped 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: networks:
- internal - internal