Skip to content

Commit 505e5cc

Browse files
committed
Fix Windows and SSL Wrappers
- Fixed SocketInit not always being odr-used when Sockets are used - Fixed SocketInit throwing errors which would call terminate() - Fixed SSL Wrappers copy constructor to really use up_ref - Fixed SSL Wrappers constness handling
1 parent 99cb1d1 commit 505e5cc

28 files changed

Lines changed: 355 additions & 105 deletions

‎.github/workflows/cmake-multi-platform.yml‎

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
c_compiler: gcc
5050

5151
steps:
52-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v7
5353

5454
- name: Set Env
5555
shell: bash
@@ -79,18 +79,49 @@ jobs:
7979
# because the default Windows generator is a multi-config generator (Visual Studio generator).
8080
run: cmake --build ${{ env.BUILD_OUTPUT_DIR }} --config ${{ matrix.build_type }}
8181

82-
- uses: actions/upload-artifact@v4
82+
- name: Upload Compile Commands
83+
uses: actions/upload-artifact@v7
8384
if: matrix.os == 'ubuntu-latest' && matrix.build_type == 'Release' && matrix.c_compiler == 'clang'
8485
with:
8586
name: compile_commands.json
8687
path: ${{ env.BUILD_OUTPUT_DIR }}/compile_commands.json
88+
archive: false
89+
90+
- name: Upload CppSockets lib
91+
uses: actions/upload-artifact@v6
92+
with:
93+
name: libcppsockets-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
94+
path: "${{ env.BUILD_OUTPUT_DIR }}/**/libcppsockets.*"
95+
96+
- name: Upload UnitTests
97+
uses: actions/upload-artifact@v6
98+
if: matrix.os != 'windows-latest'
99+
with:
100+
name: unit_tests-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
101+
path: "${{ env.BUILD_OUTPUT_DIR }}/tests/**/unit_tests*"
102+
103+
- name: Upload UnitTests
104+
uses: actions/upload-artifact@v6
105+
if: matrix.os == 'windows-latest'
106+
with:
107+
name: unit_tests-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
108+
path: |
109+
${{ env.BUILD_OUTPUT_DIR }}/tests/**/unit_tests*
110+
${{ env.BUILD_OUTPUT_DIR }}/tests/**/*.dll
111+
112+
- name: Setup DLL PATH (Windows)
113+
if: runner.os == 'Windows'
114+
shell: bash
115+
run: |
116+
echo "$VCPKG_ROOT/installed/x64-windows/bin" >> "$GITHUB_PATH"
117+
echo "$BUILD_OUTPUT_DIR/${{ matrix.build_type }}" >> "$GITHUB_PATH"
87118
88119
- name: Test
89120
working-directory: ${{ env.BUILD_OUTPUT_DIR }}
90121
# Execute tests defined by the CMake configuration. Note that --build-config is needed
91122
# because the default Windows generator is a multi-config generator (Visual Studio generator).
92123
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
93-
run: ctest --build-config ${{ matrix.build_type }} --test-dir tests --output-on-failure
124+
run: ctest --timeout 60 --build-config ${{ matrix.build_type }} --test-dir tests --output-on-failure
94125

95126
clang-tidy:
96127
needs: 'build'
@@ -99,9 +130,9 @@ jobs:
99130

100131
steps:
101132
- name: Checkout Code
102-
uses: actions/checkout@v4
133+
uses: actions/checkout@v7
103134

104-
- uses: actions/download-artifact@v4
135+
- uses: actions/download-artifact@v8
105136
with:
106137
name: compile_commands.json
107138

‎.github/workflows/code_scanning.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
steps:
2828
- name: Checkout repository
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v7
3030

3131
# Initializes the CodeQL tools for scanning.
3232
- name: Initialize CodeQL
@@ -88,7 +88,7 @@ jobs:
8888

8989
steps:
9090
- name: Checkout repository
91-
uses: actions/checkout@v3
91+
uses: actions/checkout@v7
9292

9393
- name: VCPKG Install (Windows)
9494
uses: ./.github/workflows/windows-vcpkg

