aws-samples / aws-iot-securetunneling-localproxy

AWS Iot Secure Tunneling local proxy reference C++ implementation
https://docs.aws.amazon.com/iot/latest/developerguide/what-is-secure-tunneling.html
Apache License 2.0
77 stars 72 forks source link

localproxy does not allow multiple services #40

Closed robertsarkozi closed 3 years ago

robertsarkozi commented 3 years ago

Hello,

As per the AWS documentation I should be able to achieve this scenario, in cli mode (points 4b and 5b): https://docs.aws.amazon.com/iot/latest/developerguide/multiplexing.html I should be able to add more than one service when starting the localproxy either in destination or source mode.

What I get is the following error: Invalid endpoint specified. This is because the get_host_and_port function clearly parses only one specified service.

How can I achieve what the documentation states via cli?

Thanks

kareali commented 3 years ago

Hi Robert, Which branch did you use to build the localproxy? And could you share the exact command you rand and the output?

MiaoZhangAWS commented 3 years ago

To add on, can you enable trace level output by specifying -v 6 when start local proxy? Explanation on this argument can be found in -v/--verbose.

robertsarkozi commented 3 years ago

Hello,

Thanks for the quick responses.

I didn't manually build the localproxy. I'm using the demo in this page: https://docs.aws.amazon.com/iot/latest/developerguide/secure-tunneling-demo.html. Actually, I forked it because I want to try ssh service with http, so I started to change it according to the documentation.

It works if I switch from ssh to http in all the related files (run-dest-demo.sh, index.js, bin/tunnel/create.sh), but when I add both, I get the error I posted.

The run-dest-demo.sh script fails if I add both services, because I changed it from 'localhost:22' to 'localhost:22,localhost:80' or 'SSH1=22,HTTP1=80' (in this case I change the other files accordingly).

Maybe the demo contains and older version of localproxy? Even so, if I look at the code in the master branch/main.cpp, the function I mentioned doesn't allow two services to be specified in cli.

kareali commented 3 years ago

You're welcome! and You're also correct, the demo repo has not been updated yet to include the latest localproxy binary.

The latest commit does though, like this for example:

./localproxy -r us-east-1 -d HTTP1=80,SSH1=22 -t destination_client_access_token

you can find more examples on how to use it in this tutorial

robertsarkozi commented 3 years ago

Thanks,

Well, yes, that's the link by which I was trying to change the tutorial to have two services.

I will then open an issue on the tutorial github page for it to be updated, and try to build it myself...

robertsarkozi commented 3 years ago

If I'm correct, there is a pull request for updating the demo repo with the latest localproxy changes: https://github.com/aws-samples/iot-secure-tunneling-demo/pull/9

Can this be approved and merged, @KareemAliAWS?

kareali commented 3 years ago

@robertsarkozi they are still pending review.

kareali commented 3 years ago

@robertsarkozi FYI: The PRs have merged