From 6ce1c347ae8a43041beba1e0dbd4d99b92fa0441 Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Wed, 23 Sep 2020 13:18:01 -0600 Subject: [PATCH] Make host and port separate arguments --- README.md | 6 +++--- sirtunnel.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0319eae..dd770fe 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you have: And you run the following command on your laptop: ```bash -ssh -tR 9001:localhost:8080 example.com sirtunnel.py sub1.example.com:9001 +ssh -tR 9001:localhost:8080 example.com sirtunnel.py sub1.example.com 9001 ``` Now any requests to `https://sub.example.com` will be proxied to your local @@ -30,8 +30,8 @@ The command above does 2 things: 1. It starts a standard [remote SSH tunnel][2] from the server port 9001 to local port 8080. -2. It runs the command `sirtunnel.py sub1.example.com:9001` on the server. - The python script parses `sub1.example.com:9001` and uses the Caddy API to +2. It runs the command `sirtunnel.py sub1.example.com 9001` on the server. + The python script parses `sub1.example.com 9001` and uses the Caddy API to reverse proxy `sub1.example.com` to port 9001 on the server. Caddy automatically retrieves an HTTPS cert for `sub1.example.com`. diff --git a/sirtunnel.py b/sirtunnel.py index 8562d69..40c15f6 100755 --- a/sirtunnel.py +++ b/sirtunnel.py @@ -8,8 +8,9 @@ from urllib import request if __name__ == '__main__': - tunnel_id = sys.argv[1] - host, port = tunnel_id.split(':') + host = sys.argv[1] + port = sys.argv[2] + tunnel_id = host + '-' + port caddy_add_route_request = { "@id": tunnel_id,