Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync #3499

Merged
merged 104 commits into from
May 3, 2021
Merged

sync #3499

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
9366f4b
Test original implementation by trgosk
akulumbeg Jan 25, 2021
92332fc
Update dns_websupport.sh
akulumbeg Jan 25, 2021
4956a58
Update dns_websupport.sh
akulumbeg Jan 25, 2021
effc37a
Catching up with the current state of things
akulumbeg Jan 30, 2021
dadc706
Testing HMAC
akulumbeg Jan 31, 2021
7924e01
Added a forgotten ")"
akulumbeg Jan 31, 2021
84dd864
Simplified approach for the HMAC method
akulumbeg Jan 31, 2021
7630960
Update dns_websupport.sh
akulumbeg Jan 31, 2021
0481f20
"datez" var and comments
akulumbeg Jan 31, 2021
3014955
Fix comments, error msg and time formatting
akulumbeg Feb 1, 2021
5d4d53c
Testing datez change for Solaris
akulumbeg Feb 1, 2021
783a611
Yet another Solaris test
akulumbeg Feb 1, 2021
7984d8c
And again
akulumbeg Feb 1, 2021
631398f
sed workaround for "datez"
akulumbeg Feb 3, 2021
3d338bb
Fixing the shebang accident
akulumbeg Feb 3, 2021
8dc55f4
Extra test - adding date -u -d
akulumbeg Feb 4, 2021
ced6852
2>/dev/null/ to 2>/dev/null
akulumbeg Feb 4, 2021
94917e3
Testing double 2>/dev/null into _utc_date with sed
akulumbeg Feb 4, 2021
433d9bf
Implementing/testing Neil's suggestions
akulumbeg Feb 4, 2021
9e146a8
Typo
akulumbeg Feb 4, 2021
6c9845b
adding the hex parameter to _hmac call
akulumbeg Feb 4, 2021
3a38358
Trying the original solution
akulumbeg Feb 4, 2021
2eda03f
Changing the _hmac call into Neil's suggestion
akulumbeg Feb 4, 2021
b8494ab
Update dns_websupport.sh
akulumbeg Feb 4, 2021
c8c727e
added hex param to _hmac
akulumbeg Feb 4, 2021
0021fb8
Changing the _hmac auth back
akulumbeg Feb 4, 2021
fa3cee9
Update dns_websupport.sh
akulumbeg Feb 4, 2021
aa47994
Final try, leaving _hmac as before
akulumbeg Feb 4, 2021
2386d2e
String change
akulumbeg Mar 20, 2021
c384ed9
Syncing with the original repo (#2)
akulumbeg Mar 20, 2021
8de3698
Revert "Syncing with the original repo (#2)"
akulumbeg Mar 21, 2021
472488e
change arvan api script
Jan 5, 2021
e232565
change Author name
Jan 5, 2021
91a739a
change name actor
Jan 5, 2021
6502bde
Updated --preferred-chain to issue ISRG properly
gnought Feb 10, 2021
016dca6
dnsapi/pdns: also normalize json response in detecting root zone
manuelm Feb 11, 2021
ac148ce
Chain (#3408)
Neilpang Feb 13, 2021
fb5d72c
upgrade freebsd and solaris
Neilpang Feb 13, 2021
b1988c7
duckdns - fix "integer expression expected" errors (#3397)
jerrm Feb 13, 2021
2d9506e
Implement smtp notify hook
medmunds Dec 30, 2020
6e61c34
Make shfmt happy
medmunds Dec 30, 2020
d48bff0
Only save config if send is successful
medmunds Jan 11, 2021
e272fde
Add instructions for reporting bugs
medmunds Jan 11, 2021
65a1b89
Prep for curl or Python; clean up SMTP_* variable usage
medmunds Feb 14, 2021
ce2ff25
Implement curl version of smtp notify-hook
medmunds Feb 15, 2021
fe3e8a7
More than one blank line is an abomination, apparently
medmunds Feb 15, 2021
06fb3d9
Fix: Unifi deploy hook support Unifi Cloud Key (#3327)
medmunds Feb 15, 2021
8fbec78
feat: add huaweicloud error handling
eastonman Feb 15, 2021
c090c19
fix: fix freebsd and solaris
eastonman Feb 15, 2021
fe0bee2
support openssl 3.0
Neilpang Feb 15, 2021
ae5a6d3
make the fix for rsa key only
Neilpang Feb 15, 2021
dc8d91e
Use PROJECT_NAME and VER for X-Mailer header
medmunds Feb 15, 2021
d1cdc1c
Add _clearaccountconf_mutable()
medmunds Feb 16, 2021
d044545
Rework read/save config to not save default values
medmunds Feb 16, 2021
d3c74cf
Implement _rfc2822_date helper
medmunds Feb 16, 2021
1330a09
Clean email headers and warn on unsupported address format
medmunds Feb 16, 2021
eb1606b
Clarify _readaccountconf_mutable_default
medmunds Feb 16, 2021
3503474
Add Date email header in Python implementation
medmunds Feb 17, 2021
d8918ea
Use email.policy.default in Python 3 implementation
medmunds Feb 17, 2021
db96778
Prefer Python to curl when both available
medmunds Feb 17, 2021
06f51a5
Change default SMTP_SECURE to "tls"
medmunds Feb 17, 2021
d078ce7
Update dns_dp.sh
czeming Feb 20, 2021
a290f63
No need to include EC parameters explicitly with the private key.
ghen2 Feb 23, 2021
b0f5ad7
Fixes response handling and thereby allow issuing of subdomain certs
jakelamotta Feb 24, 2021
0fe3538
Adds comment
jakelamotta Feb 24, 2021
9e5ae30
fix https://github.com/acmesh-official/acme.sh/issues/3402
Neilpang Feb 24, 2021
fd406af
dnsapi/ionos: Use POST instead of PATCH for adding TXT record
lbrocke Feb 23, 2021
5a30f5c
fix https://github.com/acmesh-official/acme.sh/issues/3433
Neilpang Mar 1, 2021
7dce465
fix https://github.com/acmesh-official/acme.sh/issues/3019
Neilpang Mar 4, 2021
d4fb313
fix format
Neilpang Mar 4, 2021
923eece
Update dns_servercow.sh to support wildcard certs
anom-human Mar 11, 2021
2cbf3f7
Update dns_servercow.sh to support wildcard certs
anom-human Mar 11, 2021
69ee816
fix https://github.com/acmesh-official/acme.sh/issues/3312
Mar 13, 2021
2b2bce6
fix format
Mar 13, 2021
42ab98b
feat: add dns_porkbun
qkdreyer Mar 12, 2021
4dd2027
fix: prevent rate limit
qkdreyer Mar 13, 2021
e0d5b91
fix freebsd
Neilpang Mar 21, 2021
051775b
String update
akulumbeg Mar 21, 2021
3c7be32
fix _exists error message when MAIL_BIN env variable is not set
ecm75 Mar 22, 2021
37e3e2f
fixed formating
ecm75 Mar 22, 2021
e21f3e6
Escape asterisks in notification content
mjbnz Apr 8, 2021
53d26e5
Add debug output of $_data variable to aid diagnosis
mjbnz Apr 8, 2021
39b09f8
Dump _post() call output to /dev/null
mjbnz Apr 8, 2021
fb079f9
Update telegram.sh
mjbnz Apr 8, 2021
64ad8b1
Merge pull request #3479 from mjbnz/dev
Neilpang Apr 9, 2021
cfbc294
fix onecom api
Neilpang Apr 14, 2021
1c58913
Add Aurora DNS API
JaZo Mar 26, 2021
f3682f0
fix format
Neilpang Apr 17, 2021
c576af7
Merge pull request #3460 from JaZo/feature/aurora
Neilpang Apr 17, 2021
509d3f6
Merge pull request #3392 from akulumbeg/dev
Neilpang Apr 19, 2021
eb0c629
more simple mail.sh fix
ecm75 Apr 29, 2021
ec0538d
Merge pull request #3455 from ecm75/notify_fix
Neilpang Apr 29, 2021
81b2d07
arguments passed to printf are more generic
goekesmi Apr 29, 2021
5707b93
Merge pull request #3493 from goekesmi/master
Neilpang May 1, 2021
91d37c7
fix compatibility issue
May 1, 2021
f855862
upgrade freebsd
Neilpang May 2, 2021
aea10a3
Merge branch 'dev' of https://github.com/acmesh-official/acme.sh into…
Neilpang May 2, 2021
1a4a180
FIX: Synology sets "default" on wrong certificate
tresni May 2, 2021
25a8240
fix https://github.com/acmesh-official/acme.sh/issues/3421
May 3, 2021
ae40445
Merge pull request #3498 from tresni/synology_dsm
Neilpang May 3, 2021
e65144a
fix https://github.com/acmesh-official/acme.sh/issues/3487
May 3, 2021
e0c32ce
minor
May 3, 2021
0a4ef17
fix nginx relative path issue:
May 3, 2021
290beb9
minor
May 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/DNS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
- uses: actions/checkout@v2
- name: Clone acmetest
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
- uses: vmactions/freebsd-vm@v0.1.3
- uses: vmactions/freebsd-vm@v0.1.4
with:
envs: 'TEST_DNS TestingDomain TEST_DNS_NO_WILDCARD TEST_DNS_SLEEP CASE TEST_LOCAL DEBUG ${{ secrets.TokenName1}} ${{ secrets.TokenName2}} ${{ secrets.TokenName3}} ${{ secrets.TokenName4}} ${{ secrets.TokenName5}}'
prepare: pkg install -y socat curl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/LetsEncrypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- uses: actions/checkout@v2
- name: Clone acmetest
run: cd .. && git clone https://github.com/acmesh-official/acmetest.git && cp -r acme.sh acmetest/
- uses: vmactions/freebsd-vm@v0.1.3
- uses: vmactions/freebsd-vm@v0.1.4
with:
envs: 'NGROK_TOKEN TEST_LOCAL'
prepare: pkg install -y socat curl
Expand Down
79 changes: 70 additions & 9 deletions acme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ DEBUG_LEVEL_NONE=0

DOH_CLOUDFLARE=1
DOH_GOOGLE=2
DOH_ALI=3
DOH_DP=4

HIDDEN_VALUE="[hidden](please add '--output-insecure' to see this value)"

Expand Down Expand Up @@ -2038,7 +2040,7 @@ _send_signed_request() {
if _post "" "$nonceurl" "" "HEAD" "$__request_conent_type" >/dev/null; then
_headers="$(cat "$HTTP_HEADER")"
_debug2 _headers "$_headers"
_CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
_CACHED_NONCE="$(echo "$_headers" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)"
fi
fi
if [ -z "$_CACHED_NONCE" ]; then
Expand Down Expand Up @@ -2118,7 +2120,7 @@ _send_signed_request() {
fi
_debug2 response "$response"

_CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2)"
_CACHED_NONCE="$(echo "$responseHeaders" | grep -i "Replay-Nonce:" | _head_n 1 | tr -d "\r\n " | cut -d ':' -f 2 | cut -d , -f 1)"

if ! _startswith "$code" "2"; then
_body="$response"
Expand Down Expand Up @@ -2266,7 +2268,7 @@ _getdeployconf() {
return 0 # do nothing
fi
_saved=$(_readdomainconf "SAVED_$_rac_key")
eval "export $_rac_key=\"$_saved\""
eval "export $_rac_key=\"\$_saved\""
}

#_saveaccountconf key value base64encode
Expand Down Expand Up @@ -2357,7 +2359,7 @@ _startserver() {
echo 'HTTP/1.0 200 OK'; \
echo 'Content-Length\: $_content_len'; \
echo ''; \
printf -- '$content';" &
printf '%s' '$content';" &
serverproc="$!"
}

Expand Down Expand Up @@ -3096,6 +3098,11 @@ _checkConf() {
_debug "Try include files"
for included in $(cat "$2" | tr "\t" " " | grep "^ *include *.*;" | sed "s/include //" | tr -d " ;"); do
_debug "check included $included"
if !_startswith "$included" "/" && _exists dirname; then
_relpath="$(dirname "$_c_file")"
_debug "_relpath" "$_relpath"
included="$_relpath/included"
fi
if _checkConf "$1" "$included"; then
return 0
fi
Expand Down Expand Up @@ -3916,7 +3923,15 @@ _ns_purge_cf() {

#checks if cf server is available
_ns_is_available_cf() {
if _get "https://cloudflare-dns.com" >/dev/null 2>&1; then
if _get "https://cloudflare-dns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}

_ns_is_available_google() {
if _get "https://dns.google" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
Expand All @@ -3931,23 +3946,69 @@ _ns_lookup_google() {
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
}

_ns_is_available_ali() {
if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}

#domain, type
_ns_lookup_ali() {
_cf_ld="$1"
_cf_ld_type="$2"
_cf_ep="https://dns.alidns.com/resolve"
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
}

_ns_is_available_dp() {
if _get "https://dns.alidns.com" "" 1 >/dev/null 2>&1; then
return 0
else
return 1
fi
}

#dnspod
_ns_lookup_dp() {
_cf_ld="$1"
_cf_ld_type="$2"
_cf_ep="https://doh.pub/dns-query"
_ns_lookup_impl "$_cf_ep" "$_cf_ld" "$_cf_ld_type"
}

#domain, type
_ns_lookup() {
if [ -z "$DOH_USE" ]; then
_debug "Detect dns server first."
if _ns_is_available_cf; then
_debug "Use cloudflare doh server"
export DOH_USE=$DOH_CLOUDFLARE
else
elif _ns_is_available_google; then
_debug "Use google doh server"
export DOH_USE=$DOH_GOOGLE
elif _ns_is_available_ali; then
_debug "Use aliyun doh server"
export DOH_USE=$DOH_ALI
elif _ns_is_available_dp; then
_debug "Use dns pod doh server"
export DOH_USE=$DOH_DP
else
_err "No doh"
fi
fi

if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then
_ns_lookup_cf "$@"
else
elif [ "$DOH_USE" = "$DOH_GOOGLE" ]; then
_ns_lookup_google "$@"
elif [ "$DOH_USE" = "$DOH_ALI" ]; then
_ns_lookup_ali "$@"
elif [ "$DOH_USE" = "$DOH_DP" ]; then
_ns_lookup_dp "$@"
else
_err "Unknown doh provider: DOH_USE=$DOH_USE"
fi

}
Expand All @@ -3972,7 +4033,7 @@ __purge_txt() {
if [ "$DOH_USE" = "$DOH_CLOUDFLARE" ] || [ -z "$DOH_USE" ]; then
_ns_purge_cf "$_p_txtdomain" "TXT"
else
_debug "no purge api for google dns api, just sleep 5 secs"
_debug "no purge api for this doh api, just sleep 5 secs"
_sleep 5
fi

Expand Down Expand Up @@ -4720,7 +4781,7 @@ $_authorizations_map"
_debug2 response "$response"

status=$(echo "$response" | _egrep_o '"status":"[^"]*' | cut -d : -f 2 | tr -d '"')
if [ "$status" = "valid" ]; then
if _contains "$status" "valid"; then
_info "$(__green Success)"
_stopserver "$serverproc"
serverproc=""
Expand Down
2 changes: 1 addition & 1 deletion deploy/synology_dsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ synology_dsm_deploy() {
# we've verified this certificate description is a thing, so save it
_savedeployconf SYNO_Certificate "$SYNO_Certificate"

default=false
default=""
if echo "$response" | sed -n "s/.*\"desc\":\"$SYNO_Certificate\",\([^{]*\).*/\1/p" | grep -- 'is_default":true' >/dev/null; then
default=true
fi
Expand Down
171 changes: 171 additions & 0 deletions dnsapi/dns_aurora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#!/usr/bin/env sh

#
#AURORA_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
#
#AURORA_Secret="sdfsdfsdfljlbjkljlkjsdfoiwje"

AURORA_Api="https://api.auroradns.eu"

######## Public functions #####################

#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_aurora_add() {
fulldomain=$1
txtvalue=$2

AURORA_Key="${AURORA_Key:-$(_readaccountconf_mutable AURORA_Key)}"
AURORA_Secret="${AURORA_Secret:-$(_readaccountconf_mutable AURORA_Secret)}"

if [ -z "$AURORA_Key" ] || [ -z "$AURORA_Secret" ]; then
AURORA_Key=""
AURORA_Secret=""
_err "You didn't specify an Aurora api key and secret yet."
_err "You can get yours from here https://cp.pcextreme.nl/auroradns/users."
return 1
fi

#save the api key and secret to the account conf file.
_saveaccountconf_mutable AURORA_Key "$AURORA_Key"
_saveaccountconf_mutable AURORA_Secret "$AURORA_Secret"

_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"

_info "Adding record"
if _aurora_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"content\":\"$txtvalue\",\"ttl\":300}"; then
if _contains "$response" "$txtvalue"; then
_info "Added, OK"
return 0
elif _contains "$response" "RecordExistsError"; then
_info "Already exists, OK"
return 0
else
_err "Add txt record error."
return 1
fi
fi
_err "Add txt record error."
return 1

}

#fulldomain txtvalue
dns_aurora_rm() {
fulldomain=$1
txtvalue=$2

AURORA_Key="${AURORA_Key:-$(_readaccountconf_mutable AURORA_Key)}"
AURORA_Secret="${AURORA_Secret:-$(_readaccountconf_mutable AURORA_Secret)}"

_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 records"
_aurora_rest GET "zones/${_domain_id}/records"

if ! _contains "$response" "$txtvalue"; then
_info "Don't need to remove."
else
records=$(echo "$response" | _normalizeJson | tr -d "[]" | sed "s/},{/}|{/g" | tr "|" "\n")
if [ "$(echo "$records" | wc -l)" -le 2 ]; then
_err "Can not parse records."
return 1
fi
record_id=$(echo "$records" | grep "\"type\": *\"TXT\"" | grep "\"name\": *\"$_sub_domain\"" | grep "\"content\": *\"$txtvalue\"" | _egrep_o "\"id\": *\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | _head_n 1 | tr -d " ")
_debug "record_id" "$record_id"
if [ -z "$record_id" ]; then
_err "Can not get record id to remove."
return 1
fi
if ! _aurora_rest DELETE "zones/$_domain_id/records/$record_id"; then
_err "Delete record error."
return 1
fi
fi
return 0

}

#################### Private functions below ##################################
#_acme-challenge.www.domain.com
#returns
# _sub_domain=_acme-challenge.www
# _domain=domain.com
# _domain_id=sdjkglgdfewsdfg
_get_root() {
domain=$1
i=1
p=1

while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
_debug h "$h"
if [ -z "$h" ]; then
#not valid
return 1
fi

if ! _aurora_rest GET "zones/$h"; then
return 1
fi

if _contains "$response" "\"name\": \"$h\""; then
_domain_id=$(echo "$response" | _normalizeJson | tr -d "{}" | tr "," "\n" | grep "\"id\": *\"" | cut -d : -f 2 | tr -d \" | _head_n 1 | tr -d " ")
_debug _domain_id "$_domain_id"
if [ "$_domain_id" ]; then
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
_domain=$h
return 0
fi
return 1
fi
p=$i
i=$(_math "$i" + 1)
done
return 1
}

_aurora_rest() {
m=$1
ep="$2"
data="$3"
_debug "$ep"

key_trimmed=$(echo "$AURORA_Key" | tr -d '"')
secret_trimmed=$(echo "$AURORA_Secret" | tr -d '"')

timestamp=$(date -u +"%Y%m%dT%H%M%SZ")
signature=$(printf "%s/%s%s" "$m" "$ep" "$timestamp" | _hmac sha256 "$(printf "%s" "$secret_trimmed" | _hex_dump | tr -d " ")" | _base64)
authorization=$(printf "AuroraDNSv1 %s" "$(printf "%s:%s" "$key_trimmed" "$signature" | _base64)")

export _H1="Content-Type: application/json; charset=UTF-8"
export _H2="X-AuroraDNS-Date: $timestamp"
export _H3="Authorization: $authorization"

if [ "$m" != "GET" ]; then
_debug data "$data"
response="$(_post "$data" "$AURORA_Api/$ep" "" "$m")"
else
response="$(_get "$AURORA_Api/$ep")"
fi

if [ "$?" != "0" ]; then
_err "error $ep"
return 1
fi
_debug2 response "$response"
return 0
}
Loading