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
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
var findMessageIntervalTime = 5000
|
||||
var publicNodes = [
|
||||
"y7odk7elskeyfpgngqfy4xn3vawyrdmn7a4aqock44ksmlnwi4pxcbad"
|
||||
"4gh2dwbmlrombeoyco55un7kbej7trsuebxfzvo53h6uj5adseceduyd"
|
||||
]
|
||||
var messageHashes = []
|
||||
var blocks = {}
|
||||
|
||||
// Make Tor connect to each node to reduce future connection time
|
||||
publicNodes.forEach(element => {
|
||||
@ -42,11 +44,14 @@ function addMessage(message, timestamp){
|
||||
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)
|
||||
|
||||
if (response.ok) { // if HTTP-status is 200-299
|
||||
// get the response body (the method explained below)
|
||||
if (raw){
|
||||
return await response.blob()
|
||||
}
|
||||
return await response.text()
|
||||
} else {
|
||||
console.debug("HTTP-Error: " + response.status)
|
||||
@ -57,10 +62,13 @@ async function findMessages(){
|
||||
let messages = (await apiGET("getblocklist", "?type=brd")).split('\n')
|
||||
messages.forEach(block => {
|
||||
if (! block){return}
|
||||
apiGET("getdata", "/" + block).then(function(d){
|
||||
console.debug(d)
|
||||
if (block in blocks){return}
|
||||
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>⚠️ 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>
|
||||
<img src="vanilla.png" alt="this website uses vanilla JS" aria-hidden="true">
|
||||
<img src="hacker.png" alt="hacker" aria-hidden="true">
|
||||
<img src="copyleft.png" alt="GNU" 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" loading="lazy">
|
||||
<img src="copyleft.png" alt="GNU" aria-hidden="true" loading="lazy">
|
||||
</div>
|
||||
</section>
|
||||
<div class="container messageFeed">
|
||||
|
@ -19,12 +19,11 @@
|
||||
|
||||
self.addEventListener('message', function(e) {
|
||||
let lookupPeer = async function(peer){
|
||||
console.log("looking up on " + peer)
|
||||
//return await fetch("")
|
||||
let newList = await fetch('http://')
|
||||
}
|
||||
var data = JSON.parse(e.data)
|
||||
|
||||
let peers = data['nodeList'][0]
|
||||
let peers = data['nodeList']
|
||||
lookupPeer(peers)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user