Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removing the unbound requirement from the source code and add a text …

…file with details on the usage of the plugin
  • Loading branch information...
commit b41cc00938a9dd8f08d68f2ef9064589a24bf4f9 1 parent 879845d
cr409 authored
15 client_resolver/Makefile.am
View
@@ -26,8 +26,10 @@ bin_PROGRAMS = unbound-host signpost-test signpost-avahi-publish signpost-avahi-
EXTRA_DIST=bootstrap.sh # README LICENSE
-AM_CPPFLAGS = -include $(top_builddir)/config.h `pkg-config --cflags avahi-client`
-AM_LDFLAGS = -lldns -lunbound
+AM_CPPFLAGS = -include $(top_builddir)/config.h
+# `pkg-config --cflags avahi-client`
+# AM_LDFLAGS = -lldns -lunbound
+
# MAINTAINERCLEANFILES=README
# noinst_DATA = README
@@ -38,9 +40,7 @@ AM_LDFLAGS = -lldns -lunbound
libnss_signpost_la_SOURCES = \
nss-signpost.c \
- nss-signpost.h \
- signpost-avahi.h \
- signpost-avahi.c
+ nss-signpost.h
#libnss_signpost_la_SOURCES += netlink.c
@@ -49,11 +49,8 @@ libnss_signpost_la_LDFLAGS = \
-module \
-export-dynamic \
-shrext .so.2 \
- -lldns \
- -lunbound \
-lcurl \
- -ljansson \
- `pkg-config --libs avahi-client`
+ -ljansson
signpost_avahi_publish_SOURCES = signpost-avahi-publish.c
31 client_resolver/README.md
View
@@ -0,0 +1,31 @@
+
+SIGNPOST NSS plugin
+-------------------------------
+
+This code has been developed in order to intercept user name requests and push them
+to the personal signpost server. The code creates an nss plugin that translates name
+resolutions, web service requests.
+
+Build and install
+-------------------------------
+
+The code is has full integration with the autotools packagin system. In order to build
+the conde you need the external libraries of curl (http://curl.haxx.se/libcurl/c/) and
+the janson json parsing library for c (http://www.digip.org/jansson/). In order the
+right package system, you need to run the command in cli.
+
+sudo apt-get install libjansson4 libjansson-dev libcurl libcurl-dev
+
+In order to compile the code of the project you need to run the following commands:
+./bootstrap.sh
+./configure
+make all install
+
+Once the library has been install you need to configure the nss system in order to use the
+signpost library. In order to achieve that, edit the file /etc/nsswitch.conf and register
+signpost as the only service for host lookup.
+
+In order to setup the personal signpost to serve http request, users must start the
+runner_solver.rb, in order to run a solver daemon, and the runner_http_server.rb, in order
+to run the http daemon thread.
+
84 client_resolver/nss-signpost.c
View
@@ -34,8 +34,6 @@
#include <arpa/inet.h>
#include <syslog.h>
-#include <unbound.h>
-
#include <curl/curl.h>
//json processing library
@@ -43,7 +41,6 @@
#include <jansson.h>
#include "nss-signport.h"
-#include "signpost-avahi.h"
/* We use 127.0.0.2 as IPv4 address. This has the advantage over
* 127.0.0.1 that it can be translated back to the local hostname. For
@@ -477,8 +474,6 @@ int ifconf_acquire_addresses(const char *name,
int fd, r, i;
struct address *list = NULL;
unsigned n_list = 0;
- struct ub_ctx* ctx;
- struct ub_result* result;
int retval;
struct in_addr in;
@@ -486,13 +481,9 @@ int ifconf_acquire_addresses(const char *name,
json_error_t error;
json_t *ips;
- //fprintf(stderr, "ifconf_acquire_addresses\n");
-
const char *server = "127.0.0.1:8080";
char url[3000];
- fprintf(stderr, "ifconf_acquire_addresses \n");
-
CURL *curl;
CURLcode res;
struct MemoryStruct chunk;
@@ -503,8 +494,7 @@ int ifconf_acquire_addresses(const char *name,
if(curl) {
sprintf(url, "http://%s/address/%s", server, name);
curl_easy_setopt(curl, CURLOPT_URL,url);
- /* send all data to this function */
- //curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
+
/* send all data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
@@ -522,25 +512,25 @@ int ifconf_acquire_addresses(const char *name,
root = json_loads(chunk.memory, 0, &error);
if(!root) {
fprintf(stderr, "error: on line %d: %s\n", error.line, error.text);
- return 1;
+ goto finish;
}
ips = json_object_get(root, "ips");
if(!json_is_array(ips)) {
fprintf(stderr, "error: commits is not an array\n");
- return 1;
+ goto finish;
}
ips = json_array_get(ips, 0);
if(!json_is_array(ips)) {
fprintf(stderr, "error: commits is not an array\n");
- return 1;
+ goto finish;
}
for(i = 0; i < json_array_size(ips); i++) {
json_t *ip = json_array_get(ips, i);
if(!json_is_string(ip)) {
fprintf(stderr, "error: ip %d: id is not a string\n", i + 1);
- return 1;
+ goto finish;
}
list = realloc(list, (n_list+1) * sizeof(struct address));
@@ -550,7 +540,7 @@ int ifconf_acquire_addresses(const char *name,
}
in.s_addr = inet_addr(json_string_value(ip));
// fprintf(stderr, "found ip %s\n", json_string_value(ip));
- fprintf(stderr, "found ip %s\n", inet_ntoa(in));
+// fprintf(stderr, "found ip %s\n", inet_ntoa(in));
list[n_list].family = AF_INET;
list[n_list].scope = 1; //ifaddrmsg->ifa_scope;
memcpy(list[n_list].address, &in.s_addr, 4);
@@ -560,69 +550,7 @@ int ifconf_acquire_addresses(const char *name,
}
r= n_list;
}
- goto finish;
-
- /* create context */
- ctx = ub_ctx_create();
- if(!ctx) {
- printf("error: could not create unbound context\n");
- retval = -1;
- goto finish;
- }
-
- //ub_ctx_debuglevel(ctx, 10);
-
- /* read /etc/resolv.conf for DNS proxy settings (from DHCP) */
- if( (retval=ub_ctx_resolvconf(ctx, "/etc/resolv.conf")) != 0) {
- fprintf(stderr, "error reading resolv.conf: %s. errno says: %s\n",
- ub_strerror(retval), strerror(errno));
- }
-
- /* read /etc/hosts for locally supplied host addresses */
- if( (retval=ub_ctx_hosts(ctx, "/etc/hosts")) != 0) {
- fprintf(stderr, "error reading hosts: %s. errno says: %s\n",
- ub_strerror(retval), strerror(errno));
- }
- /* query for webserver */
- retval = ub_resolve(ctx, name,
- 1 /* TYPE A (IPv4 address) */,
- 1 /* CLASS IN (internet) */, &result);
- if(retval != 0) {
- fprintf(stderr, "error resolving: %s. errno says: %s\n",
- ub_strerror(retval), strerror(errno));
- retval = -ENOENT;
- goto finish;
- }
-
- if(!result->havedata) {
- //fprintf(stderr, "no response found\n");
- retval = -ENOENT;
- goto finish;
- }
-
-
- while(result->data[n_list]) {
- list = realloc(list, (n_list+1) * sizeof(struct address));
- if (!list) {
- retval = -ENOMEM;
- goto finish;
- }
- in.s_addr = *(uint32_t *)result->data[n_list];
- fprintf(stderr, "found ip %s\n", inet_ntoa(in));
- list[n_list].family = AF_INET;
- list[n_list].scope = 1; //ifaddrmsg->ifa_scope;
- memcpy(list[n_list].address, result->data[n_list], 4);
- list[n_list].ifindex = 1; //ifaddrmsg->ifa_index;
-
- n_list++;
- }
- r= n_list;
- goto finish;
finish:
-// close(fd);
-
-// ub_resolve_free(result);
-// ub_ctx_delete(ctx);
if (r < 0)
free(list);
else {
Please sign in to comment.
Something went wrong with that request. Please try again.