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
6d6b2efd
Commit
6d6b2efd
authored
Feb 16, 2018
by
neilpang
Browse files
fix he for solaris
parent
c1f52299
Changes
2
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
6d6b2efd
...
...
@@ -1838,7 +1838,7 @@ _send_signed_request() {
_body
=
"
$response
"
if
[
"
$needbase64
"
]
;
then
_body
=
"
$(
echo
"
$_body
"
| _dbase64
)
"
_debug
2
_body
"
$_body
"
_debug
3
_body
"
$_body
"
fi
if
_contains
"
$_body
"
"JWS has invalid anti-replay nonce"
;
then
...
...
dnsapi/dns_he.sh
View file @
6d6b2efd
...
...
@@ -75,17 +75,19 @@ dns_he_rm() {
body
=
"
$body
&hosted_dns_zoneid=
$_zone_id
"
body
=
"
$body
&menu=edit_zone"
body
=
"
$body
&hosted_dns_editzone="
domain_regex
=
"
$(
echo
"
$_full_domain
"
|
sed
's/\./\\./g'
)
"
# escape dots
_record_id
=
$(
_post
"
$body
"
"https://dns.he.net/"
\
|
tr
-d
'\n'
\
| _egrep_o
"data=
\"
"
${
_txt_value
}
"([^>]+>){6}[^<]+<[^;]+;deleteRecord
\(
'[0-9]+','
${
domain_regex
}
','TXT'
\)
"
\
| _egrep_o
"[0-9]+','
${
domain_regex
}
','TXT'
\)
$"
\
| _egrep_o
"^[0-9]+"
)
# The series of egreps above could have been done a bit shorter but
# I wanted to double-check whether it's the correct record (in case
# HE changes their website somehow).
response
=
"
$(
_post
"
$body
"
"https://dns.he.net/"
)
"
_debug2
"response"
"
$response
"
if
!
_contains
"
$response
"
"
$_txt_value
"
;
then
_debug
"The txt record is not found, just skip"
return
0
fi
_record_id
=
"
$(
echo
"
$response
"
|
tr
-d
"#"
|
sed
"s/<tr/#<tr/g"
|
tr
-d
"
\n
"
|
tr
"#"
"
\n
"
|
grep
"
$_full_domain
"
|
grep
'"dns_tr"'
|
grep
"
$_txt_value
"
|
cut
-d
'"'
-f
4
)
"
_debug2 _record_id
"
$_record_id
"
if
[
-z
"
$_record_id
"
]
;
then
_err
"Can not find record id"
return
1
fi
# Remove the record
body
=
"email=
${
HE_Username
}
&pass=
${
HE_Password
}
"
body
=
"
$body
&menu=edit_zone"
...
...
@@ -108,41 +110,26 @@ dns_he_rm() {
########################## PRIVATE FUNCTIONS ###########################
#-- _find_zone() -------------------------------------------------------
# Returns the most specific zone found in administration interface.
#
# Example:
#
# _find_zone first.second.third.co.uk
#
# ... will return the first zone that exists in admin out of these:
# - "first.second.third.co.uk"
# - "second.third.co.uk"
# - "third.co.uk"
# - "co.uk" <-- unlikely
# - "uk" <-'
#
# (another approach would be something like this:
# https://github.com/hlandau/acme/blob/master/_doc/dns.hook
# - that's better if there are multiple pages. It's so much simpler.
# )
_find_zone
()
{
_domain
=
"
$1
"
body
=
"email=
${
HE_Username
}
&pass=
${
HE_Password
}
"
_matches
=
$(
_post
"
$body
"
"https://dns.he.net/"
\
| _egrep_o
"delete_dom.*name=
\"
[^
\"
]+
\"
value=
\"
[0-9]+"
)
response
=
"
$(
_post
"
$body
"
"https://dns.he.net/"
)
"
_debug2 response
"
$response
"
_table
=
"
$(
echo
"
$response
"
|
tr
-d
"#"
|
sed
"s/<table/#<table/g"
|
tr
-d
"
\n
"
|
tr
"#"
"
\n
"
|
grep
'id="domains_table"'
)
"
_debug2 _table
"
$_table
"
_matches
=
"
$(
echo
"
$_table
"
|
sed
"s/<tr/#<tr/g"
|
tr
"#"
"
\n
"
|
grep
'alt="edit"'
|
tr
-d
" "
|
sed
"s/<td/#<td/g"
|
tr
"#"
"
\n
"
|
sed
-n
3p
)
"
_debug2 _matches
"
$_matches
"
# Zone names and zone IDs are in same order
_zone_ids
=
$(
echo
"
$_matches
"
|
cut
-d
'"'
-f
5
)
_zone_names
=
$(
echo
"
$_matches
"
|
cut
-d
'"'
-f
3
)
_zone_ids
=
$(
echo
"
$_matches
"
|
_egrep_o
"hosted_dns_zoneid=[0-9]*&"
|
cut
-d
=
-f
2 |
tr
-d
'&'
)
_zone_names
=
$(
echo
"
$_matches
"
|
_egrep_o
"name=.*onclick"
|
cut
-d
'"'
-f
2
)
_debug2
"These are the zones on this HE account:"
_debug2
"
$_zone_names
"
_debug2
"And these are their respective IDs:"
_debug2
"
$_zone_ids
"
if
[
-z
"
$_zone_names
"
]
||
[
-z
"
$_zone_ids
"
]
;
then
_err
"Can not get zone names."
return
1
fi
# Walk through all possible zone names
_strip_counter
=
1
while
true
;
do
...
...
@@ -156,17 +143,10 @@ _find_zone() {
_debug
"Looking for zone
\"
${
_attempted_zone
}
\"
"
# Take care of "." and only match whole lines. Note that grep -F
# cannot be used because there's no way to make it match whole
# lines.
regex
=
"^
$(
echo
"
$_attempted_zone
"
|
sed
's/\./\\./g'
)
$"
line_num
=
$(
echo
"
$_zone_names
"
\
|
grep
-n
"
$regex
"
\
|
cut
-d
:
-f
1
)
if
[
-n
"
$line_num
"
]
;
then
_zone_id
=
$(
echo
"
$_zone_ids
"
|
sed
"
${
line_num
}
q;d"
)
line_num
=
"
$(
echo
"
$_zone_names
"
|
grep
-n
"
$_attempted_zone
"
|
cut
-d
:
-f
1
)
"
if
[
"
$line_num
"
]
;
then
_zone_id
=
$(
echo
"
$_zone_ids
"
|
sed
-n
"
${
line_num
}
p"
)
_debug
"Found relevant zone
\"
$_attempted_zone
\"
with id
\"
$_zone_id
\"
- will be used for domain
\"
$_domain
\"
."
return
0
fi
...
...
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