Skip to content

Commit 5caf70a

Browse files
committed
chore: add openssl dependency
1 parent fb1d48f commit 5caf70a

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=ddns-scripts_tencent_cloud
4-
PKG_VERSION:=1.0
4+
PKG_VERSION:=1.1.0
55
PKG_RELEASE:=1
66

77
PKG_LICENSE:=GPLv2
@@ -17,7 +17,7 @@ define Package/$(PKG_NAME)
1717
SUBMENU:=IP Addresses and Names
1818
TITLE:=DDNS extension for tencent.cloud.com (aka dnspod.cn)
1919
PKGARCH:=all
20-
DEPENDS:=+ddns-scripts +curl
20+
DEPENDS:=+ddns-scripts +curl +openssl-util
2121
endef
2222

2323
define Package/$(PKG_NAME)/description

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
或将文件复制到目录:
2323

2424
```shell
25+
# install dependencies
26+
opkg update
27+
opkg install ddns-scripts curl openssl-util
28+
# copy script and config file
2529
cp update_tencent_cloud_com.sh /usr/lib/ddns/update_tencent_cloud_com.sh
2630
cp tencent-cloud.com.json /usr/share/ddns/default/tencent-cloud.com.json
2731
```

assets/pic1.png

4.25 KB
Loading

update_tencent_cloud_com.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
# variable __IP already defined with the ip-address to use for update
3737
#
3838

39+
local OPENSSL=$(command -v openssl)
40+
3941
# check parameters
4042
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing key as 'username'"
4143
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing secret as 'password'"
4244
[ -z "$CURL_SSL" ] && write_log 13 "Dnspod communication require cURL with SSL support. Please install"
45+
[ -z "$OPENSSL" ] && write_log 13 "Dnspod communication require openssl. Please install"
4346
[ $use_https -eq 0 ] && use_https=1
4447

4548
# variables
@@ -179,7 +182,7 @@ x-tc-action:$(echo $__ACTION | awk '{print tolower($0)}')
179182
EOF
180183
)
181184
local __SIGNED_HEADERS="content-type;host;x-tc-action"
182-
local __HASHED_REQUEST_PAYLOAD=$(echo -n "$__PAYLOAD" | openssl sha256 -hex | awk '{print $2}')
185+
local __HASHED_REQUEST_PAYLOAD=$(echo -n "$__PAYLOAD" | $OPENSSL sha256 -hex | awk '{print $2}')
183186
local __CANONICAL_REQEUST=$(
184187
cat <<EOF
185188
$__METHOD
@@ -195,7 +198,7 @@ EOF
195198
# 步骤 2:拼接待签名字符串
196199
local __CREDENTIAL_SCOPE="$__DATE/$__SERVICE/tc3_request"
197200
local __HASHED_CANONICAL_REQUEST=$(printf "$__CANONICAL_REQEUST" |
198-
openssl sha256 -hex | awk '{print $2}')
201+
$OPENSSL sha256 -hex | awk '{print $2}')
199202
local __STRING_TO_SIGN=$(
200203
cat <<EOF
201204
$__ALGORITHM
@@ -207,13 +210,13 @@ EOF
207210

208211
# 步骤 3:计算签名
209212
local __SECRET_DATE=$(printf "$__DATE" |
210-
openssl sha256 -hmac "TC3$__SECRET_KEY" | awk '{print $2}')
213+
$OPENSSL sha256 -hmac "TC3$__SECRET_KEY" | awk '{print $2}')
211214
local __SECRET_SERVICE=$(printf $__SERVICE |
212-
openssl dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_DATE" | awk '{print $2}')
215+
$OPENSSL dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_DATE" | awk '{print $2}')
213216
local __SECRET_SIGNING=$(printf "tc3_request" |
214-
openssl dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_SERVICE" | awk '{print $2}')
217+
$OPENSSL dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_SERVICE" | awk '{print $2}')
215218
local __SIGNATURE=$(printf "$__STRING_TO_SIGN" |
216-
openssl dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_SIGNING" | awk '{print $2}')
219+
$OPENSSL dgst -sha256 -mac hmac -macopt hexkey:"$__SECRET_SIGNING" | awk '{print $2}')
217220

218221
# 步骤 4:拼接 Authorization
219222
local __AUTHORIZATION="$__ALGORITHM Credential=$__SECRET_ID/$__CREDENTIAL_SCOPE, \

0 commit comments

Comments
 (0)