Skip to content

Commit

Permalink
dns/ddclient - add "get" protocol in custom service type (opnsense#3523)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Franco Fichtner <[email protected]>
  • Loading branch information
DaCookie4u and fichtner authored Sep 2, 2023
1 parent 37ea19d commit 61333a7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function performValidation($validateFullModel = false)
continue;
}
$srv = (string)$node->server;
if ((string)$node->protocol == 'post') {
if (in_array((string)$node->protocol, ['get', 'post', 'put'])) {
if (empty($srv) || filter_var($srv, FILTER_VALIDATE_URL) === false) {
$messages->appendMessage(
new Message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@
<OptionValues>
<dyndns1>DynDNS 1</dyndns1>
<dyndns2>DynDNS 2</dyndns2>
<get>Custom GET</get>
<post>Custom POST</post>
<put>Custom PUT</put>
</OptionValues>
</protocol>
<server type="TextField">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ def match(account):
def execute(self):
if super().execute():
protocol = self.settings.get('protocol', None)
if protocol == 'post':
if protocol in [ 'get', 'post', 'put' ]:
url = self.settings.get('server')
url = url.replace('__MYIP__', self.current_address)
url = url.replace('__HOSTNAME__', self.settings.get('hostnames'))
req = requests.post(
req = requests.request(
method=protocol,
url=url,
headers={'User-Agent': 'OPNsense-dyndns'},
auth=HTTPBasicAuth(self.settings.get('username'), self.settings.get('password'))
Expand Down

0 comments on commit 61333a7

Please sign in to comment.