Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -urN ./inadyn-1.99.15/include/base64.h ./inadyn_padavan/include/base64.h
- --- ./inadyn-1.99.15/include/base64.h 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/include/base64.h 2016-01-22 14:22:01.000000000 +0300
- @@ -29,7 +29,6 @@
- #ifndef BASE64_H
- #define BASE64_H
- -#include <stdint.h>
- #include <string.h>
- #define ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */
- diff -urN ./inadyn-1.99.15/include/ddns.h ./inadyn_padavan/include/ddns.h
- --- ./inadyn-1.99.15/include/ddns.h 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/include/ddns.h 2016-01-22 14:22:01.000000000 +0300
- @@ -24,24 +24,20 @@
- #ifndef DYNDNS_H_
- #define DYNDNS_H_
- -#include <paths.h>
- -
- -#include "config.h"
- #include "os.h"
- #include "error.h"
- #include "http.h"
- #include "debug.h"
- #include "plugin.h"
- -#include "libite/lite.h"
- #define VERSION_STRING "Inadyn version " VERSION " -- Dynamic DNS update client."
- #define AGENT_NAME "inadyn/" VERSION
- -#define SUPPORT_ADDR PACKAGE_BUGREPORT
- +#define SUPPORT_ADDR "troglobit@gmail.com"
- /* Test values */
- #define DEFAULT_CONFIG_FILE "/etc/inadyn.conf"
- -#define RUNTIME_DATA_DIR _PATH_VARRUN "inadyn/"
- -#define DEFAULT_PIDFILE RUNTIME_DATA_DIR "inadyn.pid"
- +#define RUNTIME_DATA_DIR "/var/run"
- +#define DEFAULT_PIDFILE RUNTIME_DATA_DIR "/inadyn.pid"
- #define DYNDNS_MY_IP_SERVER "checkip.dyndns.org"
- #define DYNDNS_MY_CHECKIP_URL "/"
- @@ -57,16 +53,17 @@
- /* Some default configurations */
- #define DYNDNS_DEFAULT_STARTUP_SLEEP 0 /* sec */
- #define DYNDNS_DEFAULT_SLEEP 120 /* sec */
- -#define DYNDNS_MIN_SLEEP 30 /* sec */
- +#define DYNDNS_MIN_SLEEP 3 /* sec */
- #define DYNDNS_MAX_SLEEP (10 * 24 * 3600) /* 10 days in sec */
- #define DYNDNS_ERROR_UPDATE_PERIOD 600 /* 10 min */
- -#define DYNDNS_FORCED_UPDATE_PERIOD (30 * 24 * 3600) /* 30 days in sec */
- +#define DYNDNS_FAILED_UPDATE_PERIOD 300 /* 5 min */
- +#define DYNDNS_FORCED_UPDATE_PERIOD (10 * 24 * 3600) /* 10 days in sec */
- #define DYNDNS_DEFAULT_CMD_CHECK_PERIOD 1 /* sec */
- #define DYNDNS_DEFAULT_ITERATIONS 0 /* Forever */
- #define DYNDNS_HTTP_RESPONSE_BUFFER_SIZE 2500 /* Bytes */
- #define DYNDNS_HTTP_REQUEST_BUFFER_SIZE 2500 /* Bytes */
- -#define DYNDNS_MAX_ALIAS_NUMBER 10 /* maximum number of aliases per server that can be maintained */
- -#define DYNDNS_MAX_SERVER_NUMBER 5 /* maximum number of servers that can be maintained */
- +#define DYNDNS_MAX_ALIAS_NUMBER 5 /* maximum number of aliases per server that can be maintained */
- +#define DYNDNS_MAX_SERVER_NUMBER 3 /* maximum number of servers that can be maintained */
- /* local configs */
- #define USERNAME_LEN 50 /* chars */
- diff -urN ./inadyn-1.99.15/include/http.h ./inadyn_padavan/include/http.h
- --- ./inadyn-1.99.15/include/http.h 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/include/http.h 2016-01-22 14:22:01.000000000 +0300
- @@ -21,8 +21,6 @@
- #ifndef INADYN_HTTP_H_
- #define INADYN_HTTP_H_
- -#include "config.h"
- -
- #if defined(CONFIG_OPENSSL)
- #include <openssl/crypto.h>
- #include <openssl/x509.h>
- @@ -30,11 +28,6 @@
- #include <openssl/ssl.h>
- #include <openssl/tls1.h>
- #include <openssl/err.h>
- -#elif defined(CONFIG_GNUTLS)
- -#include <gnutls/openssl.h>
- -/* Missing OpenSSL wrappers */
- -#define ERR_free_strings()
- -#define OPENSSL_free(ptr) free(ptr)
- #endif
- #include "error.h"
- @@ -42,7 +35,8 @@
- #include "tcp.h"
- #define HTTP_DEFAULT_TIMEOUT 10000 /* msec */
- -#define HTTP_DEFAULT_PORT 80
- +#define HTTP_DEFAULT_PORT 80
- +#define HTTPS_DEFAULT_PORT 443
- typedef struct {
- tcp_sock_t tcp;
- @@ -54,6 +48,7 @@
- #endif
- int initialized;
- + int verbose;
- } http_t;
- typedef struct {
- diff -urN ./inadyn-1.99.15/include/md5.h ./inadyn_padavan/include/md5.h
- --- ./inadyn-1.99.15/include/md5.h 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/include/md5.h 2016-01-22 14:22:01.000000000 +0300
- @@ -29,7 +29,6 @@
- #ifndef MD5_H
- #define MD5_H
- -#include <stdint.h>
- #include <string.h>
- /**
- diff -urN ./inadyn-1.99.15/include/plugin.h ./inadyn_padavan/include/plugin.h
- --- ./inadyn-1.99.15/include/plugin.h 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/include/plugin.h 2016-01-22 14:22:01.000000000 +0300
- @@ -24,7 +24,7 @@
- #ifndef INADYN_PLUGIN_H_
- #define INADYN_PLUGIN_H_
- -#include "libite/queue.h" /* BSD sys/queue.h API */
- +#include "queue.h" /* BSD sys/queue.h API */
- #define GENERIC_HTTP_REQUEST \
- "GET %s HTTP/1.0\r\n" \
- diff -urN ./inadyn-1.99.15/include/queue.h ./inadyn_padavan/include/queue.h
- --- ./inadyn-1.99.15/include/queue.h 1970-01-01 03:00:00.000000000 +0300
- +++ ./inadyn_padavan/include/queue.h 2016-01-22 14:22:01.000000000 +0300
- @@ -0,0 +1,568 @@
- +/* $OpenBSD: queue.h,v 1.36 2012/04/11 13:29:14 naddy Exp $ */
- +/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
- +
- +/*
- + * Copyright (c) 1991, 1993
- + * The Regents of the University of California. All rights reserved.
- + *
- + * Redistribution and use in source and binary forms, with or without
- + * modification, are permitted provided that the following conditions
- + * are met:
- + * 1. Redistributions of source code must retain the above copyright
- + * notice, this list of conditions and the following disclaimer.
- + * 2. Redistributions in binary form must reproduce the above copyright
- + * notice, this list of conditions and the following disclaimer in the
- + * documentation and/or other materials provided with the distribution.
- + * 3. Neither the name of the University nor the names of its contributors
- + * may be used to endorse or promote products derived from this software
- + * without specific prior written permission.
- + *
- + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- + * SUCH DAMAGE.
- + *
- + * @(#)queue.h 8.5 (Berkeley) 8/20/94
- + */
- +
- +#ifndef _SYS_QUEUE_H_
- +#define _SYS_QUEUE_H_
- +
- +/*
- + * This file defines five types of data structures: singly-linked lists,
- + * lists, simple queues, tail queues, and circular queues.
- + *
- + *
- + * A singly-linked list is headed by a single forward pointer. The elements
- + * are singly linked for minimum space and pointer manipulation overhead at
- + * the expense of O(n) removal for arbitrary elements. New elements can be
- + * added to the list after an existing element or at the head of the list.
- + * Elements being removed from the head of the list should use the explicit
- + * macro for this purpose for optimum efficiency. A singly-linked list may
- + * only be traversed in the forward direction. Singly-linked lists are ideal
- + * for applications with large datasets and few or no removals or for
- + * implementing a LIFO queue.
- + *
- + * A list is headed by a single forward pointer (or an array of forward
- + * pointers for a hash table header). The elements are doubly linked
- + * so that an arbitrary element can be removed without a need to
- + * traverse the list. New elements can be added to the list before
- + * or after an existing element or at the head of the list. A list
- + * may only be traversed in the forward direction.
- + *
- + * A simple queue is headed by a pair of pointers, one the head of the
- + * list and the other to the tail of the list. The elements are singly
- + * linked to save space, so elements can only be removed from the
- + * head of the list. New elements can be added to the list before or after
- + * an existing element, at the head of the list, or at the end of the
- + * list. A simple queue may only be traversed in the forward direction.
- + *
- + * A tail queue is headed by a pair of pointers, one to the head of the
- + * list and the other to the tail of the list. The elements are doubly
- + * linked so that an arbitrary element can be removed without a need to
- + * traverse the list. New elements can be added to the list before or
- + * after an existing element, at the head of the list, or at the end of
- + * the list. A tail queue may be traversed in either direction.
- + *
- + * A circle queue is headed by a pair of pointers, one to the head of the
- + * list and the other to the tail of the list. The elements are doubly
- + * linked so that an arbitrary element can be removed without a need to
- + * traverse the list. New elements can be added to the list before or after
- + * an existing element, at the head of the list, or at the end of the list.
- + * A circle queue may be traversed in either direction, but has a more
- + * complex end of list detection.
- + *
- + * For details on the use of these macros, see the queue(3) manual page.
- + */
- +
- +#if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC))
- +#define _Q_INVALIDATE(a) (a) = ((void *)-1)
- +#else
- +#define _Q_INVALIDATE(a)
- +#endif
- +
- +/*
- + * Singly-linked List definitions.
- + */
- +#define SLIST_HEAD(name, type) \
- +struct name { \
- + struct type *slh_first; /* first element */ \
- +}
- +
- +#define SLIST_HEAD_INITIALIZER(head) \
- + { NULL }
- +
- +#define SLIST_ENTRY(type) \
- +struct { \
- + struct type *sle_next; /* next element */ \
- +}
- +
- +/*
- + * Singly-linked List access methods.
- + */
- +#define SLIST_FIRST(head) ((head)->slh_first)
- +#define SLIST_END(head) NULL
- +#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
- +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
- +
- +#define SLIST_FOREACH(var, head, field) \
- + for((var) = SLIST_FIRST(head); \
- + (var) != SLIST_END(head); \
- + (var) = SLIST_NEXT(var, field))
- +
- +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
- + for ((var) = SLIST_FIRST(head); \
- + (var) && ((tvar) = SLIST_NEXT(var, field), 1); \
- + (var) = (tvar))
- +
- +/*
- + * Singly-linked List functions.
- + */
- +#define SLIST_INIT(head) { \
- + SLIST_FIRST(head) = SLIST_END(head); \
- +}
- +
- +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- + (elm)->field.sle_next = (slistelm)->field.sle_next; \
- + (slistelm)->field.sle_next = (elm); \
- +} while (0)
- +
- +#define SLIST_INSERT_HEAD(head, elm, field) do { \
- + (elm)->field.sle_next = (head)->slh_first; \
- + (head)->slh_first = (elm); \
- +} while (0)
- +
- +#define SLIST_REMOVE_AFTER(elm, field) do { \
- + (elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
- +} while (0)
- +
- +#define SLIST_REMOVE_HEAD(head, field) do { \
- + (head)->slh_first = (head)->slh_first->field.sle_next; \
- +} while (0)
- +
- +#define SLIST_REMOVE(head, elm, type, field) do { \
- + if ((head)->slh_first == (elm)) { \
- + SLIST_REMOVE_HEAD((head), field); \
- + } else { \
- + struct type *curelm = (head)->slh_first; \
- + \
- + while (curelm->field.sle_next != (elm)) \
- + curelm = curelm->field.sle_next; \
- + curelm->field.sle_next = \
- + curelm->field.sle_next->field.sle_next; \
- + _Q_INVALIDATE((elm)->field.sle_next); \
- + } \
- +} while (0)
- +
- +/*
- + * List definitions.
- + */
- +#define LIST_HEAD(name, type) \
- +struct name { \
- + struct type *lh_first; /* first element */ \
- +}
- +
- +#define LIST_HEAD_INITIALIZER(head) \
- + { NULL }
- +
- +#define LIST_ENTRY(type) \
- +struct { \
- + struct type *le_next; /* next element */ \
- + struct type **le_prev; /* address of previous next element */ \
- +}
- +
- +/*
- + * List access methods
- + */
- +#define LIST_FIRST(head) ((head)->lh_first)
- +#define LIST_END(head) NULL
- +#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
- +#define LIST_NEXT(elm, field) ((elm)->field.le_next)
- +
- +#define LIST_FOREACH(var, head, field) \
- + for((var) = LIST_FIRST(head); \
- + (var)!= LIST_END(head); \
- + (var) = LIST_NEXT(var, field))
- +
- +#define LIST_FOREACH_SAFE(var, head, field, tvar) \
- + for ((var) = LIST_FIRST(head); \
- + (var) && ((tvar) = LIST_NEXT(var, field), 1); \
- + (var) = (tvar))
- +
- +/*
- + * List functions.
- + */
- +#define LIST_INIT(head) do { \
- + LIST_FIRST(head) = LIST_END(head); \
- +} while (0)
- +
- +#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
- + (listelm)->field.le_next->field.le_prev = \
- + &(elm)->field.le_next; \
- + (listelm)->field.le_next = (elm); \
- + (elm)->field.le_prev = &(listelm)->field.le_next; \
- +} while (0)
- +
- +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- + (elm)->field.le_prev = (listelm)->field.le_prev; \
- + (elm)->field.le_next = (listelm); \
- + *(listelm)->field.le_prev = (elm); \
- + (listelm)->field.le_prev = &(elm)->field.le_next; \
- +} while (0)
- +
- +#define LIST_INSERT_HEAD(head, elm, field) do { \
- + if (((elm)->field.le_next = (head)->lh_first) != NULL) \
- + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
- + (head)->lh_first = (elm); \
- + (elm)->field.le_prev = &(head)->lh_first; \
- +} while (0)
- +
- +#define LIST_REMOVE(elm, field) do { \
- + if ((elm)->field.le_next != NULL) \
- + (elm)->field.le_next->field.le_prev = \
- + (elm)->field.le_prev; \
- + *(elm)->field.le_prev = (elm)->field.le_next; \
- + _Q_INVALIDATE((elm)->field.le_prev); \
- + _Q_INVALIDATE((elm)->field.le_next); \
- +} while (0)
- +
- +#define LIST_REPLACE(elm, elm2, field) do { \
- + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
- + (elm2)->field.le_next->field.le_prev = \
- + &(elm2)->field.le_next; \
- + (elm2)->field.le_prev = (elm)->field.le_prev; \
- + *(elm2)->field.le_prev = (elm2); \
- + _Q_INVALIDATE((elm)->field.le_prev); \
- + _Q_INVALIDATE((elm)->field.le_next); \
- +} while (0)
- +
- +/*
- + * Simple queue definitions.
- + */
- +#define SIMPLEQ_HEAD(name, type) \
- +struct name { \
- + struct type *sqh_first; /* first element */ \
- + struct type **sqh_last; /* addr of last next element */ \
- +}
- +
- +#define SIMPLEQ_HEAD_INITIALIZER(head) \
- + { NULL, &(head).sqh_first }
- +
- +#define SIMPLEQ_ENTRY(type) \
- +struct { \
- + struct type *sqe_next; /* next element */ \
- +}
- +
- +/*
- + * Simple queue access methods.
- + */
- +#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
- +#define SIMPLEQ_END(head) NULL
- +#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
- +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
- +
- +#define SIMPLEQ_FOREACH(var, head, field) \
- + for((var) = SIMPLEQ_FIRST(head); \
- + (var) != SIMPLEQ_END(head); \
- + (var) = SIMPLEQ_NEXT(var, field))
- +
- +#define SIMPLEQ_FOREACH_SAFE(var, head, field, tvar) \
- + for ((var) = SIMPLEQ_FIRST(head); \
- + (var) && ((tvar) = SIMPLEQ_NEXT(var, field), 1); \
- + (var) = (tvar))
- +
- +/*
- + * Simple queue functions.
- + */
- +#define SIMPLEQ_INIT(head) do { \
- + (head)->sqh_first = NULL; \
- + (head)->sqh_last = &(head)->sqh_first; \
- +} while (0)
- +
- +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
- + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
- + (head)->sqh_last = &(elm)->field.sqe_next; \
- + (head)->sqh_first = (elm); \
- +} while (0)
- +
- +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
- + (elm)->field.sqe_next = NULL; \
- + *(head)->sqh_last = (elm); \
- + (head)->sqh_last = &(elm)->field.sqe_next; \
- +} while (0)
- +
- +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
- + (head)->sqh_last = &(elm)->field.sqe_next; \
- + (listelm)->field.sqe_next = (elm); \
- +} while (0)
- +
- +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
- + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
- + (head)->sqh_last = &(head)->sqh_first; \
- +} while (0)
- +
- +#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \
- + if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \
- + == NULL) \
- + (head)->sqh_last = &(elm)->field.sqe_next; \
- +} while (0)
- +
- +/*
- + * Tail queue definitions.
- + */
- +#define TAILQ_HEAD(name, type) \
- +struct name { \
- + struct type *tqh_first; /* first element */ \
- + struct type **tqh_last; /* addr of last next element */ \
- +}
- +
- +#define TAILQ_HEAD_INITIALIZER(head) \
- + { NULL, &(head).tqh_first }
- +
- +#define TAILQ_ENTRY(type) \
- +struct { \
- + struct type *tqe_next; /* next element */ \
- + struct type **tqe_prev; /* address of previous next element */ \
- +}
- +
- +/*
- + * tail queue access methods
- + */
- +#define TAILQ_FIRST(head) ((head)->tqh_first)
- +#define TAILQ_END(head) NULL
- +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
- +#define TAILQ_LAST(head, headname) \
- + (*(((struct headname *)((head)->tqh_last))->tqh_last))
- +/* XXX */
- +#define TAILQ_PREV(elm, headname, field) \
- + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
- +#define TAILQ_EMPTY(head) \
- + (TAILQ_FIRST(head) == TAILQ_END(head))
- +
- +#define TAILQ_FOREACH(var, head, field) \
- + for((var) = TAILQ_FIRST(head); \
- + (var) != TAILQ_END(head); \
- + (var) = TAILQ_NEXT(var, field))
- +
- +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- + for ((var) = TAILQ_FIRST(head); \
- + (var) != TAILQ_END(head) && \
- + ((tvar) = TAILQ_NEXT(var, field), 1); \
- + (var) = (tvar))
- +
- +
- +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- + for((var) = TAILQ_LAST(head, headname); \
- + (var) != TAILQ_END(head); \
- + (var) = TAILQ_PREV(var, headname, field))
- +
- +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
- + for ((var) = TAILQ_LAST(head, headname); \
- + (var) != TAILQ_END(head) && \
- + ((tvar) = TAILQ_PREV(var, headname, field), 1); \
- + (var) = (tvar))
- +
- +/*
- + * Tail queue functions.
- + */
- +#define TAILQ_INIT(head) do { \
- + (head)->tqh_first = NULL; \
- + (head)->tqh_last = &(head)->tqh_first; \
- +} while (0)
- +
- +#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
- + (head)->tqh_first->field.tqe_prev = \
- + &(elm)->field.tqe_next; \
- + else \
- + (head)->tqh_last = &(elm)->field.tqe_next; \
- + (head)->tqh_first = (elm); \
- + (elm)->field.tqe_prev = &(head)->tqh_first; \
- +} while (0)
- +
- +#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- + (elm)->field.tqe_next = NULL; \
- + (elm)->field.tqe_prev = (head)->tqh_last; \
- + *(head)->tqh_last = (elm); \
- + (head)->tqh_last = &(elm)->field.tqe_next; \
- +} while (0)
- +
- +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
- + (elm)->field.tqe_next->field.tqe_prev = \
- + &(elm)->field.tqe_next; \
- + else \
- + (head)->tqh_last = &(elm)->field.tqe_next; \
- + (listelm)->field.tqe_next = (elm); \
- + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
- +} while (0)
- +
- +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- + (elm)->field.tqe_next = (listelm); \
- + *(listelm)->field.tqe_prev = (elm); \
- + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
- +} while (0)
- +
- +#define TAILQ_REMOVE(head, elm, field) do { \
- + if (((elm)->field.tqe_next) != NULL) \
- + (elm)->field.tqe_next->field.tqe_prev = \
- + (elm)->field.tqe_prev; \
- + else \
- + (head)->tqh_last = (elm)->field.tqe_prev; \
- + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
- + _Q_INVALIDATE((elm)->field.tqe_prev); \
- + _Q_INVALIDATE((elm)->field.tqe_next); \
- +} while (0)
- +
- +#define TAILQ_REPLACE(head, elm, elm2, field) do { \
- + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
- + (elm2)->field.tqe_next->field.tqe_prev = \
- + &(elm2)->field.tqe_next; \
- + else \
- + (head)->tqh_last = &(elm2)->field.tqe_next; \
- + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
- + *(elm2)->field.tqe_prev = (elm2); \
- + _Q_INVALIDATE((elm)->field.tqe_prev); \
- + _Q_INVALIDATE((elm)->field.tqe_next); \
- +} while (0)
- +
- +/*
- + * Circular queue definitions.
- + */
- +#define CIRCLEQ_HEAD(name, type) \
- +struct name { \
- + struct type *cqh_first; /* first element */ \
- + struct type *cqh_last; /* last element */ \
- +}
- +
- +#define CIRCLEQ_HEAD_INITIALIZER(head) \
- + { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
- +
- +#define CIRCLEQ_ENTRY(type) \
- +struct { \
- + struct type *cqe_next; /* next element */ \
- + struct type *cqe_prev; /* previous element */ \
- +}
- +
- +/*
- + * Circular queue access methods
- + */
- +#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
- +#define CIRCLEQ_LAST(head) ((head)->cqh_last)
- +#define CIRCLEQ_END(head) ((void *)(head))
- +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
- +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
- +#define CIRCLEQ_EMPTY(head) \
- + (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
- +
- +#define CIRCLEQ_FOREACH(var, head, field) \
- + for((var) = CIRCLEQ_FIRST(head); \
- + (var) != CIRCLEQ_END(head); \
- + (var) = CIRCLEQ_NEXT(var, field))
- +
- +#define CIRCLEQ_FOREACH_SAFE(var, head, field, tvar) \
- + for ((var) = CIRCLEQ_FIRST(head); \
- + (var) != CIRCLEQ_END(head) && \
- + ((tvar) = CIRCLEQ_NEXT(var, field), 1); \
- + (var) = (tvar))
- +
- +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
- + for((var) = CIRCLEQ_LAST(head); \
- + (var) != CIRCLEQ_END(head); \
- + (var) = CIRCLEQ_PREV(var, field))
- +
- +#define CIRCLEQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
- + for ((var) = CIRCLEQ_LAST(head, headname); \
- + (var) != CIRCLEQ_END(head) && \
- + ((tvar) = CIRCLEQ_PREV(var, headname, field), 1); \
- + (var) = (tvar))
- +
- +/*
- + * Circular queue functions.
- + */
- +#define CIRCLEQ_INIT(head) do { \
- + (head)->cqh_first = CIRCLEQ_END(head); \
- + (head)->cqh_last = CIRCLEQ_END(head); \
- +} while (0)
- +
- +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
- + (elm)->field.cqe_next = (listelm)->field.cqe_next; \
- + (elm)->field.cqe_prev = (listelm); \
- + if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
- + (head)->cqh_last = (elm); \
- + else \
- + (listelm)->field.cqe_next->field.cqe_prev = (elm); \
- + (listelm)->field.cqe_next = (elm); \
- +} while (0)
- +
- +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
- + (elm)->field.cqe_next = (listelm); \
- + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
- + if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
- + (head)->cqh_first = (elm); \
- + else \
- + (listelm)->field.cqe_prev->field.cqe_next = (elm); \
- + (listelm)->field.cqe_prev = (elm); \
- +} while (0)
- +
- +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
- + (elm)->field.cqe_next = (head)->cqh_first; \
- + (elm)->field.cqe_prev = CIRCLEQ_END(head); \
- + if ((head)->cqh_last == CIRCLEQ_END(head)) \
- + (head)->cqh_last = (elm); \
- + else \
- + (head)->cqh_first->field.cqe_prev = (elm); \
- + (head)->cqh_first = (elm); \
- +} while (0)
- +
- +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
- + (elm)->field.cqe_next = CIRCLEQ_END(head); \
- + (elm)->field.cqe_prev = (head)->cqh_last; \
- + if ((head)->cqh_first == CIRCLEQ_END(head)) \
- + (head)->cqh_first = (elm); \
- + else \
- + (head)->cqh_last->field.cqe_next = (elm); \
- + (head)->cqh_last = (elm); \
- +} while (0)
- +
- +#define CIRCLEQ_REMOVE(head, elm, field) do { \
- + if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
- + (head)->cqh_last = (elm)->field.cqe_prev; \
- + else \
- + (elm)->field.cqe_next->field.cqe_prev = \
- + (elm)->field.cqe_prev; \
- + if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
- + (head)->cqh_first = (elm)->field.cqe_next; \
- + else \
- + (elm)->field.cqe_prev->field.cqe_next = \
- + (elm)->field.cqe_next; \
- + _Q_INVALIDATE((elm)->field.cqe_prev); \
- + _Q_INVALIDATE((elm)->field.cqe_next); \
- +} while (0)
- +
- +#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
- + if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
- + CIRCLEQ_END(head)) \
- + (head).cqh_last = (elm2); \
- + else \
- + (elm2)->field.cqe_next->field.cqe_prev = (elm2); \
- + if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
- + CIRCLEQ_END(head)) \
- + (head).cqh_first = (elm2); \
- + else \
- + (elm2)->field.cqe_prev->field.cqe_next = (elm2); \
- + _Q_INVALIDATE((elm)->field.cqe_prev); \
- + _Q_INVALIDATE((elm)->field.cqe_next); \
- +} while (0)
- +
- +#endif /* !_SYS_QUEUE_H_ */
- diff -urN ./inadyn-1.99.15/include/tcp.h ./inadyn_padavan/include/tcp.h
- --- ./inadyn-1.99.15/include/tcp.h 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/include/tcp.h 2016-01-22 14:22:01.000000000 +0300
- @@ -37,7 +37,7 @@
- int tcp_construct (tcp_sock_t *tcp);
- int tcp_destruct (tcp_sock_t *tcp);
- -int tcp_init (tcp_sock_t *tcp, char *msg);
- +int tcp_init (tcp_sock_t *tcp, char *msg, int verbose);
- int tcp_exit (tcp_sock_t *tcp);
- int tcp_send (tcp_sock_t *tcp, const char *buf, int len);
- diff -urN ./inadyn-1.99.15/Makefile ./inadyn_padavan/Makefile
- --- ./inadyn-1.99.15/Makefile 1970-01-01 03:00:00.000000000 +0300
- +++ ./inadyn_padavan/Makefile 2016-01-22 14:22:01.000000000 +0300
- @@ -0,0 +1,60 @@
- +VERSION = 1.99.15
- +NAME = inadyn
- +EXEC = src/$(NAME)
- +RM ?= rm -f
- +SHAREDIR = $(ROOTDIR)/user/shared
- +
- +PLUGIN_OBJS = src/plugin.o plugins/common.o \
- + plugins/asuscomm.o plugins/duckdns.o \
- + plugins/dyndns.o plugins/changeip.o \
- + plugins/dnsexit.o plugins/easydns.o \
- + plugins/freedns.o plugins/generic.o \
- + plugins/sitelutions.o \
- + plugins/tzo.o plugins/zoneedit.o \
- + plugins/zerigo.o plugins/dhis.o \
- + plugins/dtdns.o plugins/giradns.o \
- + plugins/duiadns.o plugins/netassist.o
- +
- +BASE_OBJS = src/main.o src/ddns.o src/cache.o \
- + src/cmd.o src/os.o src/error.o \
- + src/http.o src/ssl.o src/tcp.o \
- + src/ip.o src/sha1.o src/base64.o \
- + src/md5.o
- +
- +OBJS = $(BASE_OBJS) $(PLUGIN_OBJS)
- +SRCS = $(OBJS:.o=.c)
- +DEPS = $(SRCS:.c=.d)
- +
- +CFLAGS += -W -Wall
- +CFLAGS += -D_BSD_SOURCE -D_GNU_SOURCE
- +CFLAGS += -Iinclude -DVERSION=\"$(VERSION)\"
- +CFLAGS += -Iinclude -I$(SHAREDIR)
- +CFLAGS += -ffunction-sections -fdata-sections
- +
- +LDFLAGS += -L$(SHAREDIR) -lshared
- +LDFLAGS += -Wl,--gc-sections
- +
- +LDLIBS += -ldl
- +
- +ifeq ($(CONFIG_FIRMWARE_INCLUDE_DDNS_SSL),y)
- +CFLAGS += -DENABLE_SSL -DCONFIG_OPENSSL
- +LDLIBS += -lssl -lcrypto
- +endif
- +
- +# Pattern rules
- +.c.o:
- + $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
- +
- +# Build rules
- +all: $(EXEC)
- +
- +$(EXEC): $(OBJS)
- + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
- +
- +clean:
- + -@$(RM) $(OBJS) $(DEPS) $(EXEC)
- +
- +romfs:
- + $(ROMFSINST) $(EXEC) /bin/inadyn
- +
- +
- diff -urN ./inadyn-1.99.15/plugins/asuscomm.c ./inadyn_padavan/plugins/asuscomm.c
- --- ./inadyn-1.99.15/plugins/asuscomm.c 1970-01-01 03:00:00.000000000 +0300
- +++ ./inadyn_padavan/plugins/asuscomm.c 2016-01-22 14:22:01.000000000 +0300
- @@ -0,0 +1,263 @@
- +/* Plugin for asuscomm.com DDNS
- + *
- + * Copyright (C) 2003-2004 Narcis Ilisei <inarcis2002@hotpop.com>
- + * Copyright (C) 2006 Steve Horbachuk
- + * Copyright (C) 2010-2014 Joachim Nilsson <troglobit@gmail.com>
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, visit the Free Software Foundation
- + * website at http://www.gnu.org/licenses/gpl-2.0.html or write to the
- + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + * Boston, MA 02110-1301, USA.
- + */
- +
- +#include "md5.h"
- +#include "base64.h"
- +#include "plugin.h"
- +
- +#include <ctype.h>
- +
- +#include <nvram_linux.h>
- +
- +#define ASUSDDNS_IP_HTTP_REQUEST \
- + "GET %s?" \
- + "hostname=%s&" \
- + "myip=%s " \
- + "HTTP/1.0\r\n" \
- + "Authorization: Basic %s\r\n" \
- + "Host: %s\r\n" \
- + "User-Agent: " AGENT_NAME " " SUPPORT_ADDR "\r\n\r\n"
- +
- +static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias);
- +static int response_update(http_trans_t *trans, ddns_info_t *info, ddns_alias_t *alias);
- +static int response_register(http_trans_t *trans, ddns_info_t *info, ddns_alias_t *alias);
- +
- +static ddns_system_t asus_update = {
- + .name = "update@asus.com",
- +
- + .request = (req_fn_t)request,
- + .response = (rsp_fn_t)response_update,
- +
- + .checkip_name = DYNDNS_MY_IP_SERVER,
- + .checkip_url = DYNDNS_MY_CHECKIP_URL,
- +
- + .server_name = "ns1.asuscomm.com",
- + .server_url = "/ddns/update.jsp"
- +};
- +
- +static ddns_system_t asus_register = {
- + .name = "register@asus.com",
- +
- + .request = (req_fn_t)request,
- + .response = (rsp_fn_t)response_register,
- +
- + .checkip_name = DYNDNS_MY_IP_SERVER,
- + .checkip_url = DYNDNS_MY_CHECKIP_URL,
- +
- + .server_name = "ns1.asuscomm.com",
- + .server_url = "/ddns/register.jsp"
- +};
- +
- +#define MD5_DIGEST_BYTES 16
- +static void
- +hmac_md5( const unsigned char *input, size_t ilen, const unsigned char *key, size_t klen, unsigned char output[MD5_DIGEST_BYTES] )
- +{
- + int i;
- + md5_context ctx;
- + unsigned char k_ipad[64], k_opad[64], tk[MD5_DIGEST_BYTES];
- +
- + /* if key is longer than 64 bytes reset it to key=MD5(key) */
- + if (klen > 64) {
- + md5(key, klen, tk);
- + key = tk;
- + klen = MD5_DIGEST_BYTES;
- + }
- +
- + /* start out by storing key in pads */
- + memset(k_ipad, 0, sizeof(k_ipad));
- + memset(k_opad, 0, sizeof(k_opad));
- + memcpy(k_ipad, key, klen);
- + memcpy(k_opad, key, klen);
- +
- + /*xor key with ipad and opad values */
- + for (i = 0; i < 64; i++) {
- + k_ipad[i] ^= 0x36;
- + k_opad[i] ^= 0x5c;
- + }
- +
- + /* inner MD5 */
- + md5_starts( &ctx );
- + md5_update( &ctx, k_ipad, 64 );
- + md5_update( &ctx, input, ilen );
- + md5_finish( &ctx, output );
- +
- + /* outter MD5 */
- + md5_starts( &ctx );
- + md5_update( &ctx, k_opad, 64 );
- + md5_update( &ctx, output, MD5_DIGEST_BYTES );
- + md5_finish( &ctx, output );
- +
- + memset( &ctx, 0, sizeof( md5_context ) );
- +}
- +
- +static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias)
- +{
- + unsigned char digest[MD5_DIGEST_BYTES];
- + char auth[6*2+1+MD5_DIGEST_BYTES*2+1];
- + char *p_tmp, *p_auth = auth;
- + char *p_b64_buff = NULL;
- + size_t dlen = 0;
- + int i;
- +
- + /* prepare username (MAC) */
- + p_tmp = info->creds.username;
- + for (i = 0; i < 6*2; i++) {
- + while (*p_tmp && !isxdigit(*p_tmp))
- + p_tmp++;
- + *p_auth++ = *p_tmp ? toupper(*p_tmp++) : '0';
- + }
- +
- + /* split username and password */
- + *p_auth++ = ':';
- +
- + /* prepare password, reuse request_buf */
- + snprintf(ctx->request_buf, ctx->request_buflen, "%s%s",
- + alias->name,
- + alias->address);
- + hmac_md5(ctx->request_buf, strlen(ctx->request_buf),
- + info->creds.password, strlen(info->creds.password), digest);
- + for (i = 0; i < MD5_DIGEST_BYTES; i++)
- + p_auth += sprintf(p_auth, "%02X", digest[i]);
- +
- + /*encode*/
- + base64_encode(NULL, &dlen, auth, strlen(auth));
- + p_b64_buff = (char *) malloc(dlen);
- + if (p_b64_buff)
- + base64_encode(p_b64_buff, &dlen, auth, strlen(auth));
- +
- + if (info->creds.encoded_password)
- + free(info->creds.encoded_password);
- +
- + info->creds.encoded_password = p_b64_buff;
- + info->creds.encoded = (p_b64_buff != NULL) ? 1 : 0;
- + info->creds.size = strlen(info->creds.encoded_password);
- +
- + return snprintf(ctx->request_buf, ctx->request_buflen,
- + ASUSDDNS_IP_HTTP_REQUEST,
- + info->server_url,
- + alias->name,
- + alias->address,
- + info->creds.encoded_password,
- + info->server_name.name);
- +}
- +
- +static int response_update(http_trans_t *trans, ddns_info_t *UNUSED(info), ddns_alias_t *UNUSED(alias))
- +{
- + char *p, *p_rsp;
- + char domain[256] = {0};
- +
- + p_rsp = trans->p_rsp_body;
- +
- + if ((p = strchr(p_rsp, '|')) && (p = strchr(++p, '|')))
- + sscanf(p, "|%255[^|\r\n]", domain);
- +
- + switch (trans->status) {
- + case 200: /* update success */
- + case 220: /* update same domain success -- unused?? */
- + return RC_OK;
- + case 203: /* update failed */
- + logit(LOG_WARNING, "Domain already in use, suggested domain '%s'", domain);
- + return RC_DYNDNS_RSP_NOTOK;
- + case 233: /* update failed */
- + logit(LOG_WARNING, "Domain already in use, current domain '%s'", domain);
- + return RC_DYNDNS_RSP_NOTOK;
- + case 297: /* invalid hostname */
- + case 298: /* invalid domain name */
- + case 299: /* invalid ip format */
- + case 401: /* authentication failure */
- + case 407: /* proxy authentication required */
- + return RC_DYNDNS_RSP_NOTOK;
- + }
- +
- + if (trans->status >= 500 && trans->status < 600)
- + return RC_DYNDNS_RSP_RETRY_LATER;
- +
- + return RC_DYNDNS_RSP_NOTOK;
- +}
- +
- +static int response_register(http_trans_t *trans, ddns_info_t *UNUSED(info), ddns_alias_t *UNUSED(alias))
- +{
- + char *p, *p_rsp, *ret_key;
- + char ret_buf[64], domain[256] = {0};
- +
- + ret_key = "ddns_return_code";
- +
- + p_rsp = trans->p_rsp_body;
- +
- + if ((p = strchr(p_rsp, '|')) && (p = strchr(++p, '|')))
- + sscanf(p, "|%255[^|\r\n]", domain);
- +
- + if (trans->status >= 500 && trans->status < 600) {
- + nvram_set_temp(ret_key, "unknown_error");
- + return RC_DYNDNS_RSP_RETRY_LATER;
- + }
- +
- + snprintf(ret_buf, sizeof(ret_buf), "%s,%d", "register", trans->status);
- + nvram_set_temp(ret_key, ret_buf);
- +
- + switch (trans->status) {
- + case 200: /* registration success */
- + case 220: /* registration same domain success*/
- + return RC_OK;
- + case 203: /* registration failed */
- + logit(LOG_WARNING, "Domain already in use, suggested domain '%s'", domain);
- + return RC_DYNDNS_RSP_NOTOK;
- + case 230: /* registration new domain success */
- + logit(LOG_WARNING, "Registration success, previous domain '%s'", domain);
- + return RC_OK;
- + case 233: /* registration failed */
- + logit(LOG_WARNING, "Domain already in use, current domain '%s'", domain);
- + return RC_DYNDNS_RSP_NOTOK;
- + case 297: /* invalid hostname */
- + case 298: /* invalid domain name */
- + case 299: /* invalid ip format */
- + case 401: /* authentication failure */
- + case 407: /* proxy authentication required */
- + return RC_DYNDNS_RSP_NOTOK;
- + }
- +
- + if (trans->status < 500) /* shutdown */
- + nvram_set_temp(ret_key, "time_out");
- +
- + return RC_DYNDNS_RSP_NOTOK;
- +}
- +
- +PLUGIN_INIT(plugin_init)
- +{
- + plugin_register(&asus_update);
- + plugin_register(&asus_register);
- +}
- +
- +PLUGIN_EXIT(plugin_exit)
- +{
- + plugin_unregister(&asus_update);
- + plugin_unregister(&asus_register);
- +}
- +
- +/**
- + * Local Variables:
- + * version-control: t
- + * indent-tabs-mode: t
- + * c-file-style: "linux"
- + * End:
- + */
- diff -urN ./inadyn-1.99.15/plugins/common.c ./inadyn_padavan/plugins/common.c
- --- ./inadyn-1.99.15/plugins/common.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/common.c 2016-01-22 14:22:01.000000000 +0300
- @@ -47,7 +47,7 @@
- char wildcard[20] = "";
- if (info->wildcard)
- - strlcpy(wildcard, "&wildcard=ON", sizeof(wildcard));
- + strcpy(wildcard, "&wildcard=ON");
- return snprintf(ctx->request_buf, ctx->request_buflen,
- DYNDNS_UPDATE_IP_HTTP_REQUEST,
- @@ -70,7 +70,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(body, "good") != NULL || strstr(body, "nochg"))
- - return 0;
- + return RC_OK;
- if (strstr(body, "dnserr") != NULL || strstr(body, "911"))
- return RC_DYNDNS_RSP_RETRY_LATER;
- diff -urN ./inadyn-1.99.15/plugins/dhis.c ./inadyn_padavan/plugins/dhis.c
- --- ./inadyn-1.99.15/plugins/dhis.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/plugins/dhis.c 2016-01-22 14:22:01.000000000 +0300
- @@ -67,7 +67,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(rsp, alias->address))
- - return 0;
- + return RC_OK;
- return RC_DYNDNS_RSP_NOTOK;
- }
- diff -urN ./inadyn-1.99.15/plugins/dnsexit.c ./inadyn_padavan/plugins/dnsexit.c
- --- ./inadyn-1.99.15/plugins/dnsexit.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/dnsexit.c 2016-01-22 14:22:01.000000000 +0300
- @@ -75,8 +75,8 @@
- switch (code) {
- case 0:
- case 1:
- - return 0;
- case 4:
- + return RC_OK;
- case 11:
- return RC_DYNDNS_RSP_RETRY_LATER;
- default:
- diff -urN ./inadyn-1.99.15/plugins/duckdns.c ./inadyn_padavan/plugins/duckdns.c
- --- ./inadyn-1.99.15/plugins/duckdns.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/plugins/duckdns.c 2016-01-22 14:22:01.000000000 +0300
- @@ -22,11 +22,15 @@
- #include "plugin.h"
- +/*
- + * For API documentation we currently only have this
- + * https://www.duckdns.org/install.jsp#linux-cron
- + */
- #define DUCKDNS_UPDATE_IP_HTTP_REQUEST \
- "GET %s?" \
- "domains=%s&" \
- "token=%s&" \
- - "ip=%s& " \
- + "ip=%s " \
- "HTTP/1.0\r\n" \
- "Host: %s\r\n" \
- "User-Agent: " AGENT_NAME " " SUPPORT_ADDR "\r\n\r\n"
- @@ -43,31 +47,29 @@
- .checkip_name = "ipv4.wtfismyip.com",
- .checkip_url = "/text",
- - .server_name = "duckdns.org",
- + .server_name = "www.duckdns.org",
- .server_url = "/update"
- };
- static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias)
- {
- - char name[SERVER_NAME_LEN], *p;
- + char h_name[SERVER_NAME_LEN], *p;
- - /* Handle some.name.duckdns.org properly */
- p = strstr(alias->name, "duckdns.org");
- - if (p) {
- - size_t len = p - alias->name;
- -
- - if (len > sizeof(name))
- - len = sizeof(name);
- -
- - strlcpy(name, alias->name, len);
- + if ((p != NULL) && (p != alias->name) && (*(--p) == '.')) {
- + size_t h_len = (size_t)(p - alias->name);
- + if (h_len >= sizeof(h_name))
- + h_len = sizeof(h_name) - 1;
- + strncpy(h_name, alias->name, h_len);
- + h_name[h_len] = '\0';
- } else {
- - snprintf(name, sizeof(name), "%s", alias->name);
- + snprintf(h_name, sizeof(h_name), "%s", alias->name);
- }
- return snprintf(ctx->request_buf, ctx->request_buflen,
- DUCKDNS_UPDATE_IP_HTTP_REQUEST,
- info->server_url,
- - name,
- + h_name,
- info->creds.username,
- alias->address,
- info->server_name.name);
- @@ -79,7 +81,7 @@
- DO(http_status_valid(trans->status));
- - if (strstr(resp, "KO") || strstr(resp, "OK") || strstr(resp, "good"))
- + if (strstr(resp, "OK") || strstr(resp, "good"))
- return RC_OK;
- return RC_DYNDNS_RSP_NOTOK;
- diff -urN ./inadyn-1.99.15/plugins/dyndns.c ./inadyn_padavan/plugins/dyndns.c
- --- ./inadyn-1.99.15/plugins/dyndns.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/dyndns.c 2016-01-22 14:22:01.000000000 +0300
- @@ -10,6 +10,7 @@
- * - Loopia, and
- * - nsupdate.info
- * - Google Domains
- + * - nic.ru (RU-CENTER)
- *
- * Copyright (C) 2003-2004 Narcis Ilisei <inarcis2002@hotpop.com>
- * Copyright (C) 2006 Steve Horbachuk
- @@ -179,6 +180,23 @@
- .server_url = "/nic/update"
- };
- +/*
- + * nic.ru (RU-CENTER)
- + * https://www.nic.ru/dns/service/dns_hosting/dns_master/dynamic_dns_for_developers.html
- + */
- +static ddns_system_t nic_ru = {
- + .name = "default@nic.ru",
- +
- + .request = (req_fn_t)request,
- + .response = (rsp_fn_t)response,
- +
- + .checkip_name = "api.nic.ru:443",
- + .checkip_url = "/dyndns/checkip",
- +
- + .server_name = "api.nic.ru:443",
- + .server_url = "/dyndns/update"
- +};
- +
- static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias)
- {
- return common_request(ctx, info, alias);
- @@ -201,6 +219,7 @@
- plugin_register(&nsupdate_info_ipv4);
- plugin_register(&loopia);
- plugin_register(&googledomains);
- + plugin_register(&nic_ru);
- }
- PLUGIN_EXIT(plugin_exit)
- @@ -215,6 +234,7 @@
- plugin_unregister(&nsupdate_info_ipv4);
- plugin_unregister(&loopia);
- plugin_unregister(&googledomains);
- + plugin_unregister(&nic_ru);
- }
- /**
- diff -urN ./inadyn-1.99.15/plugins/easydns.c ./inadyn_padavan/plugins/easydns.c
- --- ./inadyn-1.99.15/plugins/easydns.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/easydns.c 2016-01-22 14:22:01.000000000 +0300
- @@ -75,7 +75,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(resp, "NOERROR"))
- - return 0;
- + return RC_OK;
- if (strstr(resp, "TOOSOON"))
- return RC_DYNDNS_RSP_RETRY_LATER;
- diff -urN ./inadyn-1.99.15/plugins/freedns.c ./inadyn_padavan/plugins/freedns.c
- --- ./inadyn-1.99.15/plugins/freedns.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/freedns.c 2016-01-22 14:22:01.000000000 +0300
- @@ -68,9 +68,8 @@
- http_set_remote_name(&client, info->server_name.name);
- http_set_bind_iface(&client, ctx->bind_interface);
- + client.verbose = ctx->dbg.level;
- client.ssl_enabled = info->ssl_enabled;
- - if (client.ssl_enabled) /* XXX: Fix this better, possibly in http_init() */
- - client.tcp.ip.port = 443;
- TRY(http_init(&client, "Sending update URL query"));
- @@ -118,7 +117,7 @@
- if (rc) {
- logit(LOG_INFO, "Update URL query failed");
- - return 0;
- + return RC_OK;
- }
- return snprintf(ctx->request_buf, ctx->request_buflen,
- @@ -140,7 +139,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(resp, alias->address))
- - return 0;
- + return RC_OK;
- return RC_DYNDNS_RSP_NOTOK;
- }
- diff -urN ./inadyn-1.99.15/plugins/generic.c ./inadyn_padavan/plugins/generic.c
- --- ./inadyn-1.99.15/plugins/generic.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/plugins/generic.c 2016-01-22 14:22:01.000000000 +0300
- @@ -95,7 +95,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(resp, "OK") || strstr(resp, "good") || strstr(resp, "true"))
- - return 0;
- + return RC_OK;
- return RC_DYNDNS_RSP_NOTOK;
- }
- diff -urN ./inadyn-1.99.15/plugins/netassist.c ./inadyn_padavan/plugins/netassist.c
- --- ./inadyn-1.99.15/plugins/netassist.c 1970-01-01 03:00:00.000000000 +0300
- +++ ./inadyn_padavan/plugins/netassist.c 2016-01-22 14:22:01.000000000 +0300
- @@ -0,0 +1,96 @@
- +/* Plugin for tb.netassist.ua IPV6 tunnelbroker
- + *
- + * Copyright (C) 2003-2004 Narcis Ilisei <inarcis2002@hotpop.com>
- + * Copyright (C) 2006 Steve Horbachuk
- + * Copyright (C) 2010-2014 Joachim Nilsson <troglobit@gmail.com>
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, visit the Free Software Foundation
- + * website at http://www.gnu.org/licenses/gpl-2.0.html or write to the
- + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + * Boston, MA 02110-1301, USA.
- + */
- +
- +#include "plugin.h"
- +
- +/* tb.netassist.ua specific update request format */
- +#define NETASSIST_IPV6TB_UPDATE_IP_REQUEST \
- + "GET %s?" \
- + "l=%s&" \
- + "p=%s&" \
- + "ip=%s " \
- + "HTTP/1.0\r\n" \
- + "Host: %s\r\n" \
- + "User-Agent: " AGENT_NAME " " SUPPORT_ADDR "\r\n\r\n"
- +
- +static int request (ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias);
- +static int response (http_trans_t *trans, ddns_info_t *info, ddns_alias_t *alias);
- +
- +static ddns_system_t plugin = {
- + .name = "ipv6tb@netassist.ua",
- +
- + .request = (req_fn_t)request,
- + .response = (rsp_fn_t)response,
- +
- + .checkip_name = "ipv4.wtfismyip.com",
- + .checkip_url = "/text",
- +
- + .server_name = "tb.netassist.ua",
- + .server_url = "/autochangeip.php"
- +};
- +
- +static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias)
- +{
- + return snprintf(ctx->request_buf, ctx->request_buflen,
- + NETASSIST_IPV6TB_UPDATE_IP_REQUEST,
- + info->server_url,
- + info->creds.username,
- + info->creds.password,
- + alias->address,
- + info->server_name.name);
- +}
- +
- +/*
- + * tb.netassist.ua specific response validation
- + * 'OK!' and 'is already registered' are the good answers.
- + */
- +static int response(http_trans_t *trans, ddns_info_t *UNUSED(info), ddns_alias_t *UNUSED(alias))
- +{
- + char *resp = trans->p_rsp_body;
- +
- + DO(http_status_valid(trans->status));
- +
- + if (strstr(resp, "OK!") ||
- + strstr(resp, "already"))
- + return RC_OK;
- +
- + return RC_DYNDNS_RSP_NOTOK;
- +}
- +
- +PLUGIN_INIT(plugin_init)
- +{
- + plugin_register(&plugin);
- +}
- +
- +PLUGIN_EXIT(plugin_exit)
- +{
- + plugin_unregister(&plugin);
- +}
- +
- +/**
- + * Local Variables:
- + * version-control: t
- + * indent-tabs-mode: t
- + * c-file-style: "linux"
- + * End:
- + */
- diff -urN ./inadyn-1.99.15/plugins/sitelutions.c ./inadyn_padavan/plugins/sitelutions.c
- --- ./inadyn-1.99.15/plugins/sitelutions.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/sitelutions.c 2016-01-22 14:22:01.000000000 +0300
- @@ -69,7 +69,7 @@
- DO(http_status_valid(trans->status));
- if (strstr(resp, "success"))
- - return 0;
- + return RC_OK;
- if (strstr(resp, "dberror"))
- return RC_DYNDNS_RSP_RETRY_LATER;
- diff -urN ./inadyn-1.99.15/plugins/tunnelbroker.c.deprecated ./inadyn_padavan/plugins/tunnelbroker.c.deprecated
- --- ./inadyn-1.99.15/plugins/tunnelbroker.c.deprecated 1970-01-01 03:00:00.000000000 +0300
- +++ ./inadyn_padavan/plugins/tunnelbroker.c.deprecated 2016-01-22 14:22:01.000000000 +0300
- @@ -0,0 +1,99 @@
- +/* Plugin for Hurricate Electric's IPv6 service
- + *
- + * Copyright (C) 2003-2004 Narcis Ilisei <inarcis2002@hotpop.com>
- + * Copyright (C) 2006 Steve Horbachuk
- + * Copyright (C) 2010-2014 Joachim Nilsson <troglobit@gmail.com>
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, visit the Free Software Foundation
- + * website at http://www.gnu.org/licenses/gpl-2.0.html or write to the
- + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + * Boston, MA 02110-1301, USA.
- + */
- +
- +#include "plugin.h"
- +
- +/* HE tunnelbroker.com specific update request format */
- +#define HE_IPV6TB_UPDATE_IP_REQUEST \
- + "GET %s?" \
- + "username=%s&" \
- + "password=%s&" \
- + "hostname=%s&" \
- + "myip=%s " \
- + "HTTP/1.0\r\n" \
- + "Host: %s\r\n" \
- + "User-Agent: " AGENT_NAME " " SUPPORT_ADDR "\r\n\r\n"
- +
- +static int request (ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias);
- +static int response (http_trans_t *trans, ddns_info_t *info, ddns_alias_t *alias);
- +
- +static ddns_system_t plugin = {
- + .name = "ipv6tb@he.net",
- +
- + .request = (req_fn_t)request,
- + .response = (rsp_fn_t)response,
- +
- + .checkip_name = "checkip.dns.he.net",
- + .checkip_url = "/",
- +
- + .server_name = "ipv4.tunnelbroker.net",
- + .server_url = "/nic/update"
- +};
- +
- +static int request(ddns_t *ctx, ddns_info_t *info, ddns_alias_t *alias)
- +{
- + return snprintf(ctx->request_buf, ctx->request_buflen,
- + HE_IPV6TB_UPDATE_IP_REQUEST,
- + info->server_url,
- + info->creds.username,
- + info->creds.password,
- + alias->name,
- + alias->address,
- + info->server_name.name);
- +}
- +
- +/*
- + * Hurricate Electric IPv6 tunnelbroker specific response validator
- + * Own IP address and 'already in use' are the good answers.
- + */
- +static int response(http_trans_t *trans, ddns_info_t *UNUSED(info), ddns_alias_t *alias)
- +{
- + char *resp = trans->p_rsp_body;
- +
- + DO(http_status_valid(trans->status));
- +
- + if (strstr(resp, alias->address) ||
- + strstr(resp, "already"))
- +// strstr(resp, "-ERROR: This tunnel is already associated with this IP address."))
- + return RC_OK;
- +
- + return RC_DYNDNS_RSP_NOTOK;
- +}
- +
- +PLUGIN_INIT(plugin_init)
- +{
- + plugin_register(&plugin);
- +}
- +
- +PLUGIN_EXIT(plugin_exit)
- +{
- + plugin_unregister(&plugin);
- +}
- +
- +/**
- + * Local Variables:
- + * version-control: t
- + * indent-tabs-mode: t
- + * c-file-style: "linux"
- + * End:
- + */
- diff -urN ./inadyn-1.99.15/plugins/tzo.c ./inadyn_padavan/plugins/tzo.c
- --- ./inadyn-1.99.15/plugins/tzo.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/tzo.c 2016-01-22 14:22:01.000000000 +0300
- @@ -75,7 +75,7 @@
- switch (code) {
- case 200:
- case 304:
- - return 0;
- + return RC_OK;
- case 414:
- case 500:
- return RC_DYNDNS_RSP_RETRY_LATER;
- diff -urN ./inadyn-1.99.15/plugins/zerigo.c ./inadyn_padavan/plugins/zerigo.c
- --- ./inadyn-1.99.15/plugins/zerigo.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/zerigo.c 2016-01-22 14:22:01.000000000 +0300
- @@ -84,7 +84,7 @@
- switch (code) {
- case 2:
- - return 0;
- + return RC_OK;
- case 4:
- return RC_DYNDNS_INVALID_OR_MISSING_PARAMETERS;
- diff -urN ./inadyn-1.99.15/plugins/zoneedit.c ./inadyn_padavan/plugins/zoneedit.c
- --- ./inadyn-1.99.15/plugins/zoneedit.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/plugins/zoneedit.c 2016-01-22 14:22:01.000000000 +0300
- @@ -76,7 +76,7 @@
- case 201:
- case 707:
- /* XXX: is 707 really OK? */
- - return 0;
- + return RC_OK;
- default:
- break;
- }
- diff -urN ./inadyn-1.99.15/src/base64.c ./inadyn_padavan/src/base64.c
- --- ./inadyn-1.99.15/src/base64.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/base64.c 2016-01-22 14:22:01.000000000 +0300
- @@ -1,26 +1,27 @@
- -/*
- - * RFC 1521 base64 encoding/decoding
- - *
- - * Copyright (C) 2006-2013, Brainspark B.V.
- +/* RFC 1521 base64 encoding/decoding
- *
- - * This file is part of PolarSSL (http://www.polarssl.org)
- - * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- + * Copyright (C) 2006-2010, Brainspark B.V.
- *
- - * All rights reserved.
- + * This file is part of PolarSSL (http://www.polarssl.org)
- + * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- *
- - * This program is free software; you can redistribute it and/or modify
- - * it under the terms of the GNU General Public License as published by
- - * the Free Software Foundation; either version 2 of the License, or
- - * (at your option) any later version.
- + * All rights reserved.
- *
- - * This program is distributed in the hope that it will be useful,
- - * but WITHOUT ANY WARRANTY; without even the implied warranty of
- - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - * GNU General Public License for more details.
- - *
- - * You should have received a copy of the GNU General Public License along
- - * with this program; if not, write to the Free Software Foundation, Inc.,
- - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, visit the Free Software Foundation
- + * website at http://www.gnu.org/licenses/gpl-2.0.html or write to the
- + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + * Boston, MA 02110-1301, USA.
- */
- #include "base64.h"
- @@ -122,11 +123,11 @@
- int base64_decode( unsigned char *dst, size_t *dlen,
- const unsigned char *src, size_t slen )
- {
- - size_t i, n;
- - uint32_t j, x;
- + size_t i, j, n;
- + unsigned long x;
- unsigned char *p;
- - for( i = n = j = 0; i < slen; i++ )
- + for( i = j = n = 0; i < slen; i++ )
- {
- if( ( slen - i ) >= 2 &&
- src[i] == '\r' && src[i + 1] == '\n' )
- @@ -152,7 +153,7 @@
- n = ((n * 6) + 7) >> 3;
- - if( dst == NULL || *dlen < n )
- + if( *dlen < n )
- {
- *dlen = n;
- return( ERR_BASE64_BUFFER_TOO_SMALL );
- diff -urN ./inadyn-1.99.15/src/cache.c ./inadyn_padavan/src/cache.c
- --- ./inadyn-1.99.15/src/cache.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/src/cache.c 2016-01-22 14:22:01.000000000 +0300
- @@ -42,7 +42,7 @@
- /* Optional setting, e.g., --cache-dir=/etc */
- char *cache_dir = NULL;
- -static int nslookup(ddns_alias_t *alias)
- +static int nslookup(ddns_alias_t *alias, int verbose)
- {
- int error;
- struct addrinfo hints;
- @@ -61,9 +61,12 @@
- /* DNS reply for alias found, convert to IP# */
- if (!getnameinfo(result->ai_addr, result->ai_addrlen, address, sizeof(address), NULL, 0, NI_NUMERICHOST)) {
- /* Update local record for next checkip call. */
- - alias->last_update = 0;
- - strlcpy(alias->address, address, sizeof(alias->address));
- - logit(LOG_INFO, "Resolving hostname %s => IP# %s", alias->name, address);
- + strncpy(alias->address, address, sizeof(alias->address));
- +
- + alias->last_update = time(NULL);
- + write_cache_file(alias);
- + if (verbose > 0)
- + logit(LOG_INFO, "Resolving hostname %s => IP# %s", alias->name, address);
- }
- freeaddrinfo(result);
- @@ -75,35 +78,37 @@
- return 1;
- }
- -static void read_one(ddns_alias_t *alias, int nonslookup)
- +static void read_one(ddns_alias_t *alias, int nonslookup, int verbose)
- {
- FILE *fp;
- - char path[256];
- + char path[256];
- - alias->last_update = 0;
- - memset(alias->address, 0, sizeof(alias->address));
- + alias->last_update = 0;
- + memset(alias->address, 0, sizeof(alias->address));
- cache_file(alias->name, path, sizeof(path));
- fp = fopen(path, "r");
- if (!fp) {
- - if (nonslookup)
- - return;
- + if (nonslookup)
- + return;
- /* Try a DNS lookup of our last known IP#. */
- - nslookup(alias);
- + nslookup(alias, verbose);
- } else {
- struct stat st;
- char address[MAX_ADDRESS_LEN];
- if (fgets(address, sizeof(address), fp)) {
- - logit(LOG_INFO, "Cached IP# %s for %s from previous invocation.", address, alias->name);
- - strlcpy(alias->address, address, sizeof(alias->address));
- + if (verbose > 0)
- + logit(LOG_INFO, "Cached IP# %s for %s from previous invocation.", address, alias->name);
- + strncpy(alias->address, address, sizeof(alias->address));
- }
- /* Initialize time since last update from modification time of cache file. */
- if (!fstat(fileno(fp), &st)) {
- alias->last_update = st.st_mtime;
- - logit(LOG_INFO, "Last update of %s on %s", alias->name, ctime(&st.st_mtime));
- + if (verbose > 0)
- + logit(LOG_INFO, "Last update of %s on %s", alias->name, ctime(&st.st_mtime));
- }
- fclose(fp);
- @@ -134,34 +139,38 @@
- {
- int i, j;
- - /* Clear DNS cache before querying for the IP below, this to
- - * prevent any artefacts from, e.g., nscd, which is a known
- - * problem with DDNS clients. */
- - res_init();
- + /* Clear DNS cache before querying for the IP below, this to
- + * prevent any artefacts from, e.g., nscd, which is a known
- + * problem with DDNS clients. */
- + res_init();
- if (!ctx)
- return RC_INVALID_POINTER;
- - for (i = 0; i < ctx->info_count; i++) {
- - ddns_info_t *info = &ctx->info[i];
- - int nonslookup;
- -
- - /* Exception for tunnelbroker.net - no name to lookup */
- - nonslookup = !strcmp(info->system->name, "ipv6tb@he.net");
- + for (i = 0; i < ctx->info_count; i++) {
- + ddns_info_t *info = &ctx->info[i];
- + int nonslookup = 0;
- + /* Exception for tunnelbroker.net - no name to lookup */
- + /* Exception for ipv6tb@netassist.ua - no name to lookup */
- + /* Exception for register@asus.com - no name to lookup */
- + if (!strcmp(info->system->name, "ipv6tb@netassist.ua") ||
- + !strcmp(info->system->name, "default@tunnelbroker.net") ||
- + !strcmp(info->system->name, "register@asus.com"))
- + nonslookup = 1;
- // XXX: TODO better plugin identifiction here
- - for (j = 0; j < info->alias_count; j++)
- - read_one(&info->alias[j], nonslookup);
- - }
- -
- + for (j = 0; j < info->alias_count; j++)
- + read_one(&info->alias[j], nonslookup, ctx->dbg.level);
- + }
- +
- return 0;
- }
- /* Update cache with new IP
- - * /var/run/inadyn/my.server.name.cache { LAST-IPADDR } MTIME */
- + * /var/run/my.server.name.cache { LAST-IPADDR } MTIME */
- int write_cache_file(ddns_alias_t *alias)
- {
- FILE *fp;
- - char path[256];
- + char path[256];
- cache_file(alias->name, path, sizeof(path));
- fp = fopen(path, "w");
- diff -urN ./inadyn-1.99.15/src/cmd.c ./inadyn_padavan/src/cmd.c
- --- ./inadyn-1.99.15/src/cmd.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/src/cmd.c 2016-01-22 14:22:01.000000000 +0300
- @@ -114,7 +114,7 @@
- {"-f", 1, {get_forced_update_period_handler, NULL}, ""},
- {"--forced-update", 1, {get_forced_update_period_handler, NULL},
- - "<SEC>\n" "\t\t\tForced DDNS server update interval. Default: 30 days"},
- + "<SEC>\n" "\t\t\tForced DDNS server update interval. Default: 10 days"},
- {"--forced_update_period", 1, {get_forced_update_period_handler, NULL}, NULL}, /* COMPAT */
- {"-F", 1, {get_options_from_file_handler, NULL}, ""},
- @@ -180,21 +180,25 @@
- "\t\t\t default@tzo.com\n"
- "\t\t\t dyndns@3322.org\n"
- "\t\t\t default@dnsomatic.com\n"
- - "\t\t\t ipv6tb@he.net\n"
- "\t\t\t dyndns@he.net\n"
- + "\t\t\t default@tunnelbroker.net\n"
- "\t\t\t default@dynsip.org\n"
- "\t\t\t default@sitelutions.com\n"
- "\t\t\t default@dnsexit.com\n"
- "\t\t\t default@changeip.com\n"
- "\t\t\t default@zerigo.com\n"
- "\t\t\t default@dhis.org\n"
- - "\t\t\t ipv4@nsupdate.info\n"
- + "\t\t\t default@nic.ru\n"
- "\t\t\t default@duckdns.org\n"
- "\t\t\t default@loopia.com\n"
- "\t\t\t default@domains.google.com\n"
- "\t\t\t default@ovh.com\n"
- + "\t\t\t default@dtdns.com\n"
- "\t\t\t default@gira.de\n"
- "\t\t\t default@duiadns.net\n"
- + "\t\t\t ipv4@nsupdate.info\n"
- + "\t\t\t update@asus.com, register@asus.com\n"
- + "\t\t\t ipv6tb@netassist.ua\n"
- "\t\t\t custom@http_srv_basic_auth"},
- {"--dyndns_system", 1, {get_dyndns_system_handler, NULL}, NULL},
- @@ -209,7 +213,7 @@
- {"--update_period_sec", 1, {get_update_period_sec_handler, NULL}, NULL},
- {"--update_period", 1, {get_update_period_handler, NULL}, NULL}, /* TODO: Replaced with startup-delay, remove in 2.0 */
- - {"-P", 1, {set_pidfile, NULL}, ""},
- + {"-P", 1, {set_pidfile, NULL}, ""},
- {"--pidfile", 1, {set_pidfile, NULL}, "<FILE>\n" "\t\t\tSet pidfile, default " DEFAULT_PIDFILE},
- #ifdef ENABLE_SSL
- @@ -319,7 +323,7 @@
- if (!p)
- return RC_OUT_OF_MEMORY;
- - strlcpy(p, p_val, strlen(p_val) + 1);
- + strcpy(p, p_val);
- cmd->argv[cmd->argc] = p;
- cmd->argc++;
- @@ -479,7 +483,7 @@
- ctx->update_once = 1;
- ctx->total_iterations = 1;
- - ctx->dbg.level = 5;
- + ctx->dbg.level = 1;
- return 0;
- }
- @@ -550,10 +554,10 @@
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->dbg.p_logfilename) < strlen(cmd->argv[num]))
- + if (sizeof(ctx->dbg.p_logfilename) <= strlen(cmd->argv[num]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->dbg.p_logfilename, cmd->argv[num], sizeof(ctx->dbg.p_logfilename));
- + strcpy(ctx->dbg.p_logfilename, cmd->argv[num]);
- return 0;
- }
- @@ -561,14 +565,17 @@
- static int get_username_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->info[infid].creds.username) < strlen(cmd->argv[num]))
- + info = &ctx->info[infid];
- +
- + if (sizeof(info->creds.username) <= strlen(cmd->argv[num]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->info[infid].creds.username, cmd->argv[num], sizeof(ctx->info[infid].creds.username));
- + strcpy(info->creds.username, cmd->argv[num]);
- return 0;
- }
- @@ -576,14 +583,17 @@
- static int get_password_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->info[infid].creds.password) < strlen(cmd->argv[num]))
- + info = &ctx->info[infid];
- +
- + if (sizeof(info->creds.password) <= strlen(cmd->argv[num]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->info[infid].creds.password, cmd->argv[num], sizeof(ctx->info[infid].creds.password));
- + strcpy(info->creds.password, cmd->argv[num]);
- return 0;
- }
- @@ -591,42 +601,46 @@
- static int get_alias_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (ctx->info[infid].alias_count >= DYNDNS_MAX_ALIAS_NUMBER)
- + info = &ctx->info[infid];
- +
- + if (info->alias_count >= DYNDNS_MAX_ALIAS_NUMBER)
- return RC_DYNDNS_TOO_MANY_ALIASES;
- - if (sizeof(ctx->info[infid].alias[ctx->info[infid].alias_count].name) < strlen(cmd->argv[num]))
- + if (sizeof(info->alias[info->alias_count].name) <= strlen(cmd->argv[num]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->info[infid].alias[ctx->info[infid].alias_count].name, cmd->argv[num], sizeof(ctx->info[infid].alias[ctx->info[infid].alias_count].name));
- - ctx->info[infid].alias_count++;
- + strcpy(info->alias[info->alias_count].name, cmd->argv[num]);
- + info->alias_count++;
- return 0;
- }
- -/* p_len is the size of the p_dest_name buffer */
- -static int get_name_and_port(char *p_src, char *p_dest_name, int *p_dest_port, size_t p_len)
- +static int get_name_and_port(const char *p_src, char *p_dest_name, size_t dest_size, int *p_dest_port)
- {
- const char *p_port = strstr(p_src, ":");
- if (p_port) {
- - int port_nr, port_ok = sscanf(p_port + 1, "%d", &port_nr);
- - size_t len;
- + int port_nr, len;
- + int port_ok = sscanf(p_port + 1, "%d", &port_nr);
- if (port_ok != 1)
- return RC_DYNDNS_INVALID_OPTION;
- -
- - *p_dest_port = port_nr;
- len = p_port - p_src;
- - if (len >= p_len)
- - len = p_len - 1;
- + if (dest_size <= (size_t)len)
- + return RC_DYNDNS_BUFFER_TOO_SMALL;
- memcpy(p_dest_name, p_src, len);
- p_dest_name[len] = 0;
- + *p_dest_port = port_nr;
- } else {
- - strlcpy(p_dest_name, p_src, p_len);
- + if (dest_size <= strlen(p_src))
- + return RC_DYNDNS_BUFFER_TOO_SMALL;
- + strcpy(p_dest_name, p_src);
- + *p_dest_port = -1;
- }
- return 0;
- @@ -641,25 +655,24 @@
- static int get_checkip_name_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- int rc;
- int port = -1;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - /*checkip_name */
- - if (sizeof(ctx->info[infid].checkip_name) < strlen(cmd->argv[num]) + 1)
- - return RC_DYNDNS_BUFFER_TOO_SMALL;
- + info = &ctx->info[infid];
- - ctx->info[infid].checkip_name.port = HTTP_DEFAULT_PORT;
- - rc = get_name_and_port(cmd->argv[num], ctx->info[infid].checkip_name.name, &port, sizeof(ctx->info[infid].checkip_name.name));
- + info->checkip_name.port = HTTP_DEFAULT_PORT;
- + rc = get_name_and_port(cmd->argv[num], info->checkip_name.name, sizeof(info->checkip_name.name), &port);
- if (rc == 0 && port != -1)
- - ctx->info[infid].checkip_name.port = port;
- + info->checkip_name.port = port;
- - if (sizeof(ctx->info[infid].checkip_url) < strlen(cmd->argv[num + 1]) + 1)
- + if (sizeof(info->checkip_url) <= strlen(cmd->argv[num + 1]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->info[infid].checkip_url, cmd->argv[num + 1], sizeof(ctx->info[infid].checkip_url));
- + strcpy(info->checkip_url, cmd->argv[num + 1]);
- return rc;
- }
- @@ -667,19 +680,19 @@
- static int get_dns_server_name_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- int rc;
- int port = -1;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->info[infid].server_name) < strlen(cmd->argv[num]))
- - return RC_DYNDNS_BUFFER_TOO_SMALL;
- + info = &ctx->info[infid];
- - ctx->info[infid].server_name.port = HTTP_DEFAULT_PORT;
- - rc = get_name_and_port(cmd->argv[num], ctx->info[infid].server_name.name, &port, sizeof(ctx->info[infid].server_name.name));
- + info->server_name.port = HTTP_DEFAULT_PORT;
- + rc = get_name_and_port(cmd->argv[num], info->server_name.name, sizeof(info->server_name.name), &port);
- if (rc == 0 && port != -1)
- - ctx->info[infid].server_name.port = port;
- + info->server_name.port = port;
- return rc;
- }
- @@ -687,14 +700,17 @@
- int get_dns_server_url_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->info[infid].server_url) < strlen(cmd->argv[num]))
- + info = &ctx->info[infid];
- +
- + if (sizeof(info->server_url) <= strlen(cmd->argv[num]))
- return RC_DYNDNS_BUFFER_TOO_SMALL;
- - strlcpy(ctx->info[infid].server_url, cmd->argv[num], sizeof(ctx->info[infid].server_url));
- + strcpy(info->server_url, cmd->argv[num]);
- return 0;
- }
- @@ -719,19 +735,19 @@
- static int get_proxy_server_handler(cmd_data_t *cmd, int num, void *context)
- {
- ddns_t *ctx = (ddns_t *)context;
- + ddns_info_t *info;
- int rc;
- int port = -1;
- if (ctx == NULL)
- return RC_INVALID_POINTER;
- - if (sizeof(ctx->info[infid].proxy_server_name) < strlen(cmd->argv[num]))
- - return RC_DYNDNS_BUFFER_TOO_SMALL;
- + info = &ctx->info[infid];
- - ctx->info[infid].proxy_server_name.port = HTTP_DEFAULT_PORT;
- - rc = get_name_and_port(cmd->argv[num], ctx->info[infid].proxy_server_name.name, &port, sizeof(ctx->info[infid].proxy_server_name.name));
- + info->proxy_server_name.port = HTTP_DEFAULT_PORT;
- + rc = get_name_and_port(cmd->argv[num], info->proxy_server_name.name, sizeof(info->proxy_server_name.name), &port);
- if (rc == 0 && port != -1)
- - ctx->info[infid].proxy_server_name.port = port;
- + info->proxy_server_name.port = port;
- return rc;
- }
- @@ -1319,10 +1335,10 @@
- int ok = 1;
- ddns_info_t *account = &ctx->info[i];
- - /* username, password, and alias not required for custom setups */
- + /* username, password not required for custom setups */
- if (strncmp(account->system->name, "custom@", 7)) {
- check_setting(strlen(account->creds.username), i, "Missing username", &ok);
- - check_setting(strlen(account->creds.password), i, "Missing password", &ok);
- +// check_setting(strlen(account->creds.password), i, "Missing password", &ok);
- }
- check_setting(account->alias_count, i, "Missing your alias/hostname", &ok);
- check_setting(strlen(account->server_name.name), i,
- @@ -1413,7 +1429,7 @@
- };
- int custom_argc = sizeof(custom_argv) / sizeof(char *);
- - if (ctx->dbg.level)
- + if (ctx->dbg.level > 1)
- logit(LOG_NOTICE, "Using default config file %s", DEFAULT_CONFIG_FILE);
- if (ctx->cfgfile)
- @@ -1430,34 +1446,36 @@
- /* settings that may change due to cmd line options */
- i = 0;
- do {
- + int port;
- + size_t src_len;
- ddns_info_t *info = &ctx->info[i];
- if (strlen(info->checkip_name.name) == 0) {
- - if (sizeof(info->checkip_name.name) < strlen(info->system->checkip_name)) {
- - rc = RC_DYNDNS_BUFFER_TOO_SMALL;
- - break;
- + if (strlen(info->system->checkip_name) > 0) {
- + port = -1;
- + info->checkip_name.port = HTTP_DEFAULT_PORT;
- + if (get_name_and_port(info->system->checkip_name, info->checkip_name.name, sizeof(info->checkip_name.name), &port) == 0) {
- + if (port > 0 && port < 65535)
- + info->checkip_name.port = port;
- + }
- }
- - strlcpy(info->checkip_name.name, info->system->checkip_name, sizeof(info->checkip_name.name));
- -
- - if (sizeof(info->checkip_url) < strlen(info->system->checkip_url)) {
- - rc = RC_DYNDNS_BUFFER_TOO_SMALL;
- - break;
- - }
- - strlcpy(info->checkip_url, info->system->checkip_url, sizeof(info->checkip_url));
- + src_len = strlen(info->system->checkip_url);
- + if (src_len > 0 && src_len < sizeof(info->checkip_url))
- + strcpy(info->checkip_url, info->system->checkip_url);
- }
- if (strlen(info->server_name.name) == 0) {
- - if (sizeof(info->server_name.name) < strlen(info->system->server_name)) {
- - rc = RC_DYNDNS_BUFFER_TOO_SMALL;
- - break;
- - }
- - strlcpy(info->server_name.name, info->system->server_name, sizeof(info->server_name.name));
- -
- - if (sizeof(info->server_url) < strlen(info->system->server_url)) {
- - rc = RC_DYNDNS_BUFFER_TOO_SMALL;
- - break;
- + if (strlen(info->system->server_name) > 0) {
- + port = -1;
- + info->server_name.port = HTTP_DEFAULT_PORT;
- + if (get_name_and_port(info->system->server_name, info->server_name.name, sizeof(info->server_name.name), &port) == 0) {
- + if (port > 0 && port < 65535)
- + info->server_name.port = port;
- + }
- }
- - strlcpy(info->server_url, info->system->server_url, sizeof(info->server_url));
- + src_len = strlen(info->system->server_url);
- + if (src_len > 0 && src_len < sizeof(info->server_url))
- + strcpy(info->server_url, info->system->server_url);
- }
- }
- while (++i < ctx->info_count);
- diff -urN ./inadyn-1.99.15/src/ddns.c ./inadyn_padavan/src/ddns.c
- --- ./inadyn-1.99.15/src/ddns.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/src/ddns.c 2016-01-22 14:22:01.000000000 +0300
- @@ -78,7 +78,8 @@
- char *address;
- int i, j, sd, anychange = 0;
- - logit(LOG_INFO, "Checking for IP# change, querying interface %s", ctx->check_interface);
- + if (ctx->dbg.level > 0)
- + logit(LOG_INFO, "Checking for IP# change, querying interface %s", ctx->check_interface);
- sd = socket(PF_INET, SOCK_DGRAM, 0);
- if (sd < 0) {
- @@ -121,13 +122,15 @@
- alias->ip_has_changed = strcmp(alias->address, address) != 0;
- if (alias->ip_has_changed) {
- anychange++;
- - strlcpy(alias->address, address, sizeof(alias->address));
- + strcpy(alias->address, address);
- }
- }
- }
- - if (!anychange)
- - logit(LOG_INFO, "No IP# change detected, still at %s", address);
- + if (!anychange) {
- + if (ctx->dbg.level > 0)
- + logit(LOG_INFO, "No IP# change detected, still at %s", address);
- + }
- return 0;
- }
- @@ -145,9 +148,12 @@
- static int server_transaction(ddns_t *ctx, int servernum)
- {
- int rc = 0;
- - http_t *http = &ctx->http_to_ip_server[servernum];
- http_trans_t *trans;
- + http_t *http = &ctx->http_to_ip_server[servernum];
- + ddns_info_t *info = &ctx->info[servernum];
- + http->verbose = ctx->dbg.level;
- + http->ssl_enabled = (info->checkip_name.port == HTTPS_DEFAULT_PORT) ? 1 : 0;
- DO(http_init(http, "Checking for IP# change"));
- /* Prepare request for IP server */
- @@ -161,7 +167,7 @@
- trans->p_rsp = ctx->work_buf;
- trans->max_rsp_len = ctx->work_buflen - 1; /* Save place for terminating \0 in string. */
- - if (ctx->dbg.level > 2)
- + if (ctx->dbg.level > 1)
- logit(LOG_DEBUG, "Querying DDNS checkip server for my public IP#: %s", ctx->request_buf);
- rc = http_transaction(http, &ctx->http_transaction);
- @@ -169,7 +175,7 @@
- rc = RC_DYNDNS_INVALID_RSP_FROM_IP_SERVER;
- http_exit(http);
- - if (ctx->dbg.level > 2)
- + if (ctx->dbg.level > 1)
- logit(LOG_DEBUG, "Checked my IP, return code: %d", rc);
- return rc;
- @@ -192,8 +198,9 @@
- return RC_INVALID_POINTER;
- haystack = ctx->http_transaction.p_rsp_body;
- - needle = haystack;
- - end = haystack + strlen(haystack) - 1;
- + needle = haystack;
- + end = haystack + strlen(haystack) - 1;
- +
- while (needle && haystack < end) {
- /* Try to find first decimal number (begin of IP) */
- needle = strpbrk(haystack, accept);
- @@ -228,15 +235,18 @@
- alias->ip_has_changed = strcmp(alias->address, address) != 0;
- if (alias->ip_has_changed) {
- anychange++;
- - strlcpy(alias->address, address, sizeof(alias->address));
- + strcpy(alias->address, address);
- }
- }
- }
- - if (!anychange)
- - logit(LOG_INFO, "No IP# change detected, still at %s", address);
- - else if (ctx->dbg.level > 1)
- - logit(LOG_INFO, "Current public IP# %s", address);
- + if (!anychange) {
- + if (ctx->dbg.level > 0)
- + logit(LOG_INFO, "No IP# change detected, still at %s", address);
- + } else {
- + if (ctx->dbg.level > 0)
- + logit(LOG_INFO, "Current public IP# %s", address);
- + }
- return 0;
- }
- @@ -301,17 +311,11 @@
- http_trans_t trans;
- http_t *client = &ctx->http_to_dyndns[info->id];
- + client->verbose = ctx->dbg.level;
- client->ssl_enabled = info->ssl_enabled;
- - if (client->ssl_enabled) /* XXX: Fix this better, possibly in http_init() */
- - client->tcp.ip.port = 443;
- -
- - rc = http_init(client, "Sending IP# update to DDNS server");
- - if (rc) {
- - /* Update failed, force update again in ctx->cmd_check_period seconds */
- - ctx->force_addr_update = 1;
- -
- - return rc;
- - }
- + if (info->server_name.port == HTTPS_DEFAULT_PORT)
- + client->ssl_enabled = 1;
- + DO(http_init(client, "Sending IP# update to DDNS server"));
- memset(ctx->work_buf, 0, ctx->work_buflen);
- memset(ctx->request_buf, 0, ctx->request_buflen);
- @@ -322,20 +326,17 @@
- trans.p_rsp = (char *)ctx->work_buf;
- trans.max_rsp_len = ctx->work_buflen - 1; /* Save place for a \0 at the end */
- - if (ctx->dbg.level > 2) {
- + if (ctx->dbg.level > 1) {
- ctx->request_buf[trans.req_len] = 0;
- logit(LOG_DEBUG, "Sending alias table update to DDNS server: %s", ctx->request_buf);
- }
- rc = http_transaction(client, &trans);
- - if (ctx->dbg.level > 2)
- + if (ctx->dbg.level > 1)
- logit(LOG_DEBUG, "DDNS server response: %s", trans.p_rsp);
- if (rc) {
- - /* Update failed, force update again in ctx->cmd_check_period seconds */
- - ctx->force_addr_update = 1;
- -
- http_exit(client);
- return rc;
- }
- @@ -346,9 +347,6 @@
- rc == RC_DYNDNS_RSP_RETRY_LATER ? "Temporary" : "Fatal");
- logit(LOG_WARNING, "[%d %s] %s", trans.status, trans.status_desc,
- trans.p_rsp_body != trans.p_rsp ? trans.p_rsp_body : "");
- -
- - /* Update failed, force update again in ctx->cmd_check_period seconds */
- - ctx->force_addr_update = 1;
- } else {
- logit(LOG_INFO, "Successful alias table update for %s => new IP# %s",
- alias->name, alias->address);
- @@ -366,7 +364,7 @@
- static int update_alias_table(ddns_t *ctx)
- {
- int i, j;
- - int rc = 0, remember = 0;
- + int rc = 0, remember = RC_OK;
- int anychange = 0;
- /* Issue #15: On external trig. force update to random addr. */
- @@ -378,16 +376,16 @@
- ddns_info_t *info = &ctx->info[i];
- for (j = 0; j < info->alias_count; j++) {
- + char backup[SERVER_NAME_LEN];
- ddns_alias_t *alias = &info->alias[j];
- - char backup[sizeof(alias->address)];
- - strlcpy(backup, alias->address, sizeof(backup));
- + strcpy(backup, alias->address);
- /* TODO: Use random address in 203.0.113.0/24 instead */
- snprintf(alias->address, sizeof(alias->address), "203.0.113.42");
- TRY(send_update(ctx, info, alias, NULL));
- - strlcpy(alias->address, backup, sizeof(alias->address));
- + strcpy(alias->address, backup);
- }
- }
- @@ -419,10 +417,10 @@
- ctx->bind_interface);
- }
- - if (RC_DYNDNS_RSP_NOTOK == rc)
- + if (rc != RC_OK && rc != RC_DYNDNS_RSP_RETRY_LATER)
- remember = rc;
- - if (RC_DYNDNS_RSP_RETRY_LATER == rc && !remember)
- + if (rc == RC_DYNDNS_RSP_RETRY_LATER && remember == RC_OK)
- remember = rc;
- }
- @@ -432,18 +430,8 @@
- static int get_encoded_user_passwd(ddns_t *ctx)
- {
- int i, rc = 0;
- - char *buf = NULL;
- - size_t len;
- -
- - /* Take base64 encoding into account when allocating buf */
- - len = strlen(ctx->info[0].creds.password) + strlen(ctx->info[0].creds.username) + 2;
- - len = (len / 3 + ((len % 3) ? 1 : 0)) * 4; /* output length = 4 * [input len / 3] */
- -
- - buf = calloc(len, sizeof(char));
- - if (!buf)
- - return RC_OUT_OF_MEMORY;
- - if (ctx->dbg.level > 2)
- - logit(LOG_DEBUG, "Allocated %zd bytes buffer %p for temp buffer before encoding.", len, buf);
- + char buf[1024] = {0};
- + size_t len, pwlen;
- for (i = 0; i < ctx->info_count; i++) {
- int rc2;
- @@ -456,20 +444,21 @@
- /* Concatenate username and password with a ':', without
- * snprintf(), since that can cause information loss if
- * the password has "\=" or similar in it, issue #57 */
- - strlcpy(buf, info->creds.username, len);
- - strlcat(buf, ":", len);
- - strlcat(buf, info->creds.password, len);
- + len = MIN(strlen(info->creds.username), sizeof(buf)-3);
- + if (len > 0)
- + strncpy(buf, info->creds.username, len);
- + buf[len] = 0;
- + strcat(buf, ":");
- + pwlen = strlen(buf);
- + len = MIN(strlen(info->creds.password), sizeof(buf)-pwlen-1);
- + if (len > 0)
- + strncpy(&buf[pwlen], info->creds.password, len);
- + buf[pwlen+len] = 0;
- /* query required buffer size for base64 encoded data */
- - if (ctx->dbg.level > 2)
- - logit(LOG_DEBUG, "Checking required size for base64 encoding of user:pass for %s ...", info->system->name);
- base64_encode(NULL, &dlen, (unsigned char *)buf, strlen(buf));
- -
- - if (ctx->dbg.level > 2)
- - logit(LOG_DEBUG, "Allocating %zd bytes buffer for base64 encoding.", dlen);
- encode = malloc(dlen);
- if (!encode) {
- - logit(LOG_WARNING, "Out of memory when base64 encoding user:pass for %s!", info->system->name);
- rc = RC_OUT_OF_MEMORY;
- break;
- }
- @@ -477,23 +466,16 @@
- /* encode */
- rc2 = base64_encode((unsigned char *)encode, &dlen, (unsigned char *)buf, strlen(buf));
- if (rc2 != 0) {
- - logit(LOG_WARNING, "Failed base64 encoding of user:pass for %s!", info->system->name);
- free(encode);
- rc = RC_OUT_BUFFER_OVERFLOW;
- break;
- }
- - if (ctx->dbg.level > 2)
- - logit(LOG_DEBUG, "Base64 encoded string: %s", encode);
- info->creds.encoded_password = encode;
- info->creds.encoded = 1;
- info->creds.size = strlen(info->creds.encoded_password);
- }
- - if (ctx->dbg.level > 2)
- - logit(LOG_DEBUG, "Freeing temp encoding buffer %p", buf);
- - free(buf);
- -
- return rc;
- }
- @@ -566,7 +548,7 @@
- /* Ask IP server something so he will respond and give me my IP */
- DO(server_transaction(ctx, servernum));
- - if (ctx->dbg.level > 2) {
- + if (ctx->dbg.level > 1) {
- logit(LOG_DEBUG, "IP server response:");
- logit(LOG_DEBUG, "%s", ctx->work_buf);
- }
- @@ -596,21 +578,28 @@
- /* dyn_dns_update_ip() failed, inform the user the (network) error
- * is not fatal and that we will retry again in a short while. */
- + case RC_DYNDNS_RSP_NOTOK:
- + case RC_DYNDNS_RSP_RETRY_LATER:
- + ctx->sleep_sec = ctx->error_update_period_sec;
- + break;
- +
- case RC_IP_INVALID_REMOTE_ADDR: /* Probably temporary DNS error. */
- case RC_IP_CONNECT_FAILED: /* Cannot connect to DDNS server atm. */
- case RC_IP_SEND_ERROR:
- case RC_IP_RECV_ERROR:
- + case RC_HTTPS_NO_SSL_SUPPORT:
- +#ifdef ENABLE_SSL
- + case RC_HTTPS_SNI_ERROR:
- + case RC_HTTPS_FAILED_CONNECT:
- + case RC_HTTPS_FAILED_GETTING_CERT:
- + case RC_HTTPS_SEND_ERROR:
- + case RC_HTTPS_RECV_ERROR:
- +#endif
- case RC_OS_INVALID_IP_ADDRESS:
- - case RC_DYNDNS_RSP_RETRY_LATER:
- case RC_DYNDNS_INVALID_RSP_FROM_IP_SERVER:
- - ctx->sleep_sec = ctx->error_update_period_sec;
- - logit(LOG_WARNING, "Will retry again in %d sec...", ctx->sleep_sec);
- + ctx->sleep_sec = DYNDNS_FAILED_UPDATE_PERIOD;
- break;
- - case RC_DYNDNS_RSP_NOTOK:
- - logit(LOG_ERR, "Error response from DDNS server, exiting!");
- - return 1;
- -
- /* All other errors, socket creation failures, invalid pointers etc. */
- default:
- logit(LOG_ERR, "Unrecoverable error %d, exiting ...", rc);
- @@ -631,6 +620,7 @@
- int ddns_main_loop(ddns_t *ctx, int argc, char *argv[])
- {
- int rc = 0;
- + int iterations_err = 0;
- static int first_startup = 1;
- if (!ctx)
- @@ -681,7 +671,8 @@
- * requires the correct time. Sleep can be interrupted with the usual
- * signals inadyn responds too. */
- if (first_startup && ctx->startup_delay_sec) {
- - logit(LOG_NOTICE, "Startup delay: %d sec ...", ctx->startup_delay_sec);
- + if (ctx->dbg.level > 1)
- + logit(LOG_NOTICE, "Startup delay: %d sec ...", ctx->startup_delay_sec);
- first_startup = 0;
- /* Now sleep a while. Using the time set in sleep_sec data member */
- @@ -689,11 +680,13 @@
- wait_for_cmd(ctx);
- if (ctx->cmd == CMD_STOP) {
- - logit(LOG_INFO, "STOP command received, exiting.");
- + if (ctx->dbg.level > 1)
- + logit(LOG_INFO, "STOP command received, exiting.");
- return 0;
- }
- if (ctx->cmd == CMD_RESTART) {
- - logit(LOG_INFO, "RESTART command received, restarting.");
- + if (ctx->dbg.level > 1)
- + logit(LOG_INFO, "RESTART command received, restarting.");
- return RC_RESTART;
- }
- if (ctx->cmd == CMD_FORCED_UPDATE) {
- @@ -716,14 +709,18 @@
- /* DDNS client main loop */
- while (1) {
- rc = check_address(ctx);
- - if (RC_OK == rc) {
- + if (rc == RC_OK) {
- + iterations_err = 0;
- if (ctx->total_iterations != 0 &&
- ++ctx->num_iterations >= ctx->total_iterations)
- break;
- + } else {
- + iterations_err++;
- }
- if (ctx->cmd == CMD_RESTART) {
- - logit(LOG_INFO, "RESTART command received. Restarting.");
- + if (ctx->dbg.level > 1)
- + logit(LOG_INFO, "RESTART command received. Restarting.");
- ctx->cmd = NO_CMD;
- rc = RC_RESTART;
- break;
- @@ -733,16 +730,49 @@
- if (check_error(ctx, rc))
- break;
- + /* prevent infinity loop on fixed number iterations after many failed update */
- + if (ctx->total_iterations > 0 && iterations_err > ctx->total_iterations)
- + break;
- +
- + /* check special case for ONCE mode */
- + if (ctx->update_once == 1) {
- + /* terminate now after server kick ass */
- + if (rc == RC_DYNDNS_RSP_NOTOK ||
- + rc == RC_DYNDNS_INVALID_RSP_FROM_IP_SERVER)
- + break;
- +
- + /* else minimal sleep for try again */
- + ctx->sleep_sec = DYNDNS_MIN_SLEEP;
- + } else {
- + /* dynamic increase interval after 3x errors (upper limit 60 min) */
- + if (iterations_err > 3) {
- + int sleep_sec = ctx->sleep_sec * (iterations_err - 2);
- + if (sleep_sec > 3600)
- + sleep_sec = 3600;
- + ctx->sleep_sec = sleep_sec;
- + }
- + }
- +
- + if (rc != RC_OK) {
- + int minutes = ctx->sleep_sec / 60;
- + if (!minutes)
- + logit(LOG_WARNING, "Will retry again after %d %s...", ctx->sleep_sec, "sec");
- + else
- + logit(LOG_WARNING, "Will retry again after %d %s...", minutes, "min");
- + }
- +
- /* Now sleep a while. Using the time set in sleep_sec data member */
- wait_for_cmd(ctx);
- if (ctx->cmd == CMD_STOP) {
- - logit(LOG_INFO, "STOP command received, exiting.");
- + if (ctx->dbg.level > 1)
- + logit(LOG_INFO, "STOP command received, exiting.");
- rc = 0;
- break;
- }
- if (ctx->cmd == CMD_RESTART) {
- - logit(LOG_INFO, "RESTART command received, restarting.");
- + if (ctx->dbg.level > 1)
- + logit(LOG_INFO, "RESTART command received, restarting.");
- rc = RC_RESTART;
- break;
- }
- diff -urN ./inadyn-1.99.15/src/error.c ./inadyn_padavan/src/error.c
- --- ./inadyn-1.99.15/src/error.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/error.c 2016-01-22 14:22:01.000000000 +0300
- @@ -20,7 +20,7 @@
- * Boston, MA 02110-1301, USA.
- */
- -#include "../include/error.h"
- +#include "error.h"
- #include <stdlib.h>
- typedef struct {
- diff -urN ./inadyn-1.99.15/src/http.c ./inadyn_padavan/src/http.c
- --- ./inadyn-1.99.15/src/http.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/http.c 2016-01-22 14:22:01.000000000 +0300
- @@ -71,9 +71,12 @@
- {
- int rc = 0;
- + if (client->ssl_enabled)
- + client->tcp.ip.port = HTTPS_DEFAULT_PORT;
- +
- do {
- TRY(local_set_params(client));
- - TRY(tcp_init(&client->tcp, msg));
- + TRY(tcp_init(&client->tcp, msg, client->verbose));
- if (client->ssl_enabled)
- TRY(ssl_init(client, msg));
- }
- diff -urN ./inadyn-1.99.15/src/ip.c ./inadyn_padavan/src/ip.c
- --- ./inadyn-1.99.15/src/ip.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/ip.c 2016-01-22 14:22:01.000000000 +0300
- @@ -32,10 +32,10 @@
- #include <errno.h>
- #include <stdio.h>
- -#include "libite/lite.h"
- #include "debug.h"
- #include "ip.h"
- +
- int ip_construct(ip_sock_t *ip)
- {
- ASSERT(ip);
- @@ -91,7 +91,7 @@
- }
- memset(&ifr, 0, sizeof(struct ifreq));
- - strlcpy(ifr.ifr_name, ip->ifname, IFNAMSIZ);
- + strncpy(ifr.ifr_name, ip->ifname, IFNAMSIZ);
- if (ioctl(sd, SIOCGIFADDR, &ifr) != -1) {
- ip->local_addr.sin_family = AF_INET;
- ip->local_addr.sin_port = htons(0);
- @@ -223,7 +223,6 @@
- bytes = recv(ip->socket, buf + total_bytes, chunk_size, 0);
- if (bytes < 0) {
- int code = os_get_socket_error();
- -
- logit(LOG_WARNING, "Network error while waiting for reply: %s",
- strerror(code));
- rc = RC_IP_RECV_ERROR;
- diff -urN ./inadyn-1.99.15/src/md5.c ./inadyn_padavan/src/md5.c
- --- ./inadyn-1.99.15/src/md5.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/md5.c 2016-01-22 14:22:01.000000000 +0300
- @@ -1,27 +1,29 @@
- -/*
- - * RFC 1321 compliant MD5 implementation
- +/* RFC 1321 compliant MD5 implementation
- *
- - * Copyright (C) 2006-2013, Brainspark B.V.
- + * Copyright (C) 2006-2010, Brainspark B.V.
- *
- - * This file is part of PolarSSL (http://www.polarssl.org)
- - * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- + * This file is part of PolarSSL (http://www.polarssl.org)
- + * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
- *
- - * All rights reserved.
- + * All rights reserved.
- *
- - * This program is free software; you can redistribute it and/or modify
- - * it under the terms of the GNU General Public License as published by
- - * the Free Software Foundation; either version 2 of the License, or
- - * (at your option) any later version.
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License
- + * as published by the Free Software Foundation; either version 2
- + * of the License, or (at your option) any later version.
- *
- - * This program is distributed in the hope that it will be useful,
- - * but WITHOUT ANY WARRANTY; without even the implied warranty of
- - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - * GNU General Public License for more details.
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- *
- - * You should have received a copy of the GNU General Public License along
- - * with this program; if not, write to the Free Software Foundation, Inc.,
- - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, visit the Free Software Foundation
- + * website at http://www.gnu.org/licenses/gpl-2.0.html or write to the
- + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + * Boston, MA 02110-1301, USA.
- */
- +
- /*
- * The MD5 algorithm was designed by Ron Rivest in 1991.
- *
- @@ -33,18 +35,18 @@
- /*
- * 32-bit integer manipulation macros (little endian)
- */
- -#ifndef GET_UINT32_LE
- -#define GET_UINT32_LE(n,b,i) \
- +#ifndef GET_ULONG_LE
- +#define GET_ULONG_LE(n,b,i) \
- { \
- - (n) = ( (uint32_t) (b)[(i) ] ) \
- - | ( (uint32_t) (b)[(i) + 1] << 8 ) \
- - | ( (uint32_t) (b)[(i) + 2] << 16 ) \
- - | ( (uint32_t) (b)[(i) + 3] << 24 ); \
- + (n) = ( (unsigned long) (b)[(i) ] ) \
- + | ( (unsigned long) (b)[(i) + 1] << 8 ) \
- + | ( (unsigned long) (b)[(i) + 2] << 16 ) \
- + | ( (unsigned long) (b)[(i) + 3] << 24 ); \
- }
- #endif
- -#ifndef PUT_UINT32_LE
- -#define PUT_UINT32_LE(n,b,i) \
- +#ifndef PUT_ULONG_LE
- +#define PUT_ULONG_LE(n,b,i) \
- { \
- (b)[(i) ] = (unsigned char) ( (n) ); \
- (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \
- @@ -69,24 +71,24 @@
- static void md5_process( md5_context *ctx, const unsigned char data[64] )
- {
- - uint32_t X[16], A, B, C, D;
- + unsigned long X[16], A, B, C, D;
- - GET_UINT32_LE( X[ 0], data, 0 );
- - GET_UINT32_LE( X[ 1], data, 4 );
- - GET_UINT32_LE( X[ 2], data, 8 );
- - GET_UINT32_LE( X[ 3], data, 12 );
- - GET_UINT32_LE( X[ 4], data, 16 );
- - GET_UINT32_LE( X[ 5], data, 20 );
- - GET_UINT32_LE( X[ 6], data, 24 );
- - GET_UINT32_LE( X[ 7], data, 28 );
- - GET_UINT32_LE( X[ 8], data, 32 );
- - GET_UINT32_LE( X[ 9], data, 36 );
- - GET_UINT32_LE( X[10], data, 40 );
- - GET_UINT32_LE( X[11], data, 44 );
- - GET_UINT32_LE( X[12], data, 48 );
- - GET_UINT32_LE( X[13], data, 52 );
- - GET_UINT32_LE( X[14], data, 56 );
- - GET_UINT32_LE( X[15], data, 60 );
- + GET_ULONG_LE( X[ 0], data, 0 );
- + GET_ULONG_LE( X[ 1], data, 4 );
- + GET_ULONG_LE( X[ 2], data, 8 );
- + GET_ULONG_LE( X[ 3], data, 12 );
- + GET_ULONG_LE( X[ 4], data, 16 );
- + GET_ULONG_LE( X[ 5], data, 20 );
- + GET_ULONG_LE( X[ 6], data, 24 );
- + GET_ULONG_LE( X[ 7], data, 28 );
- + GET_ULONG_LE( X[ 8], data, 32 );
- + GET_ULONG_LE( X[ 9], data, 36 );
- + GET_ULONG_LE( X[10], data, 40 );
- + GET_ULONG_LE( X[11], data, 44 );
- + GET_ULONG_LE( X[12], data, 48 );
- + GET_ULONG_LE( X[13], data, 52 );
- + GET_ULONG_LE( X[14], data, 56 );
- + GET_ULONG_LE( X[15], data, 60 );
- #define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
- @@ -196,7 +198,7 @@
- void md5_update( md5_context *ctx, const unsigned char *input, size_t ilen )
- {
- size_t fill;
- - uint32_t left;
- + unsigned long left;
- if( ilen <= 0 )
- return;
- @@ -204,15 +206,16 @@
- left = ctx->total[0] & 0x3F;
- fill = 64 - left;
- - ctx->total[0] += (uint32_t) ilen;
- + ctx->total[0] += (unsigned long) ilen;
- ctx->total[0] &= 0xFFFFFFFF;
- - if( ctx->total[0] < (uint32_t) ilen )
- + if( ctx->total[0] < (unsigned long) ilen )
- ctx->total[1]++;
- if( left && ilen >= fill )
- {
- - memcpy( (void *) (ctx->buffer + left), input, fill );
- + memcpy( (void *) (ctx->buffer + left),
- + (void *) input, fill );
- md5_process( ctx, ctx->buffer );
- input += fill;
- ilen -= fill;
- @@ -228,7 +231,8 @@
- if( ilen > 0 )
- {
- - memcpy( (void *) (ctx->buffer + left), input, ilen );
- + memcpy( (void *) (ctx->buffer + left),
- + (void *) input, ilen );
- }
- }
- @@ -245,27 +249,27 @@
- */
- void md5_finish( md5_context *ctx, unsigned char output[16] )
- {
- - uint32_t last, padn;
- - uint32_t high, low;
- + unsigned long last, padn;
- + unsigned long high, low;
- unsigned char msglen[8];
- high = ( ctx->total[0] >> 29 )
- | ( ctx->total[1] << 3 );
- low = ( ctx->total[0] << 3 );
- - PUT_UINT32_LE( low, msglen, 0 );
- - PUT_UINT32_LE( high, msglen, 4 );
- + PUT_ULONG_LE( low, msglen, 0 );
- + PUT_ULONG_LE( high, msglen, 4 );
- last = ctx->total[0] & 0x3F;
- padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- - md5_update( ctx, md5_padding, padn );
- + md5_update( ctx, (unsigned char *) md5_padding, padn );
- md5_update( ctx, msglen, 8 );
- - PUT_UINT32_LE( ctx->state[0], output, 0 );
- - PUT_UINT32_LE( ctx->state[1], output, 4 );
- - PUT_UINT32_LE( ctx->state[2], output, 8 );
- - PUT_UINT32_LE( ctx->state[3], output, 12 );
- + PUT_ULONG_LE( ctx->state[0], output, 0 );
- + PUT_ULONG_LE( ctx->state[1], output, 4 );
- + PUT_ULONG_LE( ctx->state[2], output, 8 );
- + PUT_ULONG_LE( ctx->state[3], output, 12 );
- }
- /*
- diff -urN ./inadyn-1.99.15/src/os.c ./inadyn_padavan/src/os.c
- --- ./inadyn-1.99.15/src/os.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/src/os.c 2016-01-22 14:22:01.000000000 +0300
- @@ -219,6 +219,7 @@
- break;
- default: /* parent */
- + waitpid(child, NULL, 0);
- break;
- }
- @@ -472,8 +473,8 @@
- return RC_FILE_IO_ACCESS_ERROR;
- }
- - if (old_pidfile(pidfile_path))
- - logit(LOG_WARNING, "Failed creating pidfile %s: %m", pidfile_path);
- + /* Not creating a pidfile is OK, the cache file is the critical point. */
- + old_pidfile(pidfile_path);
- return 0;
- }
- diff -urN ./inadyn-1.99.15/src/plugin.c ./inadyn_padavan/src/plugin.c
- --- ./inadyn-1.99.15/src/plugin.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/plugin.c 2016-01-22 14:22:01.000000000 +0300
- @@ -21,7 +21,6 @@
- * THE SOFTWARE.
- */
- -#include "config.h"
- #include <errno.h>
- #include <dlfcn.h> /* dlopen() et al */
- #include <dirent.h> /* readdir() et al */
- @@ -139,7 +138,8 @@
- }
- /* Private daemon API *******************************************************/
- -#if o
- +
- +#if 0
- /**
- * load_one - Load one plugin
- * @path: Path to finit plugins, usually %PLUGIN_PATH
- diff -urN ./inadyn-1.99.15/src/ssl.c ./inadyn_padavan/src/ssl.c
- --- ./inadyn-1.99.15/src/ssl.c 2016-01-22 13:41:48.000000000 +0300
- +++ ./inadyn_padavan/src/ssl.c 2016-01-22 14:22:01.000000000 +0300
- @@ -1,6 +1,6 @@
- /* Interface for optional HTTPS functions
- *
- - * Copyright (C) 2014 Joachim Nilsson <troglobit@gmail.com>
- + * Copyright (C) 2014-2015 Joachim Nilsson <troglobit@gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- @@ -20,8 +20,7 @@
- */
- #include "debug.h"
- -#include "http.h"
- -
- +#include "ssl.h"
- #ifdef ENABLE_SSL
- /* SSL SNI support: tell the servername we want to speak to */
- @@ -32,9 +31,6 @@
- #if defined(CONFIG_OPENSSL)
- /* api returns 1 for success */
- rc = !SSL_set_tlsext_host_name(ssl, sn);
- -#elif defined(CONFIG_GNUTLS)
- - /* api returns 0 for success */
- - rc = gnutls_server_name_set(ssl->gnutls_state, GNUTLS_NAME_DNS, sn, strlen(sn));
- #endif
- return rc;
- @@ -48,59 +44,77 @@
- (void)msg;
- return 0;
- #else
- + int err, err_ssl, rc = 0;
- char buf[256];
- const char *sn;
- -#ifdef CONFIG_GNUTLS
- - const
- -#endif
- - X509 *cert;
- + X509 *cert;
- - logit(LOG_INFO, "%s, initiating HTTPS ...", msg);
- + if (client->verbose > 1)
- + logit(LOG_INFO, "%s, initiating HTTPS ...", msg);
- - client->ssl_ctx = SSL_CTX_new(SSLv23_client_method());
- - if (!client->ssl_ctx)
- - return RC_HTTPS_OUT_OF_MEMORY;
- + do {
- + client->ssl_ctx = SSL_CTX_new(SSLv23_client_method());
- + if (!client->ssl_ctx)
- + return RC_HTTPS_OUT_OF_MEMORY;
- #if defined(CONFIG_OPENSSL)
- - /* POODLE, only allow TLSv1.x or later */
- - SSL_CTX_set_options(client->ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
- -#else
- - /* GnuTLS already defaults to TLS 1.x */
- -#endif
- -
- - client->ssl = SSL_new(client->ssl_ctx);
- - if (!client->ssl)
- - return RC_HTTPS_OUT_OF_MEMORY;
- -
- -#ifdef SSL_MODE_SEND_FALLBACK_SCSV
- - SSL_set_mode(client->ssl, SSL_MODE_SEND_FALLBACK_SCSV);
- + /* POODLE, only allow TLSv1.x or later */
- + SSL_CTX_set_options(client->ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION);
- #endif
- - http_get_remote_name(client, &sn);
- - if (set_server_name(client->ssl, sn))
- - return RC_HTTPS_SNI_ERROR;
- -
- - SSL_set_fd(client->ssl, client->tcp.ip.socket);
- - if (-1 == SSL_connect(client->ssl))
- - return RC_HTTPS_FAILED_CONNECT;
- -
- - logit(LOG_INFO, "SSL connection using %s", SSL_get_cipher(client->ssl));
- -
- - /* Get server's certificate (note: beware of dynamic allocation) - opt */
- - cert = SSL_get_peer_certificate(client->ssl);
- - if (!cert)
- - return RC_HTTPS_FAILED_GETTING_CERT;
- -
- - /* Logging some cert details. Please note: X509_NAME_oneline doesn't
- - work when giving NULL instead of a buffer. */
- - X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
- - logit(LOG_INFO, "SSL server cert subject: %s", buf);
- - X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf));
- - logit(LOG_INFO, "SSL server cert issuer: %s", buf);
- -
- - /* We could do all sorts of certificate verification stuff here before
- - deallocating the certificate. */
- - X509_free(cert);
- + client->ssl = SSL_new(client->ssl_ctx);
- + if (!client->ssl) {
- + rc = RC_HTTPS_OUT_OF_MEMORY;
- + break;
- + }
- +
- + http_get_remote_name(client, &sn);
- + if (set_server_name(client->ssl, sn)) {
- + rc = RC_HTTPS_SNI_ERROR;
- + break;
- + }
- +
- + SSL_set_fd(client->ssl, client->tcp.ip.socket);
- + err = SSL_connect(client->ssl);
- + if (err <= 0) {
- + err_ssl = SSL_get_error(client->ssl, err);
- + logit(LOG_ERR, "SSL_connect %s! (err: %d)", "FAILED", err_ssl);
- + rc = RC_HTTPS_FAILED_CONNECT;
- + break;
- + }
- +
- + if (client->verbose > 0)
- + logit(LOG_INFO, "SSL connection using %s", SSL_get_cipher(client->ssl));
- +
- + /* Get server's certificate (note: beware of dynamic allocation) - opt */
- + cert = SSL_get_peer_certificate(client->ssl);
- + if (!cert) {
- + logit(LOG_ERR, "SSL_get_peer_certificate %s!", "FAILED");
- + rc = RC_HTTPS_FAILED_GETTING_CERT;
- + break;
- + }
- +
- + /* Logging some cert details. Please note: X509_NAME_oneline doesn't
- + work when giving NULL instead of a buffer. */
- + buf[0] = 0;
- + X509_NAME_oneline(X509_get_subject_name(cert), buf, sizeof(buf));
- + if (client->verbose > 1)
- + logit(LOG_INFO, "SSL server cert subject: %s", buf);
- +
- + buf[0] = 0;
- + X509_NAME_oneline(X509_get_issuer_name(cert), buf, sizeof(buf));
- + if (client->verbose > 1)
- + logit(LOG_INFO, "SSL server cert issuer: %s", buf);
- +
- + /* We could do all sorts of certificate verification stuff here before
- + deallocating the certificate. */
- + X509_free(cert);
- + } while (0);
- +
- + if (rc) {
- + ssl_exit(client);
- + return rc;
- + }
- return 0;
- #endif
- @@ -112,17 +126,93 @@
- (void)client;
- return 0;
- #else
- - /* SSL/TLS close_notify */
- - SSL_shutdown(client->ssl);
- -
- - /* Clean up. */
- - SSL_free(client->ssl);
- - SSL_CTX_free(client->ssl_ctx);
- + if (client->ssl) {
- + /* SSL/TLS close_notify */
- + SSL_shutdown(client->ssl);
- +
- + /* Clean up. */
- + SSL_free(client->ssl);
- + client->ssl = NULL;
- + }
- +
- + if (client->ssl_ctx) {
- + /* Clean up. */
- + SSL_CTX_free(client->ssl_ctx);
- + client->ssl_ctx = NULL;
- + }
- return 0;
- #endif
- }
- +#ifdef ENABLE_SSL
- +static ssize_t
- +ssl_read_socket(SSL* ssl, char *buf, size_t len)
- +{
- + int nr, err;
- + size_t total = 0;
- +
- + do {
- + nr = SSL_read(ssl, buf + total, len - total);
- + if (nr > 0) {
- + total += (size_t)nr;
- + } else {
- + err = SSL_get_error(ssl, nr);
- + switch (err) {
- + case SSL_ERROR_ZERO_RETURN:
- + goto read_out;
- + break;
- + case SSL_ERROR_WANT_WRITE:
- + case SSL_ERROR_WANT_READ:
- + break;
- + default:
- + if (total == 0)
- + total = (ssize_t)-1;
- + logit(LOG_ERR, "SSL_read %s! (err: %d)", "FAILED", err);
- + goto read_out;
- + }
- + }
- + } while ((total < len) && SSL_pending(ssl));
- +
- +read_out:
- +
- + return (ssize_t)total;
- +}
- +
- +static ssize_t
- +ssl_write_socket(SSL* ssl, const char *buf, size_t len)
- +{
- + int nw, err;
- + size_t total = 0;
- +
- + while (total < len) {
- + nw = SSL_write(ssl, buf + total, len - total);
- + if (nw > 0) {
- + total += (size_t)nw;
- + } else {
- + err = SSL_get_error(ssl, nw);
- + switch (err) {
- + case SSL_ERROR_ZERO_RETURN:
- + goto write_out;
- + break;
- + case SSL_ERROR_WANT_WRITE:
- + case SSL_ERROR_WANT_READ:
- + break;
- + default:
- + if (total == 0)
- + total = (ssize_t)-1;
- + logit(LOG_ERR, "SSL_write %s! (err: %d)", "FAILED", err);
- + goto write_out;
- + }
- + }
- + }
- +
- +write_out:
- +
- + return (ssize_t)total;
- +}
- +#endif
- +
- int ssl_send(http_t *client, const char *buf, int len)
- {
- #ifndef ENABLE_SSL
- @@ -131,13 +221,15 @@
- (void)len;
- return RC_HTTPS_NO_SSL_SUPPORT;
- #else
- - int err = SSL_write(client->ssl, buf, len);
- + ssize_t nw;
- - if (err <= 0)
- - /* XXX: TODO add SSL_get_error() to figure out why */
- + nw = ssl_write_socket(client->ssl, buf, len);
- + if (nw <= 0)
- return RC_HTTPS_SEND_ERROR;
- - logit(LOG_DEBUG, "Successfully sent DDNS update using HTTPS!");
- + if (client->verbose > 1)
- + logit(LOG_DEBUG, "Successfully sent DDNS update using HTTPS!");
- +
- return 0;
- #endif
- }
- @@ -151,20 +243,28 @@
- (void)recv_len;
- return RC_HTTPS_NO_SSL_SUPPORT;
- #else
- - int len, err;
- + ssize_t nr;
- - /* Read HTTP header */
- - len = err = SSL_read(client->ssl, buf, buf_len);
- - if (err <= 0)
- - /* XXX: TODO add SSL_get_error() to figure out why */
- + /* Read HTTP header & body */
- + nr = ssl_read_socket(client->ssl, buf, buf_len);
- + if (nr <= 0) {
- + *recv_len = 0;
- return RC_HTTPS_RECV_ERROR;
- + }
- +
- + *recv_len = nr;
- /* Read HTTP body */
- - *recv_len = SSL_read(client->ssl, &buf[len], buf_len - len);
- - if (*recv_len <= 0)
- - *recv_len = 0;
- - *recv_len += len;
- - logit(LOG_DEBUG, "Successfully received DDNS update response (%d bytes) using HTTPS!", *recv_len);
- + buf_len -= nr;
- + if (buf_len > 0) {
- + buf += nr;
- + nr = ssl_read_socket(client->ssl, buf, buf_len);
- + if (nr > 0)
- + *recv_len += nr;
- + }
- +
- + if (client->verbose > 1)
- + logit(LOG_DEBUG, "Successfully received DDNS update response (%d bytes) using HTTPS!", *recv_len);
- return 0;
- #endif
- diff -urN ./inadyn-1.99.15/src/tcp.c ./inadyn_padavan/src/tcp.c
- --- ./inadyn-1.99.15/src/tcp.c 2016-01-22 13:41:47.000000000 +0300
- +++ ./inadyn_padavan/src/tcp.c 2016-01-22 14:22:01.000000000 +0300
- @@ -96,7 +96,7 @@
- }
- /* On error tcp_exit() is called by upper layers. */
- -int tcp_init(tcp_sock_t *tcp, char *msg)
- +int tcp_init(tcp_sock_t *tcp, char *msg, int verbose)
- {
- int rc = 0;
- char host[NI_MAXHOST];
- @@ -138,15 +138,15 @@
- /* Attempt to set TCP timers, silently fall back to OS defaults */
- sv.tv_sec = tcp->ip.timeout / 1000;
- sv.tv_usec = (tcp->ip.timeout % 1000) * 1000;
- - if (-1 == setsockopt(tcp->ip.socket, SOL_SOCKET, SO_RCVTIMEO, &sv, sizeof(sv)))
- - logit(LOG_WARNING, "Failed setting receive timeout socket option: %m");
- - if (-1 == setsockopt(tcp->ip.socket, SOL_SOCKET, SO_SNDTIMEO, &sv, sizeof(sv)))
- - logit(LOG_WARNING, "Failed setting send timeout socket option: %m");
- + setsockopt(tcp->ip.socket, SOL_SOCKET, SO_RCVTIMEO, &sv, sizeof(sv));
- + setsockopt(tcp->ip.socket, SOL_SOCKET, SO_SNDTIMEO, &sv, sizeof(sv));
- sa = tcp->ip.remote_addr;
- salen = tcp->ip.remote_len;
- - if (!getnameinfo(&sa, salen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))
- - logit(LOG_INFO, "%s, connecting to %s(%s:%d)", msg, tcp->ip.p_remote_host_name, host, tcp->ip.port);
- + if (!getnameinfo(&sa, salen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)) {
- + if (verbose > 0)
- + logit(LOG_INFO, "%s, connecting to %s (%s:%d)", msg, tcp->ip.p_remote_host_name, host, tcp->ip.port);
- + }
- else
- logit(LOG_ERR, "%s, failed resolving %s!", msg, host);
- ryzhovau@ryzhov4:~/temp$
Add Comment
Please, Sign In to add comment