⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ez-ipupdate.c

📁 Connect DDNS Client Use GNUDIP
💻 C
📖 第 1 页 / 共 5 页
字号:
/* ============================================================================ * Copyright (C) 1998-2000 Angus Mackay. All rights reserved;  * * 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; either version 2, or (at your option) * any later version. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ============================================================================ *//* * ez-ipupdate * * a very simple dynDNS client for the ez-ip dynamic dns service  * (http://www.ez-ip.net). * * why this program when something like: *   curl -u user:pass http://www.ez-ip.net/members/update/?key=val&... * would do the trick? because there are nicer clients for other OSes and * I don't like to see UNIX get the short end of the stick. * * tested under Linux and Solaris. *  */#ifdef HAVE_CONFIG_H#  include <config.h>#endif// you man very well need to edit this, don't worry though, email is only sent// if bad things happend and it has to exit when in daemon mode.#define SEND_EMAIL_CMD "mail"#define EZIP_DEFAULT_SERVER "www.EZ-IP.Net"#define EZIP_DEFAULT_PORT "80"#define EZIP_REQUEST "/members/update/"#define PGPOW_DEFAULT_SERVER "www.penguinpowered.com"#define PGPOW_DEFAULT_PORT "2345"#define PGPOW_REQUEST "update"#define PGPOW_VERSION "1.0"#define DHS_DEFAULT_SERVER "members.dhs.org"#define DHS_DEFAULT_PORT "80"#define DHS_REQUEST "/nic/hosts"#define DHS_SUCKY_TIMEOUT 60#define DYNDNS_DEFAULT_SERVER "members.dyndns.org"#define DYNDNS_DEFAULT_PORT "80"#define DYNDNS_REQUEST "/nic/update"#define DYNDNS_STAT_REQUEST "/nic/update"#define DYNDNS_MAX_INTERVAL (25*24*3600)#define QDNS_DEFAULT_SERVER "members.3322.org"#define QDNS_DEFAULT_PORT "80"#define QDNS_REQUEST "/dyndns/update"#define QDNS_STAT_REQUEST "/dyndns/update"#define QDNS_MAX_INTERVAL (25*24*3600)#define ODS_DEFAULT_SERVER "update.ods.org"#define ODS_DEFAULT_PORT "7070"#define ODS_REQUEST "update"#define TZO_DEFAULT_SERVER "cgi.tzo.com"#define TZO_DEFAULT_PORT "80"#define TZO_REQUEST "/webclient/signedon.html"#define GNUDIP_DEFAULT_SERVER ""#define GNUDIP_DEFAULT_PORT "3495"#define GNUDIP_REQUEST "0"#define EASYDNS_DEFAULT_SERVER "members.easydns.com"#define EASYDNS_DEFAULT_PORT "80"#define EASYDNS_REQUEST "/dyn/ez-ipupdate.php"#define JUSTL_DEFAULT_SERVER "www.justlinux.com"#define JUSTL_DEFAULT_PORT "80"#define JUSTL_REQUEST "/bin/controlpanel/dyndns/jlc.pl"#define JUSTL_VERSION "2.0"#define DYNS_DEFAULT_SERVER "www.dyns.cx"#define DYNS_DEFAULT_PORT "80"#define DYNS_REQUEST "/postscript.php"#define HN_DEFAULT_SERVER "www.hn.org"#define HN_DEFAULT_PORT "80"#define HN_REQUEST "/vanity/update"#define ZONEEDIT_DEFAULT_SERVER "www.zoneedit.com"#define ZONEEDIT_DEFAULT_PORT "80"#define ZONEEDIT_REQUEST "/auth/dynamic.html"#ifdef USE_MD5#  define SERVICES_STR "qdns, ezip, pgpow, dhs, dyndns, dyndns-static, ods, tzo, gnudip, easydns, justlinux, dyns, hn, zoneedit"#  define SERVICES_HELP_STR "qdns, qdns-static, \n\t\t\t\t ezip, pgpow, dhs, dyndns, \n\t\t\t\tdyndns-static, ods, tzo, gnudip, easydns, \n\t\t\t\tjustlinux, dyns, hn, zoneedit"#else#  define SERVICES_STR "qdns, ezip, pgpow, dhs, dyndns, dyndns-static, ods, tzo, easydns, justlinux, dyns, hn, zoneedit"#  define SERVICES_HELP_STR "qdns, qdns-static, \n\t\t\t\t ezip, pgpow, dhs, dyndns, \n\t\t\t\tdyndns-static, ods, tzo, easydns, \n\t\t\t\tjustlinux, dyns, hn, zoneedit"#endif#define DEFAULT_TIMEOUT 120#define DEFAULT_UPDATE_PERIOD 120#define DEFAULT_RESOLV_PERIOD 30#ifdef DEBUG#  define BUFFER_SIZE (16*1024)#else#  define BUFFER_SIZE (4*1024-1)#endif#ifdef HAVE_GETOPT_H#  include <getopt.h>#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <unistd.h>#if HAVE_FCNTL_H#  include <fcntl.h>#endif#include <netinet/in.h>#if HAVE_ARPA_INET_H#  include <arpa/inet.h>#endif#if HAVE_ERRNO_H#  include <errno.h>#endif#include <netdb.h>#include <sys/socket.h>#if HAVE_SYS_TYPES_H#  include <sys/types.h>#endif#if HAVE_SIGNAL_H#  include <signal.h>#endif#if HAVE_SYS_TIME_H#  include <sys/time.h>#endif#if HAVE_SYS_WAIT_H#  include <sys/wait.h>#endif#if HAVE_SYSLOG_H#  include <syslog.h>#endif#if HAVE_STDARG_H#  include <stdarg.h>#endif#include <error.h>#if HAVE_PWD_H && HAVE_GRP_H#  include <pwd.h>#  include <grp.h>#endif#if defined(HAVE_FORK) && !defined(HAVE_VFORK)#  define vfork fork#endif#if USE_MD5#  include <md5.h>#  define MD5_DIGEST_BYTES (16)#endif#if __linux__ || __SVR4 || __OpenBSD__ || __FreeBSD__ || __NetBSD__#  define IF_LOOKUP 1#  include <sys/ioctl.h>#  include <net/if.h>#  ifdef HAVE_SYS_SOCKIO_H#    include <sys/sockio.h>#  endif#endif#include <dprintf.h>#include <conf_file.h>#include <cache_file.h>#include <pid_file.h>#if !defined(__GNUC__) && !defined(HAVE_SNPRINTF)#error "get gcc, fix this code, or find yourself a snprintf!"#else#  if HAVE_SNPRINTF#    define  snprintf(x, y, z...) snprintf(x, y, ## z)#  else#    define  snprintf(x, y, z...) sprintf(x, ## z)#  endif#endif#if HAVE_VSNPRINTF#  define  vsnprintf(x, y, z...) vsnprintf(x, y, ## z)#else#  define  vsnprintf(x, y, z...) vsprintf(x, ## z)#endif#ifndef HAVE_HERROR#  define herror(x) fprintf(stderr, "%s: error\n", x)#endif#define N_STR(x) (x == NULL ? "" : x)#ifndef OS#  define OS "unknown"#endif// the min period for checking the interface#define MIN_UPDATE_PERIOD 10// the min/max time to wait if we fail to update#define MIN_WAIT_PERIOD 300#define MAX_WAIT_PERIOD (2*3600)// the min time that max-period can be set to#define MIN_MAXINTERVAL (24*3600)// the max time we will wait if the server tells us to#define MAX_WAITRESPONSE_WAIT (24*3600)#define MAX_MESSAGE_LEN 256#define ARGLENGTH 32/**************************************************/enum {  SERV_NULL,  SERV_EZIP,  SERV_PGPOW,  SERV_DHS,  SERV_DYNDNS,  SERV_DYNDNS_STAT,  SERV_QDNS,  SERV_QDNS_STAT,  SERV_ODS,  SERV_TZO,  SERV_GNUDIP,  SERV_EASYDNS,  SERV_JUSTL,  SERV_DYNS,  SERV_HN,  SERV_ZONEEDIT,};struct service_t{  int type;  char *name;  void (*init)(void);  int (*update_entry)(void);  int (*check_info)(void);  char **fields_used;  char *default_server;  char *default_port;  char *default_request;};enum {  UPDATERES_OK = 0,  UPDATERES_ERROR,  UPDATERES_SHUTDOWN,};/**************************************************/char *program_name = NULL;char *cache_file = NULL;char *config_file = NULL;char *server = NULL;char *port = NULL;char user[256];char auth[512];char user_name[128];char password[128];char *address = NULL;char *request = NULL;int wildcard = 0;char *mx = NULL;char *url = NULL;char *host = NULL;char *cloak_title = NULL;char *interface = NULL;int ntrys = 1;int update_period = DEFAULT_UPDATE_PERIOD;int resolv_period = DEFAULT_RESOLV_PERIOD;struct timeval timeout;int max_interval = 0;int service_set = 0;char *post_update_cmd = NULL;char *post_update_cmd_arg = NULL;int connection_type = 1;time_t last_update = 0;char *notify_email = NULL;char *pid_file = NULL;static volatile int client_sockfd;static volatile int last_sig = 0;/* service objects for various services */// this one is for when people don't configure a default service as build timeint NULL_check_info(void);static char *NULL_fields_used[] = { NULL };static struct service_t NULL_service = {  SERV_NULL,  "NULL",  NULL,  NULL,  NULL_check_info,  NULL_fields_used,  "",  "",  ""};int EZIP_update_entry(void);int EZIP_check_info(void);static char *EZIP_fields_used[] = { "server", "user", "address", "wildcard", "mx", "url", "host", NULL };static struct service_t EZIP_service = {  SERV_EZIP,  "ez-ip",  NULL,  EZIP_update_entry,  EZIP_check_info,  EZIP_fields_used,  EZIP_DEFAULT_SERVER,  EZIP_DEFAULT_PORT,  EZIP_REQUEST};int PGPOW_update_entry(void);int PGPOW_check_info(void);static char *PGPOW_fields_used[] = { "server", "host", NULL };static struct service_t PGPOW_service = {  SERV_PGPOW,  "justlinux v1.0 (penguinpowered)",  NULL,  PGPOW_update_entry,  PGPOW_check_info,  PGPOW_fields_used,  PGPOW_DEFAULT_SERVER,  PGPOW_DEFAULT_PORT,  PGPOW_REQUEST};int DHS_update_entry(void);int DHS_check_info(void);static char *DHS_fields_used[] = { "server", "user", "address", "wildcard", "mx", "url", "host", NULL };static struct service_t DHS_service = {  SERV_DHS,  "dhs",  NULL,  DHS_update_entry,  DHS_check_info,  DHS_fields_used,  DHS_DEFAULT_SERVER,  DHS_DEFAULT_PORT,  DHS_REQUEST};void DYNDNS_init(void);int DYNDNS_update_entry(void);int DYNDNS_check_info(void);static char *DYNDNS_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL };static struct service_t DYNDNS_service = {  SERV_DYNDNS,  "dyndns",  DYNDNS_init,  DYNDNS_update_entry,  DYNDNS_check_info,  DYNDNS_fields_used,  DYNDNS_DEFAULT_SERVER,  DYNDNS_DEFAULT_PORT,  DYNDNS_REQUEST};static char *DYNDNS_STAT_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL };static struct service_t DYNDNS_STAT_service = {  SERV_DYNDNS_STAT,  "dyndns-static",  DYNDNS_init,  DYNDNS_update_entry,  DYNDNS_check_info,  DYNDNS_STAT_fields_used,  DYNDNS_DEFAULT_SERVER,  DYNDNS_DEFAULT_PORT,  DYNDNS_STAT_REQUEST};static struct service_t QDNS_service = {  SERV_QDNS,  "qdns",  DYNDNS_init,  DYNDNS_update_entry,  DYNDNS_check_info,  DYNDNS_fields_used,  QDNS_DEFAULT_SERVER,  QDNS_DEFAULT_PORT,  QDNS_REQUEST};static struct service_t QDNS_STAT_service = {  SERV_QDNS_STAT,  "qdns-static",  DYNDNS_init,  DYNDNS_update_entry,  DYNDNS_check_info,  DYNDNS_STAT_fields_used,  QDNS_DEFAULT_SERVER,  QDNS_DEFAULT_PORT,  QDNS_STAT_REQUEST};int ODS_update_entry(void);int ODS_check_info(void);static char *ODS_fields_used[] = { "server", "host", "address", NULL };static struct service_t ODS_service = {  SERV_ODS,  "ods",  NULL,  ODS_update_entry,  ODS_check_info,  ODS_fields_used,  ODS_DEFAULT_SERVER,  ODS_DEFAULT_PORT,  ODS_REQUEST};int TZO_update_entry(void);int TZO_check_info(void);static char *TZO_fields_used[] = { "server", "user", "address", "host", "connection-type", NULL };static struct service_t TZO_service = {  SERV_TZO,  "tzo",  NULL,  TZO_update_entry,  TZO_check_info,  TZO_fields_used,  TZO_DEFAULT_SERVER,  TZO_DEFAULT_PORT,  TZO_REQUEST};int EASYDNS_update_entry(void);int EASYDNS_check_info(void);static char *EASYDNS_fields_used[] = { "server", "user", "address", "wildcard", "mx", "host", NULL };static struct service_t EASYDNS_service = {  SERV_EASYDNS,  "easydns",  NULL,  EASYDNS_update_entry,  EASYDNS_check_info,  EASYDNS_fields_used,  EASYDNS_DEFAULT_SERVER,  EASYDNS_DEFAULT_PORT,  EASYDNS_REQUEST};#ifdef USE_MD5int GNUDIP_update_entry(void);int GNUDIP_check_info(void);static char *GNUDIP_fields_used[] = { "server", "user", "host", "address", NULL };static struct service_t GNUDIP_service = {  SERV_GNUDIP,  "gnudip",  NULL,  GNUDIP_update_entry,  GNUDIP_check_info,  GNUDIP_fields_used,  GNUDIP_DEFAULT_SERVER,  GNUDIP_DEFAULT_PORT,  GNUDIP_REQUEST};#endifint JUSTL_update_entry(void);int JUSTL_check_info(void);static char *JUSTL_fields_used[] = { "server", "user", "host", NULL };static struct service_t JUSTL_service = {  SERV_JUSTL,  "justlinux v2.0 (penguinpowered)",  NULL,  JUSTL_update_entry,  JUSTL_check_info,  JUSTL_fields_used,  JUSTL_DEFAULT_SERVER,  JUSTL_DEFAULT_PORT,  JUSTL_REQUEST};int DYNS_update_entry(void);int DYNS_check_info(void);static char *DYNS_fields_used[] = { "server", "user", "host", NULL };static struct service_t DYNS_service = {  SERV_DYNS,  "dyns",  NULL,  DYNS_update_entry,  DYNS_check_info,  DYNS_fields_used,  DYNS_DEFAULT_SERVER,  DYNS_DEFAULT_PORT,  DYNS_REQUEST};int HN_update_entry(void);int HN_check_info(void);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -