|
Lines 103-108
Link Here
|
| 103 |
#define HEIPV6TB_DEFAULT_PORT "80" |
103 |
#define HEIPV6TB_DEFAULT_PORT "80" |
| 104 |
#define HEIPV6TB_REQUEST "/index.cgi" |
104 |
#define HEIPV6TB_REQUEST "/index.cgi" |
| 105 |
|
105 |
|
|
|
106 |
#define DNSEXIT_DEFAULT_SERVER "www.dnsexit.com" |
| 107 |
#define DNSEXIT_DEFAULT_PORT "80" |
| 108 |
#define DNSEXIT_REQUEST "/RemoteUpdate.sv" |
| 109 |
|
| 106 |
#define DEFAULT_TIMEOUT 120 |
110 |
#define DEFAULT_TIMEOUT 120 |
| 107 |
#define DEFAULT_UPDATE_PERIOD 120 |
111 |
#define DEFAULT_UPDATE_PERIOD 120 |
| 108 |
#define DEFAULT_RESOLV_PERIOD 30 |
112 |
#define DEFAULT_RESOLV_PERIOD 30 |
|
Lines 344-349
Link Here
|
| 344 |
int HEIPV6TB_check_info(void); |
348 |
int HEIPV6TB_check_info(void); |
| 345 |
static char *HEIPV6TB_fields_used[] = { "server", "user", NULL }; |
349 |
static char *HEIPV6TB_fields_used[] = { "server", "user", NULL }; |
| 346 |
|
350 |
|
|
|
351 |
int DNSEXIT_update_entry(void); |
| 352 |
int DNSEXIT_check_info(void); |
| 353 |
static char *DNSEXIT_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL }; |
| 354 |
|
| 355 |
|
| 347 |
struct service_t services[] = { |
356 |
struct service_t services[] = { |
| 348 |
{ "NULL", |
357 |
{ "NULL", |
| 349 |
{ "null", "NULL", 0, }, |
358 |
{ "null", "NULL", 0, }, |
|
Lines 517-522
Link Here
|
| 517 |
HEIPV6TB_DEFAULT_PORT, |
526 |
HEIPV6TB_DEFAULT_PORT, |
| 518 |
HEIPV6TB_REQUEST |
527 |
HEIPV6TB_REQUEST |
| 519 |
}, |
528 |
}, |
|
|
529 |
{ "dnsexit", |
| 530 |
{ "dnsexit", 0, 0, }, |
| 531 |
NULL, |
| 532 |
DNSEXIT_update_entry, |
| 533 |
DNSEXIT_check_info, |
| 534 |
DNSEXIT_fields_used, |
| 535 |
DNSEXIT_DEFAULT_SERVER, |
| 536 |
DNSEXIT_DEFAULT_PORT, |
| 537 |
DNSEXIT_REQUEST |
| 538 |
}, |
| 520 |
}; |
539 |
}; |
| 521 |
|
540 |
|
| 522 |
static struct service_t *service = NULL; |
541 |
static struct service_t *service = NULL; |
|
Lines 4251-4256
Link Here
|
| 4251 |
return(UPDATERES_OK); |
4270 |
return(UPDATERES_OK); |
| 4252 |
} |
4271 |
} |
| 4253 |
|
4272 |
|
|
|
4273 |
int DNSEXIT_check_info(void) |
| 4274 |
{ |
| 4275 |
char buf[BUFSIZ+1]; |
| 4276 |
|
| 4277 |
if((host == NULL) || (*host == '\0')) |
| 4278 |
{ |
| 4279 |
if(options & OPT_DAEMON) |
| 4280 |
{ |
| 4281 |
return(-1); |
| 4282 |
} |
| 4283 |
if(host) { free(host); } |
| 4284 |
printf("host: "); |
| 4285 |
*buf = '\0'; |
| 4286 |
fgets(buf, BUFSIZ, stdin); |
| 4287 |
host = strdup(buf); |
| 4288 |
chomp(host); |
| 4289 |
} |
| 4290 |
|
| 4291 |
if(interface == NULL && address == NULL) |
| 4292 |
{ |
| 4293 |
if(options & OPT_DAEMON) |
| 4294 |
{ |
| 4295 |
fprintf(stderr, "you must provide either an interface or an address\n"); |
| 4296 |
return(-1); |
| 4297 |
} |
| 4298 |
if(interface) { free(interface); } |
| 4299 |
printf("interface: "); |
| 4300 |
*buf = '\0'; |
| 4301 |
fgets(buf, BUFSIZ, stdin); |
| 4302 |
chomp(buf); |
| 4303 |
option_handler(CMD_interface, buf); |
| 4304 |
} |
| 4305 |
|
| 4306 |
warn_fields(service->fields_used); |
| 4307 |
|
| 4308 |
return 0; |
| 4309 |
} |
| 4310 |
|
| 4311 |
int DNSEXIT_update_entry(void) |
| 4312 |
{ |
| 4313 |
char buf[BUFFER_SIZE+1]; |
| 4314 |
char *bp = buf; |
| 4315 |
int bytes; |
| 4316 |
int btot; |
| 4317 |
int ret; |
| 4318 |
|
| 4319 |
buf[BUFFER_SIZE] = '\0'; |
| 4320 |
|
| 4321 |
if(do_connect((int*)&client_sockfd, server, port) != 0) |
| 4322 |
{ |
| 4323 |
if(!(options & OPT_QUIET)) |
| 4324 |
{ |
| 4325 |
show_message("error connecting to %s:%s\n", server, port); |
| 4326 |
} |
| 4327 |
return(UPDATERES_ERROR); |
| 4328 |
} |
| 4329 |
|
| 4330 |
snprintf(buf, BUFFER_SIZE, "GET %s?action=edit&", request); |
| 4331 |
output(buf); |
| 4332 |
if(address != NULL && *address != '\0') |
| 4333 |
{ |
| 4334 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "myip", address); |
| 4335 |
output(buf); |
| 4336 |
} |
| 4337 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "wildcard", wildcard ? "ON" : "OFF"); |
| 4338 |
output(buf); |
| 4339 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "mx", mx); |
| 4340 |
output(buf); |
| 4341 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "backmx", *mx == '\0' ? "NO" : "YES"); |
| 4342 |
output(buf); |
| 4343 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "host", host); |
| 4344 |
output(buf); |
| 4345 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "login", user_name); |
| 4346 |
output(buf); |
| 4347 |
snprintf(buf, BUFFER_SIZE, "%s=%s&", "password", password); |
| 4348 |
output(buf); |
| 4349 |
snprintf(buf, BUFFER_SIZE, " HTTP/1.0\015\012"); |
| 4350 |
output(buf); |
| 4351 |
snprintf(buf, BUFFER_SIZE, "Authorization: Basic %s\015\012", auth); |
| 4352 |
output(buf); |
| 4353 |
snprintf(buf, BUFFER_SIZE, "User-Agent: %s-%s %s [%s] (%s)\015\012", |
| 4354 |
"ez-update", VERSION, OS, (options & OPT_DAEMON) ? "daemon" : "", "by Angus Mackay"); |
| 4355 |
output(buf); |
| 4356 |
snprintf(buf, BUFFER_SIZE, "Host: %s\015\012", server); |
| 4357 |
output(buf); |
| 4358 |
snprintf(buf, BUFFER_SIZE, "\015\012"); |
| 4359 |
output(buf); |
| 4360 |
|
| 4361 |
bp = buf; |
| 4362 |
bytes = 0; |
| 4363 |
btot = 0; |
| 4364 |
while((bytes=read_input(bp, BUFFER_SIZE-btot)) > 0) |
| 4365 |
{ |
| 4366 |
bp += bytes; |
| 4367 |
btot += bytes; |
| 4368 |
dprintf((stderr, "btot: %d\n", btot)); |
| 4369 |
} |
| 4370 |
close(client_sockfd); |
| 4371 |
buf[btot] = '\0'; |
| 4372 |
|
| 4373 |
dprintf((stderr, "server output: %s\n", buf)); |
| 4374 |
|
| 4375 |
if(sscanf(buf, " HTTP/1.%*c %3d", &ret) != 1) |
| 4376 |
{ |
| 4377 |
ret = -1; |
| 4378 |
} |
| 4379 |
|
| 4380 |
switch(ret) |
| 4381 |
{ |
| 4382 |
case -1: |
| 4383 |
if(!(options & OPT_QUIET)) |
| 4384 |
{ |
| 4385 |
show_message("strange server response, are you connecting to the right server?\n"); |
| 4386 |
} |
| 4387 |
return(UPDATERES_ERROR); |
| 4388 |
break; |
| 4389 |
|
| 4390 |
case 200: |
| 4391 |
|
| 4392 |
if(strstr(buf, "0=Success") != NULL) |
| 4393 |
{ |
| 4394 |
if(!(options & OPT_QUIET)) |
| 4395 |
{ |
| 4396 |
printf("Request successful\n"); |
| 4397 |
} |
| 4398 |
} |
| 4399 |
else if(strstr(buf, "1=IP is the same as the IP on the system") != NULL) |
| 4400 |
{ |
| 4401 |
if(!(options & OPT_QUIET)) |
| 4402 |
{ |
| 4403 |
printf("Request successful but the IP is the same as previous update\n"); |
| 4404 |
} |
| 4405 |
} |
| 4406 |
else if(strstr(buf, "2=Invalid passwords") != NULL) |
| 4407 |
{ |
| 4408 |
if(!(options & OPT_QUIET)) |
| 4409 |
{ |
| 4410 |
printf("Invalid Password\n"); |
| 4411 |
} |
| 4412 |
} |
| 4413 |
else if(strstr(buf, "3=User not found") != NULL) |
| 4414 |
{ |
| 4415 |
if(!(options & OPT_QUIET)) |
| 4416 |
{ |
| 4417 |
printf("Username not found\n"); |
| 4418 |
} |
| 4419 |
} |
| 4420 |
else if(strstr(buf, "4=Update too often") != NULL) |
| 4421 |
{ |
| 4422 |
if(!(options & OPT_QUIET)) |
| 4423 |
{ |
| 4424 |
printf("Updatting too often\n"); |
| 4425 |
} |
| 4426 |
} |
| 4427 |
else |
| 4428 |
{ |
| 4429 |
show_message("Errors return from server\n"); |
| 4430 |
if(!(options & OPT_QUIET)) |
| 4431 |
{ |
| 4432 |
fprintf(stderr, "server output: %s\n", buf); |
| 4433 |
} |
| 4434 |
return(UPDATERES_ERROR); |
| 4435 |
} |
| 4436 |
break; |
| 4437 |
|
| 4438 |
case 401: |
| 4439 |
if(!(options & OPT_QUIET)) |
| 4440 |
{ |
| 4441 |
show_message("authentication failure\n"); |
| 4442 |
} |
| 4443 |
return(UPDATERES_SHUTDOWN); |
| 4444 |
break; |
| 4445 |
|
| 4446 |
default: |
| 4447 |
if(!(options & OPT_QUIET)) |
| 4448 |
{ |
| 4449 |
// reuse the auth buffer |
| 4450 |
*auth = '\0'; |
| 4451 |
sscanf(buf, " HTTP/1.%*c %*3d %255[^\r\n]", auth); |
| 4452 |
show_message("unknown return code: %d\n", ret); |
| 4453 |
show_message("server response: %s\n", auth); |
| 4454 |
} |
| 4455 |
return(UPDATERES_ERROR); |
| 4456 |
break; |
| 4457 |
} |
| 4458 |
|
| 4459 |
return(UPDATERES_OK); |
| 4460 |
} |
| 4461 |
|
| 4254 |
static int is_in_list(char *needle, char **haystack) |
4462 |
static int is_in_list(char *needle, char **haystack) |
| 4255 |
{ |
4463 |
{ |
| 4256 |
char **p; |
4464 |
char **p; |