From bb6ce10985fe7d96a8cf7d3b244b810e1379c85f Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Fri, 16 Aug 2019 16:28:54 -0500 Subject: [PATCH] Added thread call to create client service from web interface endpoint made create_client in onionrservices static --- onionr/httpapi/directconnections/__init__.py | 7 ++++++- onionr/onionrservices/__init__.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/onionr/httpapi/directconnections/__init__.py b/onionr/httpapi/directconnections/__init__.py index 02c5595e..39fb31e5 100644 --- a/onionr/httpapi/directconnections/__init__.py +++ b/onionr/httpapi/directconnections/__init__.py @@ -17,10 +17,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' -from flask import Response, Blueprint +import threading + +from flask import Response +from flask import Blueprint import deadsimplekv import filepaths +import onionrservices class DirectConnectionManagement: def __init__(self, client_api): @@ -46,5 +50,6 @@ class DirectConnectionManagement: """Spawn a thread that will create the client and eventually add it to the communicator.active_services """ + threading.Thread(target=onionrservices.OnionrServices().create_client, args=[pubkey, communicator]).start() return Response(resp) \ No newline at end of file diff --git a/onionr/onionrservices/__init__.py b/onionr/onionrservices/__init__.py index 8b7cff99..a6a44d90 100755 --- a/onionr/onionrservices/__init__.py +++ b/onionr/onionrservices/__init__.py @@ -52,7 +52,8 @@ class OnionrServices: else: return False - def create_client(self, peer, comm_inst=None): + @staticmethod + def create_client(peer, comm_inst=None): # Create ephemeral onion service to bootstrap connection address = bootstrapservice.bootstrap_client_service(peer) if not comm_inst is None: