From c185b0b02a3389360534123dc8d63d2b5f295763 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Mon, 5 Oct 2020 04:09:49 +0000 Subject: [PATCH] basic peer and block sync finished, torcheck added --- hacker.png | Bin 399 -> 0 bytes hush-hush.js | 66 ++++++++++++++++++++++++++++++++++++++++------ index.html | 47 +++++++++++++++++++++++---------- marked.min.js | 6 +++++ peer-lookup.js | 16 ++++++++--- style.css | 7 +++++ tordetect.js | 8 ++++++ worker-handler.js | 10 +++++-- 8 files changed, 132 insertions(+), 28 deletions(-) delete mode 100644 hacker.png create mode 100644 marked.min.js create mode 100644 style.css create mode 100644 tordetect.js diff --git a/hacker.png b/hacker.png deleted file mode 100644 index 5a2e1850f017f2b23c8628ba65cb6a46c3cf19d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 399 zcmV;A0dW3_P)IWd0001HP)t-sW@cvp z|NrIX 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } +} +//https://stackoverflow.com/q/10420352 +function getReadableFileSizeString(fileSizeInBytes) { + var i = -1; + var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']; + do { + fileSizeInBytes = fileSizeInBytes / 1024; + i++; + } while (fileSizeInBytes > 1024); + + return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i]; +}; + +setInterval(function(){shuffleArray(publicNodes)}, 5000) + // Make Tor connect to each node to reduce future connection time publicNodes.forEach(element => { @@ -40,7 +66,7 @@ function addMessage(message, timestamp){ let newEl = tmpl.content.cloneNode(true) newEl.children[0].children[0].children[0].innerText = message - newEl.children[0].children[0].children[1].innerText = timestamp + newEl.children[0].children[0].children[2].innerText = timestamp document.getElementsByClassName("messageFeed")[0].append(newEl) } @@ -59,16 +85,40 @@ async function apiGET(path, queryString, raw=false){ } async function findMessages(){ + if (document.hidden){ + setTimeout(function(){findMessages()}, 1000) + return + } let messages = (await apiGET("getblocklist", "?type=brd")).split('\n') messages.forEach(block => { - if (! block){return} - if (block in blocks){return} + block = reconstructHash(block) + if (!block.startsWith(difficulty)){console.debug("not difficulty reached:" + block); return} + + if (blocks.includes(block)){return} apiGET("getdata", "/" + block, raw=false).then(function(d){ - let metadata = d.split("\n")[0] + let updateMemoryUsage = function(data, block){ + let current = parseInt(document.getElementById('memUsage').innerText) + // Size is size of data (not metadata) and block hash + document.getElementById('memUsage').innerText = getReadableFileSizeString(current + ((basicTextEncoder.encode(data)).length + block.length)) + } + + try{ + verifyBlock(d, block) + verifyTime() + } + catch(e){ + console.debug(block + ":" + e) + } + + let metadata = JSON.parse(d.split("\n")[0]) + console.debug(metadata) let data = d.split('\n')[1] - blocks[block] = data + blocks.push(block) + addMessage(data, new Date(metadata['time'])) + updateMemoryUsage(data, block) }) }) + setTimeout(function(){findMessages()}, findMessageIntervalTime) } -setInterval(function(){findMessages()}, findMessageIntervalTime) \ No newline at end of file +setTimeout(function(){findMessages()}, findMessageIntervalTime) \ No newline at end of file diff --git a/index.html b/index.html index b2e792d..c08c9ec 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - hush-hush + kiccan @@ -11,32 +11,52 @@ - - + + + - +

- hush-hush + kiccan

- Anonymous decentralized message board 🤫 + anonymous decentralized message board 🌐 + +

- -

ℹ️ hush-hush is a message board program that utilizes the Onionr network.

-

⚠️ Posts are rate-limited using a partial hash collision proof of work function.

-

⏲️ The host of this web page has no control over posts. Browse and post at your own risk.

- - - + +

kiccan is a message board program that utilizes the Onionr network.

+

⏲️posts are rate-limited using a partial hash collision proof of work function.

+

⚠️ the host of this web page has no control over posts. Browse and post at your own risk.

+

post memory usage: 0kb

+
+
+
+
+
+
+ +
+
+
+
+
+
+ +