From 7c56a3c265f537c215844d1954ba7282c7e4e00d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 6 Oct 2012 09:36:02 -0700 Subject: [PATCH] Remove some sample plugins. --- configure.ac | 3 - src/plugins/Makefile.am | 5 +- .../example-ldns-opendns-deviceid/Makefile.am | 21 --- .../example-ldns-opendns-deviceid.c | 105 --------------- .../Makefile.am | 21 --- .../example-ldns-opendns-parental-control.c | 62 --------- .../Makefile.am | 21 --- .../example-ldns-opendns-set-client-ip.c | 122 ------------------ 8 files changed, 1 insertion(+), 359 deletions(-) delete mode 100644 src/plugins/example-ldns-opendns-deviceid/Makefile.am delete mode 100644 src/plugins/example-ldns-opendns-deviceid/example-ldns-opendns-deviceid.c delete mode 100644 src/plugins/example-ldns-opendns-parental-control/Makefile.am delete mode 100644 src/plugins/example-ldns-opendns-parental-control/example-ldns-opendns-parental-control.c delete mode 100644 src/plugins/example-ldns-opendns-set-client-ip/Makefile.am delete mode 100644 src/plugins/example-ldns-opendns-set-client-ip/example-ldns-opendns-set-client-ip.c diff --git a/configure.ac b/configure.ac index 60e6887f..9b41259c 100644 --- a/configure.ac +++ b/configure.ac @@ -438,9 +438,6 @@ AC_CONFIG_FILES([Makefile src/plugins/example-ldns-forward-after-nxdomain/Makefile src/plugins/example-logging/Makefile src/plugins/example-ldns-blocking/Makefile - src/plugins/example-ldns-opendns-deviceid/Makefile - src/plugins/example-ldns-opendns-parental-control/Makefile - src/plugins/example-ldns-opendns-set-client-ip/Makefile test/Makefile]) AC_OUTPUT diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index f12251df..75137c19 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -9,8 +9,5 @@ SUBDIRS = \ if USE_LDNS SUBDIRS += \ example-ldns-blocking \ - example-ldns-forward-after-nxdomain \ - example-ldns-opendns-deviceid \ - example-ldns-opendns-parental-control \ - example-ldns-opendns-set-client-ip + example-ldns-forward-after-nxdomain endif diff --git a/src/plugins/example-ldns-opendns-deviceid/Makefile.am b/src/plugins/example-ldns-opendns-deviceid/Makefile.am deleted file mode 100644 index 46a43938..00000000 --- a/src/plugins/example-ldns-opendns-deviceid/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ - -pkglib_LTLIBRARIES = \ - libdcplugin_example_ldns_opendns_deviceid.la - -libdcplugin_example_ldns_opendns_deviceid_la_LIBTOOLFLAGS = --tag=disable-static - -libdcplugin_example_ldns_opendns_deviceid_la_SOURCES = \ - example-ldns-opendns-deviceid.c - -libdcplugin_example_ldns_opendns_deviceid_la_LIBADD = @LDNS_LIBS@ - -libdcplugin_example_ldns_opendns_deviceid_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -avoid-version \ - -export-dynamic \ - -module \ - -no-undefined - -libdcplugin_example_ldns_opendns_deviceid_la_CPPFLAGS = \ - $(LTDLINCL) \ - -I../../include diff --git a/src/plugins/example-ldns-opendns-deviceid/example-ldns-opendns-deviceid.c b/src/plugins/example-ldns-opendns-deviceid/example-ldns-opendns-deviceid.c deleted file mode 100644 index 1abd6ddc..00000000 --- a/src/plugins/example-ldns-opendns-deviceid/example-ldns-opendns-deviceid.c +++ /dev/null @@ -1,105 +0,0 @@ - -#include -#include -#include -#include - -#include -#include - -DCPLUGIN_MAIN(__FILE__); - -#define EDNS_HEADER "0004000f4f70656e444e53" -#define EDNS_DEV_ID "cafebabedeadbeef" - -const char * -dcplugin_description(DCPlugin * const dcplugin) -{ - return "Add an OpenDNS device identifier to outgoing queries"; -} - -const char * -dcplugin_long_description(DCPlugin * const dcplugin) -{ - return - "Some routers provide advanced support for OpenDNS, and allow using\n" - "a specific set of settings no matter what their IP address is.\n" - "\n" - "Since they don't support dnscrypt, outgoing encrypted queries can\n" - "not be rewritten by these routers, and OpenDNS will not recognize\n" - "the router settings.\n" - "\n" - "This plugin adds a device identifier to outgoing packets, so that\n" - "router settings can be used, even when using dnscrypt.\n" - "\n" - "When connected without dnscrypt through such a router, the\n" - "following command will print your device id:\n" - "\n" - "$ dig TXT debug.opendns.com\n" - "\n" - "Just pass this device id as an argument to this plugin or, if you\n" - "don't want this information to be visible in the process name,\n" - "store it in an environment variable named OPENDNS_DEVICE_ID.\n" - "\n" - "# dnscrypt-proxy --plugin \\\n" - " libdcplugin_example_ldns_opendns_deviceid.la,XXXXXXXXXXXXXXXX"; -} - -int -dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[]) -{ - char *device_id; - char *edns_hex; - size_t edns_hex_size = sizeof EDNS_HEADER EDNS_DEV_ID; - - edns_hex = malloc(sizeof EDNS_HEADER EDNS_DEV_ID); - dcplugin_set_user_data(dcplugin, edns_hex); - if (edns_hex == NULL) { - return -1; - } - memcpy(edns_hex, EDNS_HEADER EDNS_DEV_ID, edns_hex_size); - assert(sizeof EDNS_DEV_ID - 1U == (size_t) 16U); - device_id = getenv("OPENDNS_DEVICE_ID"); - if (argc > 1 && strlen(argv[1]) == (size_t) 16U) { - device_id = argv[1]; - } - if (device_id != NULL) { - memcpy(edns_hex + sizeof EDNS_HEADER - (size_t) 1U, - device_id, sizeof EDNS_DEV_ID); - } - return 0; -} - -int -dcplugin_destroy(DCPlugin *dcplugin) -{ - free(dcplugin_get_user_data(dcplugin)); - - return 0; -} - -DCPluginSyncFilterResult -dcplugin_sync_pre_filter(DCPlugin *dcplugin, DCPluginDNSPacket *dcp_packet) -{ - uint8_t *new_packet; - ldns_rdf *edns_data; - ldns_pkt *packet; - size_t new_packet_size; - - ldns_wire2pkt(&packet, dcplugin_get_wire_data(dcp_packet), - dcplugin_get_wire_data_len(dcp_packet)); - - edns_data = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, - dcplugin_get_user_data(dcplugin)); - ldns_pkt_set_edns_data(packet, edns_data); - - ldns_pkt2wire(&new_packet, packet, &new_packet_size); - if (dcplugin_get_wire_data_max_len(dcp_packet) >= new_packet_size) { - dcplugin_set_wire_data(dcp_packet, new_packet, new_packet_size); - } - - free(new_packet); - ldns_pkt_free(packet); - - return DCP_SYNC_FILTER_RESULT_OK; -} diff --git a/src/plugins/example-ldns-opendns-parental-control/Makefile.am b/src/plugins/example-ldns-opendns-parental-control/Makefile.am deleted file mode 100644 index b8831fec..00000000 --- a/src/plugins/example-ldns-opendns-parental-control/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ - -pkglib_LTLIBRARIES = \ - libdcplugin_example_ldns_opendns_parental_control.la - -libdcplugin_example_ldns_opendns_parental_control_la_LIBTOOLFLAGS = --tag=disable-static - -libdcplugin_example_ldns_opendns_parental_control_la_SOURCES = \ - example-ldns-opendns-parental-control.c - -libdcplugin_example_ldns_opendns_parental_control_la_LIBADD = @LDNS_LIBS@ - -libdcplugin_example_ldns_opendns_parental_control_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -avoid-version \ - -export-dynamic \ - -module \ - -no-undefined - -libdcplugin_example_ldns_opendns_parental_control_la_CPPFLAGS = \ - $(LTDLINCL) \ - -I../../include diff --git a/src/plugins/example-ldns-opendns-parental-control/example-ldns-opendns-parental-control.c b/src/plugins/example-ldns-opendns-parental-control/example-ldns-opendns-parental-control.c deleted file mode 100644 index 67d63e2d..00000000 --- a/src/plugins/example-ldns-opendns-parental-control/example-ldns-opendns-parental-control.c +++ /dev/null @@ -1,62 +0,0 @@ - -#include -#include - -#include -#include - -DCPLUGIN_MAIN(__FILE__); - -const char * -dcplugin_description(DCPlugin * const dcplugin) -{ - return "Apply extended OpenDNS parental controls"; -} - -const char * -dcplugin_long_description(DCPlugin * const dcplugin) -{ - return - "This enables the following filter set, if one hasn't been defined\n" - "for the current network or device:\n" - "- lingerie/bikini\n" - "- adult themes\n" - "- nudity\n" - "- pornography\n" - "- proxy/anonymizer\n" - "- sexuality\n" - "- tasteless"; -} - -int -dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[]) -{ - return 0; -} - -DCPluginSyncFilterResult -dcplugin_sync_pre_filter(DCPlugin *dcplugin, DCPluginDNSPacket *dcp_packet) -{ - uint8_t *new_packet; - ldns_rdf *edns_data; - ldns_pkt *packet; - size_t new_packet_size; - - ldns_wire2pkt(&packet, dcplugin_get_wire_data(dcp_packet), - dcplugin_get_wire_data_len(dcp_packet)); - - edns_data = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, - "000400084f70656e444e53" - "ff"); - ldns_pkt_set_edns_data(packet, edns_data); - - ldns_pkt2wire(&new_packet, packet, &new_packet_size); - if (dcplugin_get_wire_data_max_len(dcp_packet) >= new_packet_size) { - dcplugin_set_wire_data(dcp_packet, new_packet, new_packet_size); - } - - free(new_packet); - ldns_pkt_free(packet); - - return DCP_SYNC_FILTER_RESULT_OK; -} diff --git a/src/plugins/example-ldns-opendns-set-client-ip/Makefile.am b/src/plugins/example-ldns-opendns-set-client-ip/Makefile.am deleted file mode 100644 index 5b9bb769..00000000 --- a/src/plugins/example-ldns-opendns-set-client-ip/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ - -pkglib_LTLIBRARIES = \ - libdcplugin_example_ldns_opendns_set_client_ip.la - -libdcplugin_example_ldns_opendns_set_client_ip_la_LIBTOOLFLAGS = --tag=disable-static - -libdcplugin_example_ldns_opendns_set_client_ip_la_SOURCES = \ - example-ldns-opendns-set-client-ip.c - -libdcplugin_example_ldns_opendns_set_client_ip_la_LIBADD = @LDNS_LIBS@ - -libdcplugin_example_ldns_opendns_set_client_ip_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - -avoid-version \ - -export-dynamic \ - -module \ - -no-undefined - -libdcplugin_example_ldns_opendns_set_client_ip_la_CPPFLAGS = \ - $(LTDLINCL) \ - -I../../include diff --git a/src/plugins/example-ldns-opendns-set-client-ip/example-ldns-opendns-set-client-ip.c b/src/plugins/example-ldns-opendns-set-client-ip/example-ldns-opendns-set-client-ip.c deleted file mode 100644 index 57ebccde..00000000 --- a/src/plugins/example-ldns-opendns-set-client-ip/example-ldns-opendns-set-client-ip.c +++ /dev/null @@ -1,122 +0,0 @@ - -#include -#include -#include - -#include -#include -#include - -DCPLUGIN_MAIN(__FILE__); - -#define EDNS_HEADER "4f56" "0014" "4f444e5300" "00" -#define EDNS_HEADER_CLIENT_IP "10" -#define EDNS_CLIENT_IP "7f000001" -#define EDNS_HEADER_FODDER "40" -#define EDNS_FODDER "deadbeefabad1dea" - -#define EDNS_DATA EDNS_HEADER \ - EDNS_HEADER_CLIENT_IP EDNS_CLIENT_IP EDNS_HEADER_FODDER EDNS_FODDER - -#define EDNS_CLIENT_IP_OFFSET (sizeof EDNS_HEADER - 1U + \ - sizeof EDNS_HEADER_CLIENT_IP - 1U) - -#define EDNS_FODDER_OFFSET (sizeof EDNS_HEADER - 1U + \ - sizeof EDNS_HEADER_CLIENT_IP - 1U + \ - sizeof EDNS_CLIENT_IP - 1U + \ - sizeof EDNS_HEADER_FODDER - 1U) - -const char * -dcplugin_description(DCPlugin * const dcplugin) -{ - return "Apply the OpenDNS settings defined for a specific IP address"; -} - -const char * -dcplugin_long_description(DCPlugin * const dcplugin) -{ - return - "If you defined a policy for your network, this plugin allows\n" - "using this policy no matter where you are, and without interfering\n" - "with the networks you are roaming on.\n" - "This plugin also allows using your IPv4 network settings even when\n" - "connecting to OpenDNS using IPv6.\n" - "\n" - "The IP address must be a hex-encoded IPv4 address.\n" - "\n" - "Usage:\n" - "\n" - "# dnscrypt-proxy --plugin \\\n" - " libdcplugin_example_ldns_opendns_set_client_ip.la,7f000001"; -} - -int -dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[]) -{ - char *edns_hex; - size_t edns_hex_size = sizeof EDNS_DATA; - - ldns_init_random(NULL, 0U); - edns_hex = malloc(edns_hex_size); - dcplugin_set_user_data(dcplugin, edns_hex); - if (edns_hex == NULL) { - return -1; - } - memcpy(edns_hex, EDNS_DATA, edns_hex_size); - assert(sizeof EDNS_CLIENT_IP - 1U == (size_t) 8U); - if (argc > 1 && strlen(argv[1]) == (size_t) 8U) { - memcpy(edns_hex + EDNS_CLIENT_IP_OFFSET, - argv[1], sizeof EDNS_CLIENT_IP - 1U); - } - return 0; -} - -int -dcplugin_destroy(DCPlugin *dcplugin) -{ - free(dcplugin_get_user_data(dcplugin)); - - return 0; -} - -static void -fill_with_random_hex_data(char * const str, size_t size) -{ - size_t i = (size_t) 0U; - uint16_t rnd; - - while (i < size) { - rnd = ldns_get_random(); - str[i++] = "0123456789abcdef"[rnd & 0xf]; - str[i++] = "0123456789abcdef"[(rnd >> 8) & 0xf]; - } -} - -DCPluginSyncFilterResult -dcplugin_sync_pre_filter(DCPlugin *dcplugin, DCPluginDNSPacket *dcp_packet) -{ - uint8_t *new_packet; - ldns_rdf *edns_data; - char *edns_data_str; - ldns_pkt *packet; - size_t new_packet_size; - - ldns_wire2pkt(&packet, dcplugin_get_wire_data(dcp_packet), - dcplugin_get_wire_data_len(dcp_packet)); - - edns_data_str = dcplugin_get_user_data(dcplugin); - fill_with_random_hex_data(edns_data_str + EDNS_FODDER_OFFSET, - sizeof EDNS_FODDER - 1U); - edns_data = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, edns_data_str); - ldns_pkt_set_edns_data(packet, edns_data); - - ldns_pkt2wire(&new_packet, packet, &new_packet_size); - if (dcplugin_get_wire_data_max_len(dcp_packet) >= new_packet_size) { - dcplugin_set_wire_data(dcp_packet, new_packet, new_packet_size); - } - - free(new_packet); - ldns_pkt_free(packet); - - return DCP_SYNC_FILTER_RESULT_OK; -}