mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
use API token if available
If the username is "token", use the password as an API token instead of a global one
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
PLUGIN_NAME= ddclient
|
||||
PLUGIN_VERSION= 1.13
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_DEPENDS= ddclient-devel
|
||||
PLUGIN_COMMENT= Dynamic DNS client
|
||||
PLUGIN_MAINTAINER= ad@opnsense.org
|
||||
|
||||
@@ -60,16 +60,23 @@ class Cloudflare(BaseAccount):
|
||||
|
||||
# get ZoneID
|
||||
url = "https://%s/client/v4/zones" % self._services[self.settings.get('service')]
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'OPNsense-dyndns'
|
||||
}
|
||||
# switch between bearer and email/key authentication
|
||||
if self.settings.get('username', '').find('@') == -1:
|
||||
headers["Authorization"] = "Bearer " + self.settings.get('password')
|
||||
else:
|
||||
headers["X-Auth-Email"] = self.settings.get('username')
|
||||
headers["X-Auth-Key"] = self.settings.get('password')
|
||||
|
||||
req_opts = {
|
||||
'url': url,
|
||||
'params': {
|
||||
'name': self.settings.get('zone')
|
||||
},
|
||||
'headers': {
|
||||
'User-Agent': 'OPNsense-dyndns',
|
||||
'X-Auth-Email': self.settings.get('username'),
|
||||
'X-Auth-Key': self.settings.get('password')
|
||||
}
|
||||
'headers': headers
|
||||
}
|
||||
response = requests.get(**req_opts)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user