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

Catch2 upgrade + Fix destination TCP retry loop + documentation updates #161

Merged
merged 15 commits into from
Sep 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/docker-images/base-images/amazonlinux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/p
make install

WORKDIR /home/dependencies
RUN git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git && \
RUN git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
mkdir build && \
cd build && \
Expand Down
2 changes: 1 addition & 1 deletion .github/docker-images/base-images/debian-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/p
make install

WORKDIR /home/dependencies
RUN git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git && \
RUN git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
mkdir build && \
cd build && \
Expand Down
2 changes: 1 addition & 1 deletion .github/docker-images/base-images/fedora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/p
make install

WORKDIR /home/dependencies
RUN git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git && \
RUN git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
mkdir build && \
cd build && \
Expand Down
2 changes: 1 addition & 1 deletion .github/docker-images/base-images/ubi8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/p
make install

WORKDIR /home/dependencies
RUN git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git && \
RUN git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
mkdir build && \
cd build && \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: install Catch2
working-directory: ${{ github.workspace }}
run: |
git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git
git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
$env:Path += ";C:\Program Files\OpenSSL\bin"
- name: Install Catch2
run: |
git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git
git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_TESTS=OFF -DBOOST_PKG_VERSION=1.84.0 -DWIN32_WINNT=0x0601 -DBoost_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH="C:\Boost;C:\Program Files (x86)\Catch2;C:\Program Files (x86)\protobuf;C:\Program Files\OpenSSL" -G "Visual Studio 16 2019" -A x64 ..\
cmake -DBUILD_TESTS=OFF -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION=1.84.0 -DWIN32_WINNT=0x0601 -DBoost_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH="C:\Boost;C:\Program Files (x86)\Catch2;C:\Program Files (x86)\protobuf;C:\Program Files\OpenSSL" -G "Visual Studio 16 2019" -A x64 ..\
msbuild localproxy.vcxproj -p:Configuration=Release
- name: Upload Artifact
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- make
- sudo make install
- cd $TRAVIS_BUILD_DIR
- git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git
- git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git
- cd Catch2
- mkdir -p build
- cd build
Expand Down
34 changes: 23 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set(AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME localproxy)
set(AWS_TUNNEL_LOCAL_PROXY_LIB_NAME lproxy)
project(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} CXX)

option(BUILD_TESTS "Build tests" ON)
option(BUILD_TESTS "Build tests" OFF)
option(LINK_STATIC_OPENSSL "Use static openssl libs" ON)
if(BUILD_TESTS)
set(AWS_TUNNEL_LOCAL_PROXY_TEST_NAME localproxytest)
project(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} CXX)
Expand Down Expand Up @@ -62,16 +63,18 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROJECT_SOURCE_DIR}/resources/Mess
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)

include_directories(${OPENSSL_INCLUDE_DIR})
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} OpenSSL_STATIC_SSL_LIBRARY ${OPENSSL_SSL_LIBRARY})
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} OpenSSL_STATIC_CRYPTO_LIBRARY ${OPENSSL_CRYPTO_LIBRARY})
if(LINK_STATIC_OPENSSL)
include_directories(${OPENSSL_INCLUDE_DIR})
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} OpenSSL_STATIC_SSL_LIBRARY ${OPENSSL_SSL_LIBRARY})
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} OpenSSL_STATIC_CRYPTO_LIBRARY ${OPENSSL_CRYPTO_LIBRARY})
endif()

#########################################
# Test framework dependency #
#########################################
#probably comment out for cross compiler as Catch2 is really just a header library
if(BUILD_TESTS)
find_package(Catch2 REQUIRED)
find_package(Catch2 3 REQUIRED)
endif(BUILD_TESTS)

