parent
6c4e0593b7
commit
7d36533477
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user