summaryrefslogtreecommitdiff
blob: fd80485f0f4f00cb7ebafee75b54acb363b84a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
diff -Naur ez-ipupdate-3.0.11b8.orig/example-dnsexit.conf ez-ipupdate-3.0.11b8/example-dnsexit.conf
--- ez-ipupdate-3.0.11b8.orig/example-dnsexit.conf	1970-01-01 01:00:00.000000000 +0100
+++ ez-ipupdate-3.0.11b8/example-dnsexit.conf	2011-01-23 19:32:53.181937517 +0100
@@ -0,0 +1,19 @@
+#!/usr/sbin/ez-ipupdate -c
+#
+# example config file for ez-ipupdate
+#
+# this file is actually executable!
+#
+
+service-type=dnsexit
+user=loginname:password
+host=www.yourdomain.com
+interface=eth1
+
+run-as-user=ez-ipupd
+cache-file=/var/cache/ez-ipupdate/default-cache
+
+# uncomment this once you have everything working how you want and you are
+# ready to have ez-ipupdate running in the background all the time. to stop it
+# you can use "killall -QUIT ez-ipupdate" under linux.
+#daemon
diff -Naur ez-ipupdate-3.0.11b8.orig/ez-ipupdate.c ez-ipupdate-3.0.11b8/ez-ipupdate.c
--- ez-ipupdate-3.0.11b8.orig/ez-ipupdate.c	2011-01-23 19:32:53.074938936 +0100
+++ ez-ipupdate-3.0.11b8/ez-ipupdate.c	2011-01-23 19:32:53.182937505 +0100
@@ -103,6 +103,10 @@
 #define HEIPV6TB_DEFAULT_PORT "80"
 #define HEIPV6TB_REQUEST "/index.cgi"
 
+#define DNSEXIT_DEFAULT_SERVER "www.dnsexit.com"
+#define DNSEXIT_DEFAULT_PORT "80"
+#define DNSEXIT_REQUEST "/RemoteUpdate.sv"
+
 #define DEFAULT_TIMEOUT 120
 #define DEFAULT_UPDATE_PERIOD 120
 #define DEFAULT_RESOLV_PERIOD 30
@@ -341,6 +345,11 @@
 int HEIPV6TB_check_info(void);
 static char *HEIPV6TB_fields_used[] = { "server", "user", NULL };
 
+int DNSEXIT_update_entry(void);
+int DNSEXIT_check_info(void);
+static char *DNSEXIT_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL };
+
+
 struct service_t services[] = {
   { "NULL",
     { "null", "NULL", 0, },
@@ -514,6 +523,16 @@
     HEIPV6TB_DEFAULT_PORT,
     HEIPV6TB_REQUEST
   },
+  { "dnsexit",
+	{ "dnsexit", 0, 0, },
+	NULL,
+	DNSEXIT_update_entry,
+	DNSEXIT_check_info,
+	DNSEXIT_fields_used,
+	DNSEXIT_DEFAULT_SERVER,
+	DNSEXIT_DEFAULT_PORT,
+	DNSEXIT_REQUEST
+  },	  
 };
 
 static struct service_t *service = NULL;
@@ -4241,6 +4260,195 @@
       }
       return(UPDATERES_ERROR);
       break;
+  }
+
+  return(UPDATERES_OK);
+}
+
+int DNSEXIT_check_info(void)
+{
+  char buf[BUFSIZ+1];
+
+  if((host == NULL) || (*host == '\0'))
+  {
+    if(options & OPT_DAEMON)
+    {
+      return(-1);
+    }
+    if(host) { free(host); }
+    printf("host: ");
+    *buf = '\0';
+    fgets(buf, BUFSIZ, stdin);
+    host = strdup(buf);
+    chomp(host);
+  }
+
+  if(interface == NULL && address == NULL)
+  {
+    if(options & OPT_DAEMON)
+    {
+      fprintf(stderr, "you must provide either an interface or an address\n");
+      return(-1);
+    }
+    if(interface) { free(interface); }
+    printf("interface: ");
+    *buf = '\0';
+    fgets(buf, BUFSIZ, stdin);
+    chomp(buf);
+    option_handler(CMD_interface, buf);
+  }
+
+  warn_fields(service->fields_used);
+
+  return 0;
+}
+
+int DNSEXIT_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?action=edit&", request);
+  output(buf);
+  if(address != NULL && *address != '\0')
+  {
+    snprintf(buf, BUFFER_SIZE, "%s=%s&", "myip", address);
+    output(buf);
+  }
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "wildcard", wildcard ? "ON" : "OFF");
+  output(buf);
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "mx", mx);
+  output(buf);
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "backmx", *mx == '\0' ? "NO" : "YES");
+  output(buf);
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "host", host);
+  output(buf);
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "login", user_name);
+  output(buf);
+  snprintf(buf, BUFFER_SIZE, "%s=%s&", "password", password);
+  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)
+  {
+    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:
+
+      if(strstr(buf, "0=Success") != NULL)
+      {
+        if(!(options & OPT_QUIET))
+        {
+          printf("Request successful\n");
+        }
+      }
+      else if(strstr(buf, "1=IP is the same as the IP on the system") != NULL)
+      {
+        if(!(options & OPT_QUIET))
+        {
+          printf("Request successful but the IP is the same as previous update\n");
+        }
+      }
+      else if(strstr(buf, "2=Invalid passwords") != NULL)
+      {
+        if(!(options & OPT_QUIET))
+        {
+          printf("Invalid Password\n");
+        }
+      }
+      else if(strstr(buf, "3=User not found") != NULL)
+      {
+        if(!(options & OPT_QUIET))
+        {
+          printf("Username not found\n");
+        }
+      }
+      else if(strstr(buf, "4=Update too often") != NULL)
+      {
+        if(!(options & OPT_QUIET))
+        {
+          printf("Updatting too often\n");
+        }
+      }
+      else
+      {
+        show_message("Errors return from server\n");
+        if(!(options & OPT_QUIET))
+        {
+          fprintf(stderr, "server output: %s\n", buf);
+        }
+        return(UPDATERES_ERROR);
+      }
+      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);
+        show_message("server response: %s\n", auth);
+      }
+      return(UPDATERES_ERROR);
+      break;
   }
 
   return(UPDATERES_OK);