diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-19 09:27:27 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-19 09:27:27 +0000 |
commit | d5c14fc6a5a8bdfe7af7dfe457f57c1e6f182607 (patch) | |
tree | b0dcfc9279507babdc61cd028e85f927c89c7613 /src | |
parent | 81c4a12b105773513b944f3385f74a1b6568da78 (diff) | |
download | gnunet-d5c14fc6a5a8bdfe7af7dfe457f57c1e6f182607.tar.gz gnunet-d5c14fc6a5a8bdfe7af7dfe457f57c1e6f182607.zip |
strip external hostname prefix && improve url parsing output
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 0f2cf7138..3b2132dda 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -885,9 +885,9 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
885 | if ((conn_info->client_addr->sa_family != AF_INET) && | 885 | if ((conn_info->client_addr->sa_family != AF_INET) && |
886 | (conn_info->client_addr->sa_family != AF_INET6)) | 886 | (conn_info->client_addr->sa_family != AF_INET6)) |
887 | return NULL; | 887 | return NULL; |
888 | |||
889 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 888 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
890 | "New %s connection from %s\n", method, url); | 889 | "New %s connection from %s\n", method, url); |
890 | |||
891 | /* URL parsing | 891 | /* URL parsing |
892 | * URL is valid if it is in the form [peerid[103];tag]*/ | 892 | * URL is valid if it is in the form [peerid[103];tag]*/ |
893 | url_len = strlen (url); | 893 | url_len = strlen (url); |
@@ -895,18 +895,20 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
895 | 895 | ||
896 | if (url_len < 105) | 896 | if (url_len < 105) |
897 | { | 897 | { |
898 | GNUNET_break (0); | 898 | |
899 | goto error; /* too short */ | 899 | goto error; /* too short */ |
900 | } | 900 | } |
901 | hash_start = strrchr (url, '/'); | 901 | hash_start = strrchr (url, '/'); |
902 | if (NULL == hash_start) | 902 | if (NULL == hash_start) |
903 | { | 903 | { |
904 | GNUNET_break (0); | 904 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
905 | "Invalid request with url `%s': %s\n", url, "No delimiter found"); | ||
905 | goto error; /* '/' delimiter not found */ | 906 | goto error; /* '/' delimiter not found */ |
906 | } | 907 | } |
907 | if (hash_start >= url_end) | 908 | if (hash_start >= url_end) |
908 | { | 909 | { |
909 | GNUNET_break (0); | 910 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
911 | "Invalid request with url `%s': %s\n", url, "Malformed delimiter"); | ||
910 | goto error; /* mal formed */ | 912 | goto error; /* mal formed */ |
911 | } | 913 | } |
912 | hash_start++; | 914 | hash_start++; |
@@ -914,25 +916,29 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
914 | hash_end = strrchr (hash_start, ';'); | 916 | hash_end = strrchr (hash_start, ';'); |
915 | if (NULL == hash_end) | 917 | if (NULL == hash_end) |
916 | { | 918 | { |
917 | GNUNET_break (0); | 919 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
920 | "Invalid request with url `%s': %s\n", url, "No `;' delimiter found"); | ||
918 | goto error; /* ';' delimiter not found */ | 921 | goto error; /* ';' delimiter not found */ |
919 | } | 922 | } |
920 | 923 | ||
921 | if (hash_end >= url_end) | 924 | if (hash_end >= url_end) |
922 | { | 925 | { |
923 | GNUNET_break (0); | 926 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
927 | "Invalid request with url `%s': %s\n", url, "Malformed length"); | ||
924 | goto error; /* mal formed */ | 928 | goto error; /* mal formed */ |
925 | } | 929 | } |
926 | 930 | ||
927 | if (hash_start >= hash_end) | 931 | if (hash_start >= hash_end) |
928 | { | 932 | { |
929 | GNUNET_break (0); | 933 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
934 | "Invalid request with url `%s': %s\n", url, "Malformed length"); | ||
930 | goto error; /* mal formed */ | 935 | goto error; /* mal formed */ |
931 | } | 936 | } |
932 | 937 | ||
933 | if ((strlen(hash_start) - strlen(hash_end)) != 103) | 938 | if ((strlen(hash_start) - strlen(hash_end)) != 103) |
934 | { | 939 | { |
935 | GNUNET_break (0); | 940 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
941 | "New %s connection from %s\n", method, url); | ||
936 | goto error; /* invalid hash length */ | 942 | goto error; /* invalid hash length */ |
937 | } | 943 | } |
938 | 944 | ||
@@ -941,13 +947,15 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
941 | hash[103] = '\0'; | 947 | hash[103] = '\0'; |
942 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((const char *) hash, &(target.hashPubKey))) | 948 | if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((const char *) hash, &(target.hashPubKey))) |
943 | { | 949 | { |
944 | GNUNET_break (0); | 950 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
951 | "Invalid request with url `%s': %s\n", url, "Malformed peer id"); | ||
945 | goto error; /* mal formed */ | 952 | goto error; /* mal formed */ |
946 | } | 953 | } |
947 | 954 | ||
948 | if (hash_end >= url_end) | 955 | if (hash_end >= url_end) |
949 | { | 956 | { |
950 | GNUNET_break (0); | 957 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
958 | "Invalid request with url `%s': %s\n", url, "Malformed length"); | ||
951 | goto error; /* mal formed */ | 959 | goto error; /* mal formed */ |
952 | } | 960 | } |
953 | 961 | ||
@@ -2627,6 +2635,14 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) | |||
2627 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, | 2635 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, plugin->name, |
2628 | "EXTERNAL_HOSTNAME", &plugin->external_hostname)) | 2636 | "EXTERNAL_HOSTNAME", &plugin->external_hostname)) |
2629 | { | 2637 | { |
2638 | char * tmp = NULL; | ||
2639 | if (NULL != strstr(plugin->external_hostname, "://")) | ||
2640 | { | ||
2641 | tmp = strdup(&strstr(plugin->external_hostname, "://")[3]); | ||
2642 | GNUNET_free (plugin->external_hostname); | ||
2643 | plugin->external_hostname = tmp; | ||
2644 | |||
2645 | } | ||
2630 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2646 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
2631 | _("Using external hostname `%s'\n"), plugin->external_hostname); | 2647 | _("Using external hostname `%s'\n"), plugin->external_hostname); |
2632 | plugin->notify_ext_task = GNUNET_SCHEDULER_add_now (&server_notify_external_hostname, plugin); | 2648 | plugin->notify_ext_task = GNUNET_SCHEDULER_add_now (&server_notify_external_hostname, plugin); |