make porkbun endpoint configurable

This commit is contained in:
Joel Beckmeyer 2024-10-14 08:32:12 -04:00 committed by Richard Hansen
parent d9365359bd
commit eb48bb55ae

View file

@ -1205,6 +1205,7 @@ our %protocols = (
'secretapikey' => setv(T_PASSWD, 1, undef, undef), 'secretapikey' => setv(T_PASSWD, 1, undef, undef),
'root-domain' => setv(T_FQDN, 0, undef, undef), 'root-domain' => setv(T_FQDN, 0, undef, undef),
'on-root-domain' => setv(T_BOOL, 0, 0, undef), 'on-root-domain' => setv(T_BOOL, 0, 0, undef),
'server' => setv(T_FQDNP, 0, 'api.porkbun.com', undef),
}, },
), ),
'sitelutions' => ddclient::LegacyProtocol->new( 'sitelutions' => ddclient::LegacyProtocol->new(
@ -6742,6 +6743,7 @@ Available configuration variables:
an unnamed record (Zone APEX) in a zone. an unnamed record (Zone APEX) in a zone.
It is useful to specify it as a local variable as shown in the example. It is useful to specify it as a local variable as shown in the example.
This configuration value is deprecated, use root-domain instead! This configuration value is deprecated, use root-domain instead!
* server: API endpoint to use, defaults to api.porkbun.com
* usev4, usev6 : These configuration variables can be specified as local variables to override * usev4, usev6 : These configuration variables can be specified as local variables to override
the global settings. It is useful to finely control IPv4 or IPv6 as shown in the example. the global settings. It is useful to finely control IPv4 or IPv6 as shown in the example.
* use (deprecated) : This parameter is deprecated but can be overridden like the above parameters. * use (deprecated) : This parameter is deprecated but can be overridden like the above parameters.
@ -6799,6 +6801,7 @@ EoEXAMPLE
sub nic_porkbun_update { sub nic_porkbun_update {
my $self = shift; my $self = shift;
for my $h (@_) { for my $h (@_) {
my $server = opt('server', $h);
local $_l = pushlogctx($h); local $_l = pushlogctx($h);
my ($sub_domain, $domain); my ($sub_domain, $domain);
if (opt('root-domain', $h)) { if (opt('root-domain', $h)) {
@ -6823,7 +6826,7 @@ sub nic_porkbun_update {
info("setting IPv$ipv address to $ip"); info("setting IPv$ipv address to $ip");
my $reply = geturl( my $reply = geturl(
proxy => opt('proxy'), proxy => opt('proxy'),
url => "https://api.porkbun.com/api/json/v3/dns/retrieveByNameType/$domain/$rrset_type/$sub_domain", url => "https://$server/api/json/v3/dns/retrieveByNameType/$domain/$rrset_type/$sub_domain",
headers => ['Content-Type: application/json'], headers => ['Content-Type: application/json'],
method => 'POST', method => 'POST',
data => encode_json({ data => encode_json({
@ -6861,7 +6864,7 @@ sub nic_porkbun_update {
debug("notes = %s", $notes); debug("notes = %s", $notes);
$reply = geturl( $reply = geturl(
proxy => opt('proxy'), proxy => opt('proxy'),
url => "https://api.porkbun.com/api/json/v3/dns/editByNameType/$domain/$rrset_type/$sub_domain", url => "https://$server/api/json/v3/dns/editByNameType/$domain/$rrset_type/$sub_domain",
headers => ['Content-Type: application/json'], headers => ['Content-Type: application/json'],
method => 'POST', method => 'POST',
data => encode_json({ data => encode_json({