diff --git a/docker/Dockerfile.tails-server b/docker/Dockerfile.tails-server index 82b923d..238dea5 100644 --- a/docker/Dockerfile.tails-server +++ b/docker/Dockerfile.tails-server @@ -1,4 +1,4 @@ -FROM bcgovimages/von-image:next-1 +FROM bcgovimages/von-image:next-2 ADD requirements.txt . ADD requirements.dev.txt . @@ -13,5 +13,8 @@ ADD setup.py ./ RUN pip3 install --no-cache-dir -e . +# delete old indy_vdr installed in von-image, use instead the python package (see requirements.txt) which includes libindy_vdr.so +RUN rm -rf /home/indy/.local/lib/libindy_vdr.so + ENTRYPOINT ["/bin/bash", "-c", "tails-server \"$@\""] diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index d6dc7af..befee34 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -1,4 +1,4 @@ -FROM bcgovimages/von-image:next-1 +FROM bcgovimages/von-image:next-2 ADD requirements.txt . ADD requirements.dev.txt . @@ -8,4 +8,7 @@ RUN pip3 install --no-cache-dir -r requirements.txt -r requirements.dev.txt ADD test ./ +# delete old indy_vdr installed in von-image, use instead the python package (see requirements.txt) which includes libindy_vdr.so +RUN rm -rf /home/indy/.local/lib/libindy_vdr.so + ENTRYPOINT ["python", "integration.py"] diff --git a/requirements.txt b/requirements.txt index 73fcc56..37aaa11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -aiohttp==3.7.4 +aiohttp==3.8.1 base58 +indy-vdr~=0.3.4 # temporary to fix transitive dependency issues multidict<5.0.0 -yarl==1.6.0 \ No newline at end of file +yarl==1.7.2 \ No newline at end of file diff --git a/tails_server/args.py b/tails_server/args.py index 9fce165..6290ccf 100644 --- a/tails_server/args.py +++ b/tails_server/args.py @@ -51,6 +51,20 @@ help="Specify the path to store files.", ) +PARSER.add_argument( + "--socks-proxy", + type=str, + required=False, + dest="socks_proxy", + metavar=":", + help=( + "Specifies the socks proxy (NOT http proxy) hostname and port in format " + "'hostname:port'. This is an optional parameter to be passed to ledger " + "pool configuration and ZMQ in case if tails-server is running " + "in a corporate/private network behind a corporate proxy and will " + "connect to the public (outside of corporate network) ledger pool" + ), +) def get_settings(): """Convert command line arguments to a settings dictionary.""" @@ -65,5 +79,6 @@ def get_settings(): settings["log_level"] = args.log_level settings["storage_path"] = args.storage_path + settings["socks_proxy"] = args.socks_proxy return settings diff --git a/tails_server/ledger.py b/tails_server/ledger.py index fd4ef06..9eaec5c 100644 --- a/tails_server/ledger.py +++ b/tails_server/ledger.py @@ -16,7 +16,7 @@ class BadRevocationRegistryIdError(Exception): pass -async def get_rev_reg_def(genesis_txn_bytes, rev_reg_id, storage_path): +async def get_rev_reg_def(genesis_txn_bytes, rev_reg_id, storage_path, socks_proxy = None): pool = None try: # Write the genesis transactions to the file system @@ -26,7 +26,7 @@ async def get_rev_reg_def(genesis_txn_bytes, rev_reg_id, storage_path): tmp_file.seek(0) # Try to connect to ledger try: - pool = await indy_vdr.open_pool(transactions_path=tmp_file.name) + pool = await indy_vdr.open_pool(transactions_path=tmp_file.name, socks_proxy=socks_proxy) except indy_vdr.error.VdrError as e: if e.code == indy_vdr.VdrErrorCode.INPUT: raise BadGenesisError() diff --git a/tails_server/web.py b/tails_server/web.py index d6dd313..3d00902 100644 --- a/tails_server/web.py +++ b/tails_server/web.py @@ -60,6 +60,7 @@ async def get_file(request): @routes.put("/{revocation_reg_id}") async def put_file(request): storage_path = request.app["settings"]["storage_path"] + socks_proxy = request.app["settings"]["socks_proxy"] # Check content-type for multipart content_type_header = request.headers.get("Content-Type") @@ -82,7 +83,7 @@ async def put_file(request): revocation_reg_id = request.match_info["revocation_reg_id"] try: revocation_registry_definition = await get_rev_reg_def( - genesis_txn_bytes, revocation_reg_id, storage_path + genesis_txn_bytes, revocation_reg_id, storage_path, socks_proxy ) except BadGenesisError: LOGGER.debug(f"Received invalid genesis transactions")