mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-16 14:03:00 +02:00
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into monit
Conflicts: config/rootfiles/packages/asterisk
This commit is contained in:
@@ -71,6 +71,13 @@ create_files() {
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
if [[ ! -L "/var/run" ]]; then
|
||||
boot_mesg "Repair /var/run symlink to /run..."
|
||||
mv -u /var/run/* /run/ 2>&1 > /dev/null
|
||||
rm -rf /var/run
|
||||
ln -s ../run /var/run
|
||||
fi
|
||||
|
||||
boot_mesg -n "Cleaning file systems:" ${INFO}
|
||||
|
||||
boot_mesg -n " /tmp" ${NORMAL}
|
||||
|
||||
53
src/initscripts/init.d/dhcrelay
Executable file
53
src/initscripts/init.d/dhcrelay
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
########################################################################
|
||||
# Begin $rc_base/init.d/dhcrelay
|
||||
#
|
||||
# Description : The DHCP Relay Daemon
|
||||
#
|
||||
########################################################################
|
||||
|
||||
. /etc/sysconfig/rc
|
||||
. ${rc_functions}
|
||||
|
||||
CONFIG_FILE="/var/ipfire/dhcp/relay"
|
||||
|
||||
if [ -r "${CONFIG_FILE}" ]; then
|
||||
eval $(/usr/local/bin/readhash ${CONFIG_FILE})
|
||||
fi
|
||||
|
||||
ARGS="-q"
|
||||
|
||||
for interface in ${INTERFACES}; do
|
||||
ARGS="${ARGS} -i ${interface}"
|
||||
done
|
||||
|
||||
ARGS="${ARGS} ${SERVERS}"
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
boot_mesg "Starting DHCP Relay..."
|
||||
loadproc /usr/sbin/dhcrelay ${ARGS}
|
||||
;;
|
||||
|
||||
stop)
|
||||
boot_mesg "Stopping DHCP Relay..."
|
||||
killproc -p /var/run/dhcrelay.pid /usr/sbin/dhcrelay
|
||||
;;
|
||||
|
||||
restart)
|
||||
${0} stop
|
||||
sleep 1
|
||||
${0} start
|
||||
;;
|
||||
|
||||
status)
|
||||
statusproc /usr/sbin/dhcrelay
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: ${0} {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# End $rc_base/init.d/dhcrelay
|
||||
@@ -20,7 +20,20 @@ if [ -e "/etc/sysconfig/dnsmasq" ]; then
|
||||
. /etc/sysconfig/dnsmasq
|
||||
fi
|
||||
|
||||
CACHE_SIZE=2500
|
||||
ENABLE_DNSSEC=1
|
||||
SHOW_SRV=1
|
||||
TRUST_ANCHOR=".,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5"
|
||||
|
||||
function dnssec_args() {
|
||||
local cmdline="--dnssec"
|
||||
|
||||
if [ -n "${TRUST_ANCHOR}" ]; then
|
||||
cmdline="${cmdline} --trust-anchor=${TRUST_ANCHOR}"
|
||||
fi
|
||||
|
||||
echo "${cmdline}"
|
||||
}
|
||||
|
||||
function dns_forward_args() {
|
||||
local file="${1}"
|
||||
@@ -41,7 +54,6 @@ function dns_forward_args() {
|
||||
echo "${cmdline}"
|
||||
}
|
||||
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
# kill already running copy of dnsmasq...
|
||||
@@ -73,6 +85,15 @@ case "${1}" in
|
||||
# Add custom forward dns zones.
|
||||
ARGS="${ARGS} $(dns_forward_args /var/ipfire/dnsforward/config)"
|
||||
|
||||
# Enabled DNSSEC validation
|
||||
if [ "${ENABLE_DNSSEC}" -eq 1 ]; then
|
||||
ARGS="${ARGS} $(dnssec_args)"
|
||||
fi
|
||||
|
||||
if [ -n "${CACHE_SIZE}" ]; then
|
||||
ARGS="${ARGS} --cache-size=${CACHE_SIZE}"
|
||||
fi
|
||||
|
||||
loadproc /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS
|
||||
|
||||
if [ "${SHOW_SRV}" -eq 1 ] && [ "${DNS1}" != "" -o "${DNS2}" != "" ]; then
|
||||
|
||||
@@ -17,9 +17,11 @@ fi
|
||||
# Load ethernet settings
|
||||
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
|
||||
|
||||
if [ "${RED_DEV}" == "" ]; then
|
||||
RED_DEV=ppp0
|
||||
fi
|
||||
case "${RED_TYPE}" in
|
||||
PPPOE)
|
||||
RED_DEV="ppp0"
|
||||
;;
|
||||
esac
|
||||
|
||||
# setup_netdev_trigger LED DEVICE MODE
|
||||
setup_netdev_trigger ()
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/local/bin/setddns.pl -f
|
||||
|
||||
exit 0
|
||||
exec /usr/bin/ddns update-all
|
||||
|
||||
@@ -64,7 +64,7 @@ case "${1}" in
|
||||
|
||||
# Now traverse /sys in order to "coldplug" devices that have
|
||||
# already been discovered
|
||||
/bin/udevadm trigger
|
||||
/bin/udevadm trigger --action=add
|
||||
|
||||
# Now wait for udevd to process the uevents we triggered
|
||||
/bin/udevadm settle
|
||||
|
||||
@@ -542,7 +542,7 @@ int main(int argc, char *argv[])
|
||||
replace("/harddisk/boot/grub/grub.conf", "splashimage", "#splashimage");
|
||||
replace("/harddisk/boot/grub/grub.conf", "#serial", "serial");
|
||||
replace("/harddisk/boot/grub/grub.conf", "#terminal", "terminal");
|
||||
replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,38400n8 panic=10 ");
|
||||
replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,115200n8 panic=10 ");
|
||||
|
||||
/*inittab*/
|
||||
replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:");
|
||||
|
||||
@@ -27,7 +27,7 @@ int writehostsfiles(void)
|
||||
FILE *file, *hosts;
|
||||
struct keyvalue *kv;
|
||||
char hostname[STRING_SIZE];
|
||||
char domainname[STRING_SIZE] = "";
|
||||
char domainname[STRING_SIZE] = "localdomain";
|
||||
char commandstring[STRING_SIZE];
|
||||
char buffer[STRING_SIZE];
|
||||
|
||||
|
||||
44
src/paks/owncloud/install.sh
Normal file
44
src/paks/owncloud/install.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# #
|
||||
# This file is part of the IPFire Firewall. #
|
||||
# #
|
||||
# IPFire 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. #
|
||||
# #
|
||||
# IPFire 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 IPFire; if not, write to the Free Software #
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
# #
|
||||
# Copyright (C) 2007 IPFire-Team <info@ipfire.org>. #
|
||||
# #
|
||||
############################################################################
|
||||
#
|
||||
. /opt/pakfire/lib/functions.sh
|
||||
extract_files
|
||||
restore_backup ${NAME}
|
||||
|
||||
# Fix permissions.
|
||||
chmod 777 /srv/web/owncloud/apps
|
||||
chmod 777 /srv/web/owncloud/config
|
||||
|
||||
# Create data directory.
|
||||
mkdir -p /var/owncloud/data
|
||||
chown -R nobody:nobody /var/owncloud
|
||||
|
||||
# Import web interface certificates if none exist.
|
||||
if [ ! -e "/etc/httpd/owncloud.crt" ] && [ ! -e "/etc/httpd/owncloud.key" ]; then
|
||||
cat /etc/httpd/server.crt > /etc/httpd/owncloud.crt
|
||||
cat /etc/httpd/server.key > /etc/httpd/owncloud.key
|
||||
fi
|
||||
|
||||
/etc/init.d/apache reload
|
||||
|
||||
exit 0
|
||||
30
src/paks/owncloud/uninstall.sh
Normal file
30
src/paks/owncloud/uninstall.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# #
|
||||
# This file is part of the IPFire Firewall. #
|
||||
# #
|
||||
# IPFire 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. #
|
||||
# #
|
||||
# IPFire 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 IPFire; if not, write to the Free Software #
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
# #
|
||||
# Copyright (C) 2007 IPFire-Team <info@ipfire.org>. #
|
||||
# #
|
||||
############################################################################
|
||||
#
|
||||
. /opt/pakfire/lib/functions.sh
|
||||
make_backup ${NAME}
|
||||
remove_files
|
||||
|
||||
/etc/init.d/apache reload
|
||||
|
||||
exit 0
|
||||
26
src/paks/owncloud/update.sh
Normal file
26
src/paks/owncloud/update.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
############################################################################
|
||||
# #
|
||||
# This file is part of the IPFire Firewall. #
|
||||
# #
|
||||
# IPFire 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. #
|
||||
# #
|
||||
# IPFire 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 IPFire; if not, write to the Free Software #
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
# #
|
||||
# Copyright (C) 2007 IPFire-Team <info@ipfire.org>. #
|
||||
# #
|
||||
############################################################################
|
||||
#
|
||||
. /opt/pakfire/lib/functions.sh
|
||||
./uninstall.sh
|
||||
./install.sh
|
||||
@@ -0,0 +1,365 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 292c8bd..5e0cdbe 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -69,7 +69,7 @@ objs = cache.o rfc1035.o util.o option.o forward.o network.o \
|
||||
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
|
||||
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
|
||||
dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \
|
||||
- domain.o dnssec.o blockdata.o
|
||||
+ domain.o dnssec.o blockdata.o isc.o
|
||||
|
||||
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \
|
||||
dns-protocol.h radv-protocol.h ip6addr.h
|
||||
diff --git a/src/cache.c b/src/cache.c
|
||||
index 5cec918..1f5657f 100644
|
||||
--- a/src/cache.c
|
||||
+++ b/src/cache.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "dnsmasq.h"
|
||||
|
||||
static struct crec *cache_head = NULL, *cache_tail = NULL, **hash_table = NULL;
|
||||
-#ifdef HAVE_DHCP
|
||||
+#if (defined HAVE_DHCP) || (defined HAVE_ISC_READER)
|
||||
static struct crec *dhcp_spare = NULL;
|
||||
#endif
|
||||
static struct crec *new_chain = NULL;
|
||||
@@ -222,6 +222,9 @@ static void cache_free(struct crec *crecp)
|
||||
crecp->flags &= ~F_BIGNAME;
|
||||
}
|
||||
|
||||
+ if (crecp->flags & F_DHCP)
|
||||
+ free(crecp->name.namep);
|
||||
+
|
||||
#ifdef HAVE_DNSSEC
|
||||
cache_blockdata_free(crecp);
|
||||
#endif
|
||||
@@ -1110,7 +1113,7 @@ void cache_reload(void)
|
||||
total_size = read_hostsfile(ah->fname, ah->index, total_size, (struct crec **)daemon->packet, revhashsz);
|
||||
}
|
||||
|
||||
-#ifdef HAVE_DHCP
|
||||
+#if (defined HAVE_DHCP) || (defined HAVE_ISC_READER)
|
||||
struct in_addr a_record_from_hosts(char *name, time_t now)
|
||||
{
|
||||
struct crec *crecp = NULL;
|
||||
@@ -1188,7 +1191,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
||||
addrlen = sizeof(struct in6_addr);
|
||||
}
|
||||
#endif
|
||||
-
|
||||
+
|
||||
inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
|
||||
|
||||
while ((crec = cache_find_by_name(crec, host_name, 0, flags | F_CNAME)))
|
||||
@@ -1253,7 +1256,11 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
||||
else
|
||||
crec->ttd = ttd;
|
||||
crec->addr.addr = *host_address;
|
||||
+#ifdef HAVE_ISC_READER
|
||||
+ crec->name.namep = strdup(host_name);
|
||||
+#else
|
||||
crec->name.namep = host_name;
|
||||
+#endif
|
||||
crec->uid = next_uid();
|
||||
cache_hash(crec);
|
||||
|
||||
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
|
||||
index 1c96a0e..156ac9a 100644
|
||||
--- a/src/dnsmasq.c
|
||||
+++ b/src/dnsmasq.c
|
||||
@@ -934,6 +934,11 @@ int main (int argc, char **argv)
|
||||
|
||||
poll_resolv(0, daemon->last_resolv != 0, now);
|
||||
daemon->last_resolv = now;
|
||||
+
|
||||
+#ifdef HAVE_ISC_READER
|
||||
+ if (daemon->lease_file && !daemon->dhcp)
|
||||
+ load_dhcp(now);
|
||||
+#endif
|
||||
}
|
||||
|
||||
if (FD_ISSET(piperead, &rset))
|
||||
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
|
||||
index 3032546..a40b2a9 100644
|
||||
--- a/src/dnsmasq.h
|
||||
+++ b/src/dnsmasq.h
|
||||
@@ -1447,3 +1447,8 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force);
|
||||
time_t periodic_slaac(time_t now, struct dhcp_lease *leases);
|
||||
void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface, struct dhcp_lease *leases);
|
||||
#endif
|
||||
+
|
||||
+/* isc.c */
|
||||
+#ifdef HAVE_ISC_READER
|
||||
+void load_dhcp(time_t now);
|
||||
+#endif
|
||||
diff --git a/src/isc.c b/src/isc.c
|
||||
new file mode 100644
|
||||
index 0000000..5106442
|
||||
--- /dev/null
|
||||
+++ b/src/isc.c
|
||||
@@ -0,0 +1,251 @@
|
||||
+/* dnsmasq is Copyright (c) 2014 John Volpe, Simon Kelley and
|
||||
+ Michael Tremer
|
||||
+
|
||||
+ 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; version 2 dated June, 1991, or
|
||||
+ (at your option) version 3 dated 29 June, 2007.
|
||||
+
|
||||
+ 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, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+ Code in this file is based on contributions by John Volpe and
|
||||
+ Simon Kelley. Updated for recent versions of dnsmasq by
|
||||
+ Michael Tremer.
|
||||
+*/
|
||||
+
|
||||
+#include "dnsmasq.h"
|
||||
+
|
||||
+#ifdef HAVE_ISC_READER
|
||||
+#define MAXTOK 50
|
||||
+
|
||||
+struct isc_dhcp_lease {
|
||||
+ char* name;
|
||||
+ char* fqdn;
|
||||
+ time_t expires;
|
||||
+ struct in_addr addr;
|
||||
+ struct isc_dhcp_lease* next;
|
||||
+};
|
||||
+
|
||||
+static struct isc_dhcp_lease* dhcp_lease_new(const char* hostname) {
|
||||
+ struct isc_dhcp_lease* lease = whine_malloc(sizeof(*lease));
|
||||
+
|
||||
+ lease->name = strdup(hostname);
|
||||
+ if (daemon->domain_suffix) {
|
||||
+ asprintf(&lease->fqdn, "%s.%s", hostname, daemon->domain_suffix);
|
||||
+ }
|
||||
+ lease->expires = 0;
|
||||
+ lease->next = NULL;
|
||||
+
|
||||
+ return lease;
|
||||
+}
|
||||
+
|
||||
+static void dhcp_lease_free(struct isc_dhcp_lease* lease) {
|
||||
+ if (!lease)
|
||||
+ return;
|
||||
+
|
||||
+ if (lease->name)
|
||||
+ free(lease->name);
|
||||
+ if (lease->fqdn)
|
||||
+ free(lease->fqdn);
|
||||
+ free(lease);
|
||||
+}
|
||||
+
|
||||
+static int next_token(char* token, int buffsize, FILE* fp) {
|
||||
+ int c, count = 0;
|
||||
+ char* cp = token;
|
||||
+
|
||||
+ while ((c = getc(fp)) != EOF) {
|
||||
+ if (c == '#') {
|
||||
+ do {
|
||||
+ c = getc(fp);
|
||||
+ } while (c != '\n' && c != EOF);
|
||||
+ }
|
||||
+
|
||||
+ if (c == ' ' || c == '\t' || c == '\n' || c == ';') {
|
||||
+ if (count)
|
||||
+ break;
|
||||
+ } else if ((c != '"') && (count < buffsize - 1)) {
|
||||
+ *cp++ = c;
|
||||
+ count++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *cp = 0;
|
||||
+ return count ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
+static long get_utc_offset() {
|
||||
+ time_t t = time(NULL);
|
||||
+ struct tm* time_struct = localtime(&t);
|
||||
+
|
||||
+ return time_struct->tm_gmtoff;
|
||||
+}
|
||||
+
|
||||
+static time_t parse_lease_time(const char* token_date, const char* token_time) {
|
||||
+ time_t time = (time_t)(-1);
|
||||
+ struct tm lease_time;
|
||||
+
|
||||
+ if (sscanf(token_date, "%d/%d/%d", &lease_time.tm_year, &lease_time.tm_mon, &lease_time.tm_mday) == 3) {
|
||||
+ lease_time.tm_year -= 1900;
|
||||
+ lease_time.tm_mon -= 1;
|
||||
+
|
||||
+ if (sscanf(token_time, "%d:%d:%d", &lease_time.tm_hour, &lease_time.tm_min, &lease_time.tm_sec) == 3) {
|
||||
+ time = mktime(&lease_time) + get_utc_offset();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return time;
|
||||
+}
|
||||
+
|
||||
+static struct isc_dhcp_lease* find_lease(const char* hostname, struct isc_dhcp_lease* leases) {
|
||||
+ struct isc_dhcp_lease* lease = leases;
|
||||
+
|
||||
+ while (lease) {
|
||||
+ if (strcmp(hostname, lease->name) == 0) {
|
||||
+ return lease;
|
||||
+ }
|
||||
+ lease = lease->next;
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static off_t lease_file_size = (off_t)0;
|
||||
+static ino_t lease_file_inode = (ino_t)0;
|
||||
+
|
||||
+void load_dhcp(time_t now) {
|
||||
+ struct isc_dhcp_lease* leases = NULL;
|
||||
+
|
||||
+ struct stat statbuf;
|
||||
+ if (stat(daemon->lease_file, &statbuf) == -1) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Do nothing if the lease file has not changed. */
|
||||
+ if ((statbuf.st_size <= lease_file_size) && (statbuf.st_ino == lease_file_inode))
|
||||
+ return;
|
||||
+
|
||||
+ lease_file_size = statbuf.st_size;
|
||||
+ lease_file_inode = statbuf.st_ino;
|
||||
+
|
||||
+ FILE* fp = fopen(daemon->lease_file, "r");
|
||||
+ if (!fp) {
|
||||
+ my_syslog(LOG_ERR, _("failed to load %s:%s"), daemon->lease_file, strerror(errno));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ my_syslog(LOG_INFO, _("reading %s"), daemon->lease_file);
|
||||
+
|
||||
+ char* hostname = daemon->namebuff;
|
||||
+ struct in_addr host_address;
|
||||
+ time_t time_starts = -1;
|
||||
+ time_t time_ends = -1;
|
||||
+ int nomem;
|
||||
+
|
||||
+ char token[MAXTOK];
|
||||
+ while ((next_token(token, MAXTOK, fp))) {
|
||||
+ if (strcmp(token, "lease") == 0) {
|
||||
+ hostname[0] = '\0';
|
||||
+
|
||||
+ if (next_token(token, MAXTOK, fp) && ((host_address.s_addr = inet_addr(token)) != (in_addr_t)-1)) {
|
||||
+ if (next_token(token, MAXTOK, fp) && *token == '{') {
|
||||
+ while (next_token(token, MAXTOK, fp) && *token != '}') {
|
||||
+ if ((strcmp(token, "client-hostname") == 0) || (strcmp(token, "hostname") == 0)) {
|
||||
+ if (next_token(hostname, MAXDNAME, fp)) {
|
||||
+ if (!canonicalise(hostname, &nomem)) {
|
||||
+ *hostname = 0;
|
||||
+ my_syslog(LOG_ERR, _("bad name in %s"), daemon->lease_file);
|
||||
+ }
|
||||
+ }
|
||||
+ } else if ((strcmp(token, "starts") == 0) || (strcmp(token, "ends") == 0)) {
|
||||
+ char token_date[MAXTOK];
|
||||
+ char token_time[MAXTOK];
|
||||
+
|
||||
+ int is_starts = strcmp(token, "starts") == 0;
|
||||
+
|
||||
+ // Throw away the weekday and parse the date.
|
||||
+ if (next_token(token, MAXTOK, fp) && next_token(token_date, MAXTOK, fp) && next_token(token_time, MAXTOK, fp)) {
|
||||
+ time_t time = parse_lease_time(token_date, token_time);
|
||||
+
|
||||
+ if (is_starts)
|
||||
+ time_starts = time;
|
||||
+ else
|
||||
+ time_ends = time;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!*hostname)
|
||||
+ continue;
|
||||
+
|
||||
+ if ((time_starts == -1) || (time_ends == -1))
|
||||
+ continue;
|
||||
+
|
||||
+ if (difftime(now, time_ends) > 0)
|
||||
+ continue;
|
||||
+
|
||||
+ char* dot = strchr(hostname, '.');
|
||||
+ if (dot) {
|
||||
+ if (!daemon->domain_suffix || hostname_isequal(dot + 1, daemon->domain_suffix)) {
|
||||
+ my_syslog(LOG_WARNING,
|
||||
+ _("Ignoring DHCP lease for %s because it has an illegal domain part"),
|
||||
+ hostname);
|
||||
+ continue;
|
||||
+ }
|
||||
+ *dot = 0;
|
||||
+ }
|
||||
+
|
||||
+ // Search for an existing lease in the list
|
||||
+ // with the given host name and update the data
|
||||
+ // if needed.
|
||||
+ struct isc_dhcp_lease* lease = find_lease(hostname, leases);
|
||||
+
|
||||
+ // If no lease already exists, we create a new one
|
||||
+ // and append it to the list.
|
||||
+ if (!lease) {
|
||||
+ lease = dhcp_lease_new(hostname);
|
||||
+
|
||||
+ lease->next = leases;
|
||||
+ leases = lease;
|
||||
+ }
|
||||
+
|
||||
+ // Only update more recent leases.
|
||||
+ if (lease->expires > time_ends)
|
||||
+ continue;
|
||||
+
|
||||
+ lease->addr = host_address;
|
||||
+ lease->expires = time_ends;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fclose(fp);
|
||||
+
|
||||
+ // Drop all entries.
|
||||
+ cache_unhash_dhcp();
|
||||
+
|
||||
+ while (leases) {
|
||||
+ struct isc_dhcp_lease *lease = leases;
|
||||
+ leases = lease->next;
|
||||
+
|
||||
+ if (lease->fqdn) {
|
||||
+ cache_add_dhcp_entry(lease->fqdn, AF_INET, (struct all_addr*)&lease->addr.s_addr, lease->expires);
|
||||
+ }
|
||||
+
|
||||
+ if (lease->name) {
|
||||
+ cache_add_dhcp_entry(lease->name, AF_INET, (struct all_addr*)&lease->addr.s_addr, lease->expires);
|
||||
+ }
|
||||
+
|
||||
+ // Cleanup
|
||||
+ dhcp_lease_free(lease);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
diff --git a/src/option.c b/src/option.c
|
||||
index daa728f..d16c982 100644
|
||||
--- a/src/option.c
|
||||
+++ b/src/option.c
|
||||
@@ -1642,7 +1642,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
||||
ret_err(_("bad MX target"));
|
||||
break;
|
||||
|
||||
-#ifdef HAVE_DHCP
|
||||
+#if (defined HAVE_DHCP) || (defined HAVE_ISC_READER)
|
||||
case 'l': /* --dhcp-leasefile */
|
||||
daemon->lease_file = opt_string_alloc(arg);
|
||||
break;
|
||||
65
src/patches/dnsmasq-2.71-support-nettle-3.0.patch
Normal file
65
src/patches/dnsmasq-2.71-support-nettle-3.0.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
From cdb755c5f16a6768c3e8b1f345fe15fc9244228d Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Wed, 18 Jun 2014 20:52:53 +0100
|
||||
Subject: [PATCH] Fix FTBFS with Nettle-3.0.
|
||||
|
||||
---
|
||||
CHANGELOG | 3 +++
|
||||
src/dnssec.c | 18 ++++++++++++------
|
||||
2 files changed, 15 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/dnssec.c b/src/dnssec.c
|
||||
index 2ffb75d..69bfc29 100644
|
||||
--- a/src/dnssec.c
|
||||
+++ b/src/dnssec.c
|
||||
@@ -28,6 +28,12 @@
|
||||
#include <nettle/nettle-meta.h>
|
||||
#include <nettle/bignum.h>
|
||||
|
||||
+/* Nettle-3.0 moved to a new API for DSA. We use a name that's defined in the new API
|
||||
+ to detect Nettle-3, and invoke the backwards compatibility mode. */
|
||||
+#ifdef dsa_params_init
|
||||
+#include <nettle/dsa-compat.h>
|
||||
+#endif
|
||||
+
|
||||
|
||||
#define SERIAL_UNDEF -100
|
||||
#define SERIAL_EQ 0
|
||||
@@ -121,8 +127,8 @@ static int hash_init(const struct nettle_hash *hash, void **ctxp, unsigned char
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static int rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||
- unsigned char *digest, int algo)
|
||||
+static int dnsmasq_rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||
+ unsigned char *digest, int algo)
|
||||
{
|
||||
unsigned char *p;
|
||||
size_t exp_len;
|
||||
@@ -173,8 +179,8 @@ static int rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int dsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||
- unsigned char *digest, int algo)
|
||||
+static int dnsmasq_dsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||
+ unsigned char *digest, int algo)
|
||||
{
|
||||
unsigned char *p;
|
||||
unsigned int t;
|
||||
@@ -293,10 +299,10 @@ static int verify(struct blockdata *key_data, unsigned int key_len, unsigned cha
|
||||
switch (algo)
|
||||
{
|
||||
case 1: case 5: case 7: case 8: case 10:
|
||||
- return rsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||
+ return dnsmasq_rsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||
|
||||
case 3: case 6:
|
||||
- return dsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||
+ return dnsmasq_dsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||
|
||||
#ifndef NO_NETTLE_ECC
|
||||
case 13: case 14:
|
||||
--
|
||||
1.7.10.4
|
||||
|
||||
88
src/patches/dnsmasq-2.71-use-nettle-with-minigmp.patch
Normal file
88
src/patches/dnsmasq-2.71-use-nettle-with-minigmp.patch
Normal file
@@ -0,0 +1,88 @@
|
||||
From 063efb330a3f341c2548e2cf1f67f83e49cd6395 Mon Sep 17 00:00:00 2001
|
||||
From: Simon Kelley <simon@thekelleys.org.uk>
|
||||
Date: Tue, 17 Jun 2014 19:49:31 +0100
|
||||
Subject: [PATCH] Build config: add -DNO_GMP for use with nettle/mini-gmp
|
||||
|
||||
---
|
||||
Makefile | 2 +-
|
||||
bld/pkg-wrapper | 9 +++++++--
|
||||
src/config.h | 7 +++++++
|
||||
src/dnssec.c | 3 ++-
|
||||
4 files changed, 17 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index c58b50b..17eeb27 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -61,7 +61,7 @@ lua_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CON
|
||||
lua_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1`
|
||||
nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --cflags nettle hogweed`
|
||||
nettle_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --libs nettle hogweed`
|
||||
-gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --copy -lgmp`
|
||||
+gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC NO_GMP --copy -lgmp`
|
||||
sunos_libs = `if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket -lnsl -lposix4; fi`
|
||||
version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"'
|
||||
|
||||
diff --git a/bld/pkg-wrapper b/bld/pkg-wrapper
|
||||
index 9f9332d..0ddb678 100755
|
||||
--- a/bld/pkg-wrapper
|
||||
+++ b/bld/pkg-wrapper
|
||||
@@ -11,9 +11,14 @@ in=`cat`
|
||||
|
||||
if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
|
||||
echo $in | grep $search >/dev/null 2>&1; then
|
||||
-
|
||||
+# Nasty, nasty, in --copy, arg 2 is another config to search for, use with NO_GMP
|
||||
if [ $op = "--copy" ]; then
|
||||
- pkg="$*"
|
||||
+ if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
|
||||
+ echo $in | grep $pkg >/dev/null 2>&1; then
|
||||
+ pkg=""
|
||||
+ else
|
||||
+ pkg="$*"
|
||||
+ fi
|
||||
elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
|
||||
echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||
pkg=`$pkg --static $op $*`
|
||||
diff --git a/src/config.h b/src/config.h
|
||||
index 2155544..ee6d218 100644
|
||||
--- a/src/config.h
|
||||
+++ b/src/config.h
|
||||
@@ -105,6 +105,8 @@ HAVE_AUTH
|
||||
define this to include the facility to act as an authoritative DNS
|
||||
server for one or more zones.
|
||||
|
||||
+HAVE_DNSSEC
|
||||
+ include DNSSEC validator.
|
||||
|
||||
NO_IPV6
|
||||
NO_TFTP
|
||||
@@ -118,6 +120,11 @@ NO_AUTH
|
||||
which are enabled by default in the distributed source tree. Building dnsmasq
|
||||
with something like "make COPTS=-DNO_SCRIPT" will do the trick.
|
||||
|
||||
+NO_NETTLE_ECC
|
||||
+ Don't include the ECDSA cypher in DNSSEC validation. Needed for older Nettle versions.
|
||||
+NO_GMP
|
||||
+ Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
|
||||
+
|
||||
LEASEFILE
|
||||
CONFFILE
|
||||
RESOLVFILE
|
||||
diff --git a/src/dnssec.c b/src/dnssec.c
|
||||
index 44d626b..2ffb75d 100644
|
||||
--- a/src/dnssec.c
|
||||
+++ b/src/dnssec.c
|
||||
@@ -26,7 +26,8 @@
|
||||
# include <nettle/ecc-curve.h>
|
||||
#endif
|
||||
#include <nettle/nettle-meta.h>
|
||||
-#include <gmp.h>
|
||||
+#include <nettle/bignum.h>
|
||||
+
|
||||
|
||||
#define SERIAL_UNDEF -100
|
||||
#define SERIAL_EQ 0
|
||||
--
|
||||
1.7.10.4
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
From 4e9792dc8ab29175295c79c35f9f6fbd2d453b35 Mon Sep 17 00:00:00 2001
|
||||
From: Octavian Purdila <octavian.purdila@intel.com>
|
||||
Date: Mon, 23 Dec 2013 19:06:31 +0200
|
||||
Subject: [PATCH] usbnet: mcs7830: rework link state detection
|
||||
|
||||
Even with the quirks in commit dabdaf0c (mcs7830: Fix link state
|
||||
detection) there are still spurious link-down events for some chips
|
||||
where the false link-down events count go over a few hundreds.
|
||||
|
||||
This patch takes a more conservative approach and only looks at
|
||||
link-down events where the link-down state is not combined with other
|
||||
states (e.g. half/full speed, pending frames in SRAM or TX status
|
||||
information valid). In all other cases we assume the link is up.
|
||||
|
||||
Tested on MCS7830CV-DA (USB ID 9710:7830).
|
||||
|
||||
Cc: Ondrej Zary <linux@rainbow-software.org>
|
||||
Cc: Michael Leun <lkml20120218@newton.leun.net>
|
||||
Cc: Ming Lei <ming.lei@canonical.com>
|
||||
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/usb/mcs7830.c | 19 ++++---------------
|
||||
1 file changed, 4 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
|
||||
index 9237c45..8dd48b5 100644
|
||||
--- a/drivers/net/usb/mcs7830.c
|
||||
+++ b/drivers/net/usb/mcs7830.c
|
||||
@@ -117,7 +117,6 @@ enum {
|
||||
struct mcs7830_data {
|
||||
u8 multi_filter[8];
|
||||
u8 config;
|
||||
- u8 link_counter;
|
||||
};
|
||||
|
||||
static const char driver_name[] = "MOSCHIP usb-ethernet driver";
|
||||
@@ -562,26 +561,16 @@ static void mcs7830_status(struct usbnet *dev, struct urb *urb)
|
||||
{
|
||||
u8 *buf = urb->transfer_buffer;
|
||||
bool link, link_changed;
|
||||
- struct mcs7830_data *data = mcs7830_get_data(dev);
|
||||
|
||||
if (urb->actual_length < 16)
|
||||
return;
|
||||
|
||||
- link = !(buf[1] & 0x20);
|
||||
+ link = !(buf[1] == 0x20);
|
||||
link_changed = netif_carrier_ok(dev->net) != link;
|
||||
if (link_changed) {
|
||||
- data->link_counter++;
|
||||
- /*
|
||||
- track link state 20 times to guard against erroneous
|
||||
- link state changes reported sometimes by the chip
|
||||
- */
|
||||
- if (data->link_counter > 20) {
|
||||
- data->link_counter = 0;
|
||||
- usbnet_link_change(dev, link, 0);
|
||||
- netdev_dbg(dev->net, "Link Status is: %d\n", link);
|
||||
- }
|
||||
- } else
|
||||
- data->link_counter = 0;
|
||||
+ usbnet_link_change(dev, link, 0);
|
||||
+ netdev_dbg(dev->net, "Link Status is: %d\n", link);
|
||||
+ }
|
||||
}
|
||||
|
||||
static const struct driver_info moschip_info = {
|
||||
--
|
||||
2.0.0
|
||||
|
||||
@@ -7,7 +7,7 @@ index 9ab2eee..86762bd 100644
|
||||
|
||||
/* How many PADI/PADS attempts? */
|
||||
-#define MAX_PADI_ATTEMPTS 3
|
||||
+#define MAX_PADI_ATTEMPTS 12
|
||||
+#define MAX_PADI_ATTEMPTS 4
|
||||
|
||||
/* Initial timeout for PADO/PADS */
|
||||
#define PADI_TIMEOUT 5
|
||||
|
||||
@@ -1,863 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# SmoothWall CGIs
|
||||
#
|
||||
# This code is distributed under the terms of the GPL
|
||||
#
|
||||
# (c) The SmoothWall Team
|
||||
#
|
||||
# $Id: setddns.pl,v 1.4.2.32 2006/02/07 01:29:47 franck78 Exp $
|
||||
#
|
||||
|
||||
#close(STDIN);
|
||||
#close(STDOUT);
|
||||
#close(STDERR);
|
||||
|
||||
use strict;
|
||||
use IO::Socket;
|
||||
use Net::SSLeay;
|
||||
|
||||
require '/var/ipfire/general-functions.pl';
|
||||
|
||||
#Prototypes functions
|
||||
sub encode_base64 ($;$);
|
||||
|
||||
my %settings;
|
||||
my $filename = "${General::swroot}/ddns/config";
|
||||
my $cachefile = "${General::swroot}/ddns/ipcache";
|
||||
my $ipcache = 0;
|
||||
my @current = ();
|
||||
|
||||
if (open(FILE, "$filename")) {
|
||||
@current = <FILE>;
|
||||
close(FILE);
|
||||
unless(@current) {
|
||||
exit 0;
|
||||
}
|
||||
} else {
|
||||
&General::log('Dynamic DNS failure : unable to open config file.');
|
||||
exit 0;
|
||||
}
|
||||
|
||||
&General::readhash("${General::swroot}/ddns/settings", \%settings);
|
||||
|
||||
# ignore monthly update if not in minimize update mode
|
||||
exit 0 if (($settings{'MINIMIZEUPDATES'} ne 'on') && ($ARGV[1] eq '-m'));
|
||||
|
||||
my $ip = &General::GetDyndnsRedIP();
|
||||
|
||||
if ($ip eq "unavailable") {
|
||||
&General::log("Dynamic DNS error: RED/Public IP is unavailable");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#&General::log("Dynamic DNS public router IP is: $ip");
|
||||
|
||||
if ($ARGV[0] eq '-f') {
|
||||
unlink ($cachefile); # next regular calls will try again if this force update fails.
|
||||
} else {
|
||||
open(IPCACHE, "$cachefile");
|
||||
$ipcache = <IPCACHE>;
|
||||
close(IPCACHE);
|
||||
chomp $ipcache;
|
||||
}
|
||||
|
||||
if ($ip ne $ipcache) {
|
||||
my $id = 0;
|
||||
my $success = 0;
|
||||
my $line;
|
||||
my $lines = @current;
|
||||
|
||||
foreach $line (@current) {
|
||||
$id++;
|
||||
chomp($line);
|
||||
my @temp = split(/\,/,$line);
|
||||
unless ($temp[7] ne "on") {
|
||||
$settings{'SERVICE'} = $temp[0];
|
||||
$settings{'HOSTNAME'} = $temp[1];
|
||||
$settings{'DOMAIN'} = $temp[2];
|
||||
$settings{'PROXY'} = $temp[3];
|
||||
$settings{'WILDCARDS'} = $temp[4];
|
||||
$settings{'LOGIN'} = $temp[5];
|
||||
$settings{'PASSWORD'} = $temp[6];
|
||||
$settings{'ENABLED'} = $temp[7];
|
||||
|
||||
#Some connection are very stable (more than 40 days). Finally force
|
||||
#one update / month to avoid account lost
|
||||
#cron call once/week with -f & once/month with -f -m options
|
||||
#minimize update ?
|
||||
if ( ($settings{'MINIMIZEUPDATES'} eq 'on') && ($ARGV[1] ne '-m') ) {
|
||||
if (General::DyndnsServiceSync($ip, $settings{'HOSTNAME'},$settings{'DOMAIN'})) {
|
||||
&General::log ("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} is uptodate [$ip]");
|
||||
$success++;
|
||||
next; # do not update, go to test next service
|
||||
}
|
||||
}
|
||||
if ($settings{'SERVICE'} ne "dns.lightningwirelabs.com") {
|
||||
my @service = split(/\./, "$settings{'SERVICE'}");
|
||||
$settings{'SERVICE'} = "$service[0]";
|
||||
}
|
||||
if ($settings{'SERVICE'} eq 'no-ip') {
|
||||
open(F, ">${General::swroot}/ddns/noipsettings");
|
||||
flock F, 2;
|
||||
print F "PROXY=" . ($settings{'PROXY'} eq 'on' ? "Y\n" : "N\n");
|
||||
print F "PASSWORD=$settings{'PASSWORD'}\n";
|
||||
print F "NAT=N\n";
|
||||
print F "LOGIN=$settings{'LOGIN'}\n";
|
||||
print F "INTERVAL=1\n";
|
||||
if ($settings{'HOSTNAME'} !~ s/$General::noipprefix//) {
|
||||
print F "HOSTNAME=$settings{'HOSTNAME'}\n";
|
||||
print F "GROUP=\n";
|
||||
} else {
|
||||
print F "HOSTNAME=\n";
|
||||
print F "GROUP=$settings{'HOSTNAME'}\n";
|
||||
}
|
||||
print F "DOMAIN=$settings{'DOMAIN'}\n";
|
||||
print F "DEVICE=\n";
|
||||
print F "DAEMON=N\n";
|
||||
close(F);
|
||||
|
||||
my @ddnscommand = ('/usr/bin/noip','-c',"${General::swroot}/ddns/noipsettings",'-i',"$ip");
|
||||
|
||||
my $result = system(@ddnscommand);
|
||||
if ( $result != 0) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
}
|
||||
|
||||
elsif ($settings{'SERVICE'} eq 'all-inkl') {
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https("dyndns.kasserver.com", 443, "/", Net::SSLeay::make_headers(
|
||||
'User-Agent' => 'IPFire', 'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}")
|
||||
));
|
||||
|
||||
# Valid response are 'ok' 'nochange'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server, check your credentials)");
|
||||
}
|
||||
}
|
||||
|
||||
elsif ($settings{'SERVICE'} eq 'cjb') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_http( 'www.cjb.net',
|
||||
80,
|
||||
"/cgi-bin/dynip.cgi?username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}&ip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/has been updated to point to/ ) {
|
||||
&General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : failure (bad password or login)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for cjb.net ($settings{'LOGIN'}) : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'selfhost') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'carol.selfhost.de',
|
||||
443,
|
||||
"/update?username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}&textmodi=1",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/status=(200|204)/ ) {
|
||||
$out =~ s/\n/ /g;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'dnspark') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( "www.dnspark.net",
|
||||
443,
|
||||
"/api/dynamic/update.php?hostname=$settings{'HOSTDOMAIN'}&ip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire',
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}")
|
||||
)
|
||||
);
|
||||
# Valid response are 'ok' 'nochange'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/^(ok|nochange)/ ) {
|
||||
$out =~ s/\n/ /g;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'dns.lightningwirelabs.com') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my $authstring;
|
||||
if ($settings{'LOGIN'} eq "token") {
|
||||
$authstring = "token=$settings{'PASSWORD'}";
|
||||
} else {
|
||||
$authstring = "username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}";
|
||||
}
|
||||
|
||||
my $user_agent = &General::MakeUserAgent();
|
||||
my ($out, $response) = Net::SSLeay::get_https("dns.lightningwirelabs.com", 443,
|
||||
"/update?hostname=$settings{'HOSTDOMAIN'}&address4=$ip&$authstring",
|
||||
Net::SSLeay::make_headers('User-Agent' => $user_agent)
|
||||
);
|
||||
|
||||
# Valid response are 'ok' 'nochange'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'enom') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_http( 'dynamic.name-services.com',
|
||||
80,
|
||||
"/interface.asp?Command=SetDNSHost&Zone=$settings{'DOMAIN'}&DomainPassword=$settings{'PASSWORD'}&Address=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
#Valid responses from update => ErrCount=0
|
||||
if ( $out !~ m/ErrCount=0/ ) {
|
||||
$out =~ s/(\n|\x0D)/ /g;
|
||||
$out =~ /Err1=([\w ]+) /;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($1)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'nsupdate') {
|
||||
# Fetch UI configurable values and assemble the host name.
|
||||
|
||||
my $hostName="$settings{'DOMAIN'}";
|
||||
if ($settings{'HOSTNAME'} ne "") {
|
||||
$hostName="$settings{'HOSTNAME'}.$hostName";
|
||||
}
|
||||
my $keyName=$settings{'LOGIN'};
|
||||
my $keySecret=$settings{'PASSWORD'};
|
||||
|
||||
# Use a relatively long TTL value to reduce load on DNS.
|
||||
# Some public Dynamic DNS servers use values around 4 hours,
|
||||
# some use values as low as 60 seconds.
|
||||
# XXX Maybe we could fetch the master value from the server
|
||||
# (not the timed-down version supplied by DNS cache)
|
||||
|
||||
my $timeToLive="3600";
|
||||
|
||||
# Internal setting that can be used to override the DNS server
|
||||
# where the update is applied. It can be of use when testing
|
||||
# against a private DNS server.
|
||||
|
||||
my $masterServer="";
|
||||
|
||||
# Prepare the nsupdate command script to remove and re-add the
|
||||
# updated A record for the domain.
|
||||
|
||||
my $cmdFile="/tmp/nsupdate-$hostName-commands";
|
||||
my $logFile="/tmp/nsupdate-$hostName-result";
|
||||
open(TF, ">$cmdFile");
|
||||
if ($masterServer ne "") {
|
||||
print TF "server $masterServer\n";
|
||||
}
|
||||
if ($keyName ne "" && $keySecret ne "") {
|
||||
print TF "key $keyName $keySecret\n";
|
||||
}
|
||||
print TF "update delete $hostName A\n";
|
||||
print TF "update add $hostName $timeToLive A $ip\n";
|
||||
print TF "send\n";
|
||||
close(TF);
|
||||
|
||||
# Run nsupdate with -v to use TCP instead of UDP because we're
|
||||
# issuing multiple cmds and potentially long keys, and -d to
|
||||
# get diagnostic result output.
|
||||
|
||||
my $result = system("/usr/bin/nsupdate -v -d $cmdFile 2>$logFile");
|
||||
if ($result != 0) {
|
||||
&General::log("Dynamic DNS ip-update for $hostName : failure");
|
||||
open(NSLOG, "$logFile");
|
||||
my @nsLog = <NSLOG>;
|
||||
close(NSLOG);
|
||||
my $logLine;
|
||||
foreach $logLine (@nsLog) {
|
||||
chomp($logLine);
|
||||
if ($logLine ne "") {
|
||||
&General::log("... $logLine");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $hostName : success");
|
||||
$success++;
|
||||
}
|
||||
unlink $cmdFile, $logFile;
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'freedns') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'freedns.afraid.org',
|
||||
443,
|
||||
"/dynamic/update.php?$settings{'LOGIN'}",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
#Valid responses from service are:
|
||||
#Updated n host(s) <domain>
|
||||
#ERROR: <ip> has not changed.
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
#Valid responses from update => ErrCount=0
|
||||
if ( $out !~ m/(^Updated|Address .* has not changed)/ig ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'spdns.de') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'update.spdns.de', 443,
|
||||
"/nic/update?&hostname=$settings{'HOSTDOMAIN'}&myip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' ,
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}"))
|
||||
);
|
||||
|
||||
#Valid responses from service are:
|
||||
# good xxx.xxx.xxx.xxx
|
||||
# nochg xxx.xxx.xxx.xxx
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ($out !~ m/good |nochg /ig) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'strato') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'dyndns.strato.com',
|
||||
443,
|
||||
"/nic/update?hostname=$settings{'HOSTDOMAIN'}&myip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire',
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}") )
|
||||
);
|
||||
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
#Valid responses from update => ErrCount=0
|
||||
if ( $out =~ m/good |nochg /ig) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure1 ($out)");
|
||||
$success++;
|
||||
}
|
||||
} elsif ( $out =~ m/<title>(.*)<\/title>/ig ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure2 ($1)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure3 ($response)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'regfish') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'dyndns.regfish.de',
|
||||
443,
|
||||
"/?fqdn=$settings{'DOMAIN'}&ipv4=$ip&forcehost=1&authtype=secure&token=$settings{'LOGIN'}",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'Ipfire' )
|
||||
);
|
||||
#Valid responses from service are:
|
||||
#success|100|update succeeded!
|
||||
#success|101|no update needed at this time..
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/(success\|(100|101)\|)/ig ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'ovh') {
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
|
||||
my $peer = 'www.ovh.com';
|
||||
my $peerport = 80;
|
||||
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
}
|
||||
|
||||
my $sock;
|
||||
unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) {
|
||||
&General::log("Dynamic DNS failure : could not connect to $peer:$peerport: $@");
|
||||
next;
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($GET_CMD, $code64);
|
||||
$GET_CMD = "GET http://www.ovh.com/nic/update?system=dyndns&hostname=$settings{'HOSTDOMAIN'}&myip=$ip HTTP/1.1\r\n";
|
||||
$GET_CMD .= "Host: www.ovh.com\r\n";
|
||||
chomp($code64 = encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}"));
|
||||
$GET_CMD .= "Authorization: Basic $code64\r\n";
|
||||
$GET_CMD .= "User-Agent: ipfire\r\n";
|
||||
#$GET_CMD .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$GET_CMD .= "\r\n";
|
||||
print $sock "$GET_CMD";
|
||||
|
||||
my $out = '';
|
||||
while(<$sock>) {
|
||||
$out .= $_;
|
||||
}
|
||||
close($sock);
|
||||
|
||||
#HTTP response => error (in Title tag) else text response
|
||||
#Valid responses from service:good,nochg (ez-ipupdate like)
|
||||
#Should use ez-ipdate but "system=dyndns" is not present
|
||||
if ( $out =~ m/<Title>(.*)<\/Title>/ig ) {
|
||||
&General::log("Dynamic DNS ovh.com : failure ($1)");
|
||||
}
|
||||
elsif ($out !~ m/good |nochg /ig) {
|
||||
$out =~ s/.+?\015?\012\015?\012//s; # header HTTP
|
||||
my @out = split("\r", $out);
|
||||
&General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : failure ($out[1])");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'dtdns') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_http( 'www.dtdns.com',
|
||||
80,
|
||||
"/api/autodns.cfm?id=$settings{'HOSTDOMAIN'}&pw=$settings{'PASSWORD'}",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
#Valid responses from service are:
|
||||
# now points to
|
||||
#
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/Host .* now points to/ig ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
#namecheap test
|
||||
elsif ($settings{'SERVICE'} eq 'namecheap') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'dynamicdns.park-your-domain.com',
|
||||
443,
|
||||
"/update?host=$settings{'HOSTNAME'}&domain=$settings{'DOMAIN'}&password=$settings{'PASSWORD'}&ip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
#Valid responses from service are:
|
||||
# wait confirmation!!
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/<ErrCount>0<\/ErrCount>/ ) {
|
||||
$out =~ m/<Err1>(.*)<\/Err1>/;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($1)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
#end namecheap test
|
||||
elsif ($settings{'SERVICE'} eq 'dynu') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_http( 'dynserv.ca',
|
||||
80,
|
||||
"/dyn/dynengine.cgi?func=set&name=$settings{'LOGIN'}&pass=$settings{'PASSWORD'}&ip=$ip&domain=$settings{'DOMAIN'}",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire' )
|
||||
);
|
||||
#Valid responses from service are:
|
||||
# 02 == Domain already exists, refreshing data for ... => xxx.xxx.xxx.xxx
|
||||
#
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/Domain already exists, refreshing data for/ig ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'udmedia') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'www.udmedia.de',
|
||||
443,
|
||||
"/nic/update?myip=$ip&username=$settings{'HOSTDOMAIN'}&password=$settings{'PASSWORD'}",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire',
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}")) );
|
||||
|
||||
# Valid response are 'ok' 'nochange'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/^(ok|nochg)/ ) {
|
||||
$out =~ s/\n/ /g;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials---$out-$response--)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'twodns') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'update.twodns.de',
|
||||
443,
|
||||
"/update?hostname=$settings{'HOSTDOMAIN'}&ip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire',
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}")) );
|
||||
|
||||
# Valid response are 'ok' 'nochange'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/^(good|nochg)/ ) {
|
||||
$out =~ s/\n/ /g;
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials---$out-$response--)");
|
||||
}
|
||||
}
|
||||
elsif ($settings{'SERVICE'} eq 'variomedia') {
|
||||
# use proxy ?
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
my ($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
Net::SSLeay::set_proxy($peer,$peerport,$proxysettings{'UPSTREAM_USER'},$proxysettings{'UPSTREAM_PASSWORD'} );
|
||||
}
|
||||
|
||||
if ($settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my ($out, $response) = Net::SSLeay::get_https( 'dyndns.variomedia.de',
|
||||
443,
|
||||
"/nic/update?hostname=$settings{'HOSTDOMAIN'}&myip=$ip",
|
||||
Net::SSLeay::make_headers('User-Agent' => 'IPFire',
|
||||
'Authorization' => 'Basic ' . encode_base64("$settings{'LOGIN'}:$settings{'PASSWORD'}")) );
|
||||
|
||||
# Valid response is 'good $ip'
|
||||
if ($response =~ m%HTTP/1\.. 200 OK%) {
|
||||
if ( $out !~ m/^good $ip/ ) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} ($ip) : failure ($out)");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} ($ip) : success");
|
||||
$success++;
|
||||
}
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'} : failure (could not connect to server, check your credentials---$out-$response--)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($settings{'WILDCARDS'} eq 'on') {
|
||||
$settings{'WILDCARDS'} = '-w';
|
||||
} else {
|
||||
$settings{'WILDCARDS'} = '';
|
||||
}
|
||||
|
||||
if (($settings{'SERVICE'} eq 'dyndns-custom' ||
|
||||
$settings{'SERVICE'} eq 'easydns' ||
|
||||
$settings{'SERVICE'} eq 'zoneedit') && $settings{'HOSTNAME'} eq '') {
|
||||
$settings{'HOSTDOMAIN'} = $settings{'DOMAIN'};
|
||||
} else {
|
||||
$settings{'HOSTDOMAIN'} = "$settings{'HOSTNAME'}.$settings{'DOMAIN'}";
|
||||
}
|
||||
|
||||
my @ddnscommand = ('/usr/bin/ez-ipupdate', '-a', "$ip", '-S', "$settings{'SERVICE'}", '-u', "$settings{'LOGIN'}:$settings{'PASSWORD'}", '-h', "$settings{'HOSTDOMAIN'}", "$settings{'WILDCARDS'}", '-q');
|
||||
|
||||
my $result = system(@ddnscommand);
|
||||
if ( $result != 0) {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'}: failure");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTDOMAIN'}: success");
|
||||
$success++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# If a line is disabled, then we should discount it
|
||||
$lines--;
|
||||
}
|
||||
}
|
||||
|
||||
if ($lines == $success) {
|
||||
open(IPCACHE, ">$cachefile");
|
||||
flock IPCACHE, 2;
|
||||
print IPCACHE $ip;
|
||||
close(IPCACHE);
|
||||
exit 1;
|
||||
}
|
||||
|
||||
}
|
||||
exit 0;
|
||||
|
||||
# Extracted from Base64.pm
|
||||
sub encode_base64 ($;$) {
|
||||
my $res = "";
|
||||
my $eol = $_[1];
|
||||
$eol = "\n" unless defined $eol;
|
||||
pos($_[0]) = 0; # ensure start at the beginning
|
||||
while ($_[0] =~ /(.{1,45})/gs) {
|
||||
$res .= substr(pack('u', $1), 1);
|
||||
chop($res);
|
||||
}
|
||||
$res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
|
||||
# fix padding at the end
|
||||
my $padding = (3 - length($_[0]) % 3) % 3;
|
||||
$res =~ s/.{$padding}$/'=' x $padding/e if $padding;
|
||||
# break encoded string into lines of no more than 76 characters each
|
||||
if (length $eol) {
|
||||
$res =~ s/(.{1,76})/$1$eol/g;
|
||||
}
|
||||
$res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
__END__
|
||||
old code for selfhost.de
|
||||
|
||||
my %proxysettings;
|
||||
&General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
|
||||
|
||||
my $peer = 'carol.selfhost.de';
|
||||
my $peerport = 80;
|
||||
|
||||
if ($_=$proxysettings{'UPSTREAM_PROXY'}) {
|
||||
($peer, $peerport) = (/^(?:[a-zA-Z ]+\:\/\/)?(?:[A-Za-z0-9\_\.\-]*?(?:\:[A-Za-z0-9\_\.\-]*?)?\@)?([a-zA-Z0-9\.\_\-]*?)(?:\:([0-9]{1,5}))?(?:\/.*?)?$/);
|
||||
}
|
||||
|
||||
my $sock;
|
||||
unless($sock = new IO::Socket::INET (PeerAddr => $peer, PeerPort => $peerport, Proto => 'tcp', Timeout => 5)) {
|
||||
die "Could not connect to $peer:$peerport: $@";
|
||||
return 1;
|
||||
}
|
||||
|
||||
my $GET_CMD;
|
||||
$GET_CMD = "GET https://carol.selfhost.de/update?username=$settings{'LOGIN'}&password=$settings{'PASSWORD'}&myip=$ip&textmodi=1 HTTP/1.1\r\n";
|
||||
$GET_CMD .= "Host: carol.selfhost.de\r\n";
|
||||
$GET_CMD .= "User-Agent: ipfire\r\n";
|
||||
$GET_CMD .= "Connection: close\r\n\r\n";
|
||||
print $sock "$GET_CMD";
|
||||
|
||||
my $out = '';
|
||||
while(<$sock>) {
|
||||
$out .= $_;
|
||||
}
|
||||
close($sock);
|
||||
|
||||
if ( $out !~ m/status=(200|204)/ ) {
|
||||
#cleanup http response...
|
||||
$out =~ s/.+?\015?\012\015?\012//s; # header HTTP
|
||||
my @out = split("\r", $out);
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : failure ($out[1])");
|
||||
} else {
|
||||
&General::log("Dynamic DNS ip-update for $settings{'HOSTNAME'}.$settings{'DOMAIN'} : success");
|
||||
$success++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user