From 7d36533477cb80e1263cd005e375b3395664b5ce Mon Sep 17 00:00:00 2001 From: snxraven Date: Fri, 29 Nov 2024 17:49:43 -0500 Subject: [PATCH] revert 6c4e0593b70cd18aec15b8b329df9cc85729b830 revert move to browserfs --- peartainer-server/index.js | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/peartainer-server/index.js b/peartainer-server/index.js index 100222c..b78e479 100644 --- a/peartainer-server/index.js +++ b/peartainer-server/index.js @@ -5,29 +5,11 @@ import Docker from 'dockerode'; import crypto from 'hypercore-crypto'; import { PassThrough } from 'stream'; import os from "os"; -import BrowserFS from 'browserfs'; +import fs from 'fs'; import dotenv from 'dotenv'; -// Initialize BrowserFS with LocalStorage -BrowserFS.configure({ fs: 'LocalStorage' }, (err) => { - if (err) { - console.error('Failed to configure BrowserFS:', err); - throw err; - } -}); - -const fs = BrowserFS.BFSRequire('fs'); - -// Manually load environment variables from .env file using BrowserFS -if (fs.existsSync('.env')) { - const envData = fs.readFileSync('.env', 'utf-8'); - envData.split('\n').forEach(line => { - const [key, value] = line.split('='); - if (key && value) { - process.env[key.trim()] = value.trim(); - } - }); -} +// Load environment variables from .env file +dotenv.config(); const docker = new Docker({ socketPath: os.platform() === "win32" ? '//./pipe/dockerDesktopLinuxEngine' : '/var/run/docker.sock', @@ -39,12 +21,6 @@ const terminalSessions = new Map(); // Map to track terminal sessions per peer // Function to generate a new key function generateNewKey() { const newKey = crypto.randomBytes(32); - - // Ensure .env file exists before appending - if (!fs.existsSync('.env')) { - fs.writeFileSync('.env', '', 'utf-8'); - } - fs.appendFileSync('.env', `SERVER_KEY=${newKey.toString('hex')}\n`, { flag: 'a' }); return newKey; }