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

🔧 Replaced sha1_util with Poco::SHA1Engine #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
BasedOnStyle: Microsoft

...
2 changes: 1 addition & 1 deletion .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install build Dependencies
run: |
sudo apt update
sudo apt install -y libjsoncpp-dev fakeroot libarchive-tools python3-apt zstd gettext
sudo apt install -y libpoco-dev libjsoncpp-dev fakeroot libarchive-tools python3-apt zstd gettext
curl "https://cdn.anotherfoxguy.com/makedeb/install-makedeb.sh" | sudo bash

- name: Install angelscript
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ include(FeatureSummary)

project(rorserver VERSION "2021.10")

set(CMAKE_CXX_STANDARD 17)

# Options
set(ROR_DEPENDENCY_DIR "${CMAKE_SOURCE_DIR}/dependencies/build" CACHE PATH "Path to the dependencies")
set(CMAKE_PREFIX_PATH ${ROR_DEPENDENCY_DIR} ${CMAKE_PREFIX_PATH})

set(CMAKE_THREAD_PREFER_PTHREAD YES)
find_package(Threads REQUIRED)
find_package(Angelscript)
find_package(Poco REQUIRED COMPONENTS Foundation)
find_package(jsoncpp REQUIRED)
find_package(SocketW REQUIRED)
find_package(CURL)
find_package(Angelscript)
cmake_dependent_option(RORSERVER_WITH_ANGELSCRIPT "Adds scripting support" ON "TARGET Angelscript::angelscript" OFF)
cmake_dependent_option(RORSERVER_WITH_CURL "Adds CURL request support (needs AngelScript)" ON "TARGET CURL::libcurl" OFF)

Expand Down
5 changes: 5 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ class RoRServer(ConanFile):
name = "RoRServer"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
default_options = {
"poco*:enable_pagecompiler": True,
"poco*:enable_data_mysql": False,
}

def layout(self):
self.folders.generators = os.path.join(self.folders.build, "generators")

def requirements(self):
self.requires("angelscript/2.37.0")
self.requires("jsoncpp/1.9.5")
self.requires("poco/1.13.3")
self.requires("openssl/3.3.2", override=True)
self.requires("socketw/3.11.0@anotherfoxguy/stable")
self.requires("libcurl/8.10.1")
8 changes: 7 additions & 1 deletion source/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ if (RORSERVER_WITH_CURL)
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
endif ()

target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads SocketW::SocketW jsoncpp_lib)
target_link_libraries(${PROJECT_NAME} PRIVATE
Poco::Poco
Poco::Foundation
Threads::Threads
SocketW::SocketW
jsoncpp_lib
)

IF (WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
Expand Down
17 changes: 11 additions & 6 deletions source/server/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.

#include "logger.h"
#include "sequencer.h"
#include "sha1_util.h"
#include "spamfilter.h"
#include "utils.h"

#include <cmath>
#include <cstring>
#include "Poco/SHA1Engine.h"

#ifdef __GNUC__

Expand Down Expand Up @@ -385,15 +385,20 @@ namespace Config {
}

bool setPublicPass(const std::string &pub_pass) {
if (pub_pass.length() > 0 && pub_pass.size() < 250 &&
!SHA1FromString(s_public_password, pub_pass)) {
try
{
Poco::SHA1Engine engine;
engine.update(pub_pass);
s_public_password = Poco::DigestEngine::digestToHex(engine.digest());
Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(), s_public_password.c_str());
return true;
}
catch (...)
{
Logger::Log(LOG_ERROR, "could not generate server SHA1 password hash!");
s_public_password = "";
return false;
}
Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(),
s_public_password.c_str());
return true;
}

bool setIPAddr(const std::string &ip) {
Expand Down
8 changes: 0 additions & 8 deletions source/server/rorserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#include "master-server.h"
#include "utils.h"

#include "sha1_util.h"
#include "sha1.h"

#include <iostream>
#include <cstdlib>
#include <csignal>
Expand Down Expand Up @@ -286,11 +283,6 @@ int main(int argc, char *argv[]) {
return 1;
}

if (!sha1check()) {
Logger::Log(LOG_ERROR, "sha1 malfunction!");
return -1;
}

#ifndef _WIN32
if (!Config::getForeground()) {
// no output because of background mode
Expand Down
1 change: 0 additions & 1 deletion source/server/sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#include "sequencer.h"

#include "messaging.h"
#include "sha1_util.h"
#include "receiver.h"
#include "broadcaster.h"
#include "userauth.h"
Expand Down
Loading
Loading