[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3244 - in GNUnet: . contrib m4 src/applications/advertisin
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3244 - in GNUnet: . contrib m4 src/applications/advertising src/applications/bootstrap_http src/include |
Date: |
Thu, 17 Aug 2006 23:08:55 -0700 (PDT) |
Author: grothoff
Date: 2006-08-17 23:08:47 -0700 (Thu, 17 Aug 2006)
New Revision: 3244
Removed:
GNUnet/m4/libwww.m4
Modified:
GNUnet/ChangeLog
GNUnet/README.debian
GNUnet/configure.ac
GNUnet/contrib/config-daemon.in
GNUnet/m4/Makefile.in
GNUnet/src/applications/advertising/bootstrap.c
GNUnet/src/applications/bootstrap_http/Makefile.am
GNUnet/src/applications/bootstrap_http/http.c
GNUnet/src/include/gnunet_bootstrap_service.h
GNUnet/todo
Log:
bootstrap http now using libcurl
Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/ChangeLog 2006-08-18 06:08:47 UTC (rev 3244)
@@ -1,3 +1,7 @@
+Fri Aug 18 00:01:37 PDT 2006
+ Swiched http bootstrap mechanism to using libcurl
+ (new dependency!).
+
Sat May 20 08:37:02 PDT 2006
Releasing GNUnet 0.7.0e.
Modified: GNUnet/README.debian
===================================================================
--- GNUnet/README.debian 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/README.debian 2006-08-18 06:08:47 UTC (rev 3244)
@@ -25,9 +25,9 @@
libsqlite3-dev
libmysqlclient14-dev
libncurses5-dev
+libcurl3-gnutls-dev
libextractor-dev (unstable required!)
-
Additional libextractor dependencies:
libvorbis-dev
Modified: GNUnet/configure.ac
===================================================================
--- GNUnet/configure.ac 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/configure.ac 2006-08-18 06:08:47 UTC (rev 3244)
@@ -177,6 +177,10 @@
fi
+# libcurl
+LIBCURL_CHECK_CONFIG(,,,AC_MSG_ERROR([GNUnet requires libcurl]))
+
+
# test for kvm and kstat (for CPU stats under BSD/Solaris)
AC_CHECK_LIB([kvm],[kvm_open])
AC_CHECK_LIB([kstat],[kstat_open])
Modified: GNUnet/contrib/config-daemon.in
===================================================================
--- GNUnet/contrib/config-daemon.in 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/contrib/config-daemon.in 2006-08-18 06:08:47 UTC (rev 3244)
@@ -152,15 +152,6 @@
If you have to use a proxy for outbound HTTP connections,
specify the proxy configuration here. Default is no proxy.
- config HTTP-PROXY-PORT
- int "HTTP Proxy Port"
- range 1 65535
- default 1080
- depends on Meta::ADVANCED
- help
- If you have to use a proxy for outbound HTTP connections,
- specify the proxy configuration here. Default is no proxy.
-
config APPLICATIONS
string "Which applications should gnunetd support?"
default "advertising fs getoption stats traffic"
Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/m4/Makefile.in 2006-08-18 06:08:47 UTC (rev 3244)
@@ -124,6 +124,8 @@
INTLLIBS = @INTLLIBS@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
+LIBCURL = @LIBCURL@
+LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
@@ -170,6 +172,7 @@
XFREEBSD_FALSE = @XFREEBSD_FALSE@
XFREEBSD_TRUE = @XFREEBSD_TRUE@
XGETTEXT = @XGETTEXT@
+_libcurl_config = @_libcurl_config@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
Deleted: GNUnet/m4/libwww.m4
===================================================================
--- GNUnet/m4/libwww.m4 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/m4/libwww.m4 2006-08-18 06:08:47 UTC (rev 3244)
@@ -1,101 +0,0 @@
-AC_DEFUN([AC_CHECK_LIBWWW],
- [
-
-if test "$needs_libwww" = no; then
- LDLIBWWW=
- LIBWWWCPPFLAGS=
- LIBWWWDEP=
-else
- OLD_LIBS=$LIBS
-
- LibWWW_headers="WWWLib.h WWWApp.h WWWFile.h WWWHTTP.h WWWMIME.h WWWNews.h
WWWTrans.h"
- LibWWW_config_h="wwwconf.h"
- libwww_include_list="${libwww_include} ${libwww_dir} \
- ${libwww_dir}/include ${libwww_dir}/Library/src"
- libwww_libdir_list="${libwww_library_dir} ${libwww_dir} ${libwww_dir}/lib \
- ${libwww_dir}/Library/src"
-
- if test $try_system_wwwlib = yes; then
- test -z "$libwww_config" && libwww_config=libwww-config
-
- # can we find the $libwww_config program?
- LIBWWW_CONFIG=
- if test -f "$libwww_config"; then
- LIBWWW_CONFIG=$libwww_config
- else
- AC_PATH_PROG(LIBWWW_CONFIG, $libwww_config)
- fi
-
- if test -n "$LIBWWW_CONFIG"; then
- libwww_include_found=yes
- libwww_libdir_found=yes
- LDLIBWWW=`$libwww_config --libs`
-
- # te: I have seen xmlparse.h one directory above the directory given
- # by libwww-config. Therefore, this hack:
- libwww_config_cflags=`$libwww_config --cflags`
- hack=`echo $libwww_config_cflags | sed 'address@hidden@@;
s@/w3c-libwww.*@@'`
- test -n "$hack" && test -f "$hack/xmlparse.h" \
- && libwww_config_cflags="$libwww_config_cflags -I$hack"
-
- LIBWWWCPPFLAGS="$libwww_config_cflags -DHAVE_LIBWWW -DHAVE_WWWLIB_H"
- else
- libwww_include_found=no
- libwww_libdir_found=no
- for d in $libwww_include_list; do
- ok=yes
- for h in $LibWWW_headers; do
- if test ! -f $d/$h; then
- ok=no
- break
- fi
- done
- if test $ok = yes; then
- libwww_include=$d
- libwww_include_found=yes
- break
- fi
- done
-
- if test $libwww_include_found = yes; then
- LIBWWWCPPFLAGS="-I${libwww_include} -DHAVE_LIBWWW -DHAVE_WWWLIB_H"
- else
- LIBWWWCPPFLAGS="-DHAVE_LIBWWW -DHAVE_WWWLIB_H"
- if test $try_system_wwwlib = yes; then
- libwww_include_found=yes
- AC_CHECK_HEADERS($LibWWW_headers,, libwww_include_found=no; break )
- fi
- fi
-
- # only check for libwww.a if the includes could be found
- if test $libwww_include_found = yes; then
- for d in $libwww_libdir_list; do
- if test -f $d/libwww.a; then
- libwww_libdir=$d
- libwww_libdir_found=yes
- fi
- done
-
- if test ${libwww_libdir_found} = yes; then
- LDLIBWWW="-L${libwww_libdir} -lwww"
- else
- LDLIBWWW=-lwww
- libwww_libdir_found=yes
- AC_CHECK_LIB(www, HTParse,, libwww_libdir_found=no)
- fi
- fi
- fi
- fi
-
- if test "${libwww_include_found}" != yes ||
- test "${libwww_libdir_found}" != yes; then
- AC_MSG_ERROR([GNUnet requires libwww])
- fi
- LIBS=$OLD_LIBS
-fi
-
-AC_SUBST(LDLIBWWW)
-AC_SUBST(LIBWWWCPPFLAGS)
-AC_SUBST(LIBWWWDEP)
-
-])
\ No newline at end of file
Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c 2006-08-18 02:21:15 UTC
(rev 3243)
+++ GNUnet/src/applications/advertising/bootstrap.c 2006-08-18 06:08:47 UTC
(rev 3244)
@@ -43,14 +43,20 @@
static struct PTHREAD * pt;
-static int abort_bootstrap = YES;
-
typedef struct {
P2P_hello_MESSAGE ** helos;
unsigned int helosCount;
unsigned int helosLen;
+ int do_shutdown;
} HelloListClosure;
+static HelloListClosure hlc;
+
+static int testTerminate(void * cls) {
+ HelloListClosure * c = cls;
+ return ! c->do_shutdown;
+}
+
static void processhellos(HelloListClosure * hcq) {
int rndidx;
int i;
@@ -60,7 +66,7 @@
GE_BREAK(coreAPI->ectx, 0);
return;
}
- while ( (abort_bootstrap == NO) &&
+ while ( (! hqc.do_shutdown) &&
(hcq->helosCount > 0) ) {
/* select hello by random */
rndidx = weak_randomi(hcq->helosCount);
@@ -84,7 +90,7 @@
NULL);
FREE(msg);
if ( (hcq->helosCount > 0) &&
- (abort_bootstrap == NO) ) {
+ (! hlc.do_shutdown) ) {
/* wait a bit */
unsigned int load;
int nload;
@@ -114,7 +120,8 @@
}
static void downloadHostlistCallback(const P2P_hello_MESSAGE * helo,
- HelloListClosure * cls) {
+ void * c) {
+ HelloListClosure * cls = c;
if (cls->helosCount >= cls->helosLen) {
GROW(cls->helos,
cls->helosLen,
@@ -177,29 +184,30 @@
}
static void * processThread(void * unused) {
- HelloListClosure cls;
-
- cls.helos = NULL;
- while (abort_bootstrap == NO) {
- while (abort_bootstrap == NO) {
+ hlc.helos = NULL;
+ while (! hlc.do_shutdown) {
+ while (! hlc.do_shutdown) {
PTHREAD_SLEEP(2 * cronSECONDS);
if (needBootstrap())
break;
}
- if (abort_bootstrap != NO)
+ if (! hlc.do_shutdown)
break;
#if DEBUG_BOOTSTRAP
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Starting bootstrap.\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Starting bootstrap.\n");
#endif
- cls.helosLen = 0;
- cls.helosCount = 0;
- bootstrap->bootstrap((hello_Callback)&downloadHostlistCallback,
- &cls);
- GROW(cls.helos,
- cls.helosLen,
- cls.helosCount);
- processhellos(&cls);
+ hlc.helosLen = 0;
+ hlc.helosCount = 0;
+ bootstrap->bootstrap(&downloadHostlistCallback,
+ &hlc,
+ &testTerminate,
+ &hlc);
+ GROW(hlc.helos,
+ hlc.helosLen,
+ hlc.helosCount);
+ processhellos(&hlc);
}
return NULL;
}
@@ -216,7 +224,7 @@
bootstrap = capi->requestService("bootstrap");
GE_ASSERT(capi->ectx,
bootstrap != NULL);
- abort_bootstrap = NO;
+ hlc.do_shutdown = NO;
pt = PTHREAD_CREATE(&processThread,
NULL,
8 * 1024);
@@ -230,7 +238,7 @@
void stopBootstrap() {
void * unused;
- abort_bootstrap = YES;
+ hlc.do_shutdown = YES;
PTHREAD_STOP_SLEEP(pt);
PTHREAD_JOIN(pt, &unused);
pt = NULL;
Modified: GNUnet/src/applications/bootstrap_http/Makefile.am
===================================================================
--- GNUnet/src/applications/bootstrap_http/Makefile.am 2006-08-18 02:21:15 UTC
(rev 3243)
+++ GNUnet/src/applications/bootstrap_http/Makefile.am 2006-08-18 06:08:47 UTC
(rev 3244)
@@ -7,8 +7,10 @@
libgnunetmodule_bootstrap_la_SOURCES = \
http.c
-libgnunetmodule_bootstrap_la_LIBADD = \
+libgnunetmodule_bootstrap_la_LIBADD = @LIBCURL@ \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la
+ $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la
libgnunetmodule_bootstrap_la_LDFLAGS = \
- -export-dynamic -avoid-version -module
+ -export-dynamic -avoid-version -module
+libgnunetmodule_bootstrap_la_CPPFLAGS = \
+ @LIBCURL_CPPFLAGS@
Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c 2006-08-18 02:21:15 UTC
(rev 3243)
+++ GNUnet/src/applications/bootstrap_http/http.c 2006-08-18 06:08:47 UTC
(rev 3244)
@@ -23,8 +23,11 @@
* @brief HOSTLISTURL support. Downloads hellos via http.
* @author Christian Grothoff
*
- * TODO: avoid busy-sleep-waiting (use select!); maybe
- * change to use libwww!?
+ * TODO:
+ * make use of curls multi-API to make the http download
+ * interruptable (use select & test for terminate callback
+ * -- PTHREAD_STOP_SLEEP should interrupt select
+ * as well! -- and if not, we can use a small timeout).
*/
#include "platform.h"
@@ -33,18 +36,9 @@
#include "gnunet_bootstrap_service.h"
#include "gnunet_stats_service.h"
-#define DEBUG_HTTP NO
+#include <curl/curl.h>
-#define TCP_HTTP_PORT 80
-#define HTTP_URL "http://"
-#define GET_COMMAND "GET http://%s:%u%s HTTP/1.0\r\n\r\n"
-
/**
- * The HTTP proxy (optional)
- */
-static struct sockaddr_in theProxy;
-
-/**
* Stats service (maybe NULL!)
*/
static Stats_ServiceAPI * stats;
@@ -55,242 +49,87 @@
static struct GE_Context * ectx;
+typedef struct {
+ bootstrap_hello_callback callback;
+ void * arg;
+ bootstrap_terminate_callback termTest;
+ void * targ;
+ char * buf;
+ size_t bsize;
+ const char * url;
+} BootstrapContext;
+
+
/**
- * Download hostlist from the web and call method
- * on each hello.
+ * Process downloaded bits by calling callback on each hello.
*/
-static void
-downloadHostlistHelper(char * url,
- hello_Callback callback,
- void * arg) {
- unsigned short port;
- char * hostname;
- char * filename;
- unsigned int curpos, lenHostname, lenUrl;
- IPaddr ip_info;
- struct sockaddr_in soaddr;
- int sock;
- size_t ret;
- int success;
- char * command;
- cron_t start;
- char c;
- char * buffer;
- size_t n;
+static size_t
+downloadHostlistHelper(void * ptr,
+ size_t size,
+ size_t nmemb,
+ void * stream) {
+ BootstrapContext * bctx = ptr;
+ size_t osize;
+ size_t total;
+ P2P_hello_MESSAGE * helo;
+ unsigned int hs;
- port = TCP_HTTP_PORT;
-
- if (0 != strncmp(HTTP_URL, url, strlen(HTTP_URL)) ) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Invalid URL `%s' (must begin with `%s')\n"),
- url,
- HTTP_URL);
- return;
- }
- curpos = strlen(HTTP_URL);
- hostname = &url[curpos];
- lenUrl = strlen(url);
- while ( (curpos < lenUrl) &&
- (url[curpos] != '/') )
- curpos++;
- if (curpos == lenUrl)
- filename = STRDUP("/");
- else
- filename = STRDUP(&url[curpos]);
- url[curpos] = '\0'; /* terminator for hostname */
-
- curpos = 0;
- lenHostname = strlen(hostname);
- while ( (curpos < lenHostname) &&
- (hostname[curpos] != ':') )
- curpos++;
- if (curpos == lenHostname)
- port = TCP_HTTP_PORT;
- else {
- port = atoi(hostname + curpos + 1);
- if (!port) {
+ if (size * nmemb == 0)
+ return 0; /* ok, no data */
+ osize = bctx->bsize;
+ total = size * nmemb + osize;
+ GROW(bctx->buf,
+ bctx->bsize,
+ total);
+ memcpy(&bctx->buf[osize],
+ stream,
+ size * nmemb);
+ while ( (bctx->bsize > sizeof(P2P_hello_MESSAGE)) &&
+ (bctx->termTest(bctx->targ)) ) {
+ helo = (P2P_hello_MESSAGE*) &bctx->buf[0];
+ if (bctx->bsize < P2P_hello_MESSAGE_size(helo))
+ break;
+ if ( (ntohs(helo->header.type) != p2p_PROTO_hello) ||
+ (P2P_hello_MESSAGE_size(helo) >= MAX_BUFFER_SIZE) ) {
GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Invalid port \"%s\" in hostlist specification, trying port
%d.\n"),
- TCP_HTTP_PORT);
- port = TCP_HTTP_PORT;
+ GE_WARNING | GE_USER | GE_REQUEST,
+ _("Bootstrap data obtained from `%s' is invalid.\n"),
+ bctx->url);
+ return 0; /* Error: invalid format! */
}
- }
-
- hostname[curpos] = '\0'; /* terminator for hostname */
-
- sock = SOCKET(PF_INET, SOCK_STREAM, 0);
- if (sock < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("`%s' failed at %s:%d with error: `%s'.\n"),
- "socket",
- __FILE__, __LINE__,
- STRERROR(errno));
- FREE(filename);
- return;
- }
-
- /* Do we need to connect through a proxy? */
- if (theProxy.sin_addr.s_addr == 0) {
- if (OK != get_host_by_name(ectx, hostname, &ip_info)) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Could not download list of peer contacts, host `%s' unknown.\n"),
- hostname);
- FREE(filename);
- return;
- }
-
- memcpy(&soaddr.sin_addr.s_addr,
- &ip_info,
- sizeof(IPaddr));
- soaddr.sin_port
- = htons(port);
- } else {
- soaddr.sin_addr.s_addr
- = theProxy.sin_addr.s_addr;
- soaddr.sin_port
- = theProxy.sin_port;
- }
- soaddr.sin_family = AF_INET;
-
- if (CONNECT(sock,
- (struct sockaddr*)&soaddr,
- sizeof(soaddr)) < 0) {
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("`%s' to `%s' failed at %s:%d with error: %s\n"),
- "connect",
- hostname,
- __FILE__, __LINE__,
- STRERROR(errno));
- FREE(filename);
- if (0 != CLOSE(sock))
- GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- "close");
- return;
- }
-
- /* 10: 1 + sizeof(port) */
- n = strlen(filename) + strlen(GET_COMMAND) + lenHostname + 10;
- command = MALLOC(n);
- SNPRINTF(command,
- n,
- GET_COMMAND,
- hostname,
- port,
- filename);
- FREE(filename);
- curpos = strlen(command)+1;
- curpos = SEND_BLOCKING_ALL(sock,
- command,
- curpos);
- if (SYSERR == (int)curpos) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("`%s' to `%s' failed at %s:%d with error: %s\n"),
- "send",
- hostname,
- __FILE__, __LINE__,
- STRERROR(errno));
- FREE(command);
- if (0 != CLOSE(sock))
- GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- "close");
- return;
- }
- FREE(command);
- start = get_time();
-
- /* we first have to read out the http_response*/
- /* it ends with four line delimiters: "\r\n\r\n" */
- curpos = 0;
- while (curpos < 4) {
- if (start + 300 * cronSECONDS < get_time())
- break; /* exit after 5m */
- success = RECV_NONBLOCKING(sock,
- &c,
- sizeof(c),
- &ret);
- if (success == NO) {
- PTHREAD_SLEEP(100 * cronMILLIS);
- continue;
- }
- if (ret <= 0)
- break; /* end of transmission or error */
- if ((c=='\r') || (c=='\n'))
- curpos += ret;
- else
- curpos=0;
- }
-
- if (curpos < 4) { /* we have not found it */
- GE_LOG(ectx,
- GE_WARNING | GE_BULK | GE_USER,
- _("Parsing HTTP response for URL `%s' failed.\n"),
- url);
- if (0 != CLOSE(sock))
- GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- "close");
- return;
- }
-
- buffer = MALLOC(MAX_BUFFER_SIZE);
- while (1) {
- P2P_hello_MESSAGE * helo;
-
- helo = (P2P_hello_MESSAGE*) &buffer[0];
- helo->header.type = htons(p2p_PROTO_hello);
-
- if (start + 300 * cronSECONDS < get_time())
- break; /* exit after 300s */
- curpos = 0;
- helo->senderAddressSize = 0;
- while (curpos < P2P_hello_MESSAGE_size(helo)) {
- if (start + 300 * cronSECONDS < get_time())
- break; /* exit after 300s */
- success = RECV_NONBLOCKING(sock,
- &((char*)helo)[curpos],
- P2P_hello_MESSAGE_size(helo)-curpos,
- &ret);
- if ( success == NO )
- continue;
- if (ret <= 0)
- break; /* end of file or error*/
- if (P2P_hello_MESSAGE_size(helo) >= MAX_BUFFER_SIZE)
- break; /* INVALID! Avoid overflow! */
- curpos += ret;
- }
- if (curpos != P2P_hello_MESSAGE_size(helo)) {
- if (curpos != 0)
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Parsing hello from `%s' failed.\n"),
- url);
- break;
- }
- helo->header.size = htons(P2P_hello_MESSAGE_size(helo));
+ hs = P2P_hello_MESSAGE_size(helo);
+ helo->header.size = htons(hs);
if (stats != NULL)
stats->change(stat_hellodownloaded,
1);
- callback(helo,
- arg);
+ bctx->callback(helo,
+ bctx->arg);
+ memmove(&bctx->buf[0],
+ &bctx->buf[hs],
+ bctx->bsize - hs);
+ GROW(bctx->buf,
+ bctx->bsize,
+ bctx->bsize - hs);
}
-
- FREE(buffer);
- if (0 != CLOSE(sock))
- GE_LOG_STRERROR(ectx,
- GE_WARNING | GE_BULK | GE_ADMIN,
- "close");
+ return size * nmemb;
}
-static void downloadHostlist(hello_Callback callback,
- void * arg) {
+static void downloadHostlist(bootstrap_hello_callback callback,
+ void * arg,
+ bootstrap_terminate_callback termTest,
+ void * targ) {
+ BootstrapContext bctx;
char * url;
- int i;
- int cnt;
+ char * proxy;
+ CURL * curl;
+ bctx.callback = callback;
+ bctx.arg = arg;
+ bctx.termTest = termTest;
+ bctx.targ = targ;
+ bctx.buf = NULL;
+ bctx.bsize = 0;
if (0 != GC_get_configuration_value_string(coreAPI->cfg,
"GNUNETD",
"HOSTLISTURL",
@@ -298,83 +137,56 @@
&url)) {
GE_LOG(ectx,
GE_WARNING | GE_BULK | GE_USER,
- "No hostlist URL specified in configuration, will not bootstrap.\n");
+ _("No hostlist URL specified in configuration, will not
bootstrap.\n"));
return;
}
-#if DEBUG_HTTP
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Trying to bootstrap with peers from `%s'\n",
- url);
-#endif
- cnt = 1;
- i = strlen(url);
- while (i > 0) {
- i--;
- if (url[i] == ' ')
- cnt++;
- }
- cnt = weak_randomi(cnt); /* pick random hostlist of the pack */
- i = strlen(url);
- while (i > 0) {
- i--;
- if (url[i] == ' ') {
- if (cnt > 0) {
- url[i] = '\0';
- cnt--;
- continue;
- }
- downloadHostlistHelper(&url[i+1],
- callback,
- arg);
- FREE(url);
- return;
- }
- }
- downloadHostlistHelper(&url[0],
- callback,
- arg);
+ bctx.url = url;
+ proxy = NULL;
+ GC_get_configuration_value_string(coreAPI->cfg,
+ "GNUNETD",
+ "HTTP-PROXY",
+ NULL,
+ &proxy);
+ curl = curl_easy_init();
+ curl_easy_setopt(curl,
+ CURLOPT_WRITEFUNCTION,
+ &downloadHostlistHelper);
+ curl_easy_setopt(curl,
+ CURLOPT_WRITEDATA,
+ &bctx);
+ curl_easy_setopt(curl,
+ CURLOPT_FAILONERROR,
+ 1);
+ curl_easy_setopt(curl,
+ CURLOPT_URL,
+ url);
+ if (proxy != NULL)
+ curl_easy_setopt(curl,
+ CURLOPT_PROXY,
+ proxy);
+ curl_easy_setopt(curl,
+ CURLOPT_BUFFERSIZE,
+ 1024); /* a bit more than one HELLO */
+ if (0 == strncmp(url, "http", 4))
+ curl_easy_setopt(curl,
+ CURLOPT_USERAGENT,
+ "GNUnet");
+ curl_easy_setopt(curl,
+ CURLOPT_CONNECTTIMEOUT,
+ 15L);
+ curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
FREE(url);
+ FREE(proxy);
}
Bootstrap_ServiceAPI *
provide_module_bootstrap(CoreAPIForApplication * capi) {
static Bootstrap_ServiceAPI api;
- char *proxy;
- unsigned long long proxyPort;
- IPaddr ip;
- ectx = capi->ectx;
- if (0 == GC_get_configuration_value_string(capi->cfg,
- "GNUNETD",
- "HTTP-PROXY",
- NULL,
- &proxy)) {
- if (OK != get_host_by_name(ectx,
- proxy,
- &ip)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Could not resolve name of HTTP proxy `%s'. Trying without a
proxy.\n"),
- proxy);
- theProxy.sin_addr.s_addr = 0;
- } else {
- memcpy(&theProxy.sin_addr.s_addr,
- &ip,
- sizeof(IPaddr));
- GC_get_configuration_value_number(capi->cfg,
- "GNUNETD",
- "HTTP-PROXY-PORT",
- 1,
- 65535,
- 8080,
- &proxyPort);
- theProxy.sin_port = htons(proxyPort);
- }
- FREE(proxy);
- } else {
- theProxy.sin_addr.s_addr = 0;
- }
-
+ if (0 != curl_global_init(CURL_GLOBAL_ALL))
+ return NULL;
coreAPI = capi;
stats = coreAPI->requestService("stats");
if (stats != NULL) {
Modified: GNUnet/src/include/gnunet_bootstrap_service.h
===================================================================
--- GNUnet/src/include/gnunet_bootstrap_service.h 2006-08-18 02:21:15 UTC
(rev 3243)
+++ GNUnet/src/include/gnunet_bootstrap_service.h 2006-08-18 06:08:47 UTC
(rev 3244)
@@ -40,10 +40,15 @@
* Definition of a callback function that processes
* hello messages generated by the bootstrap API.
*/
-typedef void (*hello_Callback)(const P2P_hello_MESSAGE * helo,
- void * arg);
+typedef void (*bootstrap_hello_callback)(const P2P_hello_MESSAGE * helo,
+ void * arg);
/**
+ * @return YES to continue, NO to abort
+ */
+typedef int (*bootstrap_terminate_callback)(void * arg);
+
+/**
* @brief Definition of the bootstrap API.
*/
typedef struct {
@@ -55,8 +60,10 @@
* @param callback the method to call
* @param arg extra argument to the method
*/
- void (*bootstrap)(hello_Callback callback,
- void * arg);
+ void (*bootstrap)(bootstrap_hello_callback callback,
+ void * arg,
+ bootstrap_terminate_callback term,
+ void * targ);
} Bootstrap_ServiceAPI;
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-18 02:21:15 UTC (rev 3243)
+++ GNUnet/todo 2006-08-18 06:08:47 UTC (rev 3244)
@@ -20,7 +20,7 @@
+ config: call GC change listeners on entire config on registration!!!
* transports:
+ SMTP/HTTP: do not yet compile (commented out from build)
- o libwww & libesmtp?
+ o libcurl? & libesmtp?
* server:
+ needs testing, also likely to be missing features
* applications:
@@ -28,10 +28,9 @@
stats, topology_default, state, getoption, advertising,
traffic, ecrs_core, template, tbench, tracekit, fs/fslib,
fs/module, gap, fs/ecrs, fs/uritrack, fs/namespace,
- fs/fsui, fs/collection, fs/tools compile
+ fs/fsui, fs/collection, fs/tools, bootstrap_http compile
+ fs/fsui, fs/collection, fs/uritrack, fs/namespace
must still be revised to match new API!
- + bootstrap_http: maybe switch to libwww?
+ rest: sqstore_mysql, dht, rpc, topology_f2f, vpn
+ low priority: chat, kvstore_sqlite, testbed
* setup:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3244 - in GNUnet: . contrib m4 src/applications/advertising src/applications/bootstrap_http src/include,
grothoff <=