diff --git a/ddns-hetzner.rsc b/ddns-hetzner.rsc index 135956a..a51b5e5 100644 --- a/ddns-hetzner.rsc +++ b/ddns-hetzner.rsc @@ -1,6 +1,6 @@ #!rsc by RouterOS # RouterOS script: ddns-hetzner -# Version 2.0.1 +# Version 2.0.2 # Copyright (c) 2024-2026 Philip 'ShokiNN' Henning # https://git.s1q.dev/phg/routeros-scripts-custom/about/COPYING.md # @@ -48,10 +48,8 @@ onerror Err { :onerror GetAnnouncedIPErr in={ $LogPrint debug $ScriptName ("GetAnnouncedIP - started"); - [/system/script/run "JParseFunctions"; global JSONLoad; global JSONLoads; global JSONUnload]; - $LogPrint debug $ScriptName ("GetAnnouncedIP - JParseFunctions loaded"); - :set Records ([$JSONLoads ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records"); + :set Records ([:deserialize from=json ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records"); $LogPrint debug $ScriptName ("GetAnnouncedIP - Records received: " . [:len $Records]); foreach rec in=$Records do={ $LogPrint debug $ScriptName ("GetAnnouncedIP - Record: Name: \"" . $RecordName . "\", Type: \"" . $RecordType . "\", Value: \"" . ($rec->"value") . "\", Comment: \"" . ($rec->"comment") . "\""); @@ -84,15 +82,13 @@ onerror Err { :onerror APISetRecordErr in={ $LogPrint debug $ScriptName ("APISetRecord - started"); - [/system/script/run "JParseFunctions"; global JSONLoad; global JSONLoads; global JSONUnload]; - $LogPrint debug $ScriptName ("APISetRecord - JParseFunctions loaded"); :local Records; :local Record; :local Payload; :onerror GetRecordsErr in={ - :set Records ([$JSONLoads ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records"); + :set Records ([:deserialize from=json ([/tool/fetch "$APIUrl/zones/$ZoneName/rrsets/$RecordName/$RecordType" http-method=get http-header-field="Authorization: Bearer $APIToken" output=user as-value]->"data")]->"rrset"->"records"); } do={ :if ([:find "$GetRecordsErr" "status 404";] >= 1) do={ :set Records [:toarray ""]; @@ -136,8 +132,6 @@ onerror Err { } $LogPrint debug $ScriptName ("APISetRecord - APIResponse: " . $APIResponse); - $JSONUnload; - $LogPrint debug $ScriptName ("APISetRecord - JSONUnload done"); $LogPrint debug $ScriptName ("APISetRecord - finished"); :return $APIResponse; } do={ diff --git a/doc/ddns-hetzner.md b/doc/ddns-hetzner.md index 107c9d4..a60e1df 100644 --- a/doc/ddns-hetzner.md +++ b/doc/ddns-hetzner.md @@ -11,8 +11,6 @@ - [Table of Contents](#table-of-contents) - [Description](#description) - [Requirements and installation](#requirements-and-installation) - - [Dependencies](#dependencies) - - [JSON parser Installation](#json-parser-installation) - [Pre requisites](#pre-requisites) - [Script Installation](#script-installation) - [Configuration](#configuration) @@ -30,18 +28,6 @@ RouterOS 6 isn't and won't be supported! ## Requirements and installation -### Dependencies - -This script requires [Winand](https://github.com/Winand)'s [mikrotik-json-parser](https://github.com/Winand/mikrotik-json-parser) to be installed. - -#### JSON parser Installation - -Create another new script: - - 1. Name: `JParseFunctions` - 2. Policy: `read`, `write`, `test` uncheck everything else - 3. Source: The content of [mikrotik-json-parser](https://github.com/Winand/mikrotik-json-parser/blob/master/JParseFunctions) - ### Pre requisites > [!IMPORTANT]