diff options
-rw-r--r-- | src/gns/gnunet-service-gns.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 99738056d..fa2b3e2e2 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -187,6 +187,12 @@ static char *private_zone_id; | |||
187 | /* name of the public zone */ | 187 | /* name of the public zone */ |
188 | static char *shorten_zone_id; | 188 | static char *shorten_zone_id; |
189 | 189 | ||
190 | /* ipv6 support */ | ||
191 | static int v6_enabled; | ||
192 | |||
193 | /* ipv4 support */ | ||
194 | static int v4_enabled; | ||
195 | |||
190 | /** | 196 | /** |
191 | * Continue shutdown | 197 | * Continue shutdown |
192 | */ | 198 | */ |
@@ -944,6 +950,26 @@ handle_lookup(void *cls, | |||
944 | return; | 950 | return; |
945 | } | 951 | } |
946 | 952 | ||
953 | if ((clh->type == GNUNET_GNS_RECORD_TYPE_A) && | ||
954 | (GNUNET_OK != v4_enabled)) | ||
955 | { | ||
956 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
957 | "LOOKUP: Query for A record but AF_INET not supported!"); | ||
958 | clh->name = NULL; | ||
959 | send_lookup_response(clh, 0, NULL); | ||
960 | return; | ||
961 | } | ||
962 | |||
963 | if ((clh->type == GNUNET_GNS_RECORD_AAAA) && | ||
964 | (GNUNET_OK != v6_enabled)) | ||
965 | { | ||
966 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
967 | "LOOKUP: Query for AAAA record but AF_INET6 not supported!"); | ||
968 | clh->name = NULL; | ||
969 | send_lookup_response(clh, 0, NULL); | ||
970 | return; | ||
971 | } | ||
972 | |||
947 | if (1 == ntohl(sh_msg->use_default_zone)) | 973 | if (1 == ntohl(sh_msg->use_default_zone)) |
948 | clh->zone = zone_hash; //Default zone | 974 | clh->zone = zone_hash; //Default zone |
949 | else | 975 | else |
@@ -967,7 +993,28 @@ handle_lookup(void *cls, | |||
967 | } | 993 | } |
968 | } | 994 | } |
969 | 995 | ||
996 | /** | ||
997 | * Test if the given AF is supported by this system. | ||
998 | * | ||
999 | * @param af to test | ||
1000 | * @return GNUNET_OK if the AF is supported | ||
1001 | */ | ||
1002 | static int | ||
1003 | test_af (int af) | ||
1004 | { | ||
1005 | int s; | ||
970 | 1006 | ||
1007 | s = socket (af, SOCK_STREAM, 0); | ||
1008 | if (-1 == s) | ||
1009 | { | ||
1010 | if (EAFNOSUPPORT == errno) | ||
1011 | return GNUNET_NO; | ||
1012 | fprintf (stderr, "Failed to create test socket: %s\n", STRERROR (errno)); | ||
1013 | return GNUNET_SYSERR; | ||
1014 | } | ||
1015 | close (s); | ||
1016 | return GNUNET_OK; | ||
1017 | } | ||
971 | 1018 | ||
972 | /** | 1019 | /** |
973 | * Process GNS requests. | 1020 | * Process GNS requests. |
@@ -997,6 +1044,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
997 | 1044 | ||
998 | GNS_cfg = c; | 1045 | GNS_cfg = c; |
999 | 1046 | ||
1047 | v6_enabled = test_af (AF_INET6); | ||
1048 | v4_enabled = test_af (AF_INET); | ||
1049 | |||
1000 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns", | 1050 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "gns", |
1001 | "ZONEKEY", &keyfile)) | 1051 | "ZONEKEY", &keyfile)) |
1002 | { | 1052 | { |