aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/defaults.conf9
-rw-r--r--src/nse/gnunet-service-nse.c58
-rw-r--r--src/nse/test_nse.conf10
-rw-r--r--src/transport/test_quota_compliance_tcp_peer1.conf1
-rw-r--r--src/util/crypto_aes.c2
5 files changed, 62 insertions, 18 deletions
diff --git a/contrib/defaults.conf b/contrib/defaults.conf
index 639c30f6a..2461fb54e 100644
--- a/contrib/defaults.conf
+++ b/contrib/defaults.conf
@@ -433,6 +433,15 @@ UNIX_MATCH_UID = YES
433UNIX_MATCH_GID = YES 433UNIX_MATCH_GID = YES
434PROOFFILE = $SERVICEHOME/.nse-proof 434PROOFFILE = $SERVICEHOME/.nse-proof
435 435
436# How 'slowly' should the proof-of-work be constructed (delay
437# between rounds in ms); sane values between 0 and ~1000.
438WORKDELAY = 5
439
440# Note: changing any of the values below will make this peer
441# completely incompatible with other peers!
442INTERVAL = 3600000
443WORKBITS = 20
444
436 445
437[vpn] 446[vpn]
438CONFIG = $DEFAULTCONFIG 447CONFIG = $DEFAULTCONFIG
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index ad7a0bef1..4c0dae0e1 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -63,17 +63,17 @@
63/** 63/**
64 * Amount of work required (W-bit collisions) for NSE proofs, in collision-bits. 64 * Amount of work required (W-bit collisions) for NSE proofs, in collision-bits.
65 */ 65 */
66#define NSE_WORK_REQUIRED 8 66static unsigned long long nse_work_required;
67 67
68/** 68/**
69 * Interval for sending network size estimation flood requests. 69 * Interval for sending network size estimation flood requests.
70 */ 70 */
71#define GNUNET_NSE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 71static struct GNUNET_TIME_Relative gnunet_nse_interval;
72 72
73/** 73/**
74 * Interval between proof find runs. 74 * Interval between proof find runs.
75 */ 75 */
76#define PROOF_FIND_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) 76static struct GNUNET_TIME_Relative proof_find_delay;
77 77
78 78
79/** 79/**
@@ -360,11 +360,11 @@ get_matching_bits_delay (uint32_t matching_bits)
360{ 360{
361 /* Calculated as: S + f/2 - (f / pi) * (atan(x - p'))*/ 361 /* Calculated as: S + f/2 - (f / pi) * (atan(x - p'))*/
362 // S is next_timestamp (ignored in return value) 362 // S is next_timestamp (ignored in return value)
363 // f is frequency (GNUNET_NSE_INTERVAL) 363 // f is frequency (gnunet_nse_interval)
364 // x is matching_bits 364 // x is matching_bits
365 // p' is current_size_estimate 365 // p' is current_size_estimate
366 return ((double) GNUNET_NSE_INTERVAL.rel_value / (double) 2.0) 366 return ((double) gnunet_nse_interval.rel_value / (double) 2.0)
367 - ((GNUNET_NSE_INTERVAL.rel_value / M_PI) * atan (matching_bits - current_size_estimate)); 367 - ((gnunet_nse_interval.rel_value / M_PI) * atan (matching_bits - current_size_estimate));
368} 368}
369 369
370 370
@@ -673,7 +673,7 @@ update_flood_message(void *cls,
673 } 673 }
674 current_timestamp = next_timestamp; 674 current_timestamp = next_timestamp;
675 next_timestamp = GNUNET_TIME_absolute_add (current_timestamp, 675 next_timestamp = GNUNET_TIME_absolute_add (current_timestamp,
676 GNUNET_NSE_INTERVAL); 676 gnunet_nse_interval);
677 estimate_index = (estimate_index + 1) % HISTORY_SIZE; 677 estimate_index = (estimate_index + 1) % HISTORY_SIZE;
678 if (estimate_count < HISTORY_SIZE) 678 if (estimate_count < HISTORY_SIZE)
679 estimate_count++; 679 estimate_count++;
@@ -741,7 +741,7 @@ check_proof_of_work(const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey,
741 pkey, 741 pkey,
742 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); 742 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
743 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); 743 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
744 return (count_leading_zeroes (&result) >= NSE_WORK_REQUIRED) ? GNUNET_YES : GNUNET_NO; 744 return (count_leading_zeroes (&result) >= nse_work_required) ? GNUNET_YES : GNUNET_NO;
745} 745}
746 746
747 747
@@ -799,7 +799,7 @@ find_proof (void *cls,
799 &counter, 799 &counter,
800 sizeof(uint64_t)); 800 sizeof(uint64_t));
801 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); 801 GNUNET_CRYPTO_hash (buf, sizeof (buf), &result);
802 if (NSE_WORK_REQUIRED <= count_leading_zeroes(&result)) 802 if (nse_work_required <= count_leading_zeroes(&result))
803 { 803 {
804 my_proof = counter; 804 my_proof = counter;
805 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 805 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -834,7 +834,7 @@ find_proof (void *cls,
834 { 834 {
835 my_proof = counter; 835 my_proof = counter;
836 } 836 }
837 proof_task = GNUNET_SCHEDULER_add_delayed (PROOF_FIND_DELAY, 837 proof_task = GNUNET_SCHEDULER_add_delayed (proof_find_delay,
838 &find_proof, 838 &find_proof,
839 NULL); 839 NULL);
840} 840}
@@ -979,9 +979,9 @@ handle_p2p_size_estimate(void *cls,
979 ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp); 979 ts = GNUNET_TIME_absolute_ntoh (incoming_flood->timestamp);
980 if (ts.abs_value == current_timestamp.abs_value) 980 if (ts.abs_value == current_timestamp.abs_value)
981 idx = estimate_index; 981 idx = estimate_index;
982 else if (ts.abs_value == current_timestamp.abs_value - GNUNET_NSE_INTERVAL.rel_value) 982 else if (ts.abs_value == current_timestamp.abs_value - gnunet_nse_interval.rel_value)
983 idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE; 983 idx = (estimate_index + HISTORY_SIZE - 1) % HISTORY_SIZE;
984 else if (ts.abs_value == next_timestamp.abs_value - GNUNET_NSE_INTERVAL.rel_value) 984 else if (ts.abs_value == next_timestamp.abs_value - gnunet_nse_interval.rel_value)
985 { 985 {
986 if (matching_bits <= ntohl (next_message.matching_bits)) 986 if (matching_bits <= ntohl (next_message.matching_bits))
987 return GNUNET_OK; /* ignore, simply too early */ 987 return GNUNET_OK; /* ignore, simply too early */
@@ -1212,12 +1212,12 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
1212 } 1212 }
1213 GNUNET_assert (0 == memcmp (&my_identity, identity, sizeof (struct GNUNET_PeerIdentity))); 1213 GNUNET_assert (0 == memcmp (&my_identity, identity, sizeof (struct GNUNET_PeerIdentity)));
1214 now = GNUNET_TIME_absolute_get (); 1214 now = GNUNET_TIME_absolute_get ();
1215 current_timestamp.abs_value = (now.abs_value / GNUNET_NSE_INTERVAL.rel_value) * GNUNET_NSE_INTERVAL.rel_value; 1215 current_timestamp.abs_value = (now.abs_value / gnunet_nse_interval.rel_value) * gnunet_nse_interval.rel_value;
1216 next_timestamp.abs_value = current_timestamp.abs_value + GNUNET_NSE_INTERVAL.rel_value; 1216 next_timestamp.abs_value = current_timestamp.abs_value + gnunet_nse_interval.rel_value;
1217 1217
1218 for (i=0;i<HISTORY_SIZE;i++) 1218 for (i=0;i<HISTORY_SIZE;i++)
1219 { 1219 {
1220 prev_time.abs_value = current_timestamp.abs_value - (HISTORY_SIZE - i - 1) * GNUNET_NSE_INTERVAL.rel_value; 1220 prev_time.abs_value = current_timestamp.abs_value - (HISTORY_SIZE - i - 1) * gnunet_nse_interval.rel_value;
1221 setup_flood_message (i, prev_time); 1221 setup_flood_message (i, prev_time);
1222 } 1222 }
1223 estimate_index = HISTORY_SIZE - 1; 1223 estimate_index = HISTORY_SIZE - 1;
@@ -1253,6 +1253,34 @@ run(void *cls, struct GNUNET_SERVER_Handle *server,
1253 { NULL, 0, 0 } 1253 { NULL, 0, 0 }
1254 }; 1254 };
1255 cfg = c; 1255 cfg = c;
1256
1257 if ( (GNUNET_OK !=
1258 GNUNET_CONFIGURATION_get_value_time (cfg,
1259 "NSE", "INTERVAL",
1260 &gnunet_nse_interval)) ||
1261 (GNUNET_OK !=
1262 GNUNET_CONFIGURATION_get_value_time (cfg,
1263 "NSE", "WORKDELAY",
1264 &proof_find_delay)) ||
1265 (GNUNET_OK !=
1266 GNUNET_CONFIGURATION_get_value_number (cfg,
1267 "NSE", "WORKBITS",
1268 &nse_work_required)) )
1269 {
1270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1271 _ ("NSE service is lacking key configuration settings. Exiting.\n"));
1272 GNUNET_SCHEDULER_shutdown ();
1273 return;
1274 }
1275 if (nse_work_required >= sizeof (GNUNET_HashCode) * 8)
1276 {
1277 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1278 _ ("Invalid work requirement for NSE service. Exiting.\n"));
1279 GNUNET_SCHEDULER_shutdown ();
1280 return;
1281 }
1282
1283
1256 if (GNUNET_OK != 1284 if (GNUNET_OK !=
1257 GNUNET_CONFIGURATION_get_value_filename (cfg, 1285 GNUNET_CONFIGURATION_get_value_filename (cfg,
1258 "GNUNETD", "HOSTKEY", 1286 "GNUNETD", "HOSTKEY",
diff --git a/src/nse/test_nse.conf b/src/nse/test_nse.conf
index ee3c208a2..35adc0cad 100644
--- a/src/nse/test_nse.conf
+++ b/src/nse/test_nse.conf
@@ -12,6 +12,14 @@ AUTOSTART = YES
12DEBUG = YES 12DEBUG = YES
13CONFIG = $DEFAULTCONFIG 13CONFIG = $DEFAULTCONFIG
14 14
15# Overriding network settings for faster testing (do NOT use
16# these values in production just because they are here)
17WORKDELAY = 1
18INTERVAL = 15000
19WORKBITS = 8
20
21
22
15[arm] 23[arm]
16PORT = 22354 24PORT = 22354
17DEFAULTSERVICES = nse core 25DEFAULTSERVICES = nse core
@@ -49,7 +57,7 @@ EXTERNAL_ADDRESS = 127.0.0.1
49AUTOSTART = NO 57AUTOSTART = NO
50 58
51[testing] 59[testing]
52NUM_PEERS = 100 60NUM_PEERS = 10
53WEAKRANDOM = YES 61WEAKRANDOM = YES
54TOPOLOGY = NONE 62TOPOLOGY = NONE
55CONNECT_TOPOLOGY = SMALL_WORLD_RING 63CONNECT_TOPOLOGY = SMALL_WORLD_RING
diff --git a/src/transport/test_quota_compliance_tcp_peer1.conf b/src/transport/test_quota_compliance_tcp_peer1.conf
index c09d11211..a8ea8a11c 100644
--- a/src/transport/test_quota_compliance_tcp_peer1.conf
+++ b/src/transport/test_quota_compliance_tcp_peer1.conf
@@ -36,7 +36,6 @@ PORT = 4094
36[transport-tcp] 36[transport-tcp]
37TIMEOUT = 300000 37TIMEOUT = 300000
38PORT = 4094 38PORT = 4094
39USE_LOCALADDR = YES
40 39
41[nat] 40[nat]
42DISABLEV6 = YES 41DISABLEV6 = YES
diff --git a/src/util/crypto_aes.c b/src/util/crypto_aes.c
index 1ab4a7301..e26b59abe 100644
--- a/src/util/crypto_aes.c
+++ b/src/util/crypto_aes.c
@@ -56,7 +56,7 @@ GNUNET_CRYPTO_aes_check_session_key (const struct GNUNET_CRYPTO_AesSessionKey
56 crc = GNUNET_CRYPTO_crc32_n (key, GNUNET_CRYPTO_AES_KEY_LENGTH); 56 crc = GNUNET_CRYPTO_crc32_n (key, GNUNET_CRYPTO_AES_KEY_LENGTH);
57 if (ntohl (key->crc32) == crc) 57 if (ntohl (key->crc32) == crc)
58 return GNUNET_OK; 58 return GNUNET_OK;
59 GNUNET_break (0); 59 GNUNET_break_op (0);
60 return GNUNET_SYSERR; 60 return GNUNET_SYSERR;
61} 61}
62 62