baisc block downloading finished
This commit is contained in:
parent
207188b041
commit
329d296df3
18
hush-hush.js
18
hush-hush.js
@ -15,10 +15,12 @@
|
|||||||
You should have received a copy of the GNU Affero General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
var findMessageIntervalTime = 5000
|
||||||
var publicNodes = [
|
var publicNodes = [
|
||||||
"y7odk7elskeyfpgngqfy4xn3vawyrdmn7a4aqock44ksmlnwi4pxcbad"
|
"4gh2dwbmlrombeoyco55un7kbej7trsuebxfzvo53h6uj5adseceduyd"
|
||||||
]
|
]
|
||||||
var messageHashes = []
|
var messageHashes = []
|
||||||
|
var blocks = {}
|
||||||
|
|
||||||
// Make Tor connect to each node to reduce future connection time
|
// Make Tor connect to each node to reduce future connection time
|
||||||
publicNodes.forEach(element => {
|
publicNodes.forEach(element => {
|
||||||
@ -42,11 +44,14 @@ function addMessage(message, timestamp){
|
|||||||
document.getElementsByClassName("messageFeed")[0].append(newEl)
|
document.getElementsByClassName("messageFeed")[0].append(newEl)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function apiGET(path, queryString){
|
async function apiGET(path, queryString, raw=false){
|
||||||
let response = await fetch("http://" + getCurrentNode() + ".onion/" + encodeURIComponent(path) + queryString)
|
let response = await fetch("http://" + getCurrentNode() + ".onion/" + encodeURIComponent(path) + queryString)
|
||||||
|
|
||||||
if (response.ok) { // if HTTP-status is 200-299
|
if (response.ok) { // if HTTP-status is 200-299
|
||||||
// get the response body (the method explained below)
|
// get the response body (the method explained below)
|
||||||
|
if (raw){
|
||||||
|
return await response.blob()
|
||||||
|
}
|
||||||
return await response.text()
|
return await response.text()
|
||||||
} else {
|
} else {
|
||||||
console.debug("HTTP-Error: " + response.status)
|
console.debug("HTTP-Error: " + response.status)
|
||||||
@ -57,10 +62,13 @@ async function findMessages(){
|
|||||||
let messages = (await apiGET("getblocklist", "?type=brd")).split('\n')
|
let messages = (await apiGET("getblocklist", "?type=brd")).split('\n')
|
||||||
messages.forEach(block => {
|
messages.forEach(block => {
|
||||||
if (! block){return}
|
if (! block){return}
|
||||||
apiGET("getdata", "/" + block).then(function(d){
|
if (block in blocks){return}
|
||||||
console.debug(d)
|
apiGET("getdata", "/" + block, raw=false).then(function(d){
|
||||||
|
let metadata = d.split("\n")[0]
|
||||||
|
let data = d.split('\n')[1]
|
||||||
|
blocks[block] = data
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
findMessages()
|
setInterval(function(){findMessages()}, findMessageIntervalTime)
|
@ -32,9 +32,9 @@
|
|||||||
<p>ℹ️ hush-hush is a message board program that utilizes the Onionr network.</p>
|
<p>ℹ️ hush-hush is a message board program that utilizes the Onionr network.</p>
|
||||||
<p>⚠️ Posts are rate-limited using a partial hash collision proof of work function.</p>
|
<p>⚠️ Posts are rate-limited using a partial hash collision proof of work function.</p>
|
||||||
<p>⏲️ The host of this web page has no control over posts. Browse and post at your own risk.</p>
|
<p>⏲️ The host of this web page has no control over posts. Browse and post at your own risk.</p>
|
||||||
<img src="vanilla.png" alt="this website uses vanilla JS" aria-hidden="true">
|
<img src="vanilla.png" alt="this website uses vanilla JS" aria-hidden="true" loading="lazy">
|
||||||
<img src="hacker.png" alt="hacker" aria-hidden="true">
|
<img src="hacker.png" alt="hacker" aria-hidden="true" loading="lazy">
|
||||||
<img src="copyleft.png" alt="GNU" aria-hidden="true">
|
<img src="copyleft.png" alt="GNU" aria-hidden="true" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<div class="container messageFeed">
|
<div class="container messageFeed">
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
|
|
||||||
self.addEventListener('message', function(e) {
|
self.addEventListener('message', function(e) {
|
||||||
let lookupPeer = async function(peer){
|
let lookupPeer = async function(peer){
|
||||||
console.log("looking up on " + peer)
|
let newList = await fetch('http://')
|
||||||
//return await fetch("")
|
|
||||||
}
|
}
|
||||||
var data = JSON.parse(e.data)
|
var data = JSON.parse(e.data)
|
||||||
|
|
||||||
let peers = data['nodeList'][0]
|
let peers = data['nodeList']
|
||||||
lookupPeer(peers)
|
lookupPeer(peers)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user