mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-11-09 16:01:46 +00:00
fixed RID usage for wildcard domains
This commit is contained in:
parent
281951a86b
commit
fc336e3733
@ -10,7 +10,6 @@ dns_selfhost_add() {
|
|||||||
_info "Calling acme-dns on selfhost"
|
_info "Calling acme-dns on selfhost"
|
||||||
_debug fulldomain "$fulldomain"
|
_debug fulldomain "$fulldomain"
|
||||||
_debug txtvalue "$txt"
|
_debug txtvalue "$txt"
|
||||||
_debug domain "$d"
|
|
||||||
|
|
||||||
SELFHOSTDNS_UPDATE_URL="https://selfhost.de/cgi-bin/api.pl"
|
SELFHOSTDNS_UPDATE_URL="https://selfhost.de/cgi-bin/api.pl"
|
||||||
|
|
||||||
@ -19,6 +18,10 @@ dns_selfhost_add() {
|
|||||||
SELFHOSTDNS_PASSWORD="${SELFHOSTDNS_PASSWORD:-$(_readaccountconf_mutable SELFHOSTDNS_PASSWORD)}"
|
SELFHOSTDNS_PASSWORD="${SELFHOSTDNS_PASSWORD:-$(_readaccountconf_mutable SELFHOSTDNS_PASSWORD)}"
|
||||||
# These values are domain dependent, so read them from there
|
# These values are domain dependent, so read them from there
|
||||||
SELFHOSTDNS_MAP="${SELFHOSTDNS_MAP:-$(_readdomainconf SELFHOSTDNS_MAP)}"
|
SELFHOSTDNS_MAP="${SELFHOSTDNS_MAP:-$(_readdomainconf SELFHOSTDNS_MAP)}"
|
||||||
|
# Selfhost api can't dynamically add TXT record,
|
||||||
|
# so we have to store the last used RID of the domain to support a second RID for wildcard domains
|
||||||
|
# (format: ';fulldomainA:lastRid;;fulldomainB:lastRid;...')
|
||||||
|
SELFHOSTDNS_MAP_LAST_USED_INTERNAL=$(_readdomainconf SELFHOSTDNS_MAP_LAST_USED_INTERNAL)
|
||||||
|
|
||||||
if [ -z "${SELFHOSTDNS_USERNAME:-}" ] || [ -z "${SELFHOSTDNS_PASSWORD:-}" ]; then
|
if [ -z "${SELFHOSTDNS_USERNAME:-}" ] || [ -z "${SELFHOSTDNS_PASSWORD:-}" ]; then
|
||||||
_err "SELFHOSTDNS_USERNAME and SELFHOSTDNS_PASSWORD must be set"
|
_err "SELFHOSTDNS_USERNAME and SELFHOSTDNS_PASSWORD must be set"
|
||||||
@ -30,7 +33,7 @@ dns_selfhost_add() {
|
|||||||
# e.g. don't match mytest.example.com or sub.test.example.com for test.example.com
|
# e.g. don't match mytest.example.com or sub.test.example.com for test.example.com
|
||||||
# if the domain is defined multiple times only the last occurance will be matched
|
# if the domain is defined multiple times only the last occurance will be matched
|
||||||
mapEntry=$(echo "$SELFHOSTDNS_MAP" | sed -n -E "s/(^|^.*[[:space:]])($fulldomain)(:[[:digit:]]+)([:]?[[:digit:]]*)(.*)/\2\3\4/p")
|
mapEntry=$(echo "$SELFHOSTDNS_MAP" | sed -n -E "s/(^|^.*[[:space:]])($fulldomain)(:[[:digit:]]+)([:]?[[:digit:]]*)(.*)/\2\3\4/p")
|
||||||
_debug mapEntry "$mapEntry"
|
_debug2 mapEntry "$mapEntry"
|
||||||
if test -z "$mapEntry"; then
|
if test -z "$mapEntry"; then
|
||||||
_err "SELFHOSTDNS_MAP must contain the fulldomain incl. prefix and at least one RID"
|
_err "SELFHOSTDNS_MAP must contain the fulldomain incl. prefix and at least one RID"
|
||||||
return 1
|
return 1
|
||||||
@ -38,19 +41,27 @@ dns_selfhost_add() {
|
|||||||
|
|
||||||
# get the RIDs from the map entry
|
# get the RIDs from the map entry
|
||||||
rid1=$(echo "$mapEntry" | cut -d: -f2)
|
rid1=$(echo "$mapEntry" | cut -d: -f2)
|
||||||
_debug rid1 "$rid1"
|
|
||||||
rid2=$(echo "$mapEntry" | cut -d: -f3)
|
rid2=$(echo "$mapEntry" | cut -d: -f3)
|
||||||
_debug rid2 "$rid2"
|
|
||||||
|
|
||||||
rid=$rid1
|
# read last used rid domain
|
||||||
# check for wildcard domain and use rid2 if set
|
lastUsedRidForDomainEntry=$(echo "$SELFHOSTDNS_MAP_LAST_USED_INTERNAL" | sed -n -E "s/.*(;$fulldomain:[[:digit:]]+;).*/\1/p")
|
||||||
if _startswith "$d" '*.'; then
|
_debug2 lastUsedRidForDomainEntry "$lastUsedRidForDomainEntry"
|
||||||
_debug2 "wildcard domain"
|
lastUsedRidForDomain=$(echo "$lastUsedRidForDomainEntry" | tr -d ";" | cut -d: -f2)
|
||||||
if ! test -z "$rid2"; then
|
|
||||||
rid="$rid2"
|
rid="$rid1"
|
||||||
fi
|
if [ "$lastUsedRidForDomain" = "$rid" ] && ! test -z "$rid2"; then
|
||||||
|
rid="$rid2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! test -z "$lastUsedRidForDomainEntry"; then
|
||||||
|
# replace last used rid entry for domain
|
||||||
|
SELFHOSTDNS_MAP_LAST_USED_INTERNAL=$(echo "$SELFHOSTDNS_MAP_LAST_USED_INTERNAL" | sed -n -E "s/$lastUsedRidForDomainEntry/;$fulldomain:$rid;/p")
|
||||||
|
else
|
||||||
|
# add last used rid entry for domain
|
||||||
|
SELFHOSTDNS_MAP_LAST_USED_INTERNAL="$SELFHOSTDNS_MAP_LAST_USED_INTERNAL"";$fulldomain:$rid;"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
_info "Trying to add $txt on selfhost for rid: $rid"
|
_info "Trying to add $txt on selfhost for rid: $rid"
|
||||||
|
|
||||||
data="?username=$SELFHOSTDNS_USERNAME&password=$SELFHOSTDNS_PASSWORD&rid=$rid&content=$txt"
|
data="?username=$SELFHOSTDNS_USERNAME&password=$SELFHOSTDNS_PASSWORD&rid=$rid&content=$txt"
|
||||||
@ -66,6 +77,7 @@ dns_selfhost_add() {
|
|||||||
_saveaccountconf_mutable SELFHOSTDNS_PASSWORD "$SELFHOSTDNS_PASSWORD"
|
_saveaccountconf_mutable SELFHOSTDNS_PASSWORD "$SELFHOSTDNS_PASSWORD"
|
||||||
# These values are domain dependent, so store them there
|
# These values are domain dependent, so store them there
|
||||||
_savedomainconf SELFHOSTDNS_MAP "$SELFHOSTDNS_MAP"
|
_savedomainconf SELFHOSTDNS_MAP "$SELFHOSTDNS_MAP"
|
||||||
|
_savedomainconf SELFHOSTDNS_MAP_LAST_USED_INTERNAL "$SELFHOSTDNS_MAP_LAST_USED_INTERNAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_selfhost_rm() {
|
dns_selfhost_rm() {
|
||||||
|
Loading…
Reference in New Issue
Block a user