From 8eb0e0e5de40729656fa111d6eca66b45e2d8772 Mon Sep 17 00:00:00 2001 From: gardners Date: Thu, 16 May 2013 07:06:39 +0930 Subject: [PATCH] switch new meshms to using a new service field. remove requirement that bundles have one of the known list of service types. --- rhizome.c | 7 +++---- rhizome.h | 3 ++- rhizome_database.c | 13 ++----------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/rhizome.c b/rhizome.c index c6de300e..afbe347f 100644 --- a/rhizome.c +++ b/rhizome.c @@ -188,7 +188,8 @@ int rhizome_manifest_check_sanity(rhizome_manifest *m_in) const char *name = rhizome_manifest_get(m_in, "name", NULL, 0); if (name == NULL) return WHY("Manifest missing 'name' field"); - } else if (strcasecmp(service, RHIZOME_SERVICE_MESHMS) == 0) { + } else if (strcasecmp(service, RHIZOME_SERVICE_MESHMS_OLD) == 0 + || strcasecmp(service, RHIZOME_SERVICE_MESHMS) == 0) { if (sender == NULL || !sender[0]) return WHY("MeshMS Manifest missing 'sender' field"); if (!str_is_subscriber_id(sender)) @@ -197,9 +198,7 @@ int rhizome_manifest_check_sanity(rhizome_manifest *m_in) return WHY("MeshMS Manifest missing 'recipient' field"); if (!str_is_subscriber_id(recipient)) return WHYF("MeshMS Manifest contains invalid 'recipient' field: %s", recipient); - } else { - return WHY("Invalid service type"); - } + } if (config.debug.rhizome) DEBUGF("sender='%s'", sender ? sender : "(null)"); diff --git a/rhizome.h b/rhizome.h index 082269c7..42d8cd83 100644 --- a/rhizome.h +++ b/rhizome.h @@ -181,7 +181,8 @@ typedef struct rhizome_manifest { * after it is received by Rhizome. */ #define RHIZOME_SERVICE_FILE "file" -#define RHIZOME_SERVICE_MESHMS "MeshMS1" +#define RHIZOME_SERVICE_MESHMS_OLD "MeshMS1" +#define RHIZOME_SERVICE_MESHMS "MeshMS2" extern long long rhizome_space; extern unsigned short rhizome_http_server_port; diff --git a/rhizome_database.c b/rhizome_database.c index 7037e0a8..b333ebda 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1457,16 +1457,6 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found, const char *recipient = NULL; if (service == NULL) { return WHY("Manifest has no service"); - } else if (strcasecmp(service, RHIZOME_SERVICE_FILE) == 0) { - name = rhizome_manifest_get(m, "name", NULL, 0); - if (!name) return WHY("Manifest has no name"); - } else if (strcasecmp(service, RHIZOME_SERVICE_MESHMS) == 0) { - sender = rhizome_manifest_get(m, "sender", NULL, 0); - recipient = rhizome_manifest_get(m, "recipient", NULL, 0); - if (!sender) return WHY("Manifest has no sender"); - if (!recipient) return WHY("Manifest has no recipient"); - } else { - return WHYF("Unsupported service '%s'", service); } char sqlcmd[1024]; strbuf b = strbuf_local(sqlcmd, sizeof sqlcmd); @@ -1585,7 +1575,8 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found, strbuf_sprintf(b, " name=\"%s\"", blob_name); }else ++inconsistent; - } else if (strcasecmp(service, RHIZOME_SERVICE_MESHMS) == 0) { + } + { const char *blob_sender = rhizome_manifest_get(blob_m, "sender", NULL, 0); const char *blob_recipient = rhizome_manifest_get(blob_m, "recipient", NULL, 0); if (blob_sender && !strcasecmp(blob_sender, sender) && blob_recipient && !strcasecmp(blob_recipient, recipient)) {