Skip to content

Commit 666fa99

Browse files
committed
Styling, Certificates, and SSL_Utils
- Added clang-tidy config file + CI - Reformated the code to fit the new Style - Added SSL_Utils for better smart pointers of SSL objects - Added Certificate class + extras to manipulate Certificates
1 parent 8161640 commit 666fa99

File tree

19 files changed

+1040
-256
lines changed

19 files changed

+1040
-256
lines changed

.clang-tidy

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Checks: '
2+
*,
3+
-llvmlibc-*,
4+
-google-readability-todo,
5+
-fuchsia-default-arguments-calls,
6+
-fuchsia-default-arguments-declarations,
7+
-cppcoreguidelines-init-variables,
8+
-cppcoreguidelines-pro-type-reinterpret-cast,
9+
-android-*,
10+
-altera-*,
11+
-llvm-namespace-comment,
12+
-readability-implicit-bool-conversion,
13+
-google-explicit-constructor,
14+
-fuchsia-overloaded-operator,
15+
16+
-google-readability-braces-around-statements,
17+
-google-readability-namespace-comments,
18+
-hicpp-braces-around-statements,
19+
-hicpp-explicit-conversions,
20+
-fuchsia-trailing-return
21+
'
22+
23+
WarningsAsErrors: 'bugprone-exception-escape'
24+
FormatStyle: 'none' # TODO: Replace with 'file' once we have a proper .clang-format file
25+
InheritParentConfig: true
26+
CheckOptions:
27+
misc-include-cleaner.MissingIncludes: 'false'
28+
misc-include-cleaner.IgnoreHeaders: 'CppSockets/OSDetection\.hpp'
29+
30+
bugprone-argument-comment.StrictMode: 1
31+
32+
# Readability
33+
readability-braces-around-statements.ShortStatementLines: 2
34+
35+
readability-identifier-naming.NamespaceCase: CamelCase
36+
37+
readability-identifier-length.IgnoredVariableNames: "^(fd|nb|ss)$"
38+
readability-identifier-length.IgnoredParameterNames: "^([n]|fd)$"

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{c++,cc,cpp,cxx,h,h++,hh,hpp,hxx,inl,ipp,tlh,tli}]
8+
cpp_indent_case_contents_when_block = true
9+
cpp_new_line_before_open_brace_namespace = same_line
10+
indent_size = 4
11+
indent_style = space

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: C++ CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
types: [ "opened", "reopened", "synchronize", "ready_for_review" ]
9+
10+
jobs:
11+
clang-tidy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
18+
- name: clang-tidy review
19+
uses: ZedThree/clang-tidy-review@v0.21.0

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ on:
44
push:
55
branches: [ "master" ]
66
pull_request:
7+
branches: [ "master" ]
78
types: [ "opened", "reopened", "synchronize", "ready_for_review" ]
89

910
jobs:
1011
build:
1112
runs-on: ${{ matrix.os }}
1213

1314
strategy:
14-
fail-fast: false # ensure we don't stop after 1 failure to always have a complete picture of what is failing
15+
# ensure we don't stop after 1 failure to always have a complete picture of what is failing
16+
fail-fast: false
1517

1618
# Set up a matrix to run the following configurations:
1719
# - ubuntu Debug/Release clang/gcc
@@ -50,7 +52,8 @@ jobs:
5052
- uses: actions/checkout@v3
5153

5254
- name: Set reusable strings
53-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
55+
# Turn repeated input strings (such as the build output directory) into step outputs.
56+
# These step outputs can be used throughout the workflow file.
5457
id: strings
5558
shell: bash
5659
run: |
@@ -72,7 +75,8 @@ jobs:
7275
vcpkg install
7376
7477
- name: Configure CMake
75-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
78+
# Configure CMake in a 'build' subdirectory.
79+
# `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
7680
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
7781
run: >
7882
cmake -B ${{ steps.strings.outputs.build-output-dir }}
@@ -83,11 +87,13 @@ jobs:
8387
-S ${{ github.workspace }}
8488
8589
- name: Build
86-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
90+
# Build your program with the given configuration. Note that --config is needed
91+
# because the default Windows generator is a multi-config generator (Visual Studio generator).
8792
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
8893

8994
- name: Test
9095
working-directory: ${{ steps.strings.outputs.build-output-dir }}
91-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
96+
# Execute tests defined by the CMake configuration. Note that --build-config is needed
97+
# because the default Windows generator is a multi-config generator (Visual Studio generator).
9298
# 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
99+
run: ctest --build-config ${{ matrix.build_type }} --test-dir tests --output-on-failure

.gitignore

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

3+
libcppsockets.so
34
compile_commands.json
45

56
*.tmp
67
*.gch
8+
vgcore.*
9+
10+
.vscode/
11+
.cache/

CMakeLists.txt

Lines changed: 3 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 Sat Dec 2 17:45:28 2023 Francois Michaut
7+
## Last update Mon Aug 4 23:34:08 2025 Francois Michaut
88
##
99
## CMakeLists.txt : CMake to build the CppSockets library
1010
##
@@ -22,7 +22,9 @@ configure_file(include/CppSockets/Version.hpp.in include/CppSockets/Version.hpp)
2222

2323
add_library(cppsockets
2424
source/Address.cpp
25+
source/Certificate.cpp
2526
source/IPv4.cpp
27+
source/SSL_Utils.cpp
2628
source/Socket.cpp
2729
source/SocketInit.cpp
2830
source/TlsSocket.cpp

include/CppSockets/Address.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
namespace CppSockets {
2121
class IAddress {
2222
public:
23-
[[nodiscard]] virtual std::uint32_t getAddress() const = 0;
24-
[[nodiscard]] virtual int getFamily() const = 0;
25-
[[nodiscard]] virtual const std::string &toString() const = 0;
23+
[[nodiscard]] virtual auto getAddress() const -> std::uint32_t = 0;
24+
[[nodiscard]] virtual auto getFamily() const -> int = 0;
25+
[[nodiscard]] virtual auto toString() const -> const std::string & = 0;
2626
};
2727

2828
class IEndpoint {
2929
public:
30-
[[nodiscard]] virtual std::uint16_t getPort() const = 0;
31-
[[nodiscard]] virtual const IAddress &getAddr() const = 0;
32-
[[nodiscard]] virtual const std::string &toString() const = 0;
30+
[[nodiscard]] virtual auto getPort() const -> std::uint16_t = 0;
31+
[[nodiscard]] virtual auto getAddr() const -> const IAddress & = 0;
32+
[[nodiscard]] virtual auto toString() const -> const std::string & = 0;
3333

3434
protected:
35-
[[nodiscard]] std::string makeString() const;
35+
[[nodiscard]] auto makeString() const -> std::string;
3636
};
3737

3838
template <class T>
@@ -46,15 +46,15 @@ namespace CppSockets {
4646
{};
4747
virtual ~Endpoint() = default;
4848

49-
[[nodiscard]] std::uint16_t getPort() const override {
49+
[[nodiscard]] auto getPort() const -> std::uint16_t override {
5050
return port;
5151
}
5252

53-
[[nodiscard]] const T &getAddr() const override {
53+
[[nodiscard]] auto getAddr() const -> const T & override {
5454
return addr;
5555
}
5656

57-
[[nodiscard]] const std::string &toString() const override {
57+
[[nodiscard]] auto toString() const -> const std::string & override {
5858
return str;
5959
}
6060
private:

0 commit comments

Comments
 (0)