Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
21f201e3
Commit
21f201e3
authored
Dec 06, 2016
by
neilpang
Browse files
support cloudflare rm function
parent
e2d49432
Changes
3
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
21f201e3
...
...
@@ -1991,7 +1991,8 @@ _clearupdns() {
keyauthorization
=
$(
echo
"
$ventry
"
|
cut
-d
"
$sep
"
-f
2
)
vtype
=
$(
echo
"
$ventry
"
|
cut
-d
"
$sep
"
-f
4
)
_currentRoot
=
$(
echo
"
$ventry
"
|
cut
-d
"
$sep
"
-f
5
)
txt
=
"
$(
printf
"%s"
"
$keyauthorization
"
| _digest
"sha256"
| _urlencode
)
"
_debug txt
"
$txt
"
if
[
"
$keyauthorization
"
=
"
$STATE_VERIFIED
"
]
;
then
_info
"
$d
is already verified, skip
$vtype
."
continue
...
...
@@ -2024,7 +2025,7 @@ _clearupdns() {
txtdomain
=
"_acme-challenge.
$d
"
if ! $rmcommand "$txtdomain"; then
if
!
$rmcommand
"
$txtdomain
"
"
$txt
"
;
then
_err
"Error removing txt for domain:
$txtdomain
"
return
1
fi
...
...
dnsapi/dns_cf.sh
View file @
21f201e3
...
...
@@ -55,9 +55,7 @@ dns_cf_add() {
_info
"Adding record"
if
_cf_rest POST
"zones/
$_domain_id
/dns_records"
"{
\"
type
\"
:
\"
TXT
\"
,
\"
name
\"
:
\"
$fulldomain
\"
,
\"
content
\"
:
\"
$txtvalue
\"
,
\"
ttl
\"
:120}"
;
then
if
printf
--
"%s"
"
$response
"
|
grep
"
$fulldomain
"
>
/dev/null
;
then
_info
"Added, sleeping 10 seconds"
sleep
10
#todo: check if the record takes effect
_info
"Added, OK"
return
0
else
_err
"Add txt record error."
...
...
@@ -83,9 +81,44 @@ dns_cf_add() {
}
#fulldomain
#fulldomain
txtvalue
dns_cf_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
_debug
"First detect the root zone"
if
!
_get_root
"
$fulldomain
"
;
then
_err
"invalid domain"
return
1
fi
_debug _domain_id
"
$_domain_id
"
_debug _sub_domain
"
$_sub_domain
"
_debug _domain
"
$_domain
"
_debug
"Getting txt records"
_cf_rest GET
"zones/
${
_domain_id
}
/dns_records?type=TXT&name=
$fulldomain
&content=
$txtvalue
"
if
!
printf
"%s"
"
$response
"
|
grep
\"
success
\"
:true
>
/dev/null
;
then
_err
"Error"
return
1
fi
count
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
count
\"
:[^,]*"
|
cut
-d
:
-f
2
)
_debug count
"
$count
"
if
[
"
$count
"
=
"0"
]
;
then
_info
"Don't need to remove."
else
record_id
=
$(
printf
"%s
\n
"
"
$response
"
| _egrep_o
"
\"
id
\"
:
\"
[^
\"
]*
\"
"
|
cut
-d
:
-f
2 |
tr
-d
\"
|
head
-n
1
)
_debug
"record_id"
"
$record_id
"
if
[
-z
"
$record_id
"
]
;
then
_err
"Can not get record id to remove."
return
1
fi
if
!
_cf_rest DELETE
"zones/
$_domain_id
/dns_records/
$record_id
"
;
then
_err
"Delete record error."
return
1
fi
_contains
"
$response
"
'"success":true'
fi
}
...
...
@@ -135,7 +168,7 @@ _cf_rest() {
_H2
=
"X-Auth-Key:
$CF_Key
"
_H3
=
"Content-Type: application/json"
if
[
"
$
data
"
]
;
then
if
[
"
$
m
"
!=
"GET
"
]
;
then
_debug data
"
$data
"
response
=
"
$(
_post
"
$data
"
"
$CF_Api
/
$ep
"
""
"
$m
"
)
"
else
...
...
dnsapi/dns_myapi.sh
View file @
21f201e3
...
...
@@ -22,11 +22,14 @@ dns_myapi_add() {
return
1
}
#Usage: fulldomain
#Usage: fulldomain
txtvalue
#Remove the txt record afer validation.
dns_myapi_rm
()
{
fulldomain
=
$1
txtvalue
=
$2
_info
"Using myapi"
_debug fulldomain
"
$fulldomain
"
_debug txtvalue
"
$txtvalue
"
}
#################### Private functions bellow ##################################
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment