Add config option to disable fetching via rhizome

This commit is contained in:
Jeremy Lakeman 2013-03-05 10:55:18 +10:30
parent 8771d6181b
commit 4cdd3da77f
4 changed files with 33 additions and 2 deletions

View File

@ -320,6 +320,7 @@ END_STRUCT
STRUCT(rhizome)
ATOM(int, enable, 1, int_boolean,, "If true, server opens Rhizome database when starting")
ATOM(char, fetch, 1, char_boolean,, "If false, no new bundles will be fetched from peers")
ATOM(int, clean_on_open, 1, int_boolean,, "If true, Rhizome database is cleaned at start of every command")
STRING(256, datastore_path, "", absolute_path,, "Path of rhizome storage directory, absolute or relative to instance directory")
ATOM(uint64_t, database_size, 1000000, uint64_scaled,, "Size of database in bytes")

View File

@ -896,6 +896,10 @@ struct profile_total rfmsc_stats={.name="rhizome_fetch_mdp_slot_callback"};
int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sockaddr_in *peerip,const unsigned char peersid[SID_SIZE])
{
IN();
if (!config.rhizome.fetch)
RETURN(0);
const char *bid = alloca_tohex_bid(m->cryptoSignPublic);
int priority=100; /* normal priority */

View File

@ -257,9 +257,11 @@ error:
int overlay_rhizome_saw_advertisements(int i, struct overlay_frame *f, long long now)
{
IN();
if (!f) { RETURN(-1); }
if (!f)
RETURN(-1);
if (!rhizome_db) { RETURN(0); }
if (!(rhizome_db && config.rhizome.fetch))
RETURN(0);
int ad_frame_type=ob_get(f->payload);
struct sockaddr_in httpaddr = f->recvaddr;

View File

@ -109,6 +109,30 @@ test_EncryptedTransfer() {
assert diff file1 file1x
}
doc_NoFetch="Disabling fetching still allows pushing bundles"
setup_NoFetch() {
setup_common
set_instance +A
rhizome_add_file file1
BID1=$BID
VERSION1=$VERSION
set_instance +B
rhizome_add_file file2
BID2=$BID
VERSION2=$VERSION
executeOk_servald config set rhizome.fetch 0
start_servald_instances +A +B
}
test_NoFetch() {
wait_until bundle_received_by $BID2:$VERSION2 +A
set_instance +A
executeOk_servald rhizome list
assert_rhizome_list --fromhere=1 file1 --fromhere=0 file2
set_instance +B
executeOk_servald rhizome list
assert_rhizome_list --fromhere=1 file2
}
doc_DisablingHTTPServer="Disabling HTTP rhizome transports works"
setup_DisablingHTTPServer() {
setup_common