]> git.pld-linux.org Git - packages/ez-ipupdate.git/blob - 002-ez_ipupdate_everydns.patch
- rel 6; fixes from debian and new services from openwrt
[packages/ez-ipupdate.git] / 002-ez_ipupdate_everydns.patch
1 diff -Naur ez-ipupdate-3.0.11b7/ez-ipupdate.c ez-ipupdate-3.0.11b7-sr1/ez-ipupdate.c
2 --- ez-ipupdate-3.0.11b7/ez-ipupdate.c  2002-03-12 01:31:47.000000000 +0200
3 +++ ez-ipupdate-3.0.11b7-sr1/ez-ipupdate.c      2006-10-08 17:51:40.000000000 +0200
4 @@ -103,6 +103,11 @@
5  #define HEIPV6TB_DEFAULT_PORT "80"
6  #define HEIPV6TB_REQUEST "/index.cgi"
7  
8 +#define EVERYDNS_DEFAULT_SERVER "dyn.everydns.net"
9 +#define EVERYDNS_DEFAULT_PORT "80"
10 +#define EVERYDNS_REQUEST "/index.php"
11 +#define EVERYDNS_VERSION "0.1"
12 +
13  #define DEFAULT_TIMEOUT 120
14  #define DEFAULT_UPDATE_PERIOD 120
15  #define DEFAULT_RESOLV_PERIOD 30
16 @@ -341,6 +346,10 @@
17  int HEIPV6TB_check_info(void);
18  static char *HEIPV6TB_fields_used[] = { "server", "user", NULL };
19  
20 +int EVERYDNS_update_entry(void);
21 +int EVERYDNS_check_info(void);
22 +static char *EVERYDNS_fields_used[] = { "server", "user", "host", "address", NULL };
23 +
24  struct service_t services[] = {
25    { "NULL",
26      { "null", "NULL", 0, },
27 @@ -514,6 +523,16 @@
28      HEIPV6TB_DEFAULT_PORT,
29      HEIPV6TB_REQUEST
30    },
31 +  { "everydns",
32 +    { "everydns", 0, 0, },
33 +    NULL,
34 +    EVERYDNS_update_entry,
35 +    EVERYDNS_check_info,
36 +    EVERYDNS_fields_used,
37 +    EVERYDNS_DEFAULT_SERVER,
38 +    EVERYDNS_DEFAULT_PORT,
39 +    EVERYDNS_REQUEST
40 +  },
41  };
42  
43  static struct service_t *service = NULL;
44 @@ -4246,6 +4265,165 @@
45    return(UPDATERES_OK);
46  }
47  
48 +int EVERYDNS_check_info(void)
49 +{
50 +  warn_fields(service->fields_used);
51 +
52 +  return 0;
53 +}
54 +
55 +int EVERYDNS_update_entry(void)
56 +{
57 +  char buf[BUFFER_SIZE+1];
58 +  char *bp = buf;
59 +  int bytes;
60 +  int btot;
61 +  int ret;
62 +
63 +  buf[BUFFER_SIZE] = '\0';
64 +
65 +  if(do_connect((int*)&client_sockfd, server, port) != 0)
66 +  {
67 +    if(!(options & OPT_QUIET))
68 +    {
69 +      show_message("error connecting to %s:%s\n", server, port);
70 +    }
71 +    return(UPDATERES_ERROR);
72 +  }
73 +
74 +  snprintf(buf, BUFFER_SIZE, "GET %s?ver=%s&", request, EVERYDNS_VERSION);
75 +  output(buf);
76 +  if(address)
77 +  {
78 +    snprintf(buf, BUFFER_SIZE, "%s=%s&", "ip", address);
79 +    output(buf);
80 +  }
81 +  if((host != NULL) && (*host == '\0'))
82 +  {
83 +    snprintf(buf, BUFFER_SIZE, "%s=%s&", "domain", host);
84 +    output(buf);
85 +  }
86 +  snprintf(buf, BUFFER_SIZE, " HTTP/1.0\015\012");
87 +  output(buf);
88 +  snprintf(buf, BUFFER_SIZE, "Authorization: Basic %s\015\012", auth);
89 +  output(buf);
90 +  snprintf(buf, BUFFER_SIZE, "User-Agent: %s-%s %s [%s] (%s)\015\012", 
91 +      "ez-update", VERSION, OS, (options & OPT_DAEMON) ? "daemon" : "", "by Angus Mackay");
92 +  output(buf);
93 +  snprintf(buf, BUFFER_SIZE, "Host: %s\015\012", server);
94 +  output(buf);
95 +  snprintf(buf, BUFFER_SIZE, "\015\012");
96 +  output(buf);
97 +
98 +  bp = buf;
99 +  bytes = 0;
100 +  btot = 0;
101 +  while((bytes=read_input(bp, BUFFER_SIZE-btot)) > 0)
102 +  {
103 +    bp += bytes;
104 +    btot += bytes;
105 +    dprintf((stderr, "btot: %d\n", btot));
106 +  }
107 +  close(client_sockfd);
108 +  buf[btot] = '\0';
109 +
110 +  dprintf((stderr, "server output: %s\n", buf));
111 +
112 +  if(sscanf(buf, " HTTP/1.%*c %3d", &ret) != 1)
113 +  {
114 +    ret = -1;
115 +  }
116 +
117 +  switch(ret)
118 +  {
119 +    char *p;
120 +
121 +    case -1:
122 +      if(!(options & OPT_QUIET))
123 +      {
124 +        show_message("strange server response, are you connecting to the right server?\n");
125 +      }
126 +      return(UPDATERES_ERROR);
127 +      break;
128 +
129 +    case 200:
130 +      ret = -1;
131 +      if((p=strstr(buf, "Exit code: ")) != NULL)
132 +      {
133 +         sscanf(p, "Exit code: %d", &ret);
134 +      }
135 +
136 +      /*
137 +       * 0 - Successfully Updated
138 +       */
139 +      switch(ret)
140 +      {
141 +        case -1:
142 +          if(!(options & OPT_QUIET))
143 +          {
144 +            show_message("strange server response, are you connecting to the right server?\n");
145 +          }
146 +          return(UPDATERES_ERROR);
147 +          break;
148 +
149 +        case 0:
150 +          if(!(options & OPT_QUIET))
151 +          {
152 +            printf("request successful\n");
153 +          }
154 +          break;
155 +
156 +        case 2:
157 +          if(!(options & OPT_QUIET))
158 +          {
159 +            show_message("Bad Username/password\n");
160 +          }
161 +          return(UPDATERES_SHUTDOWN);
162 +          break;
163 +          
164 +        case 5:
165 +          if(!(options & OPT_QUIET))
166 +          {
167 +            show_message("Last update too recent, please wait...\n");
168 +          }
169 +          return(UPDATERES_ERROR);
170 +          break;
171 +          
172 +        default:
173 +          if(!(options & OPT_QUIET))
174 +          {
175 +            show_message("unknown return code: %d\n", ret);
176 +            fprintf(stderr, "server response: %s\n", buf);
177 +          }
178 +          return(UPDATERES_ERROR);
179 +          break;
180 +      }
181 +      break;
182 +
183 +    case 401:
184 +      if(!(options & OPT_QUIET))
185 +      {
186 +        show_message("authentication failure\n");
187 +      }
188 +      return(UPDATERES_SHUTDOWN);
189 +      break;
190 +
191 +    default:
192 +      if(!(options & OPT_QUIET))
193 +      {
194 +        // reuse the auth buffer
195 +        *auth = '\0';
196 +        sscanf(buf, " HTTP/1.%*c %*3d %255[^\r\n]", auth);
197 +        show_message("unknown return code: %d\n", ret);
198 +        fprintf(stderr, "server response: %s\n", auth);
199 +      }
200 +      return(UPDATERES_ERROR);
201 +      break;
202 +  }
203 +
204 +  return(UPDATERES_OK);
205 +}
206 +
207  static int is_in_list(char *needle, char **haystack)
208  {
209    char **p;
This page took 0.089187 seconds and 3 git commands to generate.