From 0922b77fad58fc14f9ca475e83bdc7fca76fbd07 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Sat, 15 Feb 2025 09:53:11 +0100 Subject: [PATCH] dump --- .clang-format | 76 ++++ .gitignore | 80 +++++ CMakeLists.txt | 41 +++ README.md | 72 ++++ cmake/gTest.cmake | 10 + networking/CMakeLists.txt | 24 ++ .../include/AsyncSslClientTransport.hpp | 34 ++ .../include/AsyncSslServerTransport.hpp | 32 ++ networking/include/AsyncSslTransport.hpp | 62 ++++ networking/include/Client.hpp | 43 +++ networking/include/Helpers.hpp | 37 ++ networking/include/Server.hpp | 53 +++ networking/src/AsyncSslClientTransport.cpp | 60 ++++ networking/src/AsyncSslServerTransport.cpp | 51 +++ networking/src/AsyncSslTransport.cpp | 249 ++++++++++++++ networking/src/Client.cpp | 72 ++++ networking/src/Helpers.cpp | 93 +++++ networking/src/Server.cpp | 171 +++++++++ remotefs/CMakeLists.txt | 31 ++ remotefs/include/Acl.hpp | 24 ++ remotefs/include/FsClient.hpp | 16 + remotefs/include/FsServer.hpp | 15 + remotefs/include/Messages.hpp | 225 ++++++++++++ remotefs/src/Acl.cpp | 114 ++++++ remotefs/src/FsClient.cpp | 311 +++++++++++++++++ remotefs/src/FsServer.cpp | 325 ++++++++++++++++++ remotefs/src/main.cpp | 45 +++ remotefs/tests/CMakeLists.txt | 13 + remotefs/tests/src/AclTest.cpp | 92 +++++ utils/CMakeLists.txt | 22 ++ utils/include/Exception.h | 37 ++ utils/include/Logger.h | 65 ++++ utils/include/Options.h | 66 ++++ utils/include/SHA.h | 49 +++ utils/include/SerializableStruct.hpp | 50 +++ utils/include/Serialize.hpp | 286 +++++++++++++++ utils/include/stuff.hpp | 37 ++ utils/src/Exception.cpp | 51 +++ utils/src/Logger.cpp | 60 ++++ utils/src/Options.cpp | 71 ++++ utils/src/SHA.cpp | 43 +++ utils/src/stuff.cpp | 19 + utils/tests/CMakeLists.txt | 13 + utils/tests/src/SerializableHelperTest.cpp | 44 +++ 44 files changed, 3384 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 cmake/gTest.cmake create mode 100644 networking/CMakeLists.txt create mode 100644 networking/include/AsyncSslClientTransport.hpp create mode 100644 networking/include/AsyncSslServerTransport.hpp create mode 100644 networking/include/AsyncSslTransport.hpp create mode 100644 networking/include/Client.hpp create mode 100644 networking/include/Helpers.hpp create mode 100644 networking/include/Server.hpp create mode 100644 networking/src/AsyncSslClientTransport.cpp create mode 100644 networking/src/AsyncSslServerTransport.cpp create mode 100644 networking/src/AsyncSslTransport.cpp create mode 100644 networking/src/Client.cpp create mode 100644 networking/src/Helpers.cpp create mode 100644 networking/src/Server.cpp create mode 100644 remotefs/CMakeLists.txt create mode 100644 remotefs/include/Acl.hpp create mode 100644 remotefs/include/FsClient.hpp create mode 100644 remotefs/include/FsServer.hpp create mode 100644 remotefs/include/Messages.hpp create mode 100644 remotefs/src/Acl.cpp create mode 100644 remotefs/src/FsClient.cpp create mode 100644 remotefs/src/FsServer.cpp create mode 100644 remotefs/src/main.cpp create mode 100644 remotefs/tests/CMakeLists.txt create mode 100644 remotefs/tests/src/AclTest.cpp create mode 100644 utils/CMakeLists.txt create mode 100644 utils/include/Exception.h create mode 100644 utils/include/Logger.h create mode 100644 utils/include/Options.h create mode 100644 utils/include/SHA.h create mode 100644 utils/include/SerializableStruct.hpp create mode 100644 utils/include/Serialize.hpp create mode 100644 utils/include/stuff.hpp create mode 100644 utils/src/Exception.cpp create mode 100644 utils/src/Logger.cpp create mode 100644 utils/src/Options.cpp create mode 100644 utils/src/SHA.cpp create mode 100644 utils/src/stuff.cpp create mode 100644 utils/tests/CMakeLists.txt create mode 100644 utils/tests/src/SerializableHelperTest.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c700749 --- /dev/null +++ b/.clang-format @@ -0,0 +1,76 @@ +# Generated from CLion C/C++ Code Style settings +--- +Language: Cpp +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignConsecutiveMacros: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +AlignTrailingComments: + Kind: Always + OverEmptyLines: 2 +SpacesBeforeTrailingComments: 1 +AlignOperands: Align +AlignEscapedNewlines: Right +AlwaysBreakTemplateDeclarations: Yes +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBraces: Custom +BreakConstructorInitializers: AfterColon +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ContinuationIndentWidth: 8 +IncludeCategories: + - Regex: '^<.*' + Priority: 1 + - Regex: '^".*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentWidth: 4 +InsertNewlineAtEOF: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +PointerAlignment: Left +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false +SpaceBeforeRangeBasedForLoopColon: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..246474f --- /dev/null +++ b/.gitignore @@ -0,0 +1,80 @@ +.DS_Store + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +.idea +*.out +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c82026b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.15) +project(remotefs) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED YES) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (NOT DEFINED SANITIZE) + set(SANITIZE YES) + endif () +endif () + +if (SANITIZE STREQUAL "YES") + message(STATUS "Enabling sanitizers!") + add_compile_options(-Werror -O0 -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-unused-variable + -Wno-error=unused-function + -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion) + add_compile_options(-fsanitize=address -fno-sanitize-recover) + add_link_options(-fsanitize=address -fno-sanitize-recover) +endif () + +if (CMAKE_BUILD_TYPE STREQUAL "Release") + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) +endif () + +if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + add_compile_options(-O3) + add_link_options(-O3) +endif () + +add_compile_options(-Wno-c99-extensions) + +add_link_options(-rdynamic) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +enable_testing() + +add_subdirectory(utils) +add_subdirectory(networking) +add_subdirectory(remotefs) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..cecfd0e --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# RemoteFS + +Simple server-client remote filesystem + +## How to use + +1. Create an SSL certificate for the server `openssl req -nodes -new -x509 -keyout key.pem -out cert.pem` +1. Create a password hash for the user `echo -n "password" | openssl dgst -sha256` +1. Copy the password hash into a `users` file +1. Start the server `remotefs --mode:server --path: --users_path:users` +1. Copy `cert.pem` to the client working directory +1. Connect with the client `remotefs --mode:client --username: --password: --path:` + +## Advanced options + +Various options can be overridden using `--