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
73 stars 69 forks source link

Proxy endpoint with path enhancement #146

Open jaiswal-sumit opened 7 months ago

jaiswal-sumit commented 7 months ago

Motivation

Example: subdomain based routing: tenant-datatunnel.ourdomain.com request will be routed to data.tunneling.iot.eu-west-1.amazonaws.com subpath based routing: ourdomain.com/tenant-datatunnel request will be routed to data.tunneling.iot.eu-west-1.amazonaws.com

we found subpath based routing does works with localproxy as it tries to bind HOST with complete url to 443 [info] Attempting to establish web socket connection with endpoint wss://ourdomain.com/tenant-datatunnel:443

Hence this PR is to enhance localproxy code so it can work with subpath based request and for this added new arg variable (-p [ --endpoint-path ] arg (=/tunnel) ) ./localproxy -d 22 -v 6 -e ourdomain.com -p "/tenant-datatunnel/tunnel" With this it able to bind HOST correctly like this wss://ourdomain.com:443 and make call to GET /tenant-datatunnel/tunnel?local-proxy-mode=source HTTP/1.1 to the HOST

This change will work for all types of connection and does not contain any breaking change. -p is Made option with default value of "/tunnel".

Modifications

Change summary

3 files are modified. main.cpp to handle -p argument value LocalProxyConfig.h to carry path value TcpAdapterProxy.cpp to use path variable for making GET call to service

Testing

**Is your change tested? Yes, tested with following commands arguments for both source and destination

 -v 6 -e ourdomain.com -p "/tenant-datatunnel/tunnel"
-v 6 -e tenant-datatunnel.ourdomain.com
-v 6 -r eu-west-1

Please list your testing steps and test results.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jaiswal-sumit commented 7 months ago

@HarshGandhi-AWS & @RogerZhongAWS please check this enhancement. this is working in our integration test and need for our customer to use in this way. As mentioned in detail description it does not break any functionality and in normal condition it works well. @abeytr Kindly put your notes on integration test result.