#########################################
Expand Down Expand Up @@ -102,6 +105,7 @@ if(BUILD_TESTS)
file(GLOB TEST_CODE ${PROJECT_SOURCE_DIR}/test/*.cpp)
set(TEST_SOURCES ${TEST_CODE} ${CORE_SOURCES} ${UTIL_SOURCE})
add_executable(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${TEST_SOURCES})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} Catch2::Catch2WithMain)
endif(BUILD_TESTS)

#libatomic ensured for all platforms except OSX and WINDOWS
Expand All @@ -115,9 +119,13 @@ endif()
include_directories(${PROJECT_SOURCE_DIR}/src)

target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::SSL)
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::Crypto)
### uncomment above 2 lines and remove below 2 lines to link against OpenSSL shared libs
if(LINK_STATIC_OPENSSL)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_SSL_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY})
else()
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::SSL)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::Crypto)
endif()
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_SSL_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${Boost_STATIC_LIBRARIES})
Expand All @@ -127,9 +135,13 @@ set_property(TARGET ${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} APPEND_STRING PROPERTY

if(BUILD_TESTS)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${CMAKE_THREAD_LIBS_INIT})
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::SSL)
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::Crypto)
### uncomment above 2 lines and remove below 2 lines to link against OpenSSL shared libs
if(LINK_STATIC_OPENSSL)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_SSL_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY})
else()
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::SSL)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::Crypto)
endif()
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_SSL_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY})
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Boost_STATIC_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN git clone https://github.com/openssl/openssl.git && \
make all && \
cd /home/dependencies

RUN git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git && \
RUN git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
mkdir build && \
cd build && \
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ This code enables tunneling of a single threaded TCP client / server socket inte

---

## Quick Start for x86 Linux platforms

Install Docker https://docs.docker.com/get-started/get-docker/
`docker run --rm -it --network=host public.ecr.aws/aws-iot-securetunneling-localproxy/ubuntu-bin:amd64-latest`, then populate the missing required parameters.

## Building the local proxy via Docker

### Prerequisites
Expand Down Expand Up @@ -173,11 +178,11 @@ Source install example:
Run the ./Configure command without any arguments to check the available platform configuration options and the documentation here: https://wiki.openssl.org/index.php/Compilation_and_Installation

##### Static vs. Dynamic linking OpenSSL
In the `CMakeLists.txt`, there are marked sections with commented code that when uncommented, allow users to switch between using static vs shared OpenSSL libraries. Choosing to do so is completely optional depending on your own operational requirements. This is following guidance from https://github.com/aws-samples/aws-iot-securetunneling-localproxy/pull/145. The localproxy uses static libs by default
In the `CMakeLists.txt`, we provide a parameter -DLINK_STATIC_OPENSSL which by default is set to ON. You may link against shared libraries on your system by setting the value to OFF. Choosing to do so is completely optional depending on your own operational requirements. This is following guidance from https://github.com/aws-samples/aws-iot-securetunneling-localproxy/pull/145.

#### 5. Download and install Catch2 test framework

git clone --branch v2.13.6 https://github.com/catchorg/Catch2.git
git clone --branch v3.7.0 https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
Expand Down
2 changes: 2 additions & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

echo This script is deprecated, please refer to the Docker Images section of the README for the recommended method of pulling and running images from ECR.

architecture=$(uname -m)

if [ "${architecture}" != aarch64 -a "${architecture}" != arm64 ]; then
Expand Down
2 changes: 2 additions & 0 deletions docker-run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

echo This script is deprecated, please refer to the Docker Images section of the README for the recommended method of pulling and running images from ECR.

while getopts p: flag
do
case "${flag}" in
Expand Down
2 changes: 1 addition & 1 deletion src/ProxySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace aws { namespace iot { namespace securedtunneling { namespace settings
std::size_t const DEFAULT_MAX_DATA_FRAME_SIZE = DEFAULT_MESSAGE_MAX_SIZE + DEFAULT_DATA_LENGTH_SIZE;

char const * const KEY_TCP_CONNECTION_RETRY_COUNT = "tunneling.proxy.tcp.connection_retry_count";
std::int32_t const DEFAULT_TCP_CONNECTION_RETRY_COUNT = -1;
std::int32_t const DEFAULT_TCP_CONNECTION_RETRY_COUNT = 5;

char const * const KEY_TCP_CONNECTION_RETRY_DELAY_MS = "tunneling.proxy.tcp.connection_retry_delay_ms";
std::uint32_t const DEFAULT_TCP_CONNECTION_RETRY_DELAY_MS = 2500;
Expand Down
Loading
Loading