diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-07-14 21:11:59 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-07-14 21:11:59 +0000 |
commit | 7958f822ccba4fe2dc372c62aaaa2b2d8fe56acf (patch) | |
tree | c01cbfe7b14be839c3930104ca008a03b4ab3fb0 /src | |
parent | e87b5a8590c31cf93b5a9ff10ad74e20eea4c12f (diff) | |
download | gnunet-7958f822ccba4fe2dc372c62aaaa2b2d8fe56acf.tar.gz gnunet-7958f822ccba4fe2dc372c62aaaa2b2d8fe56acf.zip |
-fix ports
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 106 |
1 files changed, 65 insertions, 41 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index 02f7e0e9b..a6fc47e94 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c | |||
@@ -252,6 +252,9 @@ struct ProxyCurlTask | |||
252 | /* The hostname (Host header field) */ | 252 | /* The hostname (Host header field) */ |
253 | char host[256]; | 253 | char host[256]; |
254 | 254 | ||
255 | /* The port */ | ||
256 | int port; | ||
257 | |||
255 | /* The LEgacy HOstname (can be empty) */ | 258 | /* The LEgacy HOstname (can be empty) */ |
256 | char leho[256]; | 259 | char leho[256]; |
257 | 260 | ||
@@ -407,13 +410,13 @@ static struct MhdHttpList *mhd_httpd_tail; | |||
407 | static regex_t re_dotplus; | 410 | static regex_t re_dotplus; |
408 | 411 | ||
409 | /* The users local GNS zone hash */ | 412 | /* The users local GNS zone hash */ |
410 | static struct GNUNET_CRYPTO_ShortHashCode local_gns_zone; | 413 | static struct GNUNET_CRYPTO_ShortHashCode *local_gns_zone; |
411 | 414 | ||
412 | /* The users local private zone */ | 415 | /* The users local private zone */ |
413 | static struct GNUNET_CRYPTO_ShortHashCode local_private_zone; | 416 | static struct GNUNET_CRYPTO_ShortHashCode *local_private_zone; |
414 | 417 | ||
415 | /* The users local shorten zone */ | 418 | /* The users local shorten zone */ |
416 | static struct GNUNET_CRYPTO_ShortHashCode local_shorten_zone; | 419 | static struct GNUNET_CRYPTO_ShortHashCode *local_shorten_zone; |
417 | 420 | ||
418 | /* The CA for SSL certificate generation */ | 421 | /* The CA for SSL certificate generation */ |
419 | static struct ProxyCA proxy_ca; | 422 | static struct ProxyCA proxy_ca; |
@@ -600,12 +603,20 @@ con_val_iter (void *cls, | |||
600 | { | 603 | { |
601 | struct ProxyCurlTask *ctask = cls; | 604 | struct ProxyCurlTask *ctask = cls; |
602 | char* buf = ctask->host; | 605 | char* buf = ctask->host; |
606 | char* port; | ||
603 | char* cstr; | 607 | char* cstr; |
604 | const char* hdr_val; | 608 | const char* hdr_val; |
605 | 609 | ||
606 | if (0 == strcmp ("Host", key)) | 610 | if (0 == strcmp ("Host", key)) |
607 | { | 611 | { |
608 | strcpy (buf, value); | 612 | port = strstr (value, ":"); |
613 | if (NULL != port) | ||
614 | { | ||
615 | strncpy (buf, value, port-value); | ||
616 | ctask->port = atoi (++port); | ||
617 | } | ||
618 | else | ||
619 | strcpy (buf, value); | ||
609 | return MHD_YES; | 620 | return MHD_YES; |
610 | } | 621 | } |
611 | 622 | ||
@@ -1198,9 +1209,9 @@ postprocess_buffer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1198 | 1209 | ||
1199 | re_match->shorten_task = GNUNET_GNS_shorten_zone (gns_handle, | 1210 | re_match->shorten_task = GNUNET_GNS_shorten_zone (gns_handle, |
1200 | re_match->hostname, | 1211 | re_match->hostname, |
1201 | &local_private_zone, | 1212 | local_private_zone, |
1202 | &local_shorten_zone, | 1213 | local_shorten_zone, |
1203 | &local_gns_zone, | 1214 | local_gns_zone, |
1204 | &process_shorten, | 1215 | &process_shorten, |
1205 | re_match); //FIXME cancel appropriately | 1216 | re_match); //FIXME cancel appropriately |
1206 | 1217 | ||
@@ -1657,7 +1668,7 @@ process_leho_lookup (void *cls, | |||
1657 | "Curl resolve: %s\n", resolvename); | 1668 | "Curl resolve: %s\n", resolvename); |
1658 | ctask->resolver = curl_slist_append ( ctask->resolver, resolvename); | 1669 | ctask->resolver = curl_slist_append ( ctask->resolver, resolvename); |
1659 | curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver); | 1670 | curl_easy_setopt (ctask->curl, CURLOPT_RESOLVE, ctask->resolver); |
1660 | sprintf (curlurl, "https://%s%s", ctask->leho, ctask->url); | 1671 | sprintf (curlurl, "https://%s:%d%s", ctask->leho, ctask->port, ctask->url); |
1661 | curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl); | 1672 | curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl); |
1662 | } | 1673 | } |
1663 | else | 1674 | else |
@@ -1714,7 +1725,7 @@ process_get_authority (void *cls, | |||
1714 | 1725 | ||
1715 | GNUNET_GNS_lookup_zone (gns_handle, | 1726 | GNUNET_GNS_lookup_zone (gns_handle, |
1716 | ctask->host, | 1727 | ctask->host, |
1717 | &local_gns_zone, | 1728 | local_gns_zone, |
1718 | GNUNET_GNS_RECORD_LEHO, | 1729 | GNUNET_GNS_RECORD_LEHO, |
1719 | GNUNET_YES, //Only cached for performance | 1730 | GNUNET_YES, //Only cached for performance |
1720 | shorten_zonekey, | 1731 | shorten_zonekey, |
@@ -1807,6 +1818,7 @@ create_response (void *cls, | |||
1807 | ctask->buffer_read_ptr = ctask->buffer; | 1818 | ctask->buffer_read_ptr = ctask->buffer; |
1808 | ctask->buffer_write_ptr = ctask->buffer; | 1819 | ctask->buffer_write_ptr = ctask->buffer; |
1809 | ctask->pp_task = GNUNET_SCHEDULER_NO_TASK; | 1820 | ctask->pp_task = GNUNET_SCHEDULER_NO_TASK; |
1821 | ctask->port = HTTP_PORT; | ||
1810 | 1822 | ||
1811 | MHD_get_connection_values (con, | 1823 | MHD_get_connection_values (con, |
1812 | MHD_HEADER_KIND, | 1824 | MHD_HEADER_KIND, |
@@ -1867,7 +1879,7 @@ create_response (void *cls, | |||
1867 | 1879 | ||
1868 | if (GNUNET_NO == ctask->mhd->is_ssl) | 1880 | if (GNUNET_NO == ctask->mhd->is_ssl) |
1869 | { | 1881 | { |
1870 | sprintf (curlurl, "http://%s%s", ctask->host, url); | 1882 | sprintf (curlurl, "http://%s:%d%s", ctask->host, ctask->port, url); |
1871 | MHD_get_connection_values (con, | 1883 | MHD_get_connection_values (con, |
1872 | MHD_GET_ARGUMENT_KIND, | 1884 | MHD_GET_ARGUMENT_KIND, |
1873 | &get_uri_val_iter, curlurl); | 1885 | &get_uri_val_iter, curlurl); |
@@ -2844,6 +2856,13 @@ do_shutdown (void *cls, | |||
2844 | "Shutting down...\n"); | 2856 | "Shutting down...\n"); |
2845 | 2857 | ||
2846 | gnutls_global_deinit (); | 2858 | gnutls_global_deinit (); |
2859 | |||
2860 | if (NULL != local_gns_zone) | ||
2861 | GNUNET_free (local_gns_zone); | ||
2862 | if (NULL != local_private_zone) | ||
2863 | GNUNET_free (local_private_zone); | ||
2864 | if (NULL != local_shorten_zone) | ||
2865 | GNUNET_free (local_shorten_zone); | ||
2847 | 2866 | ||
2848 | if (GNUNET_SCHEDULER_NO_TASK != curl_download_task) | 2867 | if (GNUNET_SCHEDULER_NO_TASK != curl_download_task) |
2849 | { | 2868 | { |
@@ -2976,69 +2995,74 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
2976 | 2995 | ||
2977 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 2996 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
2978 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | 2997 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); |
2998 | local_gns_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | ||
2979 | GNUNET_CRYPTO_short_hash(&pkey, | 2999 | GNUNET_CRYPTO_short_hash(&pkey, |
2980 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 3000 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
2981 | &local_gns_zone); | 3001 | local_gns_zone); |
2982 | zone = &local_gns_zone; | 3002 | zone = local_gns_zone; |
2983 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | 3003 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); |
2984 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3004 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2985 | "Using zone: %s!\n", &zonename); | 3005 | "Using zone: %s!\n", &zonename); |
2986 | GNUNET_CRYPTO_rsa_key_free(key); | 3006 | GNUNET_CRYPTO_rsa_key_free(key); |
2987 | GNUNET_free(keyfile); | 3007 | GNUNET_free(keyfile); |
2988 | 3008 | keyfile = NULL; | |
3009 | |||
2989 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 3010 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
2990 | "PRIVATE_ZONEKEY", &keyfile)) | 3011 | "PRIVATE_ZONEKEY", &keyfile)) |
2991 | { | 3012 | { |
2992 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3013 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2993 | "Unable to load private zone key config value!\n"); | 3014 | "Unable to load private zone key config value!\n"); |
2994 | return GNUNET_NO; | ||
2995 | } | 3015 | } |
2996 | 3016 | ||
2997 | if (GNUNET_NO == GNUNET_DISK_file_test (keyfile)) | 3017 | if ((NULL != keyfile) && (GNUNET_NO == GNUNET_DISK_file_test (keyfile))) |
2998 | { | 3018 | { |
2999 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3019 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3000 | "Unable to load private zone key %s!\n", keyfile); | 3020 | "Unable to load private zone key %s!\n", keyfile); |
3001 | GNUNET_free(keyfile); | 3021 | GNUNET_free(keyfile); |
3002 | return GNUNET_NO; | ||
3003 | } | 3022 | } |
3004 | 3023 | else | |
3005 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 3024 | { |
3006 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | 3025 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
3007 | GNUNET_CRYPTO_short_hash(&pkey, | 3026 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); |
3008 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 3027 | local_private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); |
3009 | &local_private_zone); | 3028 | GNUNET_CRYPTO_short_hash(&pkey, |
3010 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | 3029 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
3011 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3030 | local_private_zone); |
3012 | "Using private zone: %s!\n", &zonename); | 3031 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); |
3013 | GNUNET_CRYPTO_rsa_key_free(key); | 3032 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3014 | GNUNET_free(keyfile); | 3033 | "Using private zone: %s!\n", &zonename); |
3034 | GNUNET_CRYPTO_rsa_key_free(key); | ||
3035 | GNUNET_free(keyfile); | ||
3036 | } | ||
3037 | keyfile = NULL; | ||
3015 | 3038 | ||
3016 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", | 3039 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", |
3017 | "SHORTEN_ZONEKEY", &keyfile)) | 3040 | "SHORTEN_ZONEKEY", &keyfile)) |
3018 | { | 3041 | { |
3019 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3042 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3020 | "Unable to load shorten zone key config value!\n"); | 3043 | "Unable to load shorten zone key config value!\n"); |
3021 | return GNUNET_NO; | ||
3022 | } | 3044 | } |
3023 | 3045 | ||
3024 | if (GNUNET_NO == GNUNET_DISK_file_test (keyfile)) | 3046 | if ((NULL != keyfile) && (GNUNET_NO == GNUNET_DISK_file_test (keyfile))) |
3025 | { | 3047 | { |
3026 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3048 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3027 | "Unable to load shorten zone key %s!\n", keyfile); | 3049 | "Unable to load shorten zone key %s!\n", keyfile); |
3028 | GNUNET_free(keyfile); | 3050 | GNUNET_free(keyfile); |
3029 | return GNUNET_NO; | ||
3030 | } | 3051 | } |
3031 | 3052 | else | |
3032 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 3053 | { |
3033 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); | 3054 | key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
3034 | GNUNET_CRYPTO_short_hash(&pkey, | 3055 | GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); |
3035 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 3056 | local_shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); |
3036 | &local_shorten_zone); | 3057 | GNUNET_CRYPTO_short_hash(&pkey, |
3037 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); | 3058 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
3038 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3059 | local_shorten_zone); |
3039 | "Using shorten zone: %s!\n", &zonename); | 3060 | GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); |
3040 | GNUNET_CRYPTO_rsa_key_free(key); | 3061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3041 | GNUNET_free(keyfile); | 3062 | "Using shorten zone: %s!\n", &zonename); |
3063 | GNUNET_CRYPTO_rsa_key_free(key); | ||
3064 | GNUNET_free(keyfile); | ||
3065 | } | ||
3042 | 3066 | ||
3043 | return GNUNET_YES; | 3067 | return GNUNET_YES; |
3044 | } | 3068 | } |