Author: poeml Date: Sat May 29 14:07:27 2010 New Revision: 8068 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8068&view=rev Log: mod_mirrorbrain: - A DHT "nodes" list is now included in Torrents, fixing issue #49. - To configure the nodes, a MirrorBrainDHTNode config directive was added, which takes two arguments (hostname and port). 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=8068&r1=8067&r2=8068&view=diff ============================================================================== --- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original) +++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Sat May 29 14:07:27 2010 _at_@ -242,6 +242,7 @@ const char *metalink_publisher_name; const char *metalink_publisher_url; apr_array_header_t *tracker_urls; + apr_array_header_t *dhtnodes; const char *metalink_broken_test_mirrors; const char *mirrorlist_stylesheet; const char *query; _at_@ -249,6 +250,12 @@ const char *query_hash; const char *query_hash_label; } mb_server_conf; + +typedef struct dhtnode dhtnode_t; +struct dhtnode { + char *name; + int port; +}; static ap_dbd_t *(*mb_dbd_acquire_fn)(request_rec*) = NULL; _at_@ -400,6 +407,7 @@ new->metalink_publisher_name = NULL; new->metalink_publisher_url = NULL; new->tracker_urls = apr_array_make(p, 5, sizeof (char *)); + new->dhtnodes = apr_array_make(p, 5, sizeof (dhtnode_t)); new->metalink_broken_test_mirrors = NULL; new->mirrorlist_stylesheet = NULL; new->query = DEFAULT_QUERY; _at_@ -428,6 +436,7 @@ cfgMergeString(metalink_publisher_name); cfgMergeString(metalink_publisher_url); mrg->tracker_urls = apr_array_append(p, base->tracker_urls, add->tracker_urls); + mrg->dhtnodes = apr_array_append(p, base->dhtnodes, add->dhtnodes); cfgMergeString(metalink_broken_test_mirrors); cfgMergeString(mirrorlist_stylesheet); mrg->query = (add->query != (char *) DEFAULT_QUERY) ? add->query : base->query; _at_@ -642,6 +651,21 @@ char **url = (char **) apr_array_push(cfg->tracker_urls); *url = apr_pstrdup(cmd->pool, arg1); + return NULL; +} + +static const char *mb_cmd_dht_node(cmd_parms *cmd, void *config, + const char *arg1, const char *arg2) +{ + server_rec *s = cmd->server; + mb_server_conf *cfg = + ap_get_module_config(s->module_config, &mirrorbrain_module); + + dhtnode_t *new = apr_array_push(cfg->dhtnodes); + new->name = apr_pstrdup(cmd->pool, arg1); + new->port = atoi(apr_pstrdup(cmd->pool, arg2)); + if (new->port <= 0) + return "MirrorBrainDHTNode requires a positive integer as second argument (server port)."; return NULL; } _at_@ -2732,7 +2756,6 @@ ap_rprintf(r, "%d:http://%s%s", (7 + strlen(r->hostname) + strlen(r->uri)), r->hostname, r->uri); } - ap_rputs( "e", r); #if 0 /* it would be simple to just list the URL of the redirector itself, but aria2c _at_@ -2749,10 +2772,20 @@ r->hostname, r->uri); #endif + if (!apr_is_empty_array(scfg->dhtnodes)) { + + ap_rputs( "e" + "5:nodes" + "l", r); + for (i = 0; i < scfg->dhtnodes->nelts; i++) { + dhtnode_t node = ((dhtnode_t *) scfg->dhtnodes->elts)[i]; + ap_rprintf(r, "l" "%d:%s" "i%de" "e", strlen(node.name), node.name, + node.port); + } + } + ap_rputs( "e", r); + ap_rputs( "e", r); - - /* if there's no announce key (trackerless torrent), we should add a "nodes" key. - * TODO: find out what it should contain. See http://www.bittorrent.org/beps/bep_0005.html */ return OK; } _at_@ -3079,6 +3112,12 @@ "Define the URL a Bittorrent Tracker be included in Torrents and in Magnet " "links. Directive can be repeated to specify multiple URLs."), + AP_INIT_TAKE2("MirrorBrainDHTNode", mb_cmd_dht_node, NULL, + RSRC_CONF, + "Define a DHT node to be included in Torrents " + "links. Directive can be repeated to specify multiple nodes, and takes " + "two arguments (hostname, port)."), + AP_INIT_TAKE1("MirrorBrainMetalinkBrokenTestMirrors", mb_cmd_metalink_broken_test_mirrors, NULL, RSRC_CONF, "Filename with snippet to include at the top of a metalink's " _______________________________________________ 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 Sat May 29 2010 - 12:07:29 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT