diff --git a/hush-hush.js b/hush-hush.js
index 6f90857..cf292fe 100644
--- a/hush-hush.js
+++ b/hush-hush.js
@@ -17,8 +17,8 @@
*/
var findMessageIntervalTime = 5000
var publicNodes = [
- "67xpi7z753tbmylc7etrifjxqeyizoiqg6n7p5we6e4nblit5bqenqad",
- "mpidhsfpmdgxxc5ygqluwtxptgne5swp5nkjzdre6tmnent7zqwp3cyd"
+ "4wbarqtxh6zasoxxftakrellcjzztcib7bqth4u3igof5fskrrvrk4yd",
+ "zl67stwxpjkntaxcfdhj3dvayculoojju6eek2jhsrdz6uwf224o6oqd"
]
var messageHashes = []
var blocks = []
@@ -52,8 +52,14 @@ setInterval(function(){shuffleArray(publicNodes)}, 5000)
// Make Tor connect to each node to reduce future connection time
-publicNodes.forEach(element => {
- fetch("http://" + element + ".onion/ping")
+publicNodes.forEach(node => {
+ let doPing = async function(){
+ let res = await(await fetch("http://" + node + ".onion/ping")).text()
+ if (res !== "pong!"){
+ console.debug(node)
+ }
+ }
+ doPing()
})
function getCurrentNode(){
@@ -65,22 +71,39 @@ function getCurrentNode(){
}
function addMessage(message, timestamp){
+ function sortEntries() {
+ var entries = document.getElementsByClassName('entry')
+
+ if (entries.length > 1) {
+ const sortBy = 'data-epoch'
+ const parent = entries[0].parentNode
+
+ const sorted = Array.from(entries).sort((a, b) => b.getAttribute(sortBy) - a.getAttribute(sortBy))
+ sorted.forEach(element => parent.appendChild(element))
+ }
+ }
+
message = DOMPurify.sanitize(marked(message),
{FORBID_ATTR: ['style'],
- ALLOWED_TAGS: ['b', 'p', 'em', 'i', 'a',
+ ALLOWED_TAGS: ['b', 'p', 'em', 'i', 'a', 'strong', 'sub', 'small', 'ul', 'li', 'ol', 'strike',
+ 'tr', 'td', 'th', 'table', 'thead', 'tfoot', 'colgroup', 'col', 'caption', 'marquee',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'center', 'br', 'hr']})
let childEl = document.createElement('div')
childEl.classList.add('content')
childEl.innerHTML = message
var tmpl = document.getElementById("cMsgTemplate")
+ timestamp = timestamp.toString()
let newEl = tmpl.content.cloneNode(true)
+ newEl.children[0].setAttribute('data-epoch', timestamp)
+ newEl.children[0].classList.add("entry")
newEl.children[0].children[0].children[0].innerText = ""
newEl.children[0].children[0].children[0].append(childEl)
- newEl.children[0].children[0].children[2].innerText = timestamp
+ newEl.children[0].children[0].children[2].innerText = new Date(timestamp * 1000).toString().split('GMT')[0]
document.getElementsByClassName("messageFeed")[0].prepend(newEl)
+ sortEntries()
}
async function apiGET(path, queryString, raw=false){
@@ -102,7 +125,7 @@ async function findMessages(){
setTimeout(function(){findMessages()}, 1000)
return
}
- let messages = (await apiGET("getblocklist", "?type=brd")).split('\n')
+ let messages = (await apiGET("getblocklist", "?type=kic")).split('\n')
messages.forEach(block => {
if (!block) { return}
block = reconstructHash(block)
@@ -127,7 +150,7 @@ async function findMessages(){
return
}
blocks.push(block)
- addMessage(data, new Date(metadata['time'] * 1000))
+ addMessage(data, metadata['time'])
updateMemoryUsage(data, block)
})
})
diff --git a/index.html b/index.html
index 48016b1..36f3d67 100644
--- a/index.html
+++ b/index.html
@@ -39,27 +39,29 @@
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
- You do not seem to be able to reach .onion services. Please use Tor Browser or Brave Browser's private tabs.
+ feed size: 0kb | page size: 289kb
+ You do not seem to be able to reach .onion services. Please use Tor Browser.
-
-
-
-
-
-
Markdown is supported, except for images, styles and scripts.
-
+
+
+
+
+
+
+
Markdown and limited HTML is supported.
+
+
+
+
-
-
-
+
diff --git a/message-creator.js b/message-creator.js
index 6d44e67..7cf5b68 100644
--- a/message-creator.js
+++ b/message-creator.js
@@ -1,16 +1,38 @@
+/*
+ hush-hush: anonymous message board using the onionr network
+ Copyright (C) 2020 Kevin Froman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
document.getElementById("createMessageBtn").onclick = async function(){
+ document.getElementById("createMessageBtn").setAttribute("disabled", true)
let field = document.getElementById("postMessageField")
let payload = {
"metadata": {
'time': Math.floor((Date.now() / 1000)),
- 'meta': JSON.stringify({'type': 'brd', 'ch': 'global'})
+ 'meta': JSON.stringify({'type': 'kic', 'ch': 'global'})
},
"data": field.value,
"difficulty": difficulty.length / 2
}
powWorker.postMessage(JSON.stringify(payload))
+
+ setTimeout(function(){
+ document.getElementById("createMessageBtn").removeAttribute("disabled")
+ }, 3000)
}
powWorker.addEventListener('message', function(e) {
diff --git a/onionr-blocks.js b/onionr-blocks.js
index a64c7d6..e53d47f 100644
--- a/onionr-blocks.js
+++ b/onionr-blocks.js
@@ -1,3 +1,20 @@
+/*
+ hush-hush: anonymous message board using the onionr network
+ Copyright (C) 2020 Kevin Froman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
function reconstructHash(hash){
return hash.padStart(64, 0)
}
diff --git a/powworker.js b/powworker.js
index 3f792e7..28b2271 100644
--- a/powworker.js
+++ b/powworker.js
@@ -1,3 +1,20 @@
+/*
+ hush-hush: anonymous message board using the onionr network
+ Copyright (C) 2020 Kevin Froman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
importScripts("onionr-jspow/index.js")
importScripts("sha3.js")
diff --git a/worker-handler.js b/worker-handler.js
index 5de3bba..4c05347 100644
--- a/worker-handler.js
+++ b/worker-handler.js
@@ -1,7 +1,27 @@
+/*
+ hush-hush: anonymous message board using the onionr network
+ Copyright (C) 2020 Kevin Froman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
var lookupWorker = new Worker('peer-lookup.js');
var powWorker = new Worker("powworker.js")
lookupWorker.addEventListener('message', function(e) {
+ if (publicNodes.includes(e.data)){
+ return
+ }
publicNodes.push(e.data)
}, false);