Author: poeml Date: Tue Aug 31 23:15:32 2010 New Revision: 8080 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8080&view=rev Log: mod_mirrorbrain: - In torrents, include the md5 and sha256 hash into the info dictionary - In torrents, include a "sources" list with mirror URLs, just like "url-list". This other form of listing web seeds might be used by some other clients. Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=8080&r1=8079&r2=8080&view=diff ============================================================================== --- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original) +++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Tue Aug 31 23:15:32 2010 _at_@ -2714,11 +2714,20 @@ for (i = 0; i < hashbag->sha1pieceshex->nelts; i++) { ap_rwrite(hex_decode(r, p[i], SHA1_DIGESTSIZE), SHA1_DIGESTSIZE, r); } + ap_rprintf(r, "3:md5" + "%d:", MD5_DIGESTSIZE); + ap_rwrite( hex_decode(r, hashbag->md5hex, MD5_DIGESTSIZE), + MD5_DIGESTSIZE, r); ap_rprintf(r, "4:sha1" "%d:", SHA1_DIGESTSIZE); ap_rwrite( hex_decode(r, hashbag->sha1hex, SHA1_DIGESTSIZE), SHA1_DIGESTSIZE, r); - + ap_rprintf(r, "6:sha256" + "%d:", SHA256_DIGESTSIZE); + ap_rwrite( hex_decode(r, hashbag->sha256hex, SHA256_DIGESTSIZE), + SHA256_DIGESTSIZE, r); + + /* end of info hash: */ ap_rputs( "e", r); /* Web seeds _at_@ -2729,66 +2738,84 @@ * (not a valid bencoded string)". (Which is wrong.) However, it does * _not_ seam to read past the pieces; at least it doesn't complain * about stuff occurring afterwards. */ - ap_rputs( "8:url-listl", r); - int found_urls = 0; - mirrorp = (mirror_entry_t **)mirrors_same_prefix->elts; - for (i = 0; i < mirrors_same_prefix->nelts; i++, found_urls++) { - mirror = mirrorp[i]; - ap_rprintf(r, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), - mirror->baseurl, filename); - } - if (!found_urls) { - mirrorp = (mirror_entry_t **)mirrors_same_as->elts; - for (i = 0; i < mirrors_same_as->nelts; i++, found_urls++) { + + { + apr_array_header_t *m; + m = apr_array_make(r->pool, 11, sizeof(char *)); + int found_urls = 0; + + mirrorp = (mirror_entry_t **)mirrors_same_prefix->elts; + for (i = 0; i < mirrors_same_prefix->nelts; i++, found_urls++) { mirror = mirrorp[i]; - ap_rprintf(r, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), - mirror->baseurl, filename); - } - } - if (!found_urls) { - mirrorp = (mirror_entry_t **)mirrors_same_country->elts; - for (i = 0; i < mirrors_same_country->nelts; i++, found_urls++) { - mirror = mirrorp[i]; - ap_rprintf(r, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), - mirror->baseurl, filename); - } - } - if (!found_urls) { - mirrorp = (mirror_entry_t **)mirrors_same_region->elts; - for (i = 0; i < mirrors_same_region->nelts; i++, found_urls++) { - mirror = mirrorp[i]; - ap_rprintf(r, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), - mirror->baseurl, filename); - } - } - if (!found_urls) { - mirrorp = (mirror_entry_t **)mirrors_elsewhere->elts; - for (i = 0; i < mirrors_elsewhere->nelts; i++, found_urls++) { - mirror = mirrorp[i]; - ap_rprintf(r, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), - mirror->baseurl, filename); - } - } - /* add the redirector, in case there wasn't any mirror */ - if (!found_urls) { - ap_rprintf(r, "%d:http://%s%s", (7 + strlen(r->hostname) + strlen(r->uri)), - r->hostname, r->uri); - } + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), + mirror->baseurl, filename); + } + if (!found_urls) { + mirrorp = (mirror_entry_t **)mirrors_same_as->elts; + for (i = 0; i < mirrors_same_as->nelts; i++, found_urls++) { + mirror = mirrorp[i]; + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), + mirror->baseurl, filename); + } + } + if (!found_urls) { + mirrorp = (mirror_entry_t **)mirrors_same_country->elts; + for (i = 0; i < mirrors_same_country->nelts; i++, found_urls++) { + mirror = mirrorp[i]; + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), + mirror->baseurl, filename); + } + } + if (!found_urls) { + mirrorp = (mirror_entry_t **)mirrors_same_region->elts; + for (i = 0; i < mirrors_same_region->nelts; i++, found_urls++) { + mirror = mirrorp[i]; + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), + mirror->baseurl, filename); + } + } + if (!found_urls) { + mirrorp = (mirror_entry_t **)mirrors_elsewhere->elts; + for (i = 0; i < mirrors_elsewhere->nelts; i++, found_urls++) { + mirror = mirrorp[i]; + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:%s%s", (strlen(mirror->baseurl) + strlen(filename)), + mirror->baseurl, filename); + } + } + /* add the redirector, in case there wasn't any mirror */ + if (!found_urls) { + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "%d:http://%s%s", (7 + strlen(r->hostname) + strlen(r->uri)), + r->hostname, r->uri); + } #if 0 - /* it would be simple to just list the URL of the redirector itself, but aria2c - * retrieves a Metalink then and doesn't expect it in that situation. Maybe later */ - ap_rprintf(r, "8:url-list" - "%d:http://%s%s", (7 + strlen(r->hostname) + strlen(r->uri)), - r->hostname, r->uri); + /* it would be simple to just list the URL of the redirector itself, but aria2c + * retrieves a Metalink then and doesn't expect it in that situation. Maybe later */ + APR_ARRAY_PUSH(m, char *) = + apr_psprintf(r->pool, "8:url-list" + "%d:http://%s%s", (7 + strlen(r->hostname) + strlen(r->uri)), + r->hostname, r->uri); #endif -#if 0 - /* I can't find info about this element which could possibly also list mirrors */ - ap_rprintf(r, "7:sourcesl" - "%d:http://%s%s" "e", (7 + strlen(r->hostname) + strlen(r->uri)), - r->hostname, r->uri); -#endif + if (!apr_is_empty_array(m)) { + ap_rputs( "8:url-listl", r); + for (i = 0; i < m->nelts; i++) { + char *e = ((char **) m->elts)[i]; + ap_rputs(e, r); + } + ap_rputs( "e7:sourcesl", r); + for (i = 0; i < m->nelts; i++) { + char *e = ((char **) m->elts)[i]; + ap_rputs(e, r); + } + } + } if (!apr_is_empty_array(scfg->dhtnodes)) { _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Tue Aug 31 2010 - 21:15:34 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT