diff --git a/src/backend/swarm.cjs b/src/backend/swarm.cjs index f7290819..490dacdd 100644 --- a/src/backend/swarm.cjs +++ b/src/backend/swarm.cjs @@ -476,7 +476,7 @@ const check_data_message = async (data, connection, topic, peer) => { const find_missing_peers = async (active, peers) => { for (const peer of peers) { - if (typeof peer !== 'string' || peer?.length > 64) continue + if (typeof peer !== 'string' || peer?.length !== 64) continue if (!active.peers.some((a) => a === peer)) { active.swarm.joinPeer(Buffer.from(peer, 'hex')); await sleep(100); diff --git a/src/backend/utils.cjs b/src/backend/utils.cjs index 8b947d3a..4ab648e0 100644 --- a/src/backend/utils.cjs +++ b/src/backend/utils.cjs @@ -203,14 +203,13 @@ const sanitize_join_swarm_data = (data) => { const screenshare = data?.screenshare; if (typeof screenshare !== 'boolean') return false; // if (typeof data?.avatar !== 'string') return false - let avatar = "" if (data.avatar !== undefined) { - avatar = Buffer.from(data.avatar, 'base64') - if (avatar.length > 200000) { - console.log("Avatar too big") - return false - } + avatar = Buffer.from(data.avatar, 'base64') + if (avatar.length > 200000) { + console.log("Avatar too big") + return false + } } const channels = []; @@ -297,9 +296,19 @@ const sanitize_join_swarm_data = (data) => { if (typeof videoMute !== 'boolean') return false; const screenshare = data?.screenshare; if (typeof screenshare !== 'boolean') return false; + + let avatar = "" + if (data.avatar !== undefined) { + avatar = Buffer.from(data.avatar, 'base64') + if (avatar.length > 200000) { + console.log("Avatar too big") + return false + } + } const clean_object = { address, + avatar, message, signature, topic,