packages/net/ez-ipupdate/patches/002-ez_ipupdate_everydns.patch

210 lines
5.0 KiB
Diff
Raw Normal View History

diff -Naur ez-ipupdate-3.0.11b7/ez-ipupdate.c ez-ipupdate-3.0.11b7-sr1/ez-ipupdate.c
--- ez-ipupdate-3.0.11b7/ez-ipupdate.c 2002-03-12 01:31:47.000000000 +0200
+++ ez-ipupdate-3.0.11b7-sr1/ez-ipupdate.c 2006-10-08 17:51:40.000000000 +0200
@@ -103,6 +103,11 @@
#define HEIPV6TB_DEFAULT_PORT "80"
#define HEIPV6TB_REQUEST "/index.cgi"
+#define EVERYDNS_DEFAULT_SERVER "dyn.everydns.net"
+#define EVERYDNS_DEFAULT_PORT "80"
+#define EVERYDNS_REQUEST "/index.php"
+#define EVERYDNS_VERSION "0.1"
+
#define DEFAULT_TIMEOUT 120
#define DEFAULT_UPDATE_PERIOD 120
#define DEFAULT_RESOLV_PERIOD 30
@@ -341,6 +346,10 @@
int HEIPV6TB_check_info(void);
static char *HEIPV6TB_fields_used[] = { "server", "user", NULL };
+int EVERYDNS_update_entry(void);
+int EVERYDNS_check_info(void);
+static char *EVERYDNS_fields_used[] = { "server", "user", "host", "address", NULL };
+
struct service_t services[] = {
{ "NULL",
{ "null", "NULL", 0, },
@@ -514,6 +523,16 @@
HEIPV6TB_DEFAULT_PORT,
HEIPV6TB_REQUEST
},
+ { "everydns",
+ { "everydns", 0, 0, },
+ NULL,
+ EVERYDNS_update_entry,
+ EVERYDNS_check_info,
+ EVERYDNS_fields_used,
+ EVERYDNS_DEFAULT_SERVER,
+ EVERYDNS_DEFAULT_PORT,
+ EVERYDNS_REQUEST
+ },
};
static struct service_t *service = NULL;
@@ -4246,6 +4265,165 @@
return(UPDATERES_OK);
}
+int EVERYDNS_check_info(void)
+{
+ warn_fields(service->fields_used);
+
+ return 0;
+}
+
+int EVERYDNS_update_entry(void)
+{
+ char buf[BUFFER_SIZE+1];
+ char *bp = buf;
+ int bytes;
+ int btot;
+ int ret;
+
+ buf[BUFFER_SIZE] = '\0';
+
+ if(do_connect((int*)&client_sockfd, server, port) != 0)
+ {
+ if(!(options & OPT_QUIET))
+ {
+ show_message("error connecting to %s:%s\n", server, port);
+ }
+ return(UPDATERES_ERROR);
+ }
+
+ snprintf(buf, BUFFER_SIZE, "GET %s?ver=%s&", request, EVERYDNS_VERSION);
+ output(buf);
+ if(address)
+ {
+ snprintf(buf, BUFFER_SIZE, "%s=%s&", "ip", address);
+ output(buf);
+ }
+ if((host != NULL) && (*host == '\0'))
+ {
+ snprintf(buf, BUFFER_SIZE, "%s=%s&", "domain", host);
+ output(buf);
+ }
+ snprintf(buf, BUFFER_SIZE, " HTTP/1.0\015\012");
+ output(buf);
+ snprintf(buf, BUFFER_SIZE, "Authorization: Basic %s\015\012", auth);
+ output(buf);
+ snprintf(buf, BUFFER_SIZE, "User-Agent: %s-%s %s [%s] (%s)\015\012",
+ "ez-update", VERSION, OS, (options & OPT_DAEMON) ? "daemon" : "", "by Angus Mackay");
+ output(buf);
+ snprintf(buf, BUFFER_SIZE, "Host: %s\015\012", server);
+ output(buf);
+ snprintf(buf, BUFFER_SIZE, "\015\012");
+ output(buf);
+
+ bp = buf;
+ bytes = 0;
+ btot = 0;
+ while((bytes=read_input(bp, BUFFER_SIZE-btot)) > 0)
+ {
+ bp += bytes;
+ btot += bytes;
+ dprintf((stderr, "btot: %d\n", btot));
+ }
+ close(client_sockfd);
+ buf[btot] = '\0';
+
+ dprintf((stderr, "server output: %s\n", buf));
+
+ if(sscanf(buf, " HTTP/1.%*c %3d", &ret) != 1)
+ {
+ ret = -1;
+ }
+
+ switch(ret)
+ {
+ char *p;
+
+ case -1:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("strange server response, are you connecting to the right server?\n");
+ }
+ return(UPDATERES_ERROR);
+ break;
+
+ case 200:
+ ret = -1;
+ if((p=strstr(buf, "Exit code: ")) != NULL)
+ {
+ sscanf(p, "Exit code: %d", &ret);
+ }
+
+ /*
+ * 0 - Successfully Updated
+ */
+ switch(ret)
+ {
+ case -1:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("strange server response, are you connecting to the right server?\n");
+ }
+ return(UPDATERES_ERROR);
+ break;
+
+ case 0:
+ if(!(options & OPT_QUIET))
+ {
+ printf("request successful\n");
+ }
+ break;
+
+ case 2:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("Bad Username/password\n");
+ }
+ return(UPDATERES_SHUTDOWN);
+ break;
+
+ case 5:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("Last update too recent, please wait...\n");
+ }
+ return(UPDATERES_ERROR);
+ break;
+
+ default:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("unknown return code: %d\n", ret);
+ fprintf(stderr, "server response: %s\n", buf);
+ }
+ return(UPDATERES_ERROR);
+ break;
+ }
+ break;
+
+ case 401:
+ if(!(options & OPT_QUIET))
+ {
+ show_message("authentication failure\n");
+ }
+ return(UPDATERES_SHUTDOWN);
+ break;
+
+ default:
+ if(!(options & OPT_QUIET))
+ {
+ // reuse the auth buffer
+ *auth = '\0';
+ sscanf(buf, " HTTP/1.%*c %*3d %255[^\r\n]", auth);
+ show_message("unknown return code: %d\n", ret);
+ fprintf(stderr, "server response: %s\n", auth);
+ }
+ return(UPDATERES_ERROR);
+ break;
+ }
+
+ return(UPDATERES_OK);
+}
+
static int is_in_list(char *needle, char **haystack)
{
char **p;