[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6300 - in GNUnet: doc/man src/applications/fs/fsui src/app
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6300 - in GNUnet: doc/man src/applications/fs/fsui src/applications/fs/tools |
Date: |
Thu, 14 Feb 2008 22:51:54 -0700 (MST) |
Author: grothoff
Date: 2008-02-14 22:51:54 -0700 (Thu, 14 Feb 2008)
New Revision: 6300
Added:
GNUnet/doc/man/gnunet-auto-share.1
GNUnet/src/applications/fs/tools/gnunet-auto-share.c
Modified:
GNUnet/doc/man/Makefile.am
GNUnet/doc/man/gnunet-insert.1
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/applications/fs/tools/Makefile.am
Log:
adding first draft of gnunet-auto-share
Modified: GNUnet/doc/man/Makefile.am
===================================================================
--- GNUnet/doc/man/Makefile.am 2008-02-15 04:22:46 UTC (rev 6299)
+++ GNUnet/doc/man/Makefile.am 2008-02-15 05:51:54 UTC (rev 6300)
@@ -1,4 +1,5 @@
man_MANS = \
+gnunet-auto-share.1 \
gnunet-chat.1\
gnunet-directory.1 \
gnunet-download.1 \
Added: GNUnet/doc/man/gnunet-auto-share.1
===================================================================
--- GNUnet/doc/man/gnunet-auto-share.1 (rev 0)
+++ GNUnet/doc/man/gnunet-auto-share.1 2008-02-15 05:51:54 UTC (rev 6300)
@@ -0,0 +1,106 @@
+.TH GNUNET-AUTO-SHARE "1" "14 Feb 2008" "GNUnet"
+.SH NAME
+gnunet\-auto\-share \- process to share a directory
+.SH SYNOPSIS
+.B gnunet\-auto\-share
+[\fIOPTIONS\fR] DIRECTORY
+.SH DESCRIPTION
+.PP
+In order to share files with other GNUnet users, the files must first
+be made available to GNUnet. This tool allows you to automatically
+share all files from a certain directory.
+.PP
+In order to start sharing files, invoke gnunet-auto-share with the
+name of the directory. As long as gnunet-auto-share is running, any
+files placed in the directory will be automatically shared.
+Note that files that you share may not always continue to be
+available after you leave the network.
+.PP
+gnunet\-auto\-share will automatically extract keywords from the files that
+are shared. Users that want to download files from GNUnet use
+keywords to search for the appropriate content. You can manually add keywords
+using the \-K option.
+.PP
+The directory structure of files in the shared directory will be
+maintained. gnunet\-auto\-share only supports publishing files
+using indexing. Indexing a file means that an index is
+added to the local (!) database with symbolic links to the file
+itself. The links will use the SHA-512 hash of the entire file as the
+filename. Indexing is generally significantly more efficient and the
+default choice. However, indexing only works if the indexed file can
+be read (using the same absolute path) by gnunetd, so you should
+run gnunet\-auto\-share on the same machine that uses gnunetd.
+.PP
+
+\fB\-c \fIFILENAME\fR, \fB\-\-config=FILENAME\fR
+Use alternate config file (if this option is not specified, the
+default is ~/.gnunet/gnunet.conf).
+
+.TP
+\fB\-D\fR, \fB\-\-disable\-direct\fR
+Disable direct indexing information that would otherwise refer to
+files inside of directories directly. Without \-D, contents can be
+found directly using keywords extracted with libextractor. Use \-D if
+you index directories with many similar files that are adequately
+described using keywords for the directory and for which individual
+references would unduely pollte the global keyword search space. Also
+use \-D to disable libextractor for individual file publications.
+This way you can ensure that a file will only be referenced using the
+keywords that you are specifying explicitly.
+
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Print a brief help page with all the options.
+
+.TP
+\fB\-H \fIHOSTNAME\fR, \fB\-\-host=\fIHOSTNAME\fR
+on which host is gnunetd running (default: localhost). You can also
+specify a port using the syntax HOSTNAME:PORT. The default port is
+2087.
+
+.TP
+\fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=\fILOGLEVEL\fR
+Change the loglevel. Possible values for LOGLEVEL are NOTHING, FATAL,
+ERROR, WARNING, INFO, STATUS and DEBUG. Note that options in the
+configuration file take precedence over this option (the argument
+will be ignored in that case).
+
+.TP
+\fB\-p \fIPRIORITY\fR, \fB\-\-prio=\fIPRIORITY\fR
+Executive summary: You probably don't need it.
+
+Set the priority of the inserted content (default: 65535). If the
+local database is full, GNUnet will discard the content with the
+lowest ranking. Note that ranks change over time depending on
+popularity. The default should be high enough to preserve the locally
+inserted content in favor of content that migrates from other peers.
+
+.TP
+\fB\-v\fR, \fB\-\-version\fR
+Print the version number.
+
+.TP
+\fB\-V\fR, \fB\-\-verbose\fR
+Be verbose. Using this option causes gnunet\-auto\-share to print
+progress information and the file identification that can be used to
+download the file from GNUnet.
+
+
+.SH EXAMPLES
+.PP
+
+\fBBasic example\fR
+
+Share the "/home/share" directory:
+
+# nohup gnunet\-auto\-share /home/share/ &
+
+
+.SH FILES
+.TP
+~/.gnunet/gnunet.conf
+GNUnet configuration file
+.SH "REPORTING BUGS"
+Report bugs by using mantis <https://gnunet.org/mantis/> or by sending
electronic mail to <address@hidden>
+.SH "SEE ALSO"
+\fBgnunet\-gtk\fP(1), \fBgnunet\-insert\fP(1), \fBgnunet\-search\fP(1),
\fBgnunet\-download\fP(1), \fBgnunet.conf\fP(5), \fBgnunetd\fP(1),
\fBextract\fP(1)
Modified: GNUnet/doc/man/gnunet-insert.1
===================================================================
--- GNUnet/doc/man/gnunet-insert.1 2008-02-15 04:22:46 UTC (rev 6299)
+++ GNUnet/doc/man/gnunet-insert.1 2008-02-15 05:51:54 UTC (rev 6300)
@@ -3,7 +3,7 @@
gnunet\-insert \- a command line interface for inserting new content into
GNUnet
.SH SYNOPSIS
.B gnunet\-insert
-[\fIOPTIONS\fR] FILENAME*
+[\fIOPTIONS\fR] FILENAME
.SH DESCRIPTION
.PP
In order to share files with other GNUnet users, the files must first
@@ -337,4 +337,4 @@
.SH "REPORTING BUGS"
Report bugs by using mantis <https://gnunet.org/mantis/> or by sending
electronic mail to <address@hidden>
.SH "SEE ALSO"
-\fBgnunet\-gtk\fP(1), \fBgnunet\-pseudonym\fP(1), \fBgnunet\-search\fP(1),
\fBgnunet\-download\fP(1), \fBgnunet.conf\fP(5), \fBgnunetd\fP(1),
\fBextract\fP(1)
+\fBgnunet\-auto\-share\fP(1), \fBgnunet\-gtk\fP(1),
\fBgnunet\-pseudonym\fP(1), \fBgnunet\-search\fP(1), \fBgnunet\-download\fP(1),
\fBgnunet.conf\fP(5), \fBgnunetd\fP(1), \fBextract\fP(1)
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2008-02-15 04:22:46 UTC (rev
6299)
+++ GNUnet/src/applications/fs/fsui/upload.c 2008-02-15 05:51:54 UTC (rev
6300)
@@ -623,7 +623,7 @@
GNUNET_free (utc);
return NULL;
}
- utc->meta = GNUNET_ECRS_meta_data_duplicate (md);
+ utc->meta = (md == NULL) ? GNUNET_ECRS_meta_data_create() :
GNUNET_ECRS_meta_data_duplicate (md);
}
else
{
Modified: GNUnet/src/applications/fs/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/tools/Makefile.am 2008-02-15 04:22:46 UTC
(rev 6299)
+++ GNUnet/src/applications/fs/tools/Makefile.am 2008-02-15 05:51:54 UTC
(rev 6300)
@@ -7,6 +7,7 @@
$(top_builddir)/src/util/libgnunetutil.la
bin_PROGRAMS = \
+ gnunet-auto-share \
gnunet-directory \
gnunet-pseudonym \
gnunet-search \
@@ -16,6 +17,9 @@
+gnunet_auto_share_SOURCES = \
+ gnunet-auto-share.c
+
gnunet_insert_SOURCES = \
gnunet-insert.c
Added: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-auto-share.c
(rev 0)
+++ GNUnet/src/applications/fs/tools/gnunet-auto-share.c 2008-02-15
05:51:54 UTC (rev 6300)
@@ -0,0 +1,292 @@
+/*
+ This file is part of GNUnet.
+ (C) 2008 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/fs/tools/gnunet-auto-share.c
+ * @brief Tool to share directories
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_directories.h"
+#include "gnunet_fsui_lib.h"
+#include "gnunet_util.h"
+
+static int upload_done;
+
+static struct GNUNET_GC_Configuration *cfg;
+
+static struct GNUNET_GE_Context *ectx;
+
+static struct GNUNET_FSUI_Context *ctx;
+
+static struct GNUNET_FSUI_UploadList *ul;
+
+static char *cfgFilename = GNUNET_DEFAULT_CLIENT_CONFIG_FILE;
+
+static struct GNUNET_ECRS_URI *gloKeywords;
+
+static unsigned int anonymity = 1;
+
+static unsigned int priority = 365;
+
+static int do_no_direct_references;
+
+/**
+ * Print progess message.
+ */
+static void *
+printstatus (void *ctx, const GNUNET_FSUI_Event * event)
+{
+ unsigned long long *verboselevel = ctx;
+ char *fstring;
+
+ switch (event->type)
+ {
+ case GNUNET_FSUI_upload_progress:
+ break;
+ case GNUNET_FSUI_upload_completed:
+ if (*verboselevel)
+ {
+ fstring = GNUNET_ECRS_uri_to_string (event->data.UploadCompleted.uri);
+ printf(_("Upload of `%s' complete, URI is `%s'."),
+ event->data.UploadCompleted.filename,
+ fstring);
+ GNUNET_free (fstring);
+ }
+ if (ul == event->data.UploadCompleted.uc.pos)
+ upload_done = GNUNET_YES;
+ break;
+ case GNUNET_FSUI_upload_aborted:
+ printf (_("\nUpload aborted.\n"));
+ upload_done = GNUNET_YES;
+ break;
+ case GNUNET_FSUI_upload_error:
+ printf (_("\nError uploading file: %s"),
+ event->data.UploadError.message);
+ upload_done = GNUNET_YES;
+ break;
+ case GNUNET_FSUI_upload_started:
+ case GNUNET_FSUI_upload_stopped:
+ break;
+ default:
+ printf (_("\nUnexpected event: %d\n"), event->type);
+ GNUNET_GE_BREAK (ectx, 0);
+ break;
+ }
+ return NULL;
+}
+
+/**
+ * All gnunet-auto-share command line options
+ */
+static struct GNUNET_CommandLineOption gnunetauto_shareOptions[] = {
+ {'a', "anonymity", "LEVEL",
+ gettext_noop ("set the desired LEVEL of sender-anonymity"),
+ 1, &GNUNET_getopt_configure_set_uint, &anonymity},
+ GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename), /* -c */
+ {'D', "disable-direct", NULL,
+ gettext_noop
+ ("do not use libextractor to add additional references to directory entries
and/or the published file"),
+ 0, &GNUNET_getopt_configure_set_one, &do_no_direct_references},
+ GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Automatically share a
directory.")), /* -h */
+ GNUNET_COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+ {'K', "global-key", "KEYWORD",
+ gettext_noop ("add an additional keyword for all files and directories"
+ " (this option can be specified multiple times)"),
+ 1, &GNUNET_ECRS_getopt_configure_set_keywords, &gloKeywords},
+ GNUNET_COMMAND_LINE_OPTION_LOGGING, /* -L */
+ {'p', "priority", "PRIORITY",
+ gettext_noop ("specify the priority of the content"),
+ 1, &GNUNET_getopt_configure_set_uint, &priority},
+ GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+ GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+ GNUNET_COMMAND_LINE_OPTION_END,
+};
+
+static int
+find_latest(const char * filename,
+ const char * dirName,
+ void * cls)
+{
+ time_t * latest = cls;
+ struct stat buf;
+ char * fn;
+
+ if (ul != NULL)
+ return GNUNET_SYSERR;
+ fn = GNUNET_malloc(strlen(filename) + strlen(dirName) + 2);
+ strcpy(fn, dirName);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, filename);
+ if (0 != stat(fn, &buf))
+ {
+ printf("Could not stat `%s': %s\n",
+ fn,
+ strerror(errno));
+ GNUNET_free(fn);
+ return GNUNET_OK;
+ }
+ if (*latest < buf.st_mtime)
+ *latest = buf.st_mtime;
+ if (S_ISDIR(buf.st_mode))
+ GNUNET_disk_directory_scan(ectx,
+ fn,
+ &find_latest,
+ latest);
+ GNUNET_free(fn);
+ return GNUNET_OK;
+}
+
+static int
+probe_directory(const char * filename,
+ const char * dirName,
+ void * cls)
+{
+ time_t * last = cls;
+ time_t latest;
+ struct stat buf;
+ char * fn;
+
+ if (ul != NULL)
+ return GNUNET_SYSERR;
+
+ fn = GNUNET_malloc(strlen(filename) + strlen(dirName) + 2);
+ strcpy(fn, dirName);
+ strcat(fn, DIR_SEPARATOR_STR);
+ strcat(fn, filename);
+ if (0 != stat(fn, &buf))
+ {
+ printf("Could not stat `%s': %s\n",
+ fn,
+ strerror(errno));
+ GNUNET_free(fn);
+ return GNUNET_OK;
+ }
+ if ( (buf.st_mtime < *last) &&
+ (! S_ISDIR(buf.st_mode)) )
+ {
+ GNUNET_free(fn);
+ return GNUNET_OK;
+ }
+ latest = buf.st_mtime;
+ GNUNET_disk_directory_scan(ectx,
+ fn,
+ &find_latest,
+ &latest);
+ if (latest < *last)
+ {
+ GNUNET_free(fn);
+ return GNUNET_OK;
+ }
+ ul = GNUNET_FSUI_upload_start (ctx,
+ fn,
+ (GNUNET_FSUI_DirectoryScanCallback) &
+ GNUNET_disk_directory_scan, ectx, anonymity,
+ priority, GNUNET_YES, GNUNET_YES,
+ !do_no_direct_references,
+ GNUNET_get_time() + 2 * GNUNET_CRON_YEARS,
NULL,
+ gloKeywords, NULL);
+ GNUNET_free(fn);
+ return GNUNET_SYSERR;
+}
+
+/**
+ * The main function to auto share directories with GNUnet.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return return 0 for ok, -1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+ char *dirname;
+ int i;
+ int errorCode;
+ unsigned long long verbose;
+ time_t last;
+ time_t start;
+ GNUNET_CronTime delay;
+
+ errorCode = 0;
+ i = GNUNET_init (argc,
+ argv,
+ "gnunet-auto-share [OPTIONS] DIRECTORY",
+ &cfgFilename, gnunetauto_shareOptions, &ectx, &cfg);
+ if (i == -1)
+ {
+ errorCode = -1;
+ goto quit;
+ }
+ if (i != argc - 1)
+ {
+ printf (_
+ ("You must specify one and only one directory for sharing.\n"));
+ errorCode = -1;
+ goto quit;
+ }
+ dirname = GNUNET_expand_file_name(ectx, argv[i]);
+ GNUNET_GC_get_configuration_value_number (cfg,
+ "GNUNET",
+ "VERBOSE", 0, 9999, 0, &verbose);
+ /* fundamental init */
+ ctx = GNUNET_FSUI_start (ectx, cfg, "gnunet-auto-share", GNUNET_NO, 32,
+ &printstatus, &verbose);
+ /* first insert all of the top-level files or directories */
+
+ last = 0;
+ while (GNUNET_NO == GNUNET_shutdown_test())
+ {
+ start = time(NULL);
+ GNUNET_disk_directory_scan(ectx,
+ dirname,
+ &probe_directory,
+ &last);
+ if (ul == NULL)
+ last = start;
+ if (GNUNET_YES == upload_done)
+ {
+ GNUNET_FSUI_upload_abort (ctx, ul);
+ GNUNET_FSUI_upload_stop (ctx, ul);
+ upload_done = GNUNET_NO;
+ ul = NULL;
+ }
+ if ( (ul == NULL) &&
+ (GNUNET_NO == GNUNET_shutdown_test()) )
+ {
+ GNUNET_thread_sleep(delay);
+ delay *= 2;
+ if (delay > GNUNET_CRON_HOURS)
+ delay = GNUNET_CRON_HOURS;
+ }
+ else
+ delay = 5 * GNUNET_CRON_SECONDS;
+ }
+ GNUNET_FSUI_stop (ctx);
+ if (gloKeywords != NULL)
+ GNUNET_ECRS_uri_destroy (gloKeywords);
+ GNUNET_free (dirname);
+quit:
+ GNUNET_fini (ectx, cfg);
+ return errorCode;
+}
+
+/* end of gnunet-auto-share.c */
Property changes on: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6300 - in GNUnet: doc/man src/applications/fs/fsui src/applications/fs/tools,
gnunet <=