work on site finder and fixed friend adding

master
Kevin Froman 2019-09-29 15:39:03 -05:00
parent 0067bd36b5
commit b42c0a79a1
5 changed files with 42 additions and 8 deletions

View File

@ -61,6 +61,7 @@ def onionr_main():
if __name__ == "__main__": if __name__ == "__main__":
onionr_main() onionr_main()
# Cleanup standard out/err because Python refuses to do it itsself
try: try:
sys.stderr.close() sys.stderr.close()
except (IOError, BrokenPipeError) as e: except (IOError, BrokenPipeError) as e:

View File

@ -1,9 +1,9 @@
''' """
Onionr - Private P2P Communication Onionr - Private P2P Communication
view and interact with onionr sites view and interact with onionr sites
''' """
''' """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU 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/>.
''' """
import base64 import base64
import binascii import binascii

View File

@ -1,10 +1,39 @@
"""
Onionr - Private P2P Communication
view and interact with onionr sites
"""
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from typing import Union
import onionrexceptions import onionrexceptions
from onionrutils import mnemonickeys from onionrutils import mnemonickeys
from onionrutils import stringvalidators from onionrutils import stringvalidators
from coredb import blockmetadb
from onionrblocks.onionrblockapi import Block
def find_site(user_id: str)->str: def find_site(user_id: str)->Union[str, None]:
"""Returns block hash string for latest block for a site by a given user id"""
if '-' in user_id: user_id = mnemonickeys.get_base32(user_id) if '-' in user_id: user_id = mnemonickeys.get_base32(user_id)
if not stringvalidators.validate_pub_key(user_id): raise onionrexceptions.InvalidPubkey if not stringvalidators.validate_pub_key(user_id): raise onionrexceptions.InvalidPubkey
found_site = None
sites = blockmetadb.get_blocks_by_type('zsite')
#for for site in sites:
site = Block(site)
if site.isSigner(user_id) and site.verifySig():
found_site = site.hash
return found_site

View File

@ -0,0 +1,4 @@
import zipfile
def get_zip_site_file(path):
with zipfile.ZipFile(zip_file, 'r') as zf:
for member in zf.infolist():

View File

@ -27,7 +27,7 @@ import mnemonic
class ContactManager(onionrusers.OnionrUser): class ContactManager(onionrusers.OnionrUser):
def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5): def __init__(self, publicKey, saveUser=False, recordExpireSeconds=5):
try: try:
if " " in publicKey: if "-" in publicKey:
publicKey = mnemonic.Mnemonic('english').to_entropy(publicKey) publicKey = mnemonic.Mnemonic('english').to_entropy(publicKey)
publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey)) publicKey = unpaddedbase32.b32encode(bytesconverter.str_to_bytes(publicKey))
except ValueError: except ValueError: