aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--doc/man/gnunet-download.117
-rw-r--r--doc/man/gnunet-search.16
-rw-r--r--src/fs/fs.h12
-rw-r--r--src/fs/fs_download.c4
-rw-r--r--src/fs/fs_search.c18
-rw-r--r--src/fs/gnunet-download.c6
-rw-r--r--src/fs/gnunet-search.c10
-rw-r--r--src/fs/gnunet-service-fs.c13
-rw-r--r--src/fs/test_fs_namespace.c4
-rw-r--r--src/fs/test_fs_search.c1
-rw-r--r--src/include/gnunet_fs_service.h30
12 files changed, 112 insertions, 14 deletions
diff --git a/TODO b/TODO
index fb7326dd1..e65b3b940 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,5 @@
10.9.0pre1: 10.9.0pre1:
2* FS: [CG] 2* FS: [CG]
3 - Allow checking of presence of search results and/or content via command-line tools
4 (add options to gnunet-search / gnunet-download to limit search to local peer)
5 [needed for full persistence support...]
6 - persistence support (publish, unindex, search, download) 3 - persistence support (publish, unindex, search, download)
7 - gnunet-service-fs (hot-path routing, load-based routing, nitpicks) 4 - gnunet-service-fs (hot-path routing, load-based routing, nitpicks)
8 - [gnunet-service-fs.c:208]: member 'LocalGetContext::results_bf_size' is never used 5 - [gnunet-service-fs.c:208]: member 'LocalGetContext::results_bf_size' is never used
@@ -174,6 +171,8 @@ Optimizations:
174 (theoretically reduces overhead; bounds message queue size) 171 (theoretically reduces overhead; bounds message queue size)
175 - merge multiple iteration requests over "all" peers in the queue 172 - merge multiple iteration requests over "all" peers in the queue
176 (theoretically reduces overhead; bounds messgae queue size) 173 (theoretically reduces overhead; bounds messgae queue size)
174* FS:
175 - use different queue prioritization for probe-downloads vs. normal downloads (!?)
177 176
178Minor features: 177Minor features:
179* TCP: 178* TCP:
diff --git a/doc/man/gnunet-download.1 b/doc/man/gnunet-download.1
index b0ad09b73..2da931554 100644
--- a/doc/man/gnunet-download.1
+++ b/doc/man/gnunet-download.1
@@ -7,43 +7,60 @@ gnunet\-download \- a command line interface for downloading files from GNUnet
7.SH DESCRIPTION 7.SH DESCRIPTION
8.PP 8.PP
9Download files from GNUnet. 9Download files from GNUnet.
10
10.TP 11.TP
11\fB\-a \fILEVEL\fR, \fB\-\-anonymity=LEVEL\fR 12\fB\-a \fILEVEL\fR, \fB\-\-anonymity=LEVEL\fR
12set desired level of receiver anonymity. Default is 1. 13set desired level of receiver anonymity. Default is 1.
14
13.TP 15.TP
14\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR 16\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
15use config file (defaults: ~/.gnunet/gnunet.conf) 17use config file (defaults: ~/.gnunet/gnunet.conf)
18
16.TP 19.TP
17\fB\-D, \fB\-\-delete\-incomplete\fR 20\fB\-D, \fB\-\-delete\-incomplete\fR
18causes gnunet\-download to delete incomplete downloads when aborted with CTRL\-C. Note that complete files that are part of an incomplete recursive download will not be deleted even with this option. Without this option, terminating gnunet\-download with a signal will cause incomplete downloads to stay on disk. If gnunet\-download runs to (normal) completion finishing the download, this option has no effect. 21causes gnunet\-download to delete incomplete downloads when aborted with CTRL\-C. Note that complete files that are part of an incomplete recursive download will not be deleted even with this option. Without this option, terminating gnunet\-download with a signal will cause incomplete downloads to stay on disk. If gnunet\-download runs to (normal) completion finishing the download, this option has no effect.
22
19.TP 23.TP
20\fB\-h\fR, \fB\-\-help\fR 24\fB\-h\fR, \fB\-\-help\fR
21print help page 25print help page
26
22.TP 27.TP
23\fB\-H \fIHOSTNAME\fR, \fB\-\-host=\fIHOSTNAME\fR 28\fB\-H \fIHOSTNAME\fR, \fB\-\-host=\fIHOSTNAME\fR
24on which host is gnunetd running (default: localhost). You can also specify a port using the syntax HOSTNAME:PORT. The default port is 2087. 29on which host is gnunetd running (default: localhost). You can also specify a port using the syntax HOSTNAME:PORT. The default port is 2087.
30
25.TP 31.TP
26\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR 32\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
27Change the loglevel. Possible values for LOGLEVEL are 33Change the loglevel. Possible values for LOGLEVEL are
28ERROR, WARNING, INFO and DEBUG. 34ERROR, WARNING, INFO and DEBUG.
35
36.TP
37\fB\-n\fR, \fB\-\-no-network\fR
38Only search locally, do not forward requests to other peers.
39
29.TP 40.TP
30\fB\-o \fIFILENAME\fR, \fB\-\-output=FILENAME\fR 41\fB\-o \fIFILENAME\fR, \fB\-\-output=FILENAME\fR
31write the file to FILENAME. Hint: when recursively downloading a directory, append a '/' to the end of the FILENAME to create a directory of that name. If no FILENAME is specified, gnunet\-download constructs a temporary ID from the URI of the file. The final filename is constructed based on meta\-data extracted using libextractor (if available). 42write the file to FILENAME. Hint: when recursively downloading a directory, append a '/' to the end of the FILENAME to create a directory of that name. If no FILENAME is specified, gnunet\-download constructs a temporary ID from the URI of the file. The final filename is constructed based on meta\-data extracted using libextractor (if available).
43
32.TP 44.TP
33\fB\-p \fIDOWNLOADS\fR, \fB\-\-parallelism=DOWNLOADS\fR 45\fB\-p \fIDOWNLOADS\fR, \fB\-\-parallelism=DOWNLOADS\fR
34set the maximum number of parallel downloads that is allowed. More parallel downloads can, to some extent, improve the overall time to download content. However, parallel downloads also take more memory (see also option \-r which can be used to limit memory utilization) and more sockets. GNUnet typically only supports 1024 sockets per process, and each parallel download requires a new socket. Hence it is not possible to run more than about 1000 downloads in parallel. This option is used to limit the number of files that are downloaded in parallel (\-r can be used to limit the number of blocks that are concurrently requested). As a result, the value only matters for recursive downloads. The default value is 32. Note that the overall limit of 1000 downloads applies to gnunet\-service\-fs as well and using multiple gnunet\-download processes hence does not increase this limit. 46set the maximum number of parallel downloads that is allowed. More parallel downloads can, to some extent, improve the overall time to download content. However, parallel downloads also take more memory (see also option \-r which can be used to limit memory utilization) and more sockets. GNUnet typically only supports 1024 sockets per process, and each parallel download requires a new socket. Hence it is not possible to run more than about 1000 downloads in parallel. This option is used to limit the number of files that are downloaded in parallel (\-r can be used to limit the number of blocks that are concurrently requested). As a result, the value only matters for recursive downloads. The default value is 32. Note that the overall limit of 1000 downloads applies to gnunet\-service\-fs as well and using multiple gnunet\-download processes hence does not increase this limit.
47
35.TP 48.TP
36\fB\-r \fIREQUESTS\fR, \fB\-\-request-parallelism=REQUESTS\fR 49\fB\-r \fIREQUESTS\fR, \fB\-\-request-parallelism=REQUESTS\fR
37set the maximum number of parallel requests that is allowed. If multiple files are downloaded, gnunet\-download will not run them in parallel if this would cause the number of pending requests to possibly exceed the given value. This is useful since, for example, downloading dozens of multi\-gigabyte files in parallel could exhaust memory resources and would hardly improve performance. Note that the limit only applies to this specific process and that other download activities by other processes are not included in this limit. Consider raising this limit for large recursive downloads with many large files if memory and network bandwidth are not fully utilized and if the parallelism limit (\-p option) is not reached. This option also only matters for recursive downloads. The default value is 4092. 50set the maximum number of parallel requests that is allowed. If multiple files are downloaded, gnunet\-download will not run them in parallel if this would cause the number of pending requests to possibly exceed the given value. This is useful since, for example, downloading dozens of multi\-gigabyte files in parallel could exhaust memory resources and would hardly improve performance. Note that the limit only applies to this specific process and that other download activities by other processes are not included in this limit. Consider raising this limit for large recursive downloads with many large files if memory and network bandwidth are not fully utilized and if the parallelism limit (\-p option) is not reached. This option also only matters for recursive downloads. The default value is 4092.
51
38.TP 52.TP
39\fB\-R\fR, \fB\-\-recursive\fR 53\fB\-R\fR, \fB\-\-recursive\fR
40download directories recursively (and in parallel); note that the URI must belong to a GNUnet directory and that the filename given must end with a '/' \-\- otherwise, only the file corresponding to the URI will be downloaded. Note that in addition to using '-R', you must also specify a filename ending in '.gnd' so that the code realizes that the top-level file is a directory (since we have no meta data). 54download directories recursively (and in parallel); note that the URI must belong to a GNUnet directory and that the filename given must end with a '/' \-\- otherwise, only the file corresponding to the URI will be downloaded. Note that in addition to using '-R', you must also specify a filename ending in '.gnd' so that the code realizes that the top-level file is a directory (since we have no meta data).
55
41.TP 56.TP
42\fB\-v\fR, \fB\-\-version\fR 57\fB\-v\fR, \fB\-\-version\fR
43print the version number 58print the version number
59
44.TP 60.TP
45\fB\-V\fR, \fB\-\-verbose\fR 61\fB\-V\fR, \fB\-\-verbose\fR
46print progress information 62print progress information
63
47.SH NOTES 64.SH NOTES
48The GNUNET_URI is typically obtained from gnunet\-search. gnunet\-gtk can also be used instead of gnunet\-download. 65The GNUNET_URI is typically obtained from gnunet\-search. gnunet\-gtk can also be used instead of gnunet\-download.
49If you ever have to abort a download, you can at any time continue it by re\-issuing gnunet\-download with the same filename. In that case GNUnet will not download blocks again that are already present. GNUnets file\-encoding will ensure file integrity, even if the existing file was not downloaded from GNUnet in the first place. Temporary information will be appended to the target file until the download is completed. 66If you ever have to abort a download, you can at any time continue it by re\-issuing gnunet\-download with the same filename. In that case GNUnet will not download blocks again that are already present. GNUnets file\-encoding will ensure file integrity, even if the existing file was not downloaded from GNUnet in the first place. Temporary information will be appended to the target file until the download is completed.
diff --git a/doc/man/gnunet-search.1 b/doc/man/gnunet-search.1
index 5eefaa099..526097733 100644
--- a/doc/man/gnunet-search.1
+++ b/doc/man/gnunet-search.1
@@ -1,4 +1,4 @@
1.TH GNUNET-SEARCH "1" "6 Sep 2009" "GNUnet" 1.TH GNUNET-SEARCH "1" "28 Apr 2010" "GNUnet"
2.SH NAME 2.SH NAME
3gnunet\-search \- a command line interface to search for content on GNUnet 3gnunet\-search \- a command line interface to search for content on GNUnet
4.SH SYNOPSIS 4.SH SYNOPSIS
@@ -38,6 +38,10 @@ ERROR, WARNING, INFO and DEBUG.
38Writes a GNUnet directory containing all of the search results to FILENAME. 38Writes a GNUnet directory containing all of the search results to FILENAME.
39 39
40.TP 40.TP
41\fB\-n\fR, \fB\-\-no-network\fR
42Only search locally, do not forward requests to other peers.
43
44.TP
41\fB\-v\fR, \fB\-\-version\fR 45\fB\-v\fR, \fB\-\-version\fR
42print the version number 46print the version number
43 47
diff --git a/src/fs/fs.h b/src/fs/fs.h
index 0a656e1e9..a6a12b9cd 100644
--- a/src/fs/fs.h
+++ b/src/fs/fs.h
@@ -1079,7 +1079,10 @@ struct GNUNET_FS_SearchContext
1079 */ 1079 */
1080 uint32_t mandatory_count; 1080 uint32_t mandatory_count;
1081 1081
1082 1082 /**
1083 * Options for the search.
1084 */
1085 enum GNUNET_FS_SearchOptions options;
1083}; 1086};
1084 1087
1085 1088
@@ -1439,9 +1442,10 @@ struct SearchMessage
1439 struct GNUNET_MessageHeader header; 1442 struct GNUNET_MessageHeader header;
1440 1443
1441 /** 1444 /**
1442 * Should be zero. 1445 * Bitmask with options. Zero for no options, one for loopback-only.
1446 * Other bits are currently not defined.
1443 */ 1447 */
1444 int32_t reserved GNUNET_PACKED; 1448 int32_t options GNUNET_PACKED;
1445 1449
1446 /** 1450 /**
1447 * Type of the content that we're looking for. 1451 * Type of the content that we're looking for.
@@ -1536,7 +1540,7 @@ struct GetMessage
1536 uint32_t priority GNUNET_PACKED; 1540 uint32_t priority GNUNET_PACKED;
1537 1541
1538 /** 1542 /**
1539 * Relative time to live in GNUNET_CRON_MILLISECONDS (network byte order) 1543 * Relative time to live in MILLISECONDS (network byte order)
1540 */ 1544 */
1541 int32_t ttl GNUNET_PACKED; 1545 int32_t ttl GNUNET_PACKED;
1542 1546
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 14e6266f8..fe9c18aa1 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1150,6 +1150,10 @@ transmit_download_request (void *cls,
1150 memset (sm, 0, sizeof (struct SearchMessage)); 1150 memset (sm, 0, sizeof (struct SearchMessage));
1151 sm->header.size = htons (sizeof (struct SearchMessage)); 1151 sm->header.size = htons (sizeof (struct SearchMessage));
1152 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 1152 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
1153 if (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY))
1154 sm->options = htonl (1);
1155 else
1156 sm->options = htonl (0);
1153 if (dc->pending->depth == dc->treedepth) 1157 if (dc->pending->depth == dc->treedepth)
1154 sm->type = htonl (GNUNET_BLOCK_TYPE_DBLOCK); 1158 sm->type = htonl (GNUNET_BLOCK_TYPE_DBLOCK);
1155 else 1159 else
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 2c8022237..efe5bf34a 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -458,6 +458,7 @@ process_ksk_result (struct GNUNET_FS_SearchContext *sc,
458 * @param uri specifies the search parameters; can be 458 * @param uri specifies the search parameters; can be
459 * a KSK URI or an SKS URI. 459 * a KSK URI or an SKS URI.
460 * @param anonymity desired level of anonymity 460 * @param anonymity desired level of anonymity
461 * @param options options for the search
461 * @param cctx client context 462 * @param cctx client context
462 * @param parent parent search (for namespace update searches) 463 * @param parent parent search (for namespace update searches)
463 * @return context that can be used to control the search 464 * @return context that can be used to control the search
@@ -466,6 +467,7 @@ static struct GNUNET_FS_SearchContext *
466search_start (struct GNUNET_FS_Handle *h, 467search_start (struct GNUNET_FS_Handle *h,
467 const struct GNUNET_FS_Uri *uri, 468 const struct GNUNET_FS_Uri *uri,
468 uint32_t anonymity, 469 uint32_t anonymity,
470 enum GNUNET_FS_SearchOptions options,
469 void *cctx, 471 void *cctx,
470 struct GNUNET_FS_SearchContext *parent); 472 struct GNUNET_FS_SearchContext *parent);
471 473
@@ -523,6 +525,7 @@ process_sks_result (struct GNUNET_FS_SearchContext *sc,
523 search_start (sc->h, 525 search_start (sc->h,
524 &uu, 526 &uu,
525 sc->anonymity, 527 sc->anonymity,
528 sc->options,
526 NULL, 529 NULL,
527 sc); 530 sc);
528} 531}
@@ -938,6 +941,10 @@ transmit_search_request (void *cls,
938 { 941 {
939 sm[i].header.size = htons (sizeof (struct SearchMessage)); 942 sm[i].header.size = htons (sizeof (struct SearchMessage));
940 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 943 sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
944 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
945 sm[i].options = htonl (1);
946 else
947 sm[i].options = htonl (0);
941 sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY); 948 sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY);
942 sm[i].anonymity_level = htonl (sc->anonymity); 949 sm[i].anonymity_level = htonl (sc->anonymity);
943 sm[i].query = sc->requests[i].query; 950 sm[i].query = sc->requests[i].query;
@@ -952,6 +959,10 @@ transmit_search_request (void *cls,
952 memset (sm, 0, msize); 959 memset (sm, 0, msize);
953 sm->header.size = htons (sizeof (struct SearchMessage)); 960 sm->header.size = htons (sizeof (struct SearchMessage));
954 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH); 961 sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
962 if (0 != (sc->options & GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY))
963 sm->options = htonl (1);
964 else
965 sm->options = htonl (0);
955 sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK); 966 sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK);
956 sm->anonymity_level = htonl (sc->anonymity); 967 sm->anonymity_level = htonl (sc->anonymity);
957 sm->target = sc->uri->data.sks.namespace; 968 sm->target = sc->uri->data.sks.namespace;
@@ -1042,6 +1053,7 @@ try_reconnect (struct GNUNET_FS_SearchContext *sc)
1042 * @param uri specifies the search parameters; can be 1053 * @param uri specifies the search parameters; can be
1043 * a KSK URI or an SKS URI. 1054 * a KSK URI or an SKS URI.
1044 * @param anonymity desired level of anonymity 1055 * @param anonymity desired level of anonymity
1056 * @param options options for the search
1045 * @param cctx initial value for the client context 1057 * @param cctx initial value for the client context
1046 * @param parent parent search (for namespace update searches) 1058 * @param parent parent search (for namespace update searches)
1047 * @return context that can be used to control the search 1059 * @return context that can be used to control the search
@@ -1050,6 +1062,7 @@ static struct GNUNET_FS_SearchContext *
1050search_start (struct GNUNET_FS_Handle *h, 1062search_start (struct GNUNET_FS_Handle *h,
1051 const struct GNUNET_FS_Uri *uri, 1063 const struct GNUNET_FS_Uri *uri,
1052 uint32_t anonymity, 1064 uint32_t anonymity,
1065 enum GNUNET_FS_SearchOptions options,
1053 void *cctx, 1066 void *cctx,
1054 struct GNUNET_FS_SearchContext *parent) 1067 struct GNUNET_FS_SearchContext *parent)
1055{ 1068{
@@ -1085,6 +1098,7 @@ search_start (struct GNUNET_FS_Handle *h,
1085 return NULL; 1098 return NULL;
1086 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext)); 1099 sc = GNUNET_malloc (sizeof(struct GNUNET_FS_SearchContext));
1087 sc->h = h; 1100 sc->h = h;
1101 sc->options = options;
1088 sc->uri = GNUNET_FS_uri_dup (uri); 1102 sc->uri = GNUNET_FS_uri_dup (uri);
1089 sc->anonymity = anonymity; 1103 sc->anonymity = anonymity;
1090 sc->start_time = GNUNET_TIME_absolute_get (); 1104 sc->start_time = GNUNET_TIME_absolute_get ();
@@ -1139,6 +1153,7 @@ search_start (struct GNUNET_FS_Handle *h,
1139 * @param uri specifies the search parameters; can be 1153 * @param uri specifies the search parameters; can be
1140 * a KSK URI or an SKS URI. 1154 * a KSK URI or an SKS URI.
1141 * @param anonymity desired level of anonymity 1155 * @param anonymity desired level of anonymity
1156 * @param options options for the search
1142 * @param cctx initial value for the client context 1157 * @param cctx initial value for the client context
1143 * @return context that can be used to control the search 1158 * @return context that can be used to control the search
1144 */ 1159 */
@@ -1146,9 +1161,10 @@ struct GNUNET_FS_SearchContext *
1146GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, 1161GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1147 const struct GNUNET_FS_Uri *uri, 1162 const struct GNUNET_FS_Uri *uri,
1148 uint32_t anonymity, 1163 uint32_t anonymity,
1164 enum GNUNET_FS_SearchOptions options,
1149 void *cctx) 1165 void *cctx)
1150{ 1166{
1151 return search_start (h, uri, anonymity, cctx, NULL); 1167 return search_start (h, uri, anonymity, options, cctx, NULL);
1152} 1168}
1153 1169
1154 1170
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index bc98d0275..fde254d7c 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -52,6 +52,7 @@ static int do_recursive;
52 52
53static char *filename; 53static char *filename;
54 54
55static int local_only;
55 56
56static void 57static void
57cleanup_task (void *cls, 58cleanup_task (void *cls,
@@ -225,6 +226,8 @@ run (void *cls,
225 options = GNUNET_FS_DOWNLOAD_OPTION_NONE; 226 options = GNUNET_FS_DOWNLOAD_OPTION_NONE;
226 if (do_recursive) 227 if (do_recursive)
227 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; 228 options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE;
229 if (local_only)
230 options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY;
228 dc = GNUNET_FS_download_start (ctx, 231 dc = GNUNET_FS_download_start (ctx,
229 uri, 232 uri,
230 NULL, 233 NULL,
@@ -259,6 +262,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
259 {'D', "delete-incomplete", NULL, 262 {'D', "delete-incomplete", NULL,
260 gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"), 263 gettext_noop ("delete incomplete downloads (when aborted with CTRL-C)"),
261 0, &GNUNET_GETOPT_set_one, &delete_incomplete}, 264 0, &GNUNET_GETOPT_set_one, &delete_incomplete},
265 {'n', "no-network", NULL,
266 gettext_noop ("only search the local peer (no P2P network search)"),
267 1, &GNUNET_GETOPT_set_uint, &local_only},
262 {'o', "output", "FILENAME", 268 {'o', "output", "FILENAME",
263 gettext_noop ("write the file to FILENAME"), 269 gettext_noop ("write the file to FILENAME"),
264 1, &GNUNET_GETOPT_set_string, &filename}, 270 1, &GNUNET_GETOPT_set_string, &filename},
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 64955a3ee..0226a340e 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -46,6 +46,8 @@ static unsigned int anonymity = 1;
46 46
47static int verbose; 47static int verbose;
48 48
49static int local_only;
50
49/** 51/**
50 * Type of a function that libextractor calls for each 52 * Type of a function that libextractor calls for each
51 * meta data item found. 53 * meta data item found.
@@ -231,6 +233,7 @@ run (void *cls,
231{ 233{
232 struct GNUNET_FS_Uri *uri; 234 struct GNUNET_FS_Uri *uri;
233 unsigned int argc; 235 unsigned int argc;
236 enum GNUNET_FS_SearchOptions options;
234 237
235 sched = s; 238 sched = s;
236 argc = 0; 239 argc = 0;
@@ -266,9 +269,13 @@ run (void *cls,
266 } 269 }
267 if (output_filename != NULL) 270 if (output_filename != NULL)
268 db = GNUNET_FS_directory_builder_create (NULL); 271 db = GNUNET_FS_directory_builder_create (NULL);
272 options = GNUNET_FS_SEARCH_OPTION_NONE;
273 if (local_only)
274 options |= GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY;
269 sc = GNUNET_FS_search_start (ctx, 275 sc = GNUNET_FS_search_start (ctx,
270 uri, 276 uri,
271 anonymity, 277 anonymity,
278 options,
272 NULL); 279 NULL);
273 GNUNET_FS_uri_destroy (uri); 280 GNUNET_FS_uri_destroy (uri);
274 if (NULL == sc) 281 if (NULL == sc)
@@ -293,6 +300,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
293 {'a', "anonymity", "LEVEL", 300 {'a', "anonymity", "LEVEL",
294 gettext_noop ("set the desired LEVEL of receiver-anonymity"), 301 gettext_noop ("set the desired LEVEL of receiver-anonymity"),
295 1, &GNUNET_GETOPT_set_uint, &anonymity}, 302 1, &GNUNET_GETOPT_set_uint, &anonymity},
303 {'n', "no-network", NULL,
304 gettext_noop ("only search the local peer (no P2P network search)"),
305 1, &GNUNET_GETOPT_set_uint, &local_only},
296 {'o', "output", "PREFIX", 306 {'o', "output", "PREFIX",
297 gettext_noop 307 gettext_noop
298 ("write search results to file starting with PREFIX"), 308 ("write search results to file starting with PREFIX"),
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 41be75e98..84a4f1d65 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -545,7 +545,12 @@ struct PendingRequest
545 /** 545 /**
546 * Remove this request after transmission of the current response. 546 * Remove this request after transmission of the current response.
547 */ 547 */
548 int do_remove; 548 int16_t do_remove;
549
550 /**
551 * GNUNET_YES if we should not forward this request to other peers.
552 */
553 int16_t local_only;
549 554
550}; 555};
551 556
@@ -1600,6 +1605,8 @@ forward_request_task (void *cls,
1600#endif 1605#endif
1601 return; /* already pending */ 1606 return; /* already pending */
1602 } 1607 }
1608 if (GNUNET_YES == pr->local_only)
1609 return; /* configured to not do P2P search */
1603 /* (1) select target */ 1610 /* (1) select target */
1604 psc.pr = pr; 1611 psc.pr = pr;
1605 psc.target_score = DBL_MIN; 1612 psc.target_score = DBL_MIN;
@@ -2783,6 +2790,10 @@ handle_start_search (void *cls,
2783 pr->anonymity_level = ntohl (sm->anonymity_level); 2790 pr->anonymity_level = ntohl (sm->anonymity_level);
2784 refresh_bloomfilter (pr); 2791 refresh_bloomfilter (pr);
2785 pr->query = sm->query; 2792 pr->query = sm->query;
2793 if (0 == (1 & ntohl (sm->options)))
2794 pr->local_only = GNUNET_NO;
2795 else
2796 pr->local_only = GNUNET_YES;
2786 switch (type) 2797 switch (type)
2787 { 2798 {
2788 case GNUNET_BLOCK_TYPE_DBLOCK: 2799 case GNUNET_BLOCK_TYPE_DBLOCK:
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index b57f19bc9..b154ce799 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -250,8 +250,8 @@ publish_cont (void *cls,
250 GNUNET_free (msg); 250 GNUNET_free (msg);
251 return; 251 return;
252 } 252 }
253 ksk_search = GNUNET_FS_search_start (fs, ksk_uri, 1, "ksk_search"); 253 ksk_search = GNUNET_FS_search_start (fs, ksk_uri, 1, GNUNET_FS_SEARCH_OPTION_NONE, "ksk_search");
254 sks_search = GNUNET_FS_search_start (fs, sks_uri, 1, "sks_search"); 254 sks_search = GNUNET_FS_search_start (fs, sks_uri, 1, GNUNET_FS_SEARCH_OPTION_NONE, "sks_search");
255 GNUNET_FS_uri_destroy (sks_uri); 255 GNUNET_FS_uri_destroy (sks_uri);
256} 256}
257 257
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 5f5f7f62a..32f885814 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -115,6 +115,7 @@ progress_cb (void *cls,
115 search = GNUNET_FS_search_start (fs, 115 search = GNUNET_FS_search_start (fs,
116 kuri, 116 kuri,
117 1, 117 1,
118 GNUNET_FS_SEARCH_OPTION_NONE,
118 "search"); 119 "search");
119 GNUNET_FS_uri_destroy (kuri); 120 GNUNET_FS_uri_destroy (kuri);
120 GNUNET_assert (search != NULL); 121 GNUNET_assert (search != NULL);
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index e3c99f3e9..acd059c96 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -2193,12 +2193,32 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
2193 2193
2194 2194
2195/** 2195/**
2196 * Options for searching. Compatible options
2197 * can be OR'ed together.
2198 */
2199enum GNUNET_FS_SearchOptions
2200 {
2201 /**
2202 * No options (use defaults for everything).
2203 */
2204 GNUNET_FS_SEARCH_OPTION_NONE = 0,
2205
2206 /**
2207 * Only search the local host, do not search remote systems (no P2P)
2208 */
2209 GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY = 1
2210
2211 };
2212
2213
2214/**
2196 * Start search for content. 2215 * Start search for content.
2197 * 2216 *
2198 * @param h handle to the file sharing subsystem 2217 * @param h handle to the file sharing subsystem
2199 * @param uri specifies the search parameters; can be 2218 * @param uri specifies the search parameters; can be
2200 * a KSK URI or an SKS URI. 2219 * a KSK URI or an SKS URI.
2201 * @param anonymity desired level of anonymity 2220 * @param anonymity desired level of anonymity
2221 * @param options options for the search
2202 * @param cctx initial value for the client context 2222 * @param cctx initial value for the client context
2203 * @return context that can be used to control the search 2223 * @return context that can be used to control the search
2204 */ 2224 */
@@ -2206,6 +2226,7 @@ struct GNUNET_FS_SearchContext *
2206GNUNET_FS_search_start (struct GNUNET_FS_Handle *h, 2226GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
2207 const struct GNUNET_FS_Uri *uri, 2227 const struct GNUNET_FS_Uri *uri,
2208 uint32_t anonymity, 2228 uint32_t anonymity,
2229 enum GNUNET_FS_SearchOptions options,
2209 void *cctx); 2230 void *cctx);
2210 2231
2211 2232
@@ -2248,18 +2269,23 @@ enum GNUNET_FS_DownloadOptions
2248 * No options (use defaults for everything). 2269 * No options (use defaults for everything).
2249 */ 2270 */
2250 GNUNET_FS_DOWNLOAD_OPTION_NONE = 0, 2271 GNUNET_FS_DOWNLOAD_OPTION_NONE = 0,
2272
2273 /**
2274 * Only download from the local host, do not access remote systems (no P2P)
2275 */
2276 GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY = 1,
2251 2277
2252 /** 2278 /**
2253 * Do a recursive download (that is, automatically trigger the 2279 * Do a recursive download (that is, automatically trigger the
2254 * download of files in directories). 2280 * download of files in directories).
2255 */ 2281 */
2256 GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 1, 2282 GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE = 2,
2257 2283
2258 /** 2284 /**
2259 * Do not append temporary data to 2285 * Do not append temporary data to
2260 * the target file (for the IBlocks). 2286 * the target file (for the IBlocks).
2261 */ 2287 */
2262 GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 2, 2288 GNUNET_FS_DOWNLOAD_NO_TEMPORARIES = 4,
2263 2289
2264 /** 2290 /**
2265 * Internal option used to flag this download as a 'probe' for a 2291 * Internal option used to flag this download as a 'probe' for a