]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/ddns-013-add-option-to-list-token-provider.patch
suricata: Change midstream policy to "pass-flow"
[ipfire-2.x.git] / src / patches / ddns-013-add-option-to-list-token-provider.patch
1 commit 287b2bfe7bf5e0639da9227a8c7893ce40d298ae
2 Author: Stefan Schantl <stefan.schantl@ipfire.org>
3 Date: Wed Dec 2 20:31:19 2020 +0100
4
5 Add option to list provider with token support.
6
7 This option can be used to get a list of all known provider which support
8 a token based authentication method.
9
10 In order to provide this feature the provider details has been extended
11 to contain the information if a provider supports this authentication
12 method or not.
13
14 Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
15
16 diff --git a/ddns.in b/ddns.in
17 old mode 100644
18 new mode 100755
19 index 0e377e7..538e4b0
20 --- a/ddns.in
21 +++ b/ddns.in
22 @@ -49,6 +49,10 @@ def main():
23 p_list_providers = subparsers.add_parser("list-providers",
24 help=_("List all available providers"))
25
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"))
29 +
30 # update
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))
36
37 + elif args.subparsers_name == "list-token-providers":
38 + token_provider = d.get_provider_with_token_support()
39 + print("\n".join(token_provider))
40 +
41 elif args.subparsers_name == "update":
42 d.updateone(hostname=args.hostname, force=args.force)
43
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):
49 """
50 return sorted(self.providers.keys())
51
52 + def get_provider_with_token_support(self):
53 + """
54 + Returns a list with names of all registered providers
55 + which support token based authtentication.
56 + """
57 +
58 + token_provider = []
59 +
60 + for handle, provider in sorted(self.providers.items()):
61 + if provider.supports_token_auth is True:
62 + token_provider.append(handle)
63 +
64 + return sorted(token_provider)
65 +
66 def load_configuration(self, filename):
67 logger.debug(_("Loading configuration file %s") % filename)
68
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
76
77 + # True if the provider supports authentication via a random
78 + # generated token instead of username and password.
79 + supports_token_auth = True
80 +
81 @staticmethod
82 def supported():
83 """
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
87
88 + # The DynDNS protocol version 2 only supports authentication via
89 + # username and password.
90 + supports_token_auth = False
91 +
92 def prepare_request_data(self, proto):
93 data = {
94 "hostname" : self.hostname,
95 @@ -440,6 +448,7 @@ class DDNSProviderAllInkl(DDNSProvider):
96
97 url = "http://dyndns.kasserver.com"
98 can_remove_records = False
99 + supports_token_auth = False
100
101 def update(self):
102 # There is no additional data required so we directly can
103 @@ -464,6 +473,8 @@ class DDNSProviderBindNsupdate(DDNSProvider):
104
105 DEFAULT_TTL = 60
106
107 + supports_token_auth = False
108 +
109 @staticmethod
110 def supported():
111 # Search if the nsupdate utility is available
112 @@ -550,6 +561,7 @@ class DDNSProviderChangeIP(DDNSProvider):
113
114 url = "https://nic.changeip.com/nic/update"
115 can_remove_records = False
116 + supports_token_auth = False
117
118 def update_protocol(self, proto):
119 data = {
120 @@ -616,6 +628,7 @@ class DDNSProviderDDNSS(DDNSProvider):
121
122 url = "http://www.ddnss.de/upd.php"
123 can_remove_records = False
124 + supports_token_auth = False
125
126 def update_protocol(self, proto):
127 data = {
128 @@ -678,6 +691,7 @@ class DDNSProviderDHS(DDNSProvider):
129
130 url = "http://members.dhs.org/nic/hosts"
131 can_remove_records = False
132 + supports_token_auth = False
133
134 def update_protocol(self, proto):
135 data = {
136 @@ -710,6 +724,7 @@ class DDNSProviderDNSpark(DDNSProvider):
137
138 url = "https://control.dnspark.com/api/dynamic/update.php"
139 can_remove_records = False
140 + supports_token_auth = False
141
142 def update_protocol(self, proto):
143 data = {
144 @@ -758,6 +773,7 @@ class DDNSProviderDtDNS(DDNSProvider):
145
146 url = "https://www.dtdns.com/api/autodns.cfm"
147 can_remove_records = False
148 + supports_token_auth = False
149
150 def update_protocol(self, proto):
151 data = {
152 @@ -813,6 +829,7 @@ class DDNSProviderDuckDNS(DDNSProvider):
153
154 url = "https://www.duckdns.org/update"
155 can_remove_records = False
156 + supports_token_auth = True
157
158 def update(self):
159 # Raise an error if no auth details are given.
160 @@ -914,6 +931,7 @@ class DDNSProviderDynUp(DDNSProvider):
161
162 url = "https://dynup.de/dyn.php"
163 can_remove_records = False
164 + supports_token_auth = False
165
166 def update_protocol(self, proto):
167 data = {
168 @@ -979,6 +997,8 @@ class DDNSProviderEasyDNS(DDNSProvider):
169
170 url = "http://api.cp.easydns.com/dyn/tomato.php"
171
172 + supports_token_auth = False
173 +
174 def update_protocol(self, proto):
175 data = {
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
182
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):
186
187 url = "https://dynamic.name-services.com/interface.asp"
188 can_remove_records = False
189 + supports_token_auth = False
190
191 def update_protocol(self, proto):
192 data = {
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
198
199 def update_protocol(self, proto):
200 data = {
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
206
207 def update_protocol(self, proto):
208 data = {
209 @@ -1246,6 +1270,7 @@ class DDNSProviderKEYSYSTEMS(DDNSProvider):
210
211 url = "https://dynamicdns.key-systems.net/update.php"
212 can_remove_records = False
213 + supports_token_auth = False
214
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
220
221 + supports_token_auth = True
222 +
223 url = "https://dns.lightningwirelabs.com/update"
224
225 def update(self):
226 @@ -1365,6 +1392,7 @@ class DDNSProviderNamecheap(DDNSResponseParserXML, DDNSProvider):
227
228 url = "https://dynamicdns.park-your-domain.com/update"
229 can_remove_records = False
230 + supports_token_auth = False
231
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
237
238 + supports_token_auth = True
239 +
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):
244
245 url = "https://dyndns.regfish.de/"
246 can_remove_records = False
247 + supports_token_auth = True
248
249 def update(self):
250 data = {
251 @@ -1630,6 +1661,7 @@ class DDNSProviderServercow(DDNSProvider):
252
253 url = "https://www.servercow.de/dnsupdate/update.php"
254 can_remove_records = False
255 + supports_token_auth = False
256
257 def update_protocol(self, proto):
258 data = {
259 @@ -1671,6 +1703,8 @@ class DDNSProviderSPDNS(DDNSProtocolDynDNS2, DDNSProvider):
260
261 url = "https://update.spdyn.de/nic/update"
262
263 + supports_token_auth = True
264 +
265 @property
266 def username(self):
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",)
271
272 + supports_token_auth = False
273 +
274 # Detailed information about the request and the response codes can be
275 # obtained here:
276 # http://www.zoneedit.com/doc/api/other.html
277 @@ -1821,6 +1857,7 @@ class DDNSProviderDNSmadeEasy(DDNSProvider):
278
279 url = "https://cp.dnsmadeeasy.com/servlet/updateip?"
280 can_remove_records = False
281 + supports_token_auth = False
282
283 def update_protocol(self, proto):
284 data = {
285 @@ -1871,6 +1908,7 @@ class DDNSProviderZZZZ(DDNSProvider):
286
287 url = "https://zzzz.io/api/v1/update"
288 can_remove_records = False
289 + supports_token_auth = True
290
291 def update_protocol(self, proto):
292 data = {