forked from snxraven/LinkUp-P2P-Chat
Bug Fix: Allowing clients to have different ServePorts per client and storages per client
This commit is contained in:
parent
dd8099649f
commit
5f8817a2f2
app.jsprimary-keyprimary-keyprimary-keyprimary-key
storage_1717879091736_bs8y60817ws
cores
b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233
d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e
storage_1717879094309_q0ulqlioyk
cores
68/98/6898fb828051fae650578dd1c0ae50aeb6296b8091670d5f2e726811be79bd88
fc/06/fc0621a9fe71abf74ce33e8475c694134b8f291a8c65f1d52cd55fb87fb2dca3
storage_1717879128175_e249zmbidxf
cores
2e/b0/2eb0a32e391c7819af5322f2b8aded83bacaa003ac8074f28a42e414c0003971
d5/70/d5705d8dff635531e413071d4cd0c602cbd9f149225c0659fc80d983a9fa6211
storage_1717879392474_wy31fhg5jwc
cores
c0/13/c01387dbd3fd745140f531e7feb2edeaf3f45c1646c5b3657b875a896de315ed
c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263
storage_1717879403711_j4iaqtzccmk
15
app.js
15
app.js
@ -8,7 +8,8 @@ import Hyperdrive from 'hyperdrive';
|
||||
import Corestore from 'corestore';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
const store = new Corestore('./storage');
|
||||
const storagePath = `./storage_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
|
||||
const store = new Corestore(storagePath);
|
||||
const drive = new Hyperdrive(store);
|
||||
|
||||
await drive.ready();
|
||||
@ -21,10 +22,18 @@ let peerCount = 0;
|
||||
let currentRoom = null;
|
||||
const eventEmitter = new EventEmitter();
|
||||
|
||||
// Define servePort at the top level
|
||||
let servePort;
|
||||
|
||||
// Function to get a random port between 1337 and 2223
|
||||
function getRandomPort() {
|
||||
return Math.floor(Math.random() * (2223 - 1337 + 1)) + 1337;
|
||||
}
|
||||
|
||||
async function initialize() {
|
||||
swarm = new Hyperswarm();
|
||||
|
||||
const servePort = 1337;
|
||||
servePort = getRandomPort();
|
||||
const serve = new ServeDrive({ port: servePort, get: ({ key, filename, version }) => drive });
|
||||
await serve.ready();
|
||||
console.log('Listening on http://localhost:' + serve.address().port);
|
||||
@ -129,7 +138,7 @@ function registerUser(e) {
|
||||
reader.onload = async (event) => {
|
||||
const buffer = new Uint8Array(event.target.result);
|
||||
await drive.put(`/icons/${regUsername}.png`, buffer);
|
||||
userAvatar = `http://localhost:1337/icons/${regUsername}.png`; // Set the correct URL
|
||||
userAvatar = `http://localhost:${servePort}/icons/${regUsername}.png`; // Set the correct URL
|
||||
registeredUsers[regUsername] = userAvatar;
|
||||
localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers));
|
||||
continueRegistration(regUsername);
|
||||
|
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/bitfield
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/bitfield
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/data
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/data
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/oplog
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/oplog
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/tree
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/b9/a3/b9a356644a2da150bf7ada6dfb8466754232a2b7d0d855b43b8de74284bce233/tree
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/bitfield
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/bitfield
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/data
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/data
Normal file
Binary file not shown.
After (image error) Size: 18 KiB |
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/oplog
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/oplog
Normal file
Binary file not shown.
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/tree
Normal file
BIN
storage_1717879091736_bs8y60817ws/cores/d4/59/d45903635e96b9573c62db81945b9ecfa6d111ca682e869e091c905ad28aba7e/tree
Normal file
Binary file not shown.
1
storage_1717879091736_bs8y60817ws/primary-key
Normal file
1
storage_1717879091736_bs8y60817ws/primary-key
Normal file
@ -0,0 +1 @@
|
||||
Ÿ(â°f¿éh»8ÓFOv//oOa«[Ô™–|U9{Á
|
BIN
storage_1717879094309_q0ulqlioyk/cores/68/98/6898fb828051fae650578dd1c0ae50aeb6296b8091670d5f2e726811be79bd88/oplog
Normal file
BIN
storage_1717879094309_q0ulqlioyk/cores/68/98/6898fb828051fae650578dd1c0ae50aeb6296b8091670d5f2e726811be79bd88/oplog
Normal file
Binary file not shown.
BIN
storage_1717879094309_q0ulqlioyk/cores/fc/06/fc0621a9fe71abf74ce33e8475c694134b8f291a8c65f1d52cd55fb87fb2dca3/oplog
Normal file
BIN
storage_1717879094309_q0ulqlioyk/cores/fc/06/fc0621a9fe71abf74ce33e8475c694134b8f291a8c65f1d52cd55fb87fb2dca3/oplog
Normal file
Binary file not shown.
1
storage_1717879094309_q0ulqlioyk/primary-key
Normal file
1
storage_1717879094309_q0ulqlioyk/primary-key
Normal file
@ -0,0 +1 @@
|
||||
<EFBFBD>4<EFBFBD>ھ<EFBFBD><EFBFBD>P,8<><38>UW<55>Y<EFBFBD><59><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD>ܲkC<><EFBFBD>
|
BIN
storage_1717879128175_e249zmbidxf/cores/2e/b0/2eb0a32e391c7819af5322f2b8aded83bacaa003ac8074f28a42e414c0003971/data
Normal file
BIN
storage_1717879128175_e249zmbidxf/cores/2e/b0/2eb0a32e391c7819af5322f2b8aded83bacaa003ac8074f28a42e414c0003971/data
Normal file
Binary file not shown.
BIN
storage_1717879128175_e249zmbidxf/cores/2e/b0/2eb0a32e391c7819af5322f2b8aded83bacaa003ac8074f28a42e414c0003971/oplog
Normal file
BIN
storage_1717879128175_e249zmbidxf/cores/2e/b0/2eb0a32e391c7819af5322f2b8aded83bacaa003ac8074f28a42e414c0003971/oplog
Normal file
Binary file not shown.
BIN
storage_1717879128175_e249zmbidxf/cores/d5/70/d5705d8dff635531e413071d4cd0c602cbd9f149225c0659fc80d983a9fa6211/data
Normal file
BIN
storage_1717879128175_e249zmbidxf/cores/d5/70/d5705d8dff635531e413071d4cd0c602cbd9f149225c0659fc80d983a9fa6211/data
Normal file
Binary file not shown.
After (image error) Size: 2.3 KiB |
BIN
storage_1717879128175_e249zmbidxf/cores/d5/70/d5705d8dff635531e413071d4cd0c602cbd9f149225c0659fc80d983a9fa6211/oplog
Normal file
BIN
storage_1717879128175_e249zmbidxf/cores/d5/70/d5705d8dff635531e413071d4cd0c602cbd9f149225c0659fc80d983a9fa6211/oplog
Normal file
Binary file not shown.
1
storage_1717879128175_e249zmbidxf/primary-key
Normal file
1
storage_1717879128175_e249zmbidxf/primary-key
Normal file
@ -0,0 +1 @@
|
||||
賴B-HGnゥxfムモ=&遂3ぇZム
セ貢Cシァ"カ
|
BIN
storage_1717879392474_wy31fhg5jwc/cores/c0/13/c01387dbd3fd745140f531e7feb2edeaf3f45c1646c5b3657b875a896de315ed/data
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c0/13/c01387dbd3fd745140f531e7feb2edeaf3f45c1646c5b3657b875a896de315ed/data
Normal file
Binary file not shown.
After (image error) Size: 110 KiB |
BIN
storage_1717879392474_wy31fhg5jwc/cores/c0/13/c01387dbd3fd745140f531e7feb2edeaf3f45c1646c5b3657b875a896de315ed/oplog
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c0/13/c01387dbd3fd745140f531e7feb2edeaf3f45c1646c5b3657b875a896de315ed/oplog
Normal file
Binary file not shown.
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/bitfield
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/bitfield
Normal file
Binary file not shown.
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/data
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/data
Normal file
Binary file not shown.
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/oplog
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/oplog
Normal file
Binary file not shown.
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/tree
Normal file
BIN
storage_1717879392474_wy31fhg5jwc/cores/c4/8f/c48f2d4321fd557c5dca74162b5c0ea5a8c0002b8fd79062a0ddcff7177b7263/tree
Normal file
Binary file not shown.
1
storage_1717879392474_wy31fhg5jwc/primary-key
Normal file
1
storage_1717879392474_wy31fhg5jwc/primary-key
Normal file
@ -0,0 +1 @@
|
||||
њcїSµd$и’„тЩх‚ЧvОґДќЈГ…ЉJЌЊ1Рjщ
|
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/bitfield
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/bitfield
Normal file
Binary file not shown.
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/data
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/data
Normal file
Binary file not shown.
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/oplog
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/oplog
Normal file
Binary file not shown.
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/tree
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/86/1c/861cd6d61019bca6d618dd08450271a253279417f255a1fb6f3528d6de03ebe0/tree
Normal file
Binary file not shown.
BIN
storage_1717879403711_j4iaqtzccmk/cores/dd/57/dd5738023dd4f6a0fac6ee49d5daabe572d14f89baf871381fc097adcdcff5a5/data
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/dd/57/dd5738023dd4f6a0fac6ee49d5daabe572d14f89baf871381fc097adcdcff5a5/data
Normal file
Binary file not shown.
After (image error) Size: 110 KiB |
BIN
storage_1717879403711_j4iaqtzccmk/cores/dd/57/dd5738023dd4f6a0fac6ee49d5daabe572d14f89baf871381fc097adcdcff5a5/oplog
Normal file
BIN
storage_1717879403711_j4iaqtzccmk/cores/dd/57/dd5738023dd4f6a0fac6ee49d5daabe572d14f89baf871381fc097adcdcff5a5/oplog
Normal file
Binary file not shown.
1
storage_1717879403711_j4iaqtzccmk/primary-key
Normal file
1
storage_1717879403711_j4iaqtzccmk/primary-key
Normal file
@ -0,0 +1 @@
|
||||
<EFBFBD><EFBFBD>`N<><1F><>3<EFBFBD>t<EFBFBD><74>s<EFBFBD>H|MS"<22>k<EFBFBD><6B><10><>]
|
Loading…
x
Reference in New Issue
Block a user