Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
46b3a915
Commit
46b3a915
authored
Oct 21, 2018
by
LLeny
Browse files
Fixes Neilpang/acme.sh#1888
parent
3975792b
Changes
1
Hide whitespace changes
Inline
Side-by-side
dnsapi/dns_namecheap.sh
View file @
46b3a915
...
@@ -199,9 +199,12 @@ _namecheap_check_config() {
...
@@ -199,9 +199,12 @@ _namecheap_check_config() {
_set_namecheap_TXT
()
{
_set_namecheap_TXT
()
{
subdomain
=
$2
subdomain
=
$2
txt
=
$3
txt
=
$3
tld
=
$(
echo
"
$1
"
|
cut
-d
'.'
-f
2
)
sld
=
$(
echo
"
$1
"
|
cut
-d
'.'
-f
1
)
if
!
_namecheap_set_tld_sld
"
$1
"
;
then
request
=
"namecheap.domains.dns.getHosts&SLD=
$sld
&TLD=
$tld
"
return
1
fi
request
=
"namecheap.domains.dns.getHosts&SLD=
${
_sld
}
&TLD=
${
_tld
}
"
if
!
_namecheap_post
"
$request
"
;
then
if
!
_namecheap_post
"
$request
"
;
then
_err
"
$error
"
_err
"
$error
"
...
@@ -231,7 +234,7 @@ EOT
...
@@ -231,7 +234,7 @@ EOT
_debug hostrequestfinal
"
$_hostrequest
"
_debug hostrequestfinal
"
$_hostrequest
"
request
=
"namecheap.domains.dns.setHosts&SLD=
${
sld
}
&TLD=
${
tld
}${
_hostrequest
}
"
request
=
"namecheap.domains.dns.setHosts&SLD=
${
_
sld
}
&TLD=
${
_
tld
}${
_hostrequest
}
"
if
!
_namecheap_post
"
$request
"
;
then
if
!
_namecheap_post
"
$request
"
;
then
_err
"
$error
"
_err
"
$error
"
...
@@ -244,9 +247,12 @@ EOT
...
@@ -244,9 +247,12 @@ EOT
_del_namecheap_TXT
()
{
_del_namecheap_TXT
()
{
subdomain
=
$2
subdomain
=
$2
txt
=
$3
txt
=
$3
tld
=
$(
echo
"
$1
"
|
cut
-d
'.'
-f
2
)
sld
=
$(
echo
"
$1
"
|
cut
-d
'.'
-f
1
)
if
!
_namecheap_set_tld_sld
"
$1
"
;
then
request
=
"namecheap.domains.dns.getHosts&SLD=
$sld
&TLD=
$tld
"
return
1
fi
request
=
"namecheap.domains.dns.getHosts&SLD=
${
_sld
}
&TLD=
${
_tld
}
"
if
!
_namecheap_post
"
$request
"
;
then
if
!
_namecheap_post
"
$request
"
;
then
_err
"
$error
"
_err
"
$error
"
...
@@ -286,7 +292,7 @@ EOT
...
@@ -286,7 +292,7 @@ EOT
_debug hostrequestfinal
"
$_hostrequest
"
_debug hostrequestfinal
"
$_hostrequest
"
request
=
"namecheap.domains.dns.setHosts&SLD=
${
sld
}
&TLD=
${
tld
}${
_hostrequest
}
"
request
=
"namecheap.domains.dns.setHosts&SLD=
${
_
sld
}
&TLD=
${
_
tld
}${
_hostrequest
}
"
if
!
_namecheap_post
"
$request
"
;
then
if
!
_namecheap_post
"
$request
"
;
then
_err
"
$error
"
_err
"
$error
"
...
@@ -306,3 +312,45 @@ _namecheap_add_host() {
...
@@ -306,3 +312,45 @@ _namecheap_add_host() {
_hostindex
=
$(
_math
"
$_hostindex
"
+ 1
)
_hostindex
=
$(
_math
"
$_hostindex
"
+ 1
)
_hostrequest
=
$(
printf
'%s&HostName%d=%s&RecordType%d=%s&Address%d=%s&MXPref%d=%d&TTL%d=%d'
"
$_hostrequest
"
"
$_hostindex
"
"
$1
"
"
$_hostindex
"
"
$2
"
"
$_hostindex
"
"
$3
"
"
$_hostindex
"
"
$4
"
"
$_hostindex
"
"
$5
"
)
_hostrequest
=
$(
printf
'%s&HostName%d=%s&RecordType%d=%s&Address%d=%s&MXPref%d=%d&TTL%d=%d'
"
$_hostrequest
"
"
$_hostindex
"
"
$1
"
"
$_hostindex
"
"
$2
"
"
$_hostindex
"
"
$3
"
"
$_hostindex
"
"
$4
"
"
$_hostindex
"
"
$5
"
)
}
}
_namecheap_set_tld_sld
()
{
domain
=
$1
_tld
=
""
_sld
=
""
i
=
2
while
true
;
do
_tld
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
$i
-100
)
_debug tld
"
$_tld
"
if
[
-z
"
$_tld
"
]
;
then
_debug
"invalid tld"
return
1
fi
j
=
$(
_math
"
$i
"
- 1
)
_sld
=
$(
printf
"%s"
"
$domain
"
|
cut
-d
.
-f
1-
"
$j
"
)
_debug sld
"
$_sld
"
if
[
-z
"
$_sld
"
]
;
then
_debug
"invalid sld"
return
1
fi
request
=
"namecheap.domains.dns.getHosts&SLD=
$_sld
&TLD=
$_tld
"
if
!
_namecheap_post
"
$request
"
;
then
_debug
"sld(
$_sld
)/tld(
$_tld
) not found"
else
_debug
"sld(
$_sld
)/tld(
$_tld
) found"
return
0
fi
i
=
$(
_math
"
$i
"
+ 1
)
done
}
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