‎.github/workflows/windows-vcpkg/action.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
- name: Fetch VCPKG Cache (Windows)
1818
id: fetch-vcpkg-cache
1919
if: runner.os == 'Windows'
20-
uses: actions/cache/restore@v4
20+
uses: actions/cache/restore@v6
2121
with:
2222
key: ${{ inputs.key }}-vcpkg-${{ hashFiles('vcpkg.json') }}
2323
path: ${{ env.VCPKG_CACHE }}
@@ -31,7 +31,7 @@ runs:
3131
3232
- name: Always Save VCPKG Cache (Windows)
3333
if: always() && runner.os == 'Windows' && steps.fetch-vcpkg-cache.outputs.cache-hit != 'true'
34-
uses: actions/cache/save@v4
34+
uses: actions/cache/save@v6
3535
with:
3636
key: ${{ steps.fetch-vcpkg-cache.outputs.cache-primary-key }}
3737
path: ${{ env.VCPKG_CACHE }}

‎.gitignore‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
build/
22

3-
libcppsockets.so
3+
file-share
4+
file-share-cli
5+
*.so
6+
*.dll
7+
*.exe
48
compile_commands.json
59

610
*.tmp

‎CMakeLists.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Author Francois Michaut
55
##
66
## Started on Sun Aug 28 19:26:51 2022 Francois Michaut
7-
## Last update Wed Aug 20 17:05:18 2025 Francois Michaut
7+
## Last update Thu Jul 2 01:56:37 2026 Francois Michaut
88
##
99
## CMakeLists.txt : CMake to build the CppSockets library
1010
##
@@ -31,6 +31,7 @@ add_library(cppsockets
3131
source/Socket.cpp
3232
source/SocketInit.cpp
3333
)
34+
3435
target_include_directories(cppsockets
3536
PUBLIC
3637
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
@@ -39,6 +40,8 @@ target_include_directories(cppsockets
3940
${PROJECT_SOURCE_DIR}/private
4041
)
4142

43+
target_compile_definitions(cppsockets PRIVATE CPPSOCKETS_DLL_EXPORTS=1)
44+
4245
find_package(OpenSSL 3.0 COMPONENTS SSL)
4346
target_link_libraries(cppsockets OpenSSL::SSL)
4447
if(WIN32)

‎include/CppSockets/Address.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
** Project CppSockets, 2022
2+
** Project LibCppSockets, 2022
33
**
44
** Author Francois Michaut
55
**
66
** Started on Sun Feb 13 17:09:05 2022 Francois Michaut
7-
** Last update Sat Jun 20 09:12:58 2026 Francois Michaut
7+
** Last update Wed Jul 1 14:19:51 2026 Francois Michaut
88
**
99
** Address.hpp : Interface to represent network addresses
1010
*/

‎include/CppSockets/IPv4.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
** Project CppSockets, 2022
2+
** Project LibCppSockets, 2022
33
**
44
** Author Francois Michaut
55
**
66
** Started on Sun Feb 13 17:05:02 2022 Francois Michaut
7-
** Last update Wed Aug 20 12:57:35 2025 Francois Michaut
7+
** Last update Wed Jul 1 14:19:39 2026 Francois Michaut
88
**
99
** IPv4.hpp : Class used to represent and manipulate IPv4 addresses
1010
*/

‎include/CppSockets/OSDetection.hpp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
/*
2-
** Project CppSockets, 2023
2+
** Project LibCppSockets, 2023
33
**
44
** Author Francois Michaut
55
**
66
** Started on Tue May 9 23:20:20 2023 Francois Michaut
7-
** Last update Sun May 14 14:03:20 2023 Francois Michaut
7+
** Last update Wed Jul 1 14:20:01 2026 Francois Michaut
88
**
99
** OSDetection.hpp : OS Detection macros
1010
*/
1111

1212
#pragma once
1313

1414
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
15-
#define OS_WINDOWS
15+
#define OS_WINDOWS 1
1616
#elif defined (__APPLE__)
17-
#define OS_UNIX
18-
#define OS_APPLE
17+
#define OS_UNIX 1
18+
#define OS_APPLE 1
1919
#elif defined(__linux__)
20-
#define OS_UNIX
21-
#define OS_LINUX
20+
#define OS_UNIX 1
21+
#define OS_LINUX 1
2222
#elif defined(__unix__)
23-
#define OS_UNIX
23+
#define OS_UNIX 1
2424
#else
25-
#error "Unknown compiler, please open a issue or pull request to support your compiler"
25+
#error "Unknown OS, please open a issue or pull request to support your OS"
2626
#endif

‎include/CppSockets/Socket.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
** Project CppSockets, 2022
2+
** Project LibCppSockets, 2022
33
**
44
** Author Francois Michaut
55
**
66
** Started on Sat Jan 15 01:17:42 2022 Francois Michaut
7-
** Last update Wed Aug 20 14:01:21 2025 Francois Michaut
7+
** Last update Wed Jul 1 14:20:12 2026 Francois Michaut
88
**
99
** Socket.hpp : Portable C++ socket class
1010
*/

‎include/CppSockets/Tls/Certificate.hpp‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
** Author Francois Michaut
55
**
66
** Started on Fri Aug 1 09:50:33 2025 Francois Michaut
7-
** Last update Wed Aug 20 17:17:44 2025 Francois Michaut
7+
** Last update Thu Jul 2 01:03:49 2026 Francois Michaut
88
**
99
** Certificate.hpp : Classes to create and manage Certificates
1010
*/
@@ -27,6 +27,7 @@ namespace CppSockets {
2727
x509Name();
2828
x509Name(X509_NAME_ptr ptr);
2929
x509Name(X509_NAME *ptr, bool own = true);
30+
x509Name(const X509_NAME *ptr);
3031

3132
x509Name(const x509Name &other) { *this = other; }
3233
x509Name(x509Name &&other) noexcept = default;
@@ -73,6 +74,7 @@ namespace CppSockets {
7374
x509NameEntry();
7475
x509NameEntry(X509_NAME_ENTRY_ptr ptr);
7576
x509NameEntry(X509_NAME_ENTRY *ptr, bool own = true);
77+
x509NameEntry(const X509_NAME_ENTRY *ptr);
7678
x509NameEntry(const std::string &name, int type, const std::u8string &data);
7779
x509NameEntry(const ASN1_OBJECT *obj, int type, const std::u8string &data);
7880
x509NameEntry(int nid, int type, const std::u8string &data);
@@ -103,6 +105,7 @@ namespace CppSockets {
103105
x509Extension();
104106
x509Extension(X509_EXTENSION_ptr ptr);
105107
x509Extension(X509_EXTENSION *ptr, bool own = true);
108+
x509Extension(const X509_EXTENSION *ptr);
106109
x509Extension(int nid, int crit, ASN1_OCTET_STRING *data);
107110
x509Extension(const ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data);
108111

@@ -119,8 +122,8 @@ namespace CppSockets {
119122
void set_object(const ASN1_OBJECT *obj);
120123
void set_critical(bool crit);
121124

122-
[[nodiscard]] auto get_data() const -> ASN1_OCTET_STRING *;
123-
[[nodiscard]] auto get_object() const -> ASN1_OBJECT *;
125+
[[nodiscard]] auto get_data() const -> const ASN1_OCTET_STRING *;
126+
[[nodiscard]] auto get_object() const -> const ASN1_OBJECT *;
124127
[[nodiscard]] auto get_critical() const -> bool;
125128

126129
[[nodiscard]] auto get() const -> X509_EXTENSION * { return m_ptr.get(); }
@@ -134,6 +137,7 @@ namespace CppSockets {
134137
x509Certificate();
135138
x509Certificate(X509_ptr ptr);
136139
x509Certificate(X509 *ptr, bool own = true);
140+
x509Certificate(const X509 *ptr);
137141
explicit x509Certificate(const std::filesystem::path &pem_file_path);
138142

139143
x509Certificate(const x509Certificate &other) { *this = other; }

0 commit comments

Comments
 (0)