Skip to content

Commit 88ac408

Browse files
authored
Merge pull request #4518 from AnTheMaker/nanelo_dns
Add Nanelo DNS support
2 parents 0ea84ad + 06e12a3 commit 88ac408

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

dnsapi/dns_nanelo.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env sh
2+
3+
# Official DNS API for Nanelo.com
4+
5+
# Provide the required API Key like this:
6+
# NANELO_TOKEN="FmD408PdqT1E269gUK57"
7+
8+
NANELO_API="https://api.nanelo.com/v1/"
9+
10+
######## Public functions #####################
11+
12+
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
13+
dns_nanelo_add() {
14+
fulldomain=$1
15+
txtvalue=$2
16+
17+
NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
18+
if [ -z "$NANELO_TOKEN" ]; then
19+
NANELO_TOKEN=""
20+
_err "You didn't configure a Nanelo API Key yet."
21+
_err "Please set NANELO_TOKEN and try again."
22+
_err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
23+
return 1
24+
fi
25+
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
26+
27+
_info "Adding TXT record to ${fulldomain}"
28+
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/addrecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
29+
if _contains "${response}" 'success'; then
30+
return 0
31+
fi
32+
_err "Could not create resource record, please check the logs"
33+
_err "${response}"
34+
return 1
35+
}
36+
37+
dns_nanelo_rm() {
38+
fulldomain=$1
39+
txtvalue=$2
40+
41+
NANELO_TOKEN="${NANELO_TOKEN:-$(_readaccountconf_mutable NANELO_TOKEN)}"
42+
if [ -z "$NANELO_TOKEN" ]; then
43+
NANELO_TOKEN=""
44+
_err "You didn't configure a Nanelo API Key yet."
45+
_err "Please set NANELO_TOKEN and try again."
46+
_err "Login to Nanelo.com and go to Settings > API Keys to get a Key"
47+
return 1
48+
fi
49+
_saveaccountconf_mutable NANELO_TOKEN "$NANELO_TOKEN"
50+
51+
_info "Deleting resource record $fulldomain"
52+
response="$(_get "$NANELO_API$NANELO_TOKEN/dns/deleterecord?type=TXT&ttl=60&name=${fulldomain}&value=${txtvalue}")"
53+
if _contains "${response}" 'success'; then
54+
return 0
55+
fi
56+
_err "Could not delete resource record, please check the logs"
57+
_err "${response}"
58+
return 1
59+
}

0 commit comments

Comments
 (0)