From 130b8c0b637619beaf65a9e00618c51f383451e8 Mon Sep 17 00:00:00 2001 From: Niklas Hofmann Date: Fri, 8 Aug 2014 14:00:35 +0200 Subject: [PATCH] changed name of SRV record to fingerprint --- src/Makefile.am | 2 +- src/discovery.c | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 22bf84a6..bead49e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -102,7 +102,7 @@ libmeshlink_la_SOURCES = \ $(ed25519_SOURCES) \ $(chacha_poly1305_SOURCES) -libmeshlink_la_CFLAGS = -fPIC +libmeshlink_la_CFLAGS = -fPIC -I../avahi/ libmeshlink_la_LIBADD = -lpthread -luuid ../avahi/avahi-core/.libs/libavahi-core.a ../avahi/avahi-common/.libs/libavahi-common.a ../avahi/avahi-client/.libs/libavahi-client.a diff --git a/src/discovery.c b/src/discovery.c index c004ce58..1f163cf6 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -67,6 +67,7 @@ static void discovery_create_services(meshlink_handle_t *mesh) assert(mesh->avahi_server != NULL); assert(mesh->avahi_poll != NULL); assert(mesh->avahi_servicetype != NULL); + assert(mesh->self != NULL); fprintf(stderr, "Adding service\n"); @@ -95,16 +96,9 @@ static void discovery_create_services(meshlink_handle_t *mesh) char txt_fingerprint[sizeof(MESHLINK_MDNS_FINGERPRINT_KEY) + 1 + MESHLINK_FINGERPRINTLEN + 1]; snprintf(txt_fingerprint, sizeof(txt_fingerprint), "%s=%s", MESHLINK_MDNS_FINGERPRINT_KEY, meshlink_get_fingerprint(mesh, (meshlink_node_t *)mesh->self)); - // Generate a name for the service (actually we do not care) - uuid_t srvname; - uuid_generate(srvname); - - char srvnamestr[36+1]; - uuid_unparse_lower(srvname, srvnamestr); - /* Add the service */ int ret = 0; - if((ret = avahi_server_add_service(mesh->avahi_server, mesh->avahi_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, srvnamestr, mesh->avahi_servicetype, NULL, NULL, atoi(mesh->myport), txt_name, txt_fingerprint, NULL)) < 0) + if((ret = avahi_server_add_service(mesh->avahi_server, mesh->avahi_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, meshlink_get_fingerprint(mesh, (meshlink_node_t *)mesh->self), mesh->avahi_servicetype, NULL, NULL, atoi(mesh->myport), txt_name, txt_fingerprint, NULL)) < 0) { fprintf(stderr, "Failed to add service: %s\n", avahi_strerror(ret)); goto fail; -- 2.39.5