dns/ddclient - add "get" protocol in custom service type (#3523)

---------

Co-authored-by: Franco Fichtner <franco@lastsummer.de>
This commit is contained in:
Jesse
2023-09-02 10:01:58 +02:00
committed by GitHub
co-authored by Franco Fichtner
parent 37ea19d913
commit 61333a74d8
3 changed files with 6 additions and 3 deletions
@@ -56,7 +56,7 @@ class DynDNS extends BaseModel
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(
@@ -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">
@@ -67,11 +67,12 @@ class DynDNS2(BaseAccount):
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'))