diff options
Diffstat (limited to 'src/gns/gnunet-gns-proxy.c')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 90 |
1 files changed, 21 insertions, 69 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 3a38970a8..6eb87a95e 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -606,7 +606,7 @@ struct Socks5Request | |||
606 | * Headers from response | 606 | * Headers from response |
607 | */ | 607 | */ |
608 | struct HttpResponseHeader *header_tail; | 608 | struct HttpResponseHeader *header_tail; |
609 | 609 | ||
610 | /** | 610 | /** |
611 | * SSL Certificate status | 611 | * SSL Certificate status |
612 | */ | 612 | */ |
@@ -695,16 +695,6 @@ static struct Socks5Request *s5r_tail; | |||
695 | static struct GNUNET_CRYPTO_EcdsaPublicKey local_gns_zone; | 695 | static struct GNUNET_CRYPTO_EcdsaPublicKey local_gns_zone; |
696 | 696 | ||
697 | /** | 697 | /** |
698 | * The users local shorten zone | ||
699 | */ | ||
700 | static struct GNUNET_CRYPTO_EcdsaPrivateKey local_shorten_zone; | ||
701 | |||
702 | /** | ||
703 | * Is shortening enabled? | ||
704 | */ | ||
705 | static int do_shorten; | ||
706 | |||
707 | /** | ||
708 | * The CA for SSL certificate generation | 698 | * The CA for SSL certificate generation |
709 | */ | 699 | */ |
710 | static struct ProxyCA proxy_ca; | 700 | static struct ProxyCA proxy_ca; |
@@ -873,7 +863,7 @@ check_ssl_certificate (struct Socks5Request *s5r) | |||
873 | gnutls_x509_crt_t x509_cert; | 863 | gnutls_x509_crt_t x509_cert; |
874 | int rc; | 864 | int rc; |
875 | const char *name; | 865 | const char *name; |
876 | 866 | ||
877 | s5r->ssl_checked = GNUNET_YES; | 867 | s5r->ssl_checked = GNUNET_YES; |
878 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "XXXXXX\n"); | 868 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "XXXXXX\n"); |
879 | if (CURLE_OK != | 869 | if (CURLE_OK != |
@@ -1039,7 +1029,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) | |||
1039 | size_t delta_cdomain; | 1029 | size_t delta_cdomain; |
1040 | int domain_matched; | 1030 | int domain_matched; |
1041 | char *tok; | 1031 | char *tok; |
1042 | 1032 | ||
1043 | /* first, check SSL certificate */ | 1033 | /* first, check SSL certificate */ |
1044 | if ((GNUNET_YES != s5r->ssl_checked) && | 1034 | if ((GNUNET_YES != s5r->ssl_checked) && |
1045 | (HTTPS_PORT == s5r->port)) | 1035 | (HTTPS_PORT == s5r->port)) |
@@ -1047,7 +1037,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) | |||
1047 | if (GNUNET_OK != check_ssl_certificate (s5r)) | 1037 | if (GNUNET_OK != check_ssl_certificate (s5r)) |
1048 | return 0; | 1038 | return 0; |
1049 | } | 1039 | } |
1050 | 1040 | ||
1051 | ndup = GNUNET_strndup (buffer, bytes); | 1041 | ndup = GNUNET_strndup (buffer, bytes); |
1052 | hdr_type = strtok (ndup, ":"); | 1042 | hdr_type = strtok (ndup, ":"); |
1053 | if (NULL == hdr_type) | 1043 | if (NULL == hdr_type) |
@@ -1287,7 +1277,7 @@ curl_upload_cb (void *buf, size_t size, size_t nmemb, void *cls) | |||
1287 | struct Socks5Request *s5r = cls; | 1277 | struct Socks5Request *s5r = cls; |
1288 | size_t len = size * nmemb; | 1278 | size_t len = size * nmemb; |
1289 | size_t to_copy; | 1279 | size_t to_copy; |
1290 | 1280 | ||
1291 | if ( (0 == s5r->io_len) && | 1281 | if ( (0 == s5r->io_len) && |
1292 | (SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) ) | 1282 | (SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) ) |
1293 | { | 1283 | { |
@@ -1763,7 +1753,7 @@ create_response (void *cls, | |||
1763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1764 | "Processing %u bytes UPLOAD\n", | 1754 | "Processing %u bytes UPLOAD\n", |
1765 | (unsigned int) *upload_data_size); | 1755 | (unsigned int) *upload_data_size); |
1766 | 1756 | ||
1767 | /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else | 1757 | /* FIXME: This must be set or a header with Transfer-Encoding: chunked. Else |
1768 | * upload callback is not called! | 1758 | * upload callback is not called! |
1769 | */ | 1759 | */ |
@@ -2827,7 +2817,6 @@ do_s5r_read (void *cls) | |||
2827 | &local_gns_zone, | 2817 | &local_gns_zone, |
2828 | GNUNET_DNSPARSER_TYPE_A, | 2818 | GNUNET_DNSPARSER_TYPE_A, |
2829 | GNUNET_NO /* only cached */, | 2819 | GNUNET_NO /* only cached */, |
2830 | (GNUNET_YES == do_shorten) ? &local_shorten_zone : NULL, | ||
2831 | &handle_gns_result, | 2820 | &handle_gns_result, |
2832 | s5r); | 2821 | s5r); |
2833 | break; | 2822 | break; |
@@ -3141,46 +3130,6 @@ run_cont () | |||
3141 | 3130 | ||
3142 | 3131 | ||
3143 | /** | 3132 | /** |
3144 | * Method called to inform about the egos of the shorten zone of this peer. | ||
3145 | * | ||
3146 | * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, | ||
3147 | * this function is only called ONCE, and 'NULL' being passed in | ||
3148 | * @a ego does indicate an error (i.e. name is taken or no default | ||
3149 | * value is known). If @a ego is non-NULL and if '*ctx' | ||
3150 | * is set in those callbacks, the value WILL be passed to a subsequent | ||
3151 | * call to the identity callback of #GNUNET_IDENTITY_connect (if | ||
3152 | * that one was not NULL). | ||
3153 | * | ||
3154 | * @param cls closure, NULL | ||
3155 | * @param ego ego handle | ||
3156 | * @param ctx context for application to store data for this ego | ||
3157 | * (during the lifetime of this process, initially NULL) | ||
3158 | * @param name name assigned by the user for this ego, | ||
3159 | * NULL if the user just deleted the ego and it | ||
3160 | * must thus no longer be used | ||
3161 | */ | ||
3162 | static void | ||
3163 | identity_shorten_cb (void *cls, | ||
3164 | struct GNUNET_IDENTITY_Ego *ego, | ||
3165 | void **ctx, | ||
3166 | const char *name) | ||
3167 | { | ||
3168 | id_op = NULL; | ||
3169 | if (NULL == ego) | ||
3170 | { | ||
3171 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3172 | _("No ego configured for `shorten-zone`\n")); | ||
3173 | } | ||
3174 | else | ||
3175 | { | ||
3176 | local_shorten_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); | ||
3177 | do_shorten = GNUNET_YES; | ||
3178 | } | ||
3179 | run_cont (); | ||
3180 | } | ||
3181 | |||
3182 | |||
3183 | /** | ||
3184 | * Method called to inform about the egos of the master zone of this peer. | 3133 | * Method called to inform about the egos of the master zone of this peer. |
3185 | * | 3134 | * |
3186 | * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, | 3135 | * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get, |
@@ -3216,10 +3165,7 @@ identity_master_cb (void *cls, | |||
3216 | } | 3165 | } |
3217 | GNUNET_IDENTITY_ego_get_public_key (ego, | 3166 | GNUNET_IDENTITY_ego_get_public_key (ego, |
3218 | &local_gns_zone); | 3167 | &local_gns_zone); |
3219 | id_op = GNUNET_IDENTITY_get (identity, | 3168 | run_cont (); |
3220 | "gns-short", | ||
3221 | &identity_shorten_cb, | ||
3222 | NULL); | ||
3223 | } | 3169 | } |
3224 | 3170 | ||
3225 | 3171 | ||
@@ -3232,7 +3178,9 @@ identity_master_cb (void *cls, | |||
3232 | * @param c configuration | 3178 | * @param c configuration |
3233 | */ | 3179 | */ |
3234 | static void | 3180 | static void |
3235 | run (void *cls, char *const *args, const char *cfgfile, | 3181 | run (void *cls, |
3182 | char *const *args, | ||
3183 | const char *cfgfile, | ||
3236 | const struct GNUNET_CONFIGURATION_Handle *c) | 3184 | const struct GNUNET_CONFIGURATION_Handle *c) |
3237 | { | 3185 | { |
3238 | char* cafile_cfg = NULL; | 3186 | char* cafile_cfg = NULL; |
@@ -3323,22 +3271,26 @@ main (int argc, char *const *argv) | |||
3323 | "</head><body>cURL fail</body></html>"; | 3271 | "</head><body>cURL fail</body></html>"; |
3324 | int ret; | 3272 | int ret; |
3325 | 3273 | ||
3326 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 3274 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, |
3275 | &argc, &argv)) | ||
3327 | return 2; | 3276 | return 2; |
3328 | GNUNET_log_setup ("gnunet-gns-proxy", "WARNING", NULL); | 3277 | GNUNET_log_setup ("gnunet-gns-proxy", |
3329 | curl_failure_response = MHD_create_response_from_buffer (strlen (page), | 3278 | "WARNING", |
3330 | (void*)page, | 3279 | NULL); |
3331 | MHD_RESPMEM_PERSISTENT); | 3280 | curl_failure_response |
3281 | = MHD_create_response_from_buffer (strlen (page), | ||
3282 | (void *) page, | ||
3283 | MHD_RESPMEM_PERSISTENT); | ||
3332 | 3284 | ||
3333 | ret = | 3285 | ret = |
3334 | (GNUNET_OK == | 3286 | (GNUNET_OK == |
3335 | GNUNET_PROGRAM_run (argc, argv, "gnunet-gns-proxy", | 3287 | GNUNET_PROGRAM_run (argc, argv, |
3288 | "gnunet-gns-proxy", | ||
3336 | _("GNUnet GNS proxy"), | 3289 | _("GNUnet GNS proxy"), |
3337 | options, | 3290 | options, |
3338 | &run, NULL)) ? 0 : 1; | 3291 | &run, NULL)) ? 0 : 1; |
3339 | MHD_destroy_response (curl_failure_response); | 3292 | MHD_destroy_response (curl_failure_response); |
3340 | GNUNET_free_non_null ((char *) argv); | 3293 | GNUNET_free_non_null ((char *) argv); |
3341 | GNUNET_CRYPTO_ecdsa_key_clear (&local_shorten_zone); | ||
3342 | return ret; | 3294 | return ret; |
3343 | } | 3295 | } |
3344 | 3296 | ||