mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-27 14:29:51 +00:00
Modify lookup uri format to distinguish between serval identities and gateway services
This commit is contained in:
parent
2fa5fbfee7
commit
222cb80ce7
@ -92,7 +92,7 @@ static void add_record(){
|
|||||||
// TODO check that did is a valid phone number
|
// TODO check that did is a valid phone number
|
||||||
|
|
||||||
char url[256];
|
char url[256];
|
||||||
snprintf(url, sizeof(url), "sid://%s/%s|%s|%s", sid, did, did, name);
|
snprintf(url, sizeof(url), "sid://%s/local/%s|%s|%s", sid, did, did, name);
|
||||||
add_item(did, url);
|
add_item(did, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ int monitor_send_lookup_response(const char *sid, const int port, const char *ex
|
|||||||
WHY("No local identity, cannot send DNA LOOKUP reply");
|
WHY("No local identity, cannot send DNA LOOKUP reply");
|
||||||
else{
|
else{
|
||||||
char uri[256];
|
char uri[256];
|
||||||
snprintf(uri, sizeof(uri), "sid://%s/%s", alloca_tohex_sid(keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key), ext);
|
snprintf(uri, sizeof(uri), "sid://%s/external/%s", alloca_tohex_sid(keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key), ext);
|
||||||
DEBUGF("Sending response to %s for %s", sid, uri);
|
DEBUGF("Sending response to %s for %s", sid, uri);
|
||||||
overlay_mdp_dnalookup_reply(&addr, keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key, uri, ext, name);
|
overlay_mdp_dnalookup_reply(&addr, keyring->contexts[cn]->identities[in]->keypairs[kp]->public_key, uri, ext, name);
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ int overlay_saw_mdp_frame(overlay_mdp_frame *mdp, time_ms_t now)
|
|||||||
strbuf b = strbuf_alloca(SID_STRLEN + DID_MAXSIZE + 10);
|
strbuf b = strbuf_alloca(SID_STRLEN + DID_MAXSIZE + 10);
|
||||||
strbuf_puts(b, "sid://");
|
strbuf_puts(b, "sid://");
|
||||||
strbuf_tohex(b, packedSid, SID_SIZE);
|
strbuf_tohex(b, packedSid, SID_SIZE);
|
||||||
strbuf_putc(b, '/');
|
strbuf_puts(b, "/local/");
|
||||||
strbuf_puts(b, unpackedDid);
|
strbuf_puts(b, unpackedDid);
|
||||||
overlay_mdp_dnalookup_reply(&mdp->out.src, packedSid, strbuf_str(b), unpackedDid, name);
|
overlay_mdp_dnalookup_reply(&mdp->out.src, packedSid, strbuf_str(b), unpackedDid, name);
|
||||||
kp++;
|
kp++;
|
||||||
|
@ -70,11 +70,11 @@ test_publish() {
|
|||||||
set_instance +A
|
set_instance +A
|
||||||
executeOk_servald dna lookup "$DIDB"
|
executeOk_servald dna lookup "$DIDB"
|
||||||
assertStdoutLineCount '==' 1
|
assertStdoutLineCount '==' 1
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
||||||
executeOk_servald dna lookup "$DIDC"
|
executeOk_servald dna lookup "$DIDC"
|
||||||
assertStdoutLineCount '==' 2
|
assertStdoutLineCount '==' 2
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDC/$DIDC:$DIDC:$NAMEC\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$"
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDD/$DIDD:$DIDD:$NAMED\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDD/local/$DIDD:$DIDD:$NAMED\$"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,11 +123,11 @@ test_routing() {
|
|||||||
set_instance +B
|
set_instance +B
|
||||||
executeOk_servald dna lookup "$DIDC"
|
executeOk_servald dna lookup "$DIDC"
|
||||||
assertStdoutLineCount '==' 1
|
assertStdoutLineCount '==' 1
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDC/$DIDC:$DIDC:$NAMEC\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDC/local/$DIDC:$DIDC:$NAMEC\$"
|
||||||
set_instance +C
|
set_instance +C
|
||||||
executeOk_servald dna lookup "$DIDB"
|
executeOk_servald dna lookup "$DIDB"
|
||||||
assertStdoutLineCount '==' 1
|
assertStdoutLineCount '==' 1
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
||||||
executeOk_servald mdp ping $SIDB 3
|
executeOk_servald mdp ping $SIDB 3
|
||||||
tfw_cat --stdout --stderr
|
tfw_cat --stdout --stderr
|
||||||
}
|
}
|
||||||
|
12
tests/dnaprotocol
Executable file → Normal file
12
tests/dnaprotocol
Executable file → Normal file
@ -82,16 +82,16 @@ doc_LookupWildcard="Lookup by wildcard"
|
|||||||
test_LookupWildcard() {
|
test_LookupWildcard() {
|
||||||
executeOk_servald dna lookup "*"
|
executeOk_servald dna lookup "*"
|
||||||
assertStdoutLineCount '==' 2
|
assertStdoutLineCount '==' 2
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDA/$DIDA:$DIDA:$NAMEA\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA\$"
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB\$"
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
||||||
}
|
}
|
||||||
|
|
||||||
doc_LookupEmpty="Lookup by empty string"
|
doc_LookupEmpty="Lookup by empty string"
|
||||||
test_LookupEmpty() {
|
test_LookupEmpty() {
|
||||||
executeOk_servald dna lookup ""
|
executeOk_servald dna lookup ""
|
||||||
assertStdoutLineCount '==' 2
|
assertStdoutLineCount '==' 2
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDA/$DIDA:$DIDA:$NAMEA$"
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA$"
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB$"
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB$"
|
||||||
}
|
}
|
||||||
|
|
||||||
doc_LookupNonExistent="Lookup non-existent phone number"
|
doc_LookupNonExistent="Lookup non-existent phone number"
|
||||||
@ -104,14 +104,14 @@ doc_LookupLocal="Lookup local phone number"
|
|||||||
test_LookupLocal() {
|
test_LookupLocal() {
|
||||||
executeOk_servald dna lookup "$DIDA"
|
executeOk_servald dna lookup "$DIDA"
|
||||||
assertStdoutLineCount '==' 1
|
assertStdoutLineCount '==' 1
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDA/$DIDA:$DIDA:$NAMEA$"
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA$"
|
||||||
}
|
}
|
||||||
|
|
||||||
doc_LookupRemote="Lookup remote phone number"
|
doc_LookupRemote="Lookup remote phone number"
|
||||||
test_LookupRemote() {
|
test_LookupRemote() {
|
||||||
executeOk_servald dna lookup "$DIDB"
|
executeOk_servald dna lookup "$DIDB"
|
||||||
assertStdoutLineCount '==' 1
|
assertStdoutLineCount '==' 1
|
||||||
assertStdoutGrep --matches=1 "^sid://$SIDB/$DIDB:$DIDB:$NAMEB$"
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB$"
|
||||||
}
|
}
|
||||||
|
|
||||||
doc_NodeinfoLocal="Node info auto-resolves for local identities"
|
doc_NodeinfoLocal="Node info auto-resolves for local identities"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user