Skip to content

Commit

Permalink
adding option for host port
Browse files Browse the repository at this point in the history
  • Loading branch information
rsurgiewicz committed Nov 10, 2021
1 parent 721224a commit 8edfc41
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions jprq/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def main():
@click.argument('port')
@click.option('-s', '--subdomain', default='')
@click.option('--host', default='open.jprq.io')
@click.option('--hostport', default='80')
def http(**kwargs):
host = kwargs['host']
port = kwargs['port']
hostport = kwargs['hostport']
username = kwargs['subdomain'] or getuser()

print(f"\n\033[1;35mjprq : {__version__}\033[00m \033[34m{'Press Ctrl+C to quit.':>60}\n")
Expand All @@ -29,7 +31,7 @@ def http(**kwargs):
try:
loop.run_until_complete(
open_http_tunnel(
ws_uri=f'wss://{host}/_ws/?username={username}&port={port}&version={__version__}',
ws_uri=f'wss://{host}:{hostport}/_ws/?username={username}&port={port}&version={__version__}',
http_uri=f'http://127.0.0.1:{port}',
)
)
Expand All @@ -40,16 +42,18 @@ def http(**kwargs):
@main.command()
@click.argument('port', type=click.INT)
@click.option('--host', default='tcp.jprq.io')
@click.option('--hostport', default='80')
def tcp(**kwargs):
host = kwargs['host']
hostport = kwargs['hostport']
port = kwargs['port']

print(f"\n\033[1;35mjprq : {__version__}\033[00m \033[34m{'Press Ctrl+C to quit.':>60}\n")

loop = asyncio.get_event_loop()
try:
loop.run_until_complete(
open_tcp_tunnel(remote_server_host=host, ws_uri=f'wss://{host}/_ws/', local_server_port=port)
open_tcp_tunnel(remote_server_host=host, ws_uri=f'wss://{host}:{hostport}/_ws/', local_server_port=port)
)
except KeyboardInterrupt:
print("\n\033[31mjprq tunnel closed\033[00m")
Expand Down

0 comments on commit 8edfc41

Please sign in to comment.