Skip to content

Commit

Permalink
Update to version 2
Browse files Browse the repository at this point in the history
- changes:
    - Change install directory and library names. See readme.md for details
    - "listener" naming is replaced by "server"

- improvements:
    - Extend test scope: Check TLS connection with RSA and EC certificates
    - Improvement of example. Not needed to install libraries to execute example

- bug fixes:
    - Immediately flush out stream when receiving messages in forwarding mode
  • Loading branch information
nilshenrich committed May 17, 2024
2 parents 8ca0a92 + 247d1fe commit 8e4897f
Show file tree
Hide file tree
Showing 34 changed files with 780 additions and 522 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
name: release

on:
push:
tags:
- "v*"
push:
tags:
- "v*"

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
release:
name: release
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Get tag name
id: tag-name
run: echo "out=$(basename $GITHUB_REF)" >> $GITHUB_OUTPUT
- name: Get tag name
id: tag-name
run: echo "out=$(basename $GITHUB_REF)" >> $GITHUB_OUTPUT

- name: Get tag message
id: tag-message
run: |
TAG_MSG=$(git tag -l --format='%(contents)' ${{ steps.tag-name.outputs.out }})
echo "TAG_MSG<<EOF" >> $GITHUB_ENV
echo "$TAG_MSG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Get tag message
id: tag-message
run: |
TAG_MSG=$(git tag -l --format='%(contents)' ${{ steps.tag-name.outputs.out }})
echo "TAG_MSG<<EOF" >> $GITHUB_ENV
echo "$TAG_MSG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag-name.outputs.out }}
release_name: ${{ steps.tag-name.outputs.out }}
body: ${{ env.TAG_MSG }}
draft: false
prerelease: false
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag-name.outputs.out }}
release_name: ${{ steps.tag-name.outputs.out }}
body: ${{ env.TAG_MSG }}
draft: false
prerelease: false
86 changes: 54 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,59 @@
name: test

on:
push:
branches:
- main
pull_request:
branches:
- main
push:
branches:
- main
pull_request:
branches:
- main

jobs:
gtest:
name: gtest
runs-on: ubuntu-latest
steps:

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev openssl
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Run tests
run: ./RunAllTests.sh
working-directory: test/gtest

- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-gtest
path: test/gtest/results.json
if-no-files-found: error
gtest:
name: gtest
runs-on: ubuntu-latest
steps:

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev openssl
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install GoogleTest
run: |
mkdir build
cd build
cmake ..
sudo make install
working-directory: test/gtest/googletest

- name: Build
run: |
mkdir build
cd build
cmake ..
make -j4
working-directory: test/gtest

- name: Run tests
run: ./RunFilteredTests.sh ${{ matrix.protocol }} ${{ matrix.mode }} ${{ matrix.certType }}
working-directory: test/gtest

- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-gtest_${{ matrix.protocol }}-${{ matrix.mode }}-${{ matrix.certType }}
path: test/gtest/results.json
if-no-files-found: error

strategy:
matrix:
protocol: ["tcp", "tls"]
mode: ["continuous", "fragmentation", "general"]
certType: ["ec", "rsa"]
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.10)
# For debugging please use the command "cmake -DCMAKE_BUILD_TYPE=Debug .."

project(TCP_ServerClient)# Not used
cmake_minimum_required(VERSION 3.10)

add_subdirectory(Server)
add_subdirectory(Client)
project(tcp) # Never used
add_subdirectory(Server) # Compile server library
add_subdirectory(Client) # Compile client library
34 changes: 17 additions & 17 deletions Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
cmake_minimum_required(VERSION 3.10)

# Project name
project(TcpClient VERSION 1.0 DESCRIPTION "TCP client")
project(TlsClient VERSION 1.0 DESCRIPTION "TLS client")
project(tcpclient VERSION 2.0 DESCRIPTION "TCP client")
project(tlsclient VERSION 2.0 DESCRIPTION "TLS client")

# Include standard directories
include(GNUInstallDirs)
Expand All @@ -18,40 +18,40 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

# Source files to be compiled
add_library(TcpClient SHARED "src/TcpClient.cpp")
add_library(TlsClient SHARED "src/TlsClient.cpp")
add_library(tcpclient SHARED "src/TcpClient.cpp")
add_library(tlsclient SHARED "src/TlsClient.cpp")

# Set include path to search for headers
include_directories(include)

# Set compiler flags
target_compile_options(TcpClient PUBLIC -fexceptions
target_compile_options(tcpclient PUBLIC -fexceptions
$<$<CONFIG:DEBUG>: -DDEVELOP -Wall -g -Og>
$<$<CONFIG:RELEASE>: -O3>)
target_link_options(TcpClient PUBLIC $<$<CONFIG:RELEASE>: -s>)
target_compile_options(TlsClient PUBLIC -fexceptions
target_link_options(tcpclient PUBLIC $<$<CONFIG:RELEASE>: -s>)
target_compile_options(tlsclient PUBLIC -fexceptions
$<$<CONFIG:DEBUG>: -DDEVELOP -Wall -g -Og>
$<$<CONFIG:RELEASE>: -O3>)
target_link_options(TlsClient PUBLIC $<$<CONFIG:RELEASE>: -s>)
target_link_options(tlsclient PUBLIC $<$<CONFIG:RELEASE>: -s>)

# Use C++17 standard
set_target_properties(TcpClient PROPERTIES
set_target_properties(tcpclient PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "include/TcpClient.h;include/Client.h;include/Defines.h;include/Client.tpp"
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "include/TcpClient.h;include/Client.h;include/ClientDefines.h;include/Client.tpp"
CXX_STANDARD 17
CMAKE_CXX_STANDARD_REQUIRED True)
set_target_properties(TlsClient PROPERTIES
set_target_properties(tlsclient PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "include/TlsClient.h;include/Client.h;include/Defines.h;include/Client.tpp"
SOVERSION ${PROJECT_VERSION_MAJOR}
PUBLIC_HEADER "include/TlsClient.h;include/Client.h;include/ClientDefines.h;include/Client.tpp"
CXX_STANDARD 17
CMAKE_CXX_STANDARD_REQUIRED True)

# Install rule (copy to install directory)
install(TARGETS TcpClient TlsClient
install(TARGETS tcpclient tlsclient
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/TcpClient)
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tcp )

# Print build type
message("Build type: ${CMAKE_BUILD_TYPE}")
message("Client build type: ${CMAKE_BUILD_TYPE}")
6 changes: 3 additions & 3 deletions Client/include/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Base framework for all classes that build a network client based on TCP.
* This class contains no functionality, but serves a base framework for the creation of stable clients based on TCP.
* When compiling with the -DDEBUG flag, the class will print out all received messages to the console.
* @version 1.0
* @version 2.0
* @date 2021-12-28
*
* @copyright Copyright (c) 2021
Expand All @@ -29,7 +29,7 @@
#include <netdb.h>
#include <sys/socket.h>

#include "Defines.h"
#include "ClientDefines.h"

namespace tcp
{
Expand Down Expand Up @@ -130,7 +130,7 @@ namespace tcp

/**
* @brief Start the client and connects to the server.
* If connection to listener succeeds, this method returns CLIENT_START_OK, otherwise it returns an error code.
* If connection to server succeeds, this method returns CLIENT_START_OK, otherwise it returns an error code.
*
* @param serverIp
* @param serverPort
Expand Down
2 changes: 1 addition & 1 deletion Client/include/Client.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void Client<SocketType, SocketDeleter>::receive()
else
{
// Just forward incoming message to output stream
CONTINUOUS_OUTPUT_STREAM << msg;
CONTINUOUS_OUTPUT_STREAM << msg << flush;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Client/include/Defines.h → Client/include/ClientDefines.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @file Defines.h
* @file ClientDefines.h
* @author Nils Henrich
* @brief Basic definitions for the network client
* @version 1.0
* @version 2.0
* @date 2021-12-28
*
* @copyright Copyright (c) 2021
Expand Down
Loading

0 comments on commit 8e4897f

Please sign in to comment.