mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-22 00:46:37 +00:00
fix: suppress seek events when solo, add moz-extension CORS, add server logging
This commit is contained in:
@@ -1167,6 +1167,15 @@ async function handleAsyncMessage(message, sender, sendResponse) {
|
|||||||
}, FORCE_SYNC_TIMEOUT);
|
}, FORCE_SYNC_TIMEOUT);
|
||||||
}
|
}
|
||||||
addToHistory(message.action, 'You');
|
addToHistory(message.action, 'You');
|
||||||
|
|
||||||
|
const isNonEssentialEvent = message.action === EVENTS.PLAY || message.action === EVENTS.PAUSE || message.action === EVENTS.SEEK;
|
||||||
|
const hasOtherPeers = currentRoom && Array.isArray(currentRoom.peers) && currentRoom.peers.length > 0;
|
||||||
|
|
||||||
|
if (isNonEssentialEvent && !hasOtherPeers) {
|
||||||
|
sendResponse({ status: 'ok_solo' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit(message.action, { ...message.payload, peerId });
|
emit(message.action, { ...message.payload, peerId });
|
||||||
sendResponse({ status: 'ok' });
|
sendResponse({ status: 'ok' });
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "koalasync",
|
"name": "koalasync",
|
||||||
"version": "1.8.5",
|
"version": "1.8.6",
|
||||||
"description": "KoalaSync Build Scripts",
|
"description": "KoalaSync Build Scripts",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+6
-1
@@ -44,9 +44,10 @@ const httpServer = createServer(app);
|
|||||||
const io = new Server(httpServer, {
|
const io = new Server(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: (origin, callback) => {
|
origin: (origin, callback) => {
|
||||||
if (!origin || origin === 'https://sync.koalastuff.net' || origin.startsWith('chrome-extension://')) {
|
if (!origin || origin === 'https://sync.koalastuff.net' || origin.startsWith('chrome-extension://') || origin.startsWith('moz-extension://')) {
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
|
log('CORS', `Rejected origin: ${origin}`);
|
||||||
callback(new Error('Not allowed by CORS'));
|
callback(new Error('Not allowed by CORS'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -296,6 +297,7 @@ io.on('connection', (socket) => {
|
|||||||
|
|
||||||
const ip = socket._clientIp || socket.handshake.address;
|
const ip = socket._clientIp || socket.handshake.address;
|
||||||
if (!checkAuthRate(ip, roomId)) {
|
if (!checkAuthRate(ip, roomId)) {
|
||||||
|
log('AUTH', `Auth rate limit blocked ${ip} from room ${roomId.substring(0, 3)}***`);
|
||||||
socket.emit(EVENTS.ERROR, { message: "Too many failed attempts. Try again later." });
|
socket.emit(EVENTS.ERROR, { message: "Too many failed attempts. Try again later." });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -317,6 +319,7 @@ io.on('connection', (socket) => {
|
|||||||
roomCreationLocks.set(roomId, lockPromise);
|
roomCreationLocks.set(roomId, lockPromise);
|
||||||
try {
|
try {
|
||||||
if (rooms.size >= MAX_ROOMS) {
|
if (rooms.size >= MAX_ROOMS) {
|
||||||
|
log('ROOM', `Server at capacity: ${rooms.size}/${MAX_ROOMS} rooms — rejecting join`);
|
||||||
socket.emit(EVENTS.ERROR, { message: "Server capacity reached" });
|
socket.emit(EVENTS.ERROR, { message: "Server capacity reached" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -343,11 +346,13 @@ io.on('connection', (socket) => {
|
|||||||
if (room.passwordHash) {
|
if (room.passwordHash) {
|
||||||
if (!password || !(await bcrypt.compare(password, room.passwordHash))) {
|
if (!password || !(await bcrypt.compare(password, room.passwordHash))) {
|
||||||
recordAuthFailure(ip, roomId);
|
recordAuthFailure(ip, roomId);
|
||||||
|
log('AUTH', `Invalid password from ${ip} for room ${roomId.substring(0, 3)}***`);
|
||||||
socket.emit(EVENTS.ERROR, { message: "Invalid password" });
|
socket.emit(EVENTS.ERROR, { message: "Invalid password" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (room.peers.size >= MAX_PEERS_PER_ROOM) {
|
if (room.peers.size >= MAX_PEERS_PER_ROOM) {
|
||||||
|
log('ROOM', `Room full (${room.peers.size}/${MAX_PEERS_PER_ROOM}): ${roomId.substring(0, 3)}***`);
|
||||||
socket.emit(EVENTS.ERROR, { message: "Room full" });
|
socket.emit(EVENTS.ERROR, { message: "Room full" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user