From 1e32446f2ad09887945a7207c0a3e37080417087 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 25 Apr 2018 01:56:40 -0500 Subject: [PATCH] fixed self issue --- docs/onionr-draft.md | 8 +++++++- onionr/api.py | 11 +++++++++++ onionr/onionrcrypto.py | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/onionr-draft.md b/docs/onionr-draft.md index 5ab91cb0..acce39e7 100644 --- a/docs/onionr-draft.md +++ b/docs/onionr-draft.md @@ -24,7 +24,13 @@ All traffic is over Tor/I2P, connecting only to Tor onion and I2P hidden service Onionr nodes use HTTP (over Tor/I2P) to exchange keys, metadata, and blocks. Blocks are identified by their sha3_256 hash. Nodes sync a table of blocks hashes and attempt to download blocks they do not yet have from random peers. -Blocks may be encrypted using Curve25519. +Blocks may be encrypted using Curve25519 or Salsa20. + +Blocks have IDs in the following format: + +-Optional hash of public key of publisher (base64)-optional signature (non-optional if publisher is specified) (Base64)-block type-block hash(sha3-256) + +pubkeyHash-signature-type-hash ## Connections diff --git a/onionr/api.py b/onionr/api.py index b68326d0..f8715366 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -161,6 +161,17 @@ class API: time.sleep(self._privateDelayTime - elapsed) return resp + + @app.route('/') + def banner(): + self.mimeType = 'text/html' + self.validateHost('public') + try: + with open('static-data/index.html', 'r') as html: + resp = Response(html.read()) + except FileNotFoundError: + resp = Response("") + return resp @app.route('/public/') def public_handler(): diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index 5f462b51..8f212f0e 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -174,8 +174,10 @@ class OnionrCrypto: public_key = private_key.verify_key.encode(encoder=nacl.encoding.Base32Encoder()) return (public_key.decode(), private_key.encode(encoder=nacl.encoding.Base32Encoder()).decode()) - def pubKeyHashID(self, pubkey=self.pubKey): + def pubKeyHashID(self, pubkey=''): '''Accept a ed25519 public key, return a truncated result of X many sha3_256 hash rounds''' + if pubkey == '': + pubkey = self.pubKey prev = '' pubkey = pubkey.encode() for i in range(self.HASH_ID_ROUNDS):