Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support socks proxy #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docker/Dockerfile.tails-server
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bcgovimages/von-image:next-1
FROM bcgovimages/von-image:next-2

ADD requirements.txt .
ADD requirements.dev.txt .
Expand All @@ -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 \"$@\""]

5 changes: 4 additions & 1 deletion docker/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM bcgovimages/von-image:next-1
FROM bcgovimages/von-image:next-2

ADD requirements.txt .
ADD requirements.dev.txt .
Expand All @@ -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"]
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
yarl==1.7.2
15 changes: 15 additions & 0 deletions tails_server/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
help="Specify the path to store files.",
)

PARSER.add_argument(
"--socks-proxy",
type=str,
required=False,
dest="socks_proxy",
metavar="<host>:<port>",
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."""
Expand All @@ -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
4 changes: 2 additions & 2 deletions tails_server/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion tails_server/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down