From 385e2bdb4ee80431fb1d1aec48938e2e7ae91f0e Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 17 Aug 2012 19:42:11 +0930 Subject: [PATCH] Improve Rhizome INFO messages --- rhizome_fetch.c | 13 ++++++------- rhizome_http.c | 14 ++++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 61215b44..814f5d4d 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -85,10 +85,8 @@ rhizome_file_fetch_record file_fetch_queue[MAX_QUEUED_FILES]; only to deal with packet errors (but also naughty people who might want to mess with the transfer. - For HTTP over IPv4, the biggest problem is that we don't know the IPv4 address of - the sender, or in fact that the link is over IPv4 and thus that HTTP over IPv4 is - an option. We probably need to be passed this information. This has since been - incorporated. + For HTTP over IPv4, the IPv4 address and port number of the sender is sent as part of the + advertisement. */ /* As defined below uses 64KB */ @@ -645,7 +643,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri } struct sockaddr_in addr = *peerip; addr.sin_family = AF_INET; - INFOF("HTTP CONNECT family=%u port=%u addr=%u.%u.%u.%u", + INFOF("RHIZOME HTTP REQUEST, CONNECT family=%u port=%u addr=%u.%u.%u.%u", addr.sin_family, ntohs(addr.sin_port), ((unsigned char*)&addr.sin_addr.s_addr)[0], ((unsigned char*)&addr.sin_addr.s_addr)[1], @@ -668,8 +666,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri *manifest_kept = 1; q->alarm.poll.fd=sock; strncpy(q->fileid, m->fileHexHash, RHIZOME_FILEHASH_STRLEN + 1); - snprintf(q->request,1024,"GET /rhizome/file/%s HTTP/1.0\r\n\r\n", q->fileid); - q->request_len=strlen(q->request); + q->request_len = snprintf(q->request, sizeof q->request, "GET /rhizome/file/%s HTTP/1.0\r\n\r\n", q->fileid); q->request_ofs=0; q->state=RHIZOME_FETCH_CONNECTING; q->file_len=-1; @@ -698,6 +695,8 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri return -1; } + INFOF("RHIZOME HTTP REQUEST, GET \"/rhizome/file/%s\"", q->fileid); + /* Watch for activity on the socket */ q->alarm.function=rhizome_fetch_poll; fetch_stats.name="rhizome_fetch_poll"; diff --git a/rhizome_http.c b/rhizome_http.c index 1c6d264b..f78b2d0e 100644 --- a/rhizome_http.c +++ b/rhizome_http.c @@ -199,7 +199,7 @@ error: return WHY("Failed to start rhizome HTTP server"); success: - INFOF("Started Rhizome HTTP server on port %d, fd = %d", port, rhizome_server_socket); + INFOF("RHIZOME HTTP SERVER, START port=%d, fd=%d", port, rhizome_server_socket); rhizome_http_server_port = port; /* Add Rhizome HTTPd server to list of file descriptors to watch */ server_alarm.function = rhizome_server_poll; @@ -267,8 +267,7 @@ void rhizome_server_poll(struct sched_ent *alarm) while ((sock = accept(rhizome_server_socket, &addr, &addr_len)) != -1) { if (addr.sa_family == AF_INET) { struct sockaddr_in *peerip = (struct sockaddr_in *)&addr; - if (debug & DEBUG_RHIZOME_TX) - DEBUGF("HTTP ACCEPT addrlen=%u family=%u port=%u addr=%u.%u.%u.%u", + INFOF("RHIZOME HTTP SERVER, ACCEPT addrlen=%u family=%u port=%u addr=%u.%u.%u.%u", addr_len, peerip->sin_family, peerip->sin_port, ((unsigned char*)&peerip->sin_addr.s_addr)[0], ((unsigned char*)&peerip->sin_addr.s_addr)[1], @@ -276,9 +275,9 @@ void rhizome_server_poll(struct sched_ent *alarm) ((unsigned char*)&peerip->sin_addr.s_addr)[3] ); } else { - if (debug & DEBUG_RHIZOME_TX) - DEBUGF("HTTP ACCEPT addrlen=%u family=%u data=%s", - addr_len, addr.sa_family, alloca_tohex((unsigned char *)addr.sa_data, sizeof addr.sa_data)); + INFOF("RHIZOME HTTP SERVER, ACCEPT addrlen=%u family=%u data=%s", + addr_len, addr.sa_family, alloca_tohex((unsigned char *)addr.sa_data, sizeof addr.sa_data) + ); } rhizome_http_request *request = calloc(sizeof(rhizome_http_request), 1); if (request == NULL) { @@ -528,8 +527,7 @@ static int rhizome_server_parse_http_request(rhizome_http_request *r) } if (path) { char *id = NULL; - if (debug & DEBUG_RHIZOME_TX) - DEBUGF("GET %s", alloca_toprint(1024, path, pathlen)); + INFOF("RHIZOME HTTP SERVER, GET %s", alloca_toprint(1024, path, pathlen)); if (strcmp(path, "/favicon.ico") == 0) { r->request_type = RHIZOME_HTTP_REQUEST_FAVICON; rhizome_server_http_response_header(r, 200, "image/vnd.microsoft.icon", favicon_len);