tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

main.js (595B)


      1 import fs from 'fs/promises';
      2 import { WebSocketServer } from 'ws';
      3 
      4 const wss = new WebSocketServer({ port: 59497 });
      5 
      6 const timestamp = new Date().toISOString().slice(0, 19).replace(/[:]/g, '-');
      7 const filename = `wslog-${timestamp}.txt`;
      8 const f = await fs.open(filename, 'w');
      9 console.log(`Writing to ${filename}`);
     10 console.log('Ctrl-C to stop');
     11 
     12 process.on('SIGINT', () => {
     13  console.log(`\nWritten to ${filename}`);
     14  process.exit();
     15 });
     16 
     17 wss.on('connection', async ws => {
     18  ws.on('message', data => {
     19    const s = data.toString();
     20    f.write(s + '\n');
     21    console.log(s);
     22  });
     23 });