From 76356d5e3fa2df40551bc3902863f5fafc725ad3 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 7 Aug 2019 17:46:57 -0500 Subject: [PATCH] added some more readmes --- onionr/apiservers/README.md | 9 +++++++++ onionr/apiservers/private/README.md | 8 ++++++++ onionr/apiservers/private/__init__.py | 2 +- onionr/communicator/README.md | 4 ++-- onionr/communicator/onlinepeers/README.md | 12 ++++++++++++ onionr/communicator/onlinepeers/pickonlinepeers.py | 10 +++++----- 6 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 onionr/apiservers/README.md create mode 100644 onionr/apiservers/private/README.md create mode 100644 onionr/communicator/onlinepeers/README.md diff --git a/onionr/apiservers/README.md b/onionr/apiservers/README.md new file mode 100644 index 00000000..3a439ac3 --- /dev/null +++ b/onionr/apiservers/README.md @@ -0,0 +1,9 @@ +# API Servers + +Contains the WSGI servers Onionr uses for remote peer communication and local daemon control + +## Files + +* \_\_init\_\_.py: Exposes the server classes +* private: Contains the client API (the server used to interact with the local Onionr daemon, and view the web UI) +* public: Contains the public API (the server used by remote peers to talk to our daemon) \ No newline at end of file diff --git a/onionr/apiservers/private/README.md b/onionr/apiservers/private/README.md new file mode 100644 index 00000000..95b785eb --- /dev/null +++ b/onionr/apiservers/private/README.md @@ -0,0 +1,8 @@ +# Private API Server + +Private API server, used to access the web interface locally and control Onionr + +## Files + +* \_\_init\_\_.py: Sets up the server and a few misc functions +* register_private_blueprints.py: Adds in flask blueprints for various sub-APIs \ No newline at end of file diff --git a/onionr/apiservers/private/__init__.py b/onionr/apiservers/private/__init__.py index adeda677..b413ac91 100644 --- a/onionr/apiservers/private/__init__.py +++ b/onionr/apiservers/private/__init__.py @@ -72,7 +72,7 @@ class PrivateAPI: ''' Validate that the client token matches the given token. Used to prevent CSRF and data exfiltration ''' - if len(self.clientToken) == 0: + if not self.clientToken: logger.error("client password needs to be set") return False try: diff --git a/onionr/communicator/README.md b/onionr/communicator/README.md index 941f3642..9925f247 100644 --- a/onionr/communicator/README.md +++ b/onionr/communicator/README.md @@ -5,11 +5,11 @@ Onionr communicator is the Onionr client. It "connects" to remote Onionr peers a * Finding new peers * Uploading blocks * Downloading blocks -* Daemon maintnence/housekeeping +* Daemon maintenance/housekeeping ## Files * \_\_init\_\_.py: Contains the main communicator code. Inits and launches the communicator and sets up the timers * peeraction.py: contains a function to send commands to remote peers * bootstrappers.py: adds peers from the bootstrap list to the communicator to try to connect to them -* onlinepers: management of the online peer pool for the communicator \ No newline at end of file +* onlinepeers: management of the online peer pool for the communicator \ No newline at end of file diff --git a/onionr/communicator/onlinepeers/README.md b/onionr/communicator/onlinepeers/README.md new file mode 100644 index 00000000..fe56995f --- /dev/null +++ b/onionr/communicator/onlinepeers/README.md @@ -0,0 +1,12 @@ +# Online Peers + +Manages a pool of peers to perform actions with. Since Onionr does not maintain socket connections, it holds a list of peers. + + +## Files + +* \_\_init\_\_.py: exposes some functions to interact with the pool +* clearofflinepeer.py: Pop the oldest peer in the offline list +* onlinepeers.py: communicator timer to add new peers to the pool randomly +* pickonlinepeers.py: returns a random peer from the online pool +* removeonlinepeer.py: removes a specified peer from the online pool \ No newline at end of file diff --git a/onionr/communicator/onlinepeers/pickonlinepeers.py b/onionr/communicator/onlinepeers/pickonlinepeers.py index 8eb6b7ec..5fdcc08e 100644 --- a/onionr/communicator/onlinepeers/pickonlinepeers.py +++ b/onionr/communicator/onlinepeers/pickonlinepeers.py @@ -20,16 +20,16 @@ import secrets def pick_online_peer(comm_inst): '''randomly picks peer from pool without bias (using secrets module)''' - retData = '' + ret_data = '' while True: - peerLength = len(comm_inst.onlinePeers) - if peerLength <= 0: + peer_length = len(comm_inst.onlinePeers) + if peer_length <= 0: break try: # get a random online peer, securely. May get stuck in loop if network is lost or if all peers in pool magically disconnect at once - retData = comm_inst.onlinePeers[secrets.randbelow(peerLength)] + ret_data = comm_inst.onlinePeers[secrets.randbelow(peer_length)] except IndexError: pass else: break - return retData \ No newline at end of file + return ret_data \ No newline at end of file