Skip to content

Commit

Permalink
🔧 Replaced sha1_util with Poco::SHA1Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherFoxGuy committed Jan 8, 2025
1 parent 59bef02 commit 784b06b
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 1,067 deletions.
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ 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(Angelscript)

cmake_dependent_option(RORSERVER_WITH_ANGELSCRIPT "Adds scripting support" ON "TARGET Angelscript::angelscript" OFF)

# setup paths
Expand Down
5 changes: 5 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ 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")
8 changes: 7 additions & 1 deletion source/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ if (RORSERVER_WITH_ANGELSCRIPT)
target_link_libraries(${PROJECT_NAME} PRIVATE Angelscript::angelscript angelscript_addons)
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

0 comments on commit 784b06b

Please sign in to comment.