Skip to content

Commit ec4d291

Browse files
committed
dns/ddclient: cloudflare - read proxied attribute from hostname and send it back to prevent it being removed. closes opnsense#3426
1 parent 6340b8a commit ec4d291

File tree

1 file changed

+15
-5
lines changed
  • dns/ddclient/src/opnsense/scripts/ddclient/lib/account

1 file changed

+15
-5
lines changed

dns/ddclient/src/opnsense/scripts/ddclient/lib/account/cloudflare.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ def execute(self):
8181
syslog.LOG_ERR,
8282
"Account %s error parsing JSON response [ZoneID] %s" % (self.description, response.text)
8383
)
84-
return
84+
return False
8585
if not payload.get('success', False):
8686
syslog.syslog(
8787
syslog.LOG_ERR,
8888
"Account %s error receiving ZoneID [%s]" % (self.description, json.dumps(payload.get('errors', {})))
8989
)
90-
return
90+
return False
9191

9292
zone_id = payload['result'][0]['id']
9393
if self.is_verbose:
@@ -123,9 +123,18 @@ def execute(self):
123123
self.description, json.dumps(payload.get('errors', {}))
124124
)
125125
)
126-
return
126+
return False
127+
128+
if len(payload['result']) == 0:
129+
syslog.syslog(
130+
syslog.LOG_ERR, "Account %s error locating hostname %s [%s]" % (
131+
self.description, self.settings.get('hostnames'), recordType
132+
)
133+
)
134+
return False
127135

128136
record_id = payload['result'][0]['id']
137+
proxied = payload['result'][0]['proxied']
129138
if self.is_verbose:
130139
syslog.syslog(
131140
syslog.LOG_NOTICE,
@@ -138,7 +147,8 @@ def execute(self):
138147
'json': {
139148
'type': recordType,
140149
'name': self.settings.get('hostnames'),
141-
'content': str(self.current_address)
150+
'content': str(self.current_address),
151+
'proxied': proxied
142152
},
143153
'headers': req_opts['headers']
144154
}
@@ -152,7 +162,7 @@ def execute(self):
152162
syslog.LOG_ERR,
153163
"Account %s error parsing JSON response [UpdateIP] %s" % (self.description, response.text)
154164
)
155-
return
165+
return False
156166
if payload.get('success', False):
157167
syslog.syslog(
158168
syslog.LOG_NOTICE,

0 commit comments

Comments
 (0)