1 commit 287b2bfe7bf5e0639da9227a8c7893ce40d298ae
2 Author: Stefan Schantl <stefan.schantl@ipfire.org>
3 Date: Wed Dec 2 20:31:19 2020 +0100
5 Add option to list provider with token support.
7 This option can be used to get a list of all known provider which support
8 a token based authentication method.
10 In order to provide this feature the provider details has been extended
11 to contain the information if a provider supports this authentication
14 Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
16 diff --git a/ddns.in b/ddns.in
19 index 0e377e7..538e4b0
22 @@ -49,6 +49,10 @@ def main():
23 p_list_providers = subparsers.add_parser("list-providers",
24 help=_("List all available providers"))
26 + # list-token-provider
27 + p_list_token_provider = subparsers.add_parser("list-token-provider",
28 + help=_("List all providers which supports authentication via token"))
31 p_update = subparsers.add_parser("update", help=_("Update DNS record"))
32 p_update.add_argument("hostname")
33 @@ -85,6 +89,10 @@ def main():
34 provider_names = d.get_provider_names()
35 print("\n".join(provider_names))
37 + elif args.subparsers_name == "list-token-providers":
38 + token_provider = d.get_provider_with_token_support()
39 + print("\n".join(token_provider))
41 elif args.subparsers_name == "update":
42 d.updateone(hostname=args.hostname, force=args.force)
44 diff --git a/src/ddns/__init__.py b/src/ddns/__init__.py
45 index 3e43fa7..ca232bf 100644
46 --- a/src/ddns/__init__.py
47 +++ b/src/ddns/__init__.py
48 @@ -86,6 +86,20 @@ class DDNSCore(object):
50 return sorted(self.providers.keys())
52 + def get_provider_with_token_support(self):
54 + Returns a list with names of all registered providers
55 + which support token based authtentication.
60 + for handle, provider in sorted(self.providers.items()):
61 + if provider.supports_token_auth is True:
62 + token_provider.append(handle)
64 + return sorted(token_provider)
66 def load_configuration(self, filename):
67 logger.debug(_("Loading configuration file %s") % filename)
69 diff --git a/src/ddns/providers.py b/src/ddns/providers.py
70 index a1ca3f3..b0066d5 100644
71 --- a/src/ddns/providers.py
72 +++ b/src/ddns/providers.py
73 @@ -73,6 +73,10 @@ class DDNSProvider(object):
74 # Required to remove AAAA records if IPv6 is absent again.
75 can_remove_records = True
77 + # True if the provider supports authentication via a random
78 + # generated token instead of username and password.
79 + supports_token_auth = True
84 @@ -352,6 +356,10 @@ class DDNSProtocolDynDNS2(object):
85 # The DynDNS protocol version 2 does not allow to remove records
86 can_remove_records = False
88 + # The DynDNS protocol version 2 only supports authentication via
89 + # username and password.
90 + supports_token_auth = False
92 def prepare_request_data(self, proto):
94 "hostname" : self.hostname,
95 @@ -440,6 +448,7 @@ class DDNSProviderAllInkl(DDNSProvider):
97 url = "http://dyndns.kasserver.com"
98 can_remove_records = False
99 + supports_token_auth = False
102 # There is no additional data required so we directly can
103 @@ -464,6 +473,8 @@ class DDNSProviderBindNsupdate(DDNSProvider):
107 + supports_token_auth = False
111 # Search if the nsupdate utility is available
112 @@ -550,6 +561,7 @@ class DDNSProviderChangeIP(DDNSProvider):
114 url = "https://nic.changeip.com/nic/update"
115 can_remove_records = False
116 + supports_token_auth = False
118 def update_protocol(self, proto):
120 @@ -616,6 +628,7 @@ class DDNSProviderDDNSS(DDNSProvider):
122 url = "http://www.ddnss.de/upd.php"
123 can_remove_records = False
124 + supports_token_auth = False
126 def update_protocol(self, proto):
128 @@ -678,6 +691,7 @@ class DDNSProviderDHS(DDNSProvider):
130 url = "http://members.dhs.org/nic/hosts"
131 can_remove_records = False
132 + supports_token_auth = False
134 def update_protocol(self, proto):
136 @@ -710,6 +724,7 @@ class DDNSProviderDNSpark(DDNSProvider):
138 url = "https://control.dnspark.com/api/dynamic/update.php"
139 can_remove_records = False
140 + supports_token_auth = False
142 def update_protocol(self, proto):
144 @@ -758,6 +773,7 @@ class DDNSProviderDtDNS(DDNSProvider):
146 url = "https://www.dtdns.com/api/autodns.cfm"
147 can_remove_records = False
148 + supports_token_auth = False
150 def update_protocol(self, proto):
152 @@ -813,6 +829,7 @@ class DDNSProviderDuckDNS(DDNSProvider):
154 url = "https://www.duckdns.org/update"
155 can_remove_records = False
156 + supports_token_auth = True
159 # Raise an error if no auth details are given.
160 @@ -914,6 +931,7 @@ class DDNSProviderDynUp(DDNSProvider):
162 url = "https://dynup.de/dyn.php"
163 can_remove_records = False
164 + supports_token_auth = False
166 def update_protocol(self, proto):
168 @@ -979,6 +997,8 @@ class DDNSProviderEasyDNS(DDNSProvider):
170 url = "http://api.cp.easydns.com/dyn/tomato.php"
172 + supports_token_auth = False
174 def update_protocol(self, proto):
176 "myip" : self.get_address(proto, "-"),
177 @@ -1032,6 +1052,7 @@ class DDNSProviderDynsNet(DDNSProvider):
178 website = "http://www.dyns.net/"
179 protocols = ("ipv4",)
180 can_remove_records = False
181 + supports_token_auth = False
183 # There is very detailed informatio about how to send the update request and
184 # the possible response codes. (Currently we are using the v1.1 proto)
185 @@ -1083,6 +1104,7 @@ class DDNSProviderEnomCom(DDNSResponseParserXML, DDNSProvider):
187 url = "https://dynamic.name-services.com/interface.asp"
188 can_remove_records = False
189 + supports_token_auth = False
191 def update_protocol(self, proto):
193 @@ -1125,6 +1147,7 @@ class DDNSProviderEntryDNS(DDNSProvider):
194 # here: https://entrydns.net/help
195 url = "https://entrydns.net/records/modify"
196 can_remove_records = False
197 + supports_token_auth = True
199 def update_protocol(self, proto):
201 @@ -1165,6 +1188,7 @@ class DDNSProviderFreeDNSAfraidOrg(DDNSProvider):
202 # page. All used values have been collected by testing.
203 url = "https://freedns.afraid.org/dynamic/update.php"
204 can_remove_records = False
205 + supports_token_auth = True
207 def update_protocol(self, proto):
209 @@ -1246,6 +1270,7 @@ class DDNSProviderKEYSYSTEMS(DDNSProvider):
211 url = "https://dynamicdns.key-systems.net/update.php"
212 can_remove_records = False
213 + supports_token_auth = False
215 def update_protocol(self, proto):
216 address = self.get_address(proto)
217 @@ -1297,6 +1322,8 @@ class DDNSProviderLightningWireLabs(DDNSProvider):
218 # Information about the format of the HTTPS request is to be found
219 # https://dns.lightningwirelabs.com/knowledge-base/api/ddns
221 + supports_token_auth = True
223 url = "https://dns.lightningwirelabs.com/update"
226 @@ -1365,6 +1392,7 @@ class DDNSProviderNamecheap(DDNSResponseParserXML, DDNSProvider):
228 url = "https://dynamicdns.park-your-domain.com/update"
229 can_remove_records = False
230 + supports_token_auth = False
232 def update_protocol(self, proto):
233 # Namecheap requires the hostname splitted into a host and domain part.
234 @@ -1458,6 +1486,8 @@ class DDNSProviderNsupdateINFO(DDNSProtocolDynDNS2, DDNSProvider):
235 # has not been implemented here, yet.
236 can_remove_records = False
238 + supports_token_auth = True
240 # After a failed update, there will be no retries
241 # https://bugzilla.ipfire.org/show_bug.cgi?id=10603
242 holdoff_failure_days = None
243 @@ -1534,6 +1564,7 @@ class DDNSProviderRegfish(DDNSProvider):
245 url = "https://dyndns.regfish.de/"
246 can_remove_records = False
247 + supports_token_auth = True
251 @@ -1630,6 +1661,7 @@ class DDNSProviderServercow(DDNSProvider):
253 url = "https://www.servercow.de/dnsupdate/update.php"
254 can_remove_records = False
255 + supports_token_auth = False
257 def update_protocol(self, proto):
259 @@ -1671,6 +1703,8 @@ class DDNSProviderSPDNS(DDNSProtocolDynDNS2, DDNSProvider):
261 url = "https://update.spdyn.de/nic/update"
263 + supports_token_auth = True
267 return self.get("username") or self.hostname
268 @@ -1774,6 +1808,8 @@ class DDNSProviderZoneedit(DDNSProvider):
269 website = "http://www.zoneedit.com"
270 protocols = ("ipv4",)
272 + supports_token_auth = False
274 # Detailed information about the request and the response codes can be
276 # http://www.zoneedit.com/doc/api/other.html
277 @@ -1821,6 +1857,7 @@ class DDNSProviderDNSmadeEasy(DDNSProvider):
279 url = "https://cp.dnsmadeeasy.com/servlet/updateip?"
280 can_remove_records = False
281 + supports_token_auth = False
283 def update_protocol(self, proto):
285 @@ -1871,6 +1908,7 @@ class DDNSProviderZZZZ(DDNSProvider):
287 url = "https://zzzz.io/api/v1/update"
288 can_remove_records = False
289 + supports_token_auth = True
291 def update_protocol(self, proto):