// worker.js const HTML_TEMPLATE = ` RDP Connection Download
computer

Remote Desktop Connection

download Preparing your RDP connection file...
`; // Rest of the worker code remains the same function generateRdpContent(server, username, protocol) { return [ 'screen mode id:i:2', 'use multimon:i:0', 'desktopwidth:i:1280', // 720p width 'desktopheight:i:720', // 720p height 'session bpp:i:24', // 24-bit color depth 'winposstr:s:0,1,0,0,800,600', 'compression:i:1', 'keyboardhook:i:2', 'audiocapturemode:i:0', 'videoplaybackmode:i:1', 'connection type:i:7', 'networkautodetect:i:1', 'bandwidthautodetect:i:1', 'displayconnectionbar:i:1', 'enableworkspacereconnect:i:0', 'disable wallpaper:i:1', // Performance optimizations 'allow font smoothing:i:0', 'allow desktop composition:i:0', 'disable full window drag:i:1', 'disable menu anims:i:1', 'disable themes:i:1', 'disable cursor setting:i:1', 'bitmapcachepersistenable:i:1', 'audiomode:i:2', 'redirectprinters:i:0', 'redirectcomports:i:0', 'redirectsmartcards:i:0', 'redirectclipboard:i:1', 'redirectposdevices:i:0', 'autoreconnection enabled:i:1', 'authentication level:i:2', 'prompt for credentials:i:1', 'connection type:i:7', 'compress:i:1', 'bitmap caching:i:1', 'max bpp:i:24', 'bulk compression:i:1', `full address:s:${server}`, `username:s:${username}`, 'enablecredsspsupport:i:1', protocol ? `protocol:s:${protocol}` : '', ].filter(Boolean).join('\r\n'); } async function handleRequest(request) { const url = new URL(request.url); const params = url.searchParams; const server = params.get('server'); const username = params.get('username'); const rdpFile = params.get('rdpFile'); const protocol = params.get('protocol'); const download = params.get('download'); if (!server || !username || !rdpFile) { return new Response('Missing required parameters', { status: 400 }); } if (download === '1') { const rdpContent = generateRdpContent(server, username, protocol); return new Response(rdpContent, { headers: { 'Content-Type': 'application/x-rdp', 'Content-Disposition': `attachment; filename="${rdpFile}.rdp"`, 'Cache-Control': 'no-store' } }); } return new Response(HTML_TEMPLATE, { headers: { 'Content-Type': 'text/html', 'Cache-Control': 'no-store' } }); } addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); });