diff options
-rw-r--r-- | src/include/gnunet_testing_lib.h | 8 | ||||
-rw-r--r-- | src/testing/test_testing.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_connect.c | 4 | ||||
-rw-r--r-- | src/testing/test_testing_data_topology_clique.conf | 1 | ||||
-rw-r--r-- | src/testing/test_testing_topology.c | 2 | ||||
-rw-r--r-- | src/testing/testing.c | 28 | ||||
-rw-r--r-- | src/testing/testing_group.c | 237 |
7 files changed, 184 insertions, 98 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index 6ad3e408c..7830ac226 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -43,6 +43,8 @@ extern "C" | |||
43 | #endif | 43 | #endif |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #define HOSTKEYFILESIZE 914 | ||
47 | |||
46 | /** | 48 | /** |
47 | * Handle for a GNUnet daemon (technically a set of | 49 | * Handle for a GNUnet daemon (technically a set of |
48 | * daemons; the handle is really for the master ARM | 50 | * daemons; the handle is really for the master ARM |
@@ -409,6 +411,7 @@ typedef void (*GNUNET_TESTING_NotifyTopology)(void *cls, | |||
409 | * (use NULL for localhost). | 411 | * (use NULL for localhost). |
410 | * @param ssh_username ssh username to use when connecting to hostname | 412 | * @param ssh_username ssh username to use when connecting to hostname |
411 | * @param sshport port to pass to ssh process when connecting to hostname | 413 | * @param sshport port to pass to ssh process when connecting to hostname |
414 | * @param hostkey pointer to a hostkey to be written to disk (instead of being generated) | ||
412 | * @param hostkey_callback function to call once the hostkey has been | 415 | * @param hostkey_callback function to call once the hostkey has been |
413 | * generated for this peer, but it hasn't yet been started | 416 | * generated for this peer, but it hasn't yet been started |
414 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) | 417 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) |
@@ -423,8 +426,9 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
423 | const char *hostname, | 426 | const char *hostname, |
424 | const char *ssh_username, | 427 | const char *ssh_username, |
425 | uint16_t sshport, | 428 | uint16_t sshport, |
426 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, | 429 | const char *hostkey, |
427 | void *hostkey_cls, | 430 | GNUNET_TESTING_NotifyHostkeyCreated |
431 | hostkey_callback, void *hostkey_cls, | ||
428 | GNUNET_TESTING_NotifyDaemonRunning cb, | 432 | GNUNET_TESTING_NotifyDaemonRunning cb, |
429 | void *cb_cls); | 433 | void *cb_cls); |
430 | 434 | ||
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c index 64bf7572a..880ecb399 100644 --- a/src/testing/test_testing.c +++ b/src/testing/test_testing.c | |||
@@ -76,7 +76,7 @@ run (void *cls, | |||
76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); | 76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); |
77 | #endif | 77 | #endif |
78 | d = | 78 | d = |
79 | GNUNET_TESTING_daemon_start (cfg, TIMEOUT, NULL, NULL, 0, NULL, NULL, | 79 | GNUNET_TESTING_daemon_start (cfg, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, |
80 | &my_cb, NULL); | 80 | &my_cb, NULL); |
81 | GNUNET_assert (d != NULL); | 81 | GNUNET_assert (d != NULL); |
82 | } | 82 | } |
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 2c3014635..f42142319 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c | |||
@@ -133,7 +133,7 @@ my_cb1 (void *cls, | |||
133 | "Daemon `%s' started.\n", GNUNET_i2s (id)); | 133 | "Daemon `%s' started.\n", GNUNET_i2s (id)); |
134 | #endif | 134 | #endif |
135 | d2 = | 135 | d2 = |
136 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, | 136 | GNUNET_TESTING_daemon_start (c2, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, |
137 | &my_cb2, NULL); | 137 | &my_cb2, NULL); |
138 | GNUNET_assert (d2 != NULL); | 138 | GNUNET_assert (d2 != NULL); |
139 | 139 | ||
@@ -154,7 +154,7 @@ run (void *cls, | |||
154 | c2 = GNUNET_CONFIGURATION_create (); | 154 | c2 = GNUNET_CONFIGURATION_create (); |
155 | GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); | 155 | GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); |
156 | d1 = | 156 | d1 = |
157 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, | 157 | GNUNET_TESTING_daemon_start (c1, TIMEOUT, NULL, NULL, 0, NULL, NULL, NULL, |
158 | &my_cb1, NULL); | 158 | &my_cb1, NULL); |
159 | GNUNET_assert (d1 != NULL); | 159 | GNUNET_assert (d1 != NULL); |
160 | } | 160 | } |
diff --git a/src/testing/test_testing_data_topology_clique.conf b/src/testing/test_testing_data_topology_clique.conf index 012c2cab4..7858d7661 100644 --- a/src/testing/test_testing_data_topology_clique.conf +++ b/src/testing/test_testing_data_topology_clique.conf | |||
@@ -23,6 +23,7 @@ PORT = 2567 | |||
23 | 23 | ||
24 | [transport-tcp] | 24 | [transport-tcp] |
25 | PORT = 2568 | 25 | PORT = 2568 |
26 | ENABLE_UPNP = NO | ||
26 | 27 | ||
27 | [transport-udp] | 28 | [transport-udp] |
28 | PORT = 2568 | 29 | PORT = 2568 |
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index cf1b3232c..8ad864be7 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "gnunet_core_service.h" | 26 | #include "gnunet_core_service.h" |
27 | #include "gnunet_os_lib.h" | 27 | #include "gnunet_os_lib.h" |
28 | 28 | ||
29 | #define VERBOSE GNUNET_NO | 29 | #define VERBOSE GNUNET_YES |
30 | 30 | ||
31 | #define DELAY_FOR_LOGGING GNUNET_NO | 31 | #define DELAY_FOR_LOGGING GNUNET_NO |
32 | 32 | ||
diff --git a/src/testing/testing.c b/src/testing/testing.c index 75eab1a06..a24c1feae 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -385,6 +385,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
385 | return; | 385 | return; |
386 | } | 386 | } |
387 | d->hostkeybuf[103] = '\0'; | 387 | d->hostkeybuf[103] = '\0'; |
388 | |||
388 | if ((bytes_read < 0) || | 389 | if ((bytes_read < 0) || |
389 | (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, | 390 | (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, |
390 | &d->id.hashPubKey))) | 391 | &d->id.hashPubKey))) |
@@ -789,6 +790,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, | |||
789 | * (use NULL for localhost). | 790 | * (use NULL for localhost). |
790 | * @param ssh_username ssh username to use when connecting to hostname | 791 | * @param ssh_username ssh username to use when connecting to hostname |
791 | * @param sshport port to pass to ssh process when connecting to hostname | 792 | * @param sshport port to pass to ssh process when connecting to hostname |
793 | * @param hostkey pointer to a hostkey to be written to disk (instead of being generated) | ||
792 | * @param hostkey_callback function to call once the hostkey has been | 794 | * @param hostkey_callback function to call once the hostkey has been |
793 | * generated for this peer, but it hasn't yet been started | 795 | * generated for this peer, but it hasn't yet been started |
794 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) | 796 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) |
@@ -803,6 +805,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
803 | const char *hostname, | 805 | const char *hostname, |
804 | const char *ssh_username, | 806 | const char *ssh_username, |
805 | uint16_t sshport, | 807 | uint16_t sshport, |
808 | const char *hostkey, | ||
806 | GNUNET_TESTING_NotifyHostkeyCreated | 809 | GNUNET_TESTING_NotifyHostkeyCreated |
807 | hostkey_callback, void *hostkey_cls, | 810 | hostkey_callback, void *hostkey_cls, |
808 | GNUNET_TESTING_NotifyDaemonRunning cb, | 811 | GNUNET_TESTING_NotifyDaemonRunning cb, |
@@ -811,6 +814,9 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
811 | struct GNUNET_TESTING_Daemon *ret; | 814 | struct GNUNET_TESTING_Daemon *ret; |
812 | char *arg; | 815 | char *arg; |
813 | char *username; | 816 | char *username; |
817 | char *servicehome; | ||
818 | char *hostkeyfile; | ||
819 | struct GNUNET_DISK_FileHandle *fn; | ||
814 | 820 | ||
815 | ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); | 821 | ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); |
816 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); | 822 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); |
@@ -842,6 +848,28 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
842 | GNUNET_CONFIGURATION_set_value_string (ret->cfg, | 848 | GNUNET_CONFIGURATION_set_value_string (ret->cfg, |
843 | "PATHS", | 849 | "PATHS", |
844 | "DEFAULTCONFIG", ret->cfgfile); | 850 | "DEFAULTCONFIG", ret->cfgfile); |
851 | if (hostkey != NULL) | ||
852 | { | ||
853 | GNUNET_assert(GNUNET_OK == | ||
854 | GNUNET_CONFIGURATION_get_value_string (ret->cfg, | ||
855 | "PATHS", | ||
856 | "SERVICEHOME", | ||
857 | &servicehome)); | ||
858 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_create (servicehome)); | ||
859 | GNUNET_asprintf(&hostkeyfile, "%s/.hostkey", servicehome); | ||
860 | fn = | ||
861 | GNUNET_DISK_file_open (hostkeyfile, | ||
862 | GNUNET_DISK_OPEN_READWRITE | ||
863 | | GNUNET_DISK_OPEN_CREATE, | ||
864 | GNUNET_DISK_PERM_USER_READ | | ||
865 | GNUNET_DISK_PERM_USER_WRITE); | ||
866 | GNUNET_assert(fn != NULL); | ||
867 | GNUNET_assert(HOSTKEYFILESIZE == GNUNET_DISK_file_write(fn, hostkey, HOSTKEYFILESIZE)); | ||
868 | GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fn)); | ||
869 | GNUNET_free(servicehome); | ||
870 | GNUNET_free(hostkeyfile); | ||
871 | } | ||
872 | |||
845 | /* 1) write configuration to temporary file */ | 873 | /* 1) write configuration to temporary file */ |
846 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) | 874 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) |
847 | { | 875 | { |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index f3eeb9069..78de644f4 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -304,6 +304,11 @@ struct InternalStartContext | |||
304 | const char *username; | 304 | const char *username; |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * Pointer to starting memory location of a hostkey | ||
308 | */ | ||
309 | const char *hostkey; | ||
310 | |||
311 | /** | ||
307 | * Port to use for ssh. | 312 | * Port to use for ssh. |
308 | */ | 313 | */ |
309 | uint16_t sshport; | 314 | uint16_t sshport; |
@@ -629,6 +634,96 @@ struct UnblacklistContext | |||
629 | uint32_t first_uid; | 634 | uint32_t first_uid; |
630 | }; | 635 | }; |
631 | 636 | ||
637 | struct RandomContext | ||
638 | { | ||
639 | /** | ||
640 | * The peergroup | ||
641 | */ | ||
642 | struct GNUNET_TESTING_PeerGroup *pg; | ||
643 | |||
644 | /** | ||
645 | * uid of the first peer | ||
646 | */ | ||
647 | uint32_t first_uid; | ||
648 | |||
649 | /** | ||
650 | * Peer data for first peer. | ||
651 | */ | ||
652 | struct PeerData *first; | ||
653 | |||
654 | /** | ||
655 | * Random percentage to use | ||
656 | */ | ||
657 | double percentage; | ||
658 | }; | ||
659 | |||
660 | struct MinimumContext | ||
661 | { | ||
662 | /** | ||
663 | * The peergroup | ||
664 | */ | ||
665 | struct GNUNET_TESTING_PeerGroup *pg; | ||
666 | |||
667 | /** | ||
668 | * uid of the first peer | ||
669 | */ | ||
670 | uint32_t first_uid; | ||
671 | |||
672 | /** | ||
673 | * Peer data for first peer. | ||
674 | */ | ||
675 | struct PeerData *first; | ||
676 | |||
677 | /** | ||
678 | * Number of conns per peer | ||
679 | */ | ||
680 | unsigned int num_to_add; | ||
681 | |||
682 | /** | ||
683 | * Permuted array of all possible connections. Only add the Nth | ||
684 | * peer if it's in the Nth position. | ||
685 | */ | ||
686 | unsigned int *pg_array; | ||
687 | |||
688 | /** | ||
689 | * What number is the current element we are iterating over? | ||
690 | */ | ||
691 | unsigned int current; | ||
692 | }; | ||
693 | |||
694 | struct DFSContext | ||
695 | { | ||
696 | /** | ||
697 | * The peergroup | ||
698 | */ | ||
699 | struct GNUNET_TESTING_PeerGroup *pg; | ||
700 | |||
701 | /** | ||
702 | * uid of the first peer | ||
703 | */ | ||
704 | uint32_t first_uid; | ||
705 | |||
706 | /** | ||
707 | * uid of the second peer | ||
708 | */ | ||
709 | uint32_t second_uid; | ||
710 | |||
711 | /** | ||
712 | * Peer data for first peer. | ||
713 | */ | ||
714 | struct PeerData *first; | ||
715 | |||
716 | /** | ||
717 | * Which peer has been chosen as the one to add? | ||
718 | */ | ||
719 | unsigned int chosen; | ||
720 | |||
721 | /** | ||
722 | * What number is the current element we are iterating over? | ||
723 | */ | ||
724 | unsigned int current; | ||
725 | }; | ||
726 | |||
632 | /** | 727 | /** |
633 | * Convert unique ID to hash code. | 728 | * Convert unique ID to hash code. |
634 | * | 729 | * |
@@ -2100,6 +2195,7 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, | |||
2100 | return connect_attempts; | 2195 | return connect_attempts; |
2101 | } | 2196 | } |
2102 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read %u total peers in topology\n", total_peers); | 2197 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read %u total peers in topology\n", total_peers); |
2198 | GNUNET_assert(total_peers == pg->total); | ||
2103 | curr_state = PEER_INDEX; | 2199 | curr_state = PEER_INDEX; |
2104 | while((buf[count] != '\n') && (count < frstat.st_size - 1)) | 2200 | while((buf[count] != '\n') && (count < frstat.st_size - 1)) |
2105 | count++; | 2201 | count++; |
@@ -2131,18 +2227,19 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, | |||
2131 | return connect_attempts; | 2227 | return connect_attempts; |
2132 | } | 2228 | } |
2133 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read second peer index %u\n", second_peer_index); | 2229 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Read second peer index %u\n", second_peer_index); |
2134 | while((buf[count] != '\n') && (buf[count] != ' ') && (count < frstat.st_size - 1)) | 2230 | /* Assume file is written with first peer 1, but array index is 0 */ |
2231 | connect_attempts += proc (pg, first_peer_index - 1, second_peer_index - 1); | ||
2232 | while((buf[count] != '\n') && (buf[count] != ',') && (count < frstat.st_size - 1)) | ||
2135 | count++; | 2233 | count++; |
2136 | if (buf[count] == '\n') | 2234 | if (buf[count] == '\n') |
2137 | { | 2235 | { |
2138 | curr_state = PEER_INDEX; | 2236 | curr_state = PEER_INDEX; |
2139 | } | 2237 | } |
2140 | else if (buf[count] != ' ') | 2238 | else if (buf[count] != ',') |
2141 | { | 2239 | { |
2142 | curr_state = OTHER_PEER_INDEX; | 2240 | curr_state = OTHER_PEER_INDEX; |
2143 | } | 2241 | } |
2144 | count++; | 2242 | count++; |
2145 | curr_state = OTHER_PEER_INDEX; | ||
2146 | break; | 2243 | break; |
2147 | default: | 2244 | default: |
2148 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Found bad data in topology file while in state %d!\n", curr_state); | 2245 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Found bad data in topology file while in state %d!\n", curr_state); |
@@ -3078,95 +3175,6 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, | |||
3078 | return num_connections; | 3175 | return num_connections; |
3079 | } | 3176 | } |
3080 | 3177 | ||
3081 | struct RandomContext | ||
3082 | { | ||
3083 | /** | ||
3084 | * The peergroup | ||
3085 | */ | ||
3086 | struct GNUNET_TESTING_PeerGroup *pg; | ||
3087 | |||
3088 | /** | ||
3089 | * uid of the first peer | ||
3090 | */ | ||
3091 | uint32_t first_uid; | ||
3092 | |||
3093 | /** | ||
3094 | * Peer data for first peer. | ||
3095 | */ | ||
3096 | struct PeerData *first; | ||
3097 | |||
3098 | /** | ||
3099 | * Random percentage to use | ||
3100 | */ | ||
3101 | double percentage; | ||
3102 | }; | ||
3103 | |||
3104 | struct MinimumContext | ||
3105 | { | ||
3106 | /** | ||
3107 | * The peergroup | ||
3108 | */ | ||
3109 | struct GNUNET_TESTING_PeerGroup *pg; | ||
3110 | |||
3111 | /** | ||
3112 | * uid of the first peer | ||
3113 | */ | ||
3114 | uint32_t first_uid; | ||
3115 | |||
3116 | /** | ||
3117 | * Peer data for first peer. | ||
3118 | */ | ||
3119 | struct PeerData *first; | ||
3120 | |||
3121 | /** | ||
3122 | * Number of conns per peer | ||
3123 | */ | ||
3124 | unsigned int num_to_add; | ||
3125 | |||
3126 | /** | ||
3127 | * Permuted array of all possible connections. Only add the Nth | ||
3128 | * peer if it's in the Nth position. | ||
3129 | */ | ||
3130 | unsigned int *pg_array; | ||
3131 | |||
3132 | /** | ||
3133 | * What number is the current element we are iterating over? | ||
3134 | */ | ||
3135 | unsigned int current; | ||
3136 | }; | ||
3137 | |||
3138 | struct DFSContext | ||
3139 | { | ||
3140 | /** | ||
3141 | * The peergroup | ||
3142 | */ | ||
3143 | struct GNUNET_TESTING_PeerGroup *pg; | ||
3144 | |||
3145 | /** | ||
3146 | * uid of the first peer | ||
3147 | */ | ||
3148 | uint32_t first_uid; | ||
3149 | |||
3150 | /** | ||
3151 | * uid of the second peer | ||
3152 | */ | ||
3153 | uint32_t second_uid; | ||
3154 | |||
3155 | /** | ||
3156 | * Peer data for first peer. | ||
3157 | */ | ||
3158 | struct PeerData *first; | ||
3159 | |||
3160 | /** | ||
3161 | * Which peer has been chosen as the one to add? | ||
3162 | */ | ||
3163 | unsigned int chosen; | ||
3164 | |||
3165 | /** | ||
3166 | * What number is the current element we are iterating over? | ||
3167 | */ | ||
3168 | unsigned int current; | ||
3169 | }; | ||
3170 | 3178 | ||
3171 | /** | 3179 | /** |
3172 | * Iterator for choosing random peers to connect. | 3180 | * Iterator for choosing random peers to connect. |
@@ -4324,6 +4332,7 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4324 | internal_context->hostname, | 4332 | internal_context->hostname, |
4325 | internal_context->username, | 4333 | internal_context->username, |
4326 | internal_context->sshport, | 4334 | internal_context->sshport, |
4335 | internal_context->hostkey, | ||
4327 | &internal_hostkey_callback, | 4336 | &internal_hostkey_callback, |
4328 | internal_context, | 4337 | internal_context, |
4329 | &internal_startup_callback, | 4338 | &internal_startup_callback, |
@@ -4405,6 +4414,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
4405 | char *baseservicehome; | 4414 | char *baseservicehome; |
4406 | char *newservicehome; | 4415 | char *newservicehome; |
4407 | char *tmpdir; | 4416 | char *tmpdir; |
4417 | char *hostkeys_file; | ||
4418 | char *hostkey_data; | ||
4419 | struct GNUNET_DISK_FileHandle *fd; | ||
4408 | struct GNUNET_CONFIGURATION_Handle *pcfg; | 4420 | struct GNUNET_CONFIGURATION_Handle *pcfg; |
4409 | unsigned int off; | 4421 | unsigned int off; |
4410 | unsigned int hostcnt; | 4422 | unsigned int hostcnt; |
@@ -4412,12 +4424,15 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
4412 | uint16_t sshport; | 4424 | uint16_t sshport; |
4413 | uint32_t upnum; | 4425 | uint32_t upnum; |
4414 | uint32_t fdnum; | 4426 | uint32_t fdnum; |
4427 | uint64_t fs; | ||
4428 | uint64_t total_hostkeys; | ||
4415 | 4429 | ||
4416 | if (0 == total) | 4430 | if (0 == total) |
4417 | { | 4431 | { |
4418 | GNUNET_break (0); | 4432 | GNUNET_break (0); |
4419 | return NULL; | 4433 | return NULL; |
4420 | } | 4434 | } |
4435 | hostkey_data = NULL; | ||
4421 | upnum = 0; | 4436 | upnum = 0; |
4422 | fdnum = 0; | 4437 | fdnum = 0; |
4423 | pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup)); | 4438 | pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup)); |
@@ -4509,6 +4524,42 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
4509 | hostcnt = 0; | 4524 | hostcnt = 0; |
4510 | minport = LOW_PORT; | 4525 | minport = LOW_PORT; |
4511 | } | 4526 | } |
4527 | |||
4528 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE", | ||
4529 | &hostkeys_file)) | ||
4530 | { | ||
4531 | if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) | ||
4532 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Couldn't read hostkeys file!"); | ||
4533 | else | ||
4534 | { | ||
4535 | /* Check hostkey file size, read entire thing into memory */ | ||
4536 | fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ, | ||
4537 | GNUNET_DISK_PERM_NONE); | ||
4538 | if (NULL == fd) | ||
4539 | { | ||
4540 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file); | ||
4541 | return NULL; | ||
4542 | } | ||
4543 | |||
4544 | if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES)) | ||
4545 | fs = 0; | ||
4546 | |||
4547 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found file size %llu for hostkeys, expect hostkeys to be size %d\n", fs, HOSTKEYFILESIZE); | ||
4548 | |||
4549 | if (fs % HOSTKEYFILESIZE != 0) | ||
4550 | { | ||
4551 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "File size %llu seems incorrect for hostkeys...\n", fs); | ||
4552 | } | ||
4553 | else | ||
4554 | { | ||
4555 | total_hostkeys = fs / HOSTKEYFILESIZE; | ||
4556 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Will read %llu hostkeys from file\n", total_hostkeys); | ||
4557 | hostkey_data = GNUNET_malloc_large (fs); | ||
4558 | GNUNET_assert (fs == GNUNET_DISK_file_read (fd, hostkey_data, fs)); | ||
4559 | } | ||
4560 | } | ||
4561 | } | ||
4562 | |||
4512 | for (off = 0; off < total; off++) | 4563 | for (off = 0; off < total; off++) |
4513 | { | 4564 | { |
4514 | if (hostcnt > 0) | 4565 | if (hostcnt > 0) |
@@ -4570,6 +4621,8 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
4570 | pg->peers[off].internal_context.hostname = hostname; | 4621 | pg->peers[off].internal_context.hostname = hostname; |
4571 | pg->peers[off].internal_context.username = username; | 4622 | pg->peers[off].internal_context.username = username; |
4572 | pg->peers[off].internal_context.sshport = sshport; | 4623 | pg->peers[off].internal_context.sshport = sshport; |
4624 | if (hostkey_data != NULL) | ||
4625 | pg->peers[off].internal_context.hostkey = &hostkey_data[off * HOSTKEYFILESIZE]; | ||
4573 | pg->peers[off].internal_context.hostkey_callback = hostkey_callback; | 4626 | pg->peers[off].internal_context.hostkey_callback = hostkey_callback; |
4574 | pg->peers[off].internal_context.hostkey_cls = hostkey_cls; | 4627 | pg->peers[off].internal_context.hostkey_cls = hostkey_cls; |
4575 | pg->peers[off].internal_context.start_cb = cb; | 4628 | pg->peers[off].internal_context.start_cb = cb; |