Skip to content

Commit 7ae8538

Browse files
committed
🔧 Replaced sha1_util with Poco::SHA1Engine
1 parent c606d21 commit 7ae8538

File tree

12 files changed

+35
-1064
lines changed

12 files changed

+35
-1064
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
BasedOnStyle: Microsoft
3+
4+
...

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# ensure cmake features we need
22
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
3+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake)
4+
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_BINARY_DIR})
35

46
project(rorserver)
57

8+
9+
find_package(Poco REQUIRED)
10+
611
# setup paths
712
SET(RUNTIME_OUTPUT_DIRECTORY "${rorserver_SOURCE_DIR}/bin/")
813
SET(LIBRARY_OUTPUT_DIRECTORY "${rorserver_SOURCE_DIR}/lib/")

conanfile.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[requires]
2+
poco/1.11.1
3+
4+
[generators]
5+
cmake_find_package_multi
6+
virtualrunenv
7+
8+
[imports]
9+
bin, *.dll -> ./bin/ @ keep_path=False
10+
lib, *.dll -> ./bin/ @ keep_path=False
11+
12+
[options]
13+
poco:enable_pagecompiler=True

source/server/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE
1111
${CMAKE_SOURCE_DIR}/dependencies/jsoncpp/include/
1212
)
1313

14+
target_link_libraries(${PROJECT_NAME} PRIVATE Poco::Poco)
15+
1416
# libraries
1517
if (RORSERVER_WITH_ANGELSCRIPT)
1618
add_dependencies(${PROJECT_NAME} angelscript)

source/server/config.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
2222

2323
#include "logger.h"
2424
#include "sequencer.h"
25-
#include "sha1_util.h"
2625
#include "spamfilter.h"
2726
#include "utils.h"
2827

2928
#include <cmath>
3029
#include <cstring>
30+
#include "Poco/SHA1Engine.h"
3131

3232
#ifdef __GNUC__
3333

@@ -385,15 +385,20 @@ namespace Config {
385385
}
386386

387387
bool setPublicPass(const std::string &pub_pass) {
388-
if (pub_pass.length() > 0 && pub_pass.size() < 250 &&
389-
!SHA1FromString(s_public_password, pub_pass)) {
388+
try
389+
{
390+
Poco::SHA1Engine engine;
391+
engine.update(pub_pass);
392+
s_public_password = Poco::DigestEngine::digestToHex(engine.digest());
393+
Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(), s_public_password.c_str());
394+
return true;
395+
}
396+
catch (...)
397+
{
390398
Logger::Log(LOG_ERROR, "could not generate server SHA1 password hash!");
391399
s_public_password = "";
392400
return false;
393401
}
394-
Logger::Log(LOG_DEBUG, "sha1(%s) = %s", pub_pass.c_str(),
395-
s_public_password.c_str());
396-
return true;
397402
}
398403

399404
bool setIPAddr(const std::string &ip) {

source/server/rorserver.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
2929
#include "master-server.h"
3030
#include "utils.h"
3131

32-
#include "sha1_util.h"
33-
#include "sha1.h"
34-
3532
#include <iostream>
3633
#include <cstdlib>
3734
#include <csignal>
@@ -286,11 +283,6 @@ int main(int argc, char *argv[]) {
286283
return 1;
287284
}
288285

289-
if (!sha1check()) {
290-
Logger::Log(LOG_ERROR, "sha1 malfunction!");
291-
return -1;
292-
}
293-
294286
#ifndef _WIN32
295287
if (!Config::getForeground()) {
296288
// no output because of background mode

source/server/sequencer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
2121
#include "sequencer.h"
2222

2323
#include "messaging.h"
24-
#include "sha1_util.h"
2524
#include "receiver.h"
2625
#include "broadcaster.h"
2726
#include "userauth.h"

0 commit comments

Comments
 (0)