summaryrefslogtreecommitdiff
path: root/other/bootstrap_serverdaemon
diff options
context:
space:
mode:
authorAstonex <softukitu@gmail.com>2013-07-31 23:02:09 +0100
committerAstonex <softukitu@gmail.com>2013-07-31 23:02:09 +0100
commitf05aa308701f33f3bf9df022a4b376deeedef235 (patch)
treec10b8a3cca6822400853bfd3bc2c5fd1cca73f83 /other/bootstrap_serverdaemon
parent8dfba27242ca23fca5de852541f2101568dbf7cb (diff)
parentc558cb63f6db35bd51f2f2331e21df03105ee82a (diff)
Merge remote-tracking branch 'ProjectTox/master'
Diffstat (limited to 'other/bootstrap_serverdaemon')
-rw-r--r--other/bootstrap_serverdaemon/CMakeLists.txt13
-rw-r--r--other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c11
-rw-r--r--other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake73
-rw-r--r--other/bootstrap_serverdaemon/server.cfg4
4 files changed, 94 insertions, 7 deletions
diff --git a/other/bootstrap_serverdaemon/CMakeLists.txt b/other/bootstrap_serverdaemon/CMakeLists.txt
index 6aa4dbee..512179f3 100644
--- a/other/bootstrap_serverdaemon/CMakeLists.txt
+++ b/other/bootstrap_serverdaemon/CMakeLists.txt
@@ -3,8 +3,17 @@ project(DHT_bootstrap_daemon C)
3 3
4set(exe_name DHT_bootstrap_daemon) 4set(exe_name DHT_bootstrap_daemon)
5 5
6find_package(LIBCONFIG REQUIRED)
7
8include_directories(${LIBCONFIG_INCLUDE_DIR})
9
6add_executable(${exe_name} 10add_executable(${exe_name}
7 DHT_bootstrap_daemon.c) 11 DHT_bootstrap_daemon.c)
12
13target_link_libraries(${exe_name}
14 ${LIBCONFIG_LIBRARY})
8 15
9target_link_libraries(${exe_name} config)
10linkCoreLibraries(${exe_name}) 16linkCoreLibraries(${exe_name})
17
18set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
19find_package(LibConfig REQUIRED)
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
index 8e278b28..4f28fb3c 100644
--- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
+++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
@@ -123,11 +123,12 @@ void manage_keys(char *keys_file)
123{ 123{
124 const uint32_t KEYS_SIZE = crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES; 124 const uint32_t KEYS_SIZE = crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES;
125 uint8_t keys[KEYS_SIZE]; 125 uint8_t keys[KEYS_SIZE];
126 126 struct stat existence;
127 /* TODO: stat the file before trying to open it. We aren't cave people! */ 127 FILE *keysf;
128 FILE *keysf = fopen(keys_file, "r"); 128
129 if (keysf != NULL) { 129 /* Check if file exits, proceed to open and load keys */
130 /* if file was opened successfully -- load keys */ 130 if(stat(keys_file,&existence) >= 0) {
131 keysf = fopen(keys_file, "r");
131 size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keysf); 132 size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keysf);
132 if (read_size != KEYS_SIZE) { 133 if (read_size != KEYS_SIZE) {
133 printf("Error while reading the key file\nExiting.\n"); 134 printf("Error while reading the key file\nExiting.\n");
diff --git a/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake b/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake
new file mode 100644
index 00000000..7d6270e6
--- /dev/null
+++ b/other/bootstrap_serverdaemon/cmake/Modules/FindLibConfig.cmake
@@ -0,0 +1,73 @@
1#Ref: https://github.com/schnorr/pajeng/blob/master/cmake/FindLibConfig.cmake
2#
3# This module defines
4# LIBCONFIG_INCLUDE_DIR, where to find cppunit include files, etc.
5# LIBCONFIG_LIBRARIES, the libraries to link against to use CppUnit.
6# LIBCONFIG_STATIC_LIBRARIY_PATH
7# LIBCONFIG_FOUND, If false, do not try to use CppUnit.
8
9# also defined, but not for general use are
10# LIBCONFIG_LIBRARY, where to find the CUnit library.
11
12#MESSAGE("Searching for libconfig library")
13
14FIND_PATH(LIBCONFIG_INCLUDE_DIR libconfig.h
15 /usr/local/include
16 /usr/include
17)
18
19FIND_PATH(LIBCONFIGPP_INCLUDE_DIR libconfig.h++
20 /usr/local/include
21 /usr/include
22)
23
24FIND_LIBRARY(LIBCONFIG_LIBRARY config
25 /usr/local/lib
26 /usr/lib
27)
28
29FIND_LIBRARY(LIBCONFIGPP_LIBRARY config++
30 /usr/local/lib
31 /usr/lib
32)
33
34FIND_LIBRARY(LIBCONFIG_STATIC_LIBRARY "libconfig${CMAKE_STATIC_LIBRARY_SUFFIX}"
35 /usr/local/lib
36 /usr/lib
37)
38
39FIND_LIBRARY(LIBCONFIGPP_STATIC_LIBRARY "libconfig++${CMAKE_STATIC_LIBRARY_SUFFIX}"
40 /usr/local/lib
41 /usr/lib
42)
43
44
45IF(LIBCONFIG_INCLUDE_DIR)
46 IF(LIBCONFIG_LIBRARY)
47 SET(LIBCONFIG_FOUND TRUE)
48 SET(LIBCONFIG_LIBRARIES ${LIBCONFIG_LIBRARY})
49 SET(LIBCONFIG_STATIC_LIBRARY_PATH ${LIBCONFIG_STATIC_LIBRARY})
50 ENDIF(LIBCONFIG_LIBRARY)
51ENDIF(LIBCONFIG_INCLUDE_DIR)
52
53IF(LIBCONFIGPP_INCLUDE_DIR)
54 IF(LIBCONFIGPP_LIBRARY)
55 SET(LIBCONFIGPP_FOUND TRUE)
56 SET(LIBCONFIGPP_LIBRARIES ${LIBCONFIGPP_LIBRARY})
57 SET(LIBCONFIGPP_STATIC_LIBRARY_PATH ${LIBCONFIGPP_STATIC_LIBRARY})
58 ENDIF(LIBCONFIGPP_LIBRARY)
59ENDIF(LIBCONFIGPP_INCLUDE_DIR)
60
61IF (LIBCONFIG_FOUND)
62 IF (NOT LibConfig_FIND_QUIETLY)
63 MESSAGE(STATUS "Found LibConfig++: ${LIBCONFIGPP_LIBRARIES}" )
64 MESSAGE(STATUS "Found LibConfig: ${LIBCONFIG_LIBRARIES}")
65 MESSAGE(STATUS "static LibConfig path: ${LIBCONFIG_STATIC_LIBRARY_PATH}")
66 ENDIF (NOT LibConfig_FIND_QUIETLY)
67ELSE (LIBCONFIG_FOUND)
68 IF (LibConfig_FIND_REQUIRED)
69 MESSAGE(SEND_ERROR "Could NOT find LibConfig")
70 ENDIF (LibConfig_FIND_REQUIRED)
71ENDIF (LIBCONFIG_FOUND)
72
73MARK_AS_ADVANCED(LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARIES)
diff --git a/other/bootstrap_serverdaemon/server.cfg b/other/bootstrap_serverdaemon/server.cfg
index 8ef516ca..527c2a72 100644
--- a/other/bootstrap_serverdaemon/server.cfg
+++ b/other/bootstrap_serverdaemon/server.cfg
@@ -6,11 +6,15 @@ port = 33445;
6// The key file 6// The key file
7// make sure that the user who runs the server 7// make sure that the user who runs the server
8// does have permissions to read it/write to it 8// does have permissions to read it/write to it
9// Remember to replace the provided example with
10// the directory the DHT server will run in.
9keys_file = "/home/tom/.bootstrap_server.keys" 11keys_file = "/home/tom/.bootstrap_server.keys"
10 12
11// The PID file written to by bootstrap_server, 13// The PID file written to by bootstrap_server,
12// make sure that the user who runs the server 14// make sure that the user who runs the server
13// does have permissions to write to it 15// does have permissions to write to it
16// Remember to replace the provided example with
17// the directory the DHT server will run in.
14pid_file = "/home/tom/.bootstrap_server.pid"; 18pid_file = "/home/tom/.bootstrap_server.pid";
15 19
16// The info of the node bootstap_server will 20// The info of the node bootstap_server will