added improved control of rhizome http and mdp servers via

separate config options with their own predicate functions.
This commit is contained in:
gardners 2012-11-30 14:47:27 +10:30
parent 7a4e3d20f8
commit b91e832ad7
6 changed files with 61 additions and 19 deletions

View File

@ -124,16 +124,16 @@ schedule(&_sched_##X); }
/* Get rhizome server started BEFORE populating fd list so that
the server's listen socket is in the list for poll() */
if (rhizome_enabled()) {
if (!rhizome_opendb()){
/* Rhizome http server needs to know which callback to attach
if (is_rhizome_enabled()) rhizome_opendb();
/* Rhizome http server needs to know which callback to attach
to client sockets, so provide it here, along with the name to
appear in time accounting statistics. */
rhizome_http_server_start(rhizome_server_parse_http_request,
"rhizome_server_parse_http_request",
RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX);
}
}
if (is_rhizome_http_enabled())
rhizome_http_server_start(rhizome_server_parse_http_request,
"rhizome_server_parse_http_request",
RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX);
// start the dna helper if configured
dna_helper_start();

View File

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "overlay_address.h"
#include "overlay_packet.h"
#include "mdp_client.h"
#include "rhizome.h"
#include "crypto.h"
int overlay_mdp_service_rhizomerequest(overlay_mdp_frame *mdp)
@ -150,12 +151,18 @@ int overlay_mdp_try_interal_services(overlay_mdp_frame *mdp)
case MDP_PORT_KEYMAPREQUEST: RETURN(keyring_mapping_request(keyring,mdp));
case MDP_PORT_DNALOOKUP: RETURN(overlay_mdp_service_dnalookup(mdp));
case MDP_PORT_ECHO: RETURN(overlay_mdp_service_echo(mdp));
case MDP_PORT_RHIZOME_REQUEST: RETURN(overlay_mdp_service_rhizomerequest(mdp));
case MDP_PORT_RHIZOME_RESPONSE: RETURN(overlay_mdp_service_rhizomeresponse(mdp));
default:
/* Unbound socket. We won't be sending ICMP style connection refused
messages, partly because they are a waste of bandwidth. */
RETURN(WHYF("Received packet for which no listening process exists (MDP ports: src=%d, dst=%d",
mdp->out.src.port,mdp->out.dst.port));
case MDP_PORT_RHIZOME_REQUEST:
if (is_rhizome_mdp_server_running()) {
RETURN(overlay_mdp_service_rhizomerequest(mdp));
} else break;
case MDP_PORT_RHIZOME_RESPONSE:
if (is_rhizome_mdp_server_running()) {
RETURN(overlay_mdp_service_rhizomeresponse(mdp));
} else break;
}
/* Unbound socket. We won't be sending ICMP style connection refused
messages, partly because they are a waste of bandwidth. */
RETURN(WHYF("Received packet for which no listening process exists (MDP ports: src=%d, dst=%d",
mdp->out.src.port,mdp->out.dst.port));
}

View File

@ -22,9 +22,37 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "rhizome.h"
#include <stdlib.h>
int rhizome_enabled()
int is_rhizome_enabled()
{
return confValueGetBoolean("rhizome.enable", 1);;
return confValueGetBoolean("rhizome.enable", 1);
}
int is_rhizome_http_enabled()
{
return confValueGetBoolean("rhizome.enable", 1)
&& confValueGetBoolean("rhizome.http.enable", 1)
&& rhizome_db;
}
int is_rhizome_mdp_enabled()
{
return confValueGetBoolean("rhizome.enable", 1)
&& confValueGetBoolean("rhizome.mdp.enable", 1)
&& rhizome_db;
}
int is_rhizome_mdp_server_running()
{
return is_rhizome_mdp_enabled();
}
int is_rhizome_advertise_enabled()
{
return confValueGetBoolean("rhizome.enable", 1)
&& confValueGetBoolean("rhizome.advertise.enable", 1)
&& rhizome_db
&& ( is_rhizome_http_server_running()
||is_rhizome_mdp_server_running());
}
int rhizome_fetch_delay_ms()

View File

@ -439,6 +439,13 @@ int rhizome_http_server_start(int (*http_parse_func)(rhizome_http_request *),
const char *http_parse_func_description,
int port_low,int port_high);
int is_rhizome_enabled();
int is_rhizome_mdp_enabled();
int is_rhizome_http_enabled();
int is_rhizome_advertise_enabled();
int is_rhizome_mdp_server_running();
int is_rhizome_http_server_running();
typedef struct rhizome_direct_bundle_cursor {
/* Where the current fill started */
long long start_size_high;

View File

@ -72,7 +72,7 @@ unsigned char favicon_bytes[]={
,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int favicon_len=318;
int rhizome_http_server_running()
int is_rhizome_http_server_running()
{
return rhizome_server_socket != -1;
}

View File

@ -145,7 +145,7 @@ int overlay_rhizome_add_advertisements(int interface_number, struct overlay_buff
XXX We will move all processing of Rhizome into a separate process
so that the CPU delays caused by Rhizome verifying signatures isn't a problem.
*/
if (!rhizome_http_server_running() || !rhizome_db)
if (!is_rhizome_advertise_enabled())
RETURN(0);
int pass;