From 85e269d867ed093ae8299884c75d1eeea07e7472 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sun, 13 Mar 2011 20:04:55 -0400 Subject: [PATCH] mdu: ddns: miniDNS support --- release/src/router/mdu/mdu.c | 54 ++++++++++++++++++++++++++++++++++- release/src/router/www/basic-ddns.asp | 1 + 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/release/src/router/mdu/mdu.c b/release/src/router/mdu/mdu.c index 78eaf5752e..cf742c2c74 100644 --- a/release/src/router/mdu/mdu.c +++ b/release/src/router/mdu/mdu.c @@ -45,7 +45,7 @@ #define M_UNKNOWN_ERROR__D "Unknown error (%d)." -#define M_UNKNOWN_RESPONSE__D "Unknown response (%d)." +#define M_UNKNOWN_RESPONSE__D "Unknown response (%d)." #define M_INVALID_HOST "Invalid hostname." #define M_INVALID_AUTH "Invalid authentication." #define M_INVALID_PARAM__D "Invalid parameter (%d)." @@ -1366,6 +1366,55 @@ static void update_everydns(void) error(M_UNKNOWN_ERROR__D, r); } + +/* + + miniDNS.net + http://www.minidns.net/areg.php?opcode=ADD&host=bar.minidns.net&username=foo&password=topsecret&ip=1.2.3.4 + + --- + +"okay. BAR.MINIDNS.NET mapped to 1.2.3.4." +"auth_fail. Incorrect username/password/hostname." +"auth_fail. Host name format error." + +*/ +static void update_minidns(void) +{ + int r; + char *body; + char query[2048]; + const char *p; + + // +opt +opt +opt + sprintf(query, "/areg.php?opcode=ADD&host=%s&username=%s&password=%s", + get_option_required("host"), + get_option_required("user"), + get_option_required("pass")); + + // +opt + append_addr_option(query, "&ip=%s"); + + r = wget(0, 0, "www.minidns.net", query, NULL, 1, &body); + if (r == 200) { + if (strstr(body, "okay.") != NULL) { + success(); + } + else if (strstr(body, "Host name format error") != NULL) { + error(M_INVALID_HOST); + } + else if (strstr(body, "auth_fail") != NULL) { + error(M_INVALID_AUTH); + } + else { + error(M_UNKNOWN_RESPONSE__D, -1); + } + } + + error(M_UNKNOWN_ERROR__D, r); +} + + /* editdns.net @@ -1760,6 +1809,9 @@ int main(int argc, char *argv[]) else if (strcmp(p, "editdns") == 0) { update_editdns(); } + else if (strcmp(p, "minidns") == 0) { + update_minidns(); + } else if (strcmp(p, "heipv6tb") == 0) { update_heipv6tb(); } diff --git a/release/src/router/www/basic-ddns.asp b/release/src/router/www/basic-ddns.asp index 6069ed6e9d..9f4b78010d 100644 --- a/release/src/router/www/basic-ddns.asp +++ b/release/src/router/www/basic-ddns.asp @@ -60,6 +60,7 @@ var services = [ ['seasydns', 'easyDNS (https)', 'http://www.easydns.com/', 'uhwm'], ['editdns', 'EditDNS', 'http://www.editdns.net/', 'tpz'], ['everydns', 'EveryDNS', 'http://www.everydns.net/', 'uj', null, null, 'Domain (optional)'], + ['minidns', 'miniDNS', 'http://www.minidns.net/', 'uh'], ['enom', 'eNom', 'http://www.enom.com/', 'ut', 'Domain'], ['afraid', 'FreeDNS (afraid.org)', 'http://freedns.afraid.org/', 'az'], ['heipv6tb', 'HE.net IPv6 Tunnel Broker', 'http://www.tunnelbroker.net/', 'uh', 'User ID (not your username)', null, 'Global Tunnel ID'], -- 2.11.4.GIT