mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 17:47:03 +08:00
beacon: support meta with limited len 64
This commit is contained in:
parent
1908bceec9
commit
f15a551e4a
|
@ -174,10 +174,10 @@ apost_log()
|
||||||
|
|
||||||
post_beacon()
|
post_beacon()
|
||||||
{
|
{
|
||||||
if [[ $# != 1 || -z "$1" ]]; then
|
if [[ $# < 1 || -z "$1" ]]; then
|
||||||
fmt_fatal "usage: post_beacon <beacon>"
|
fmt_fatal "usage: post_beacon <beacon>"
|
||||||
fi
|
fi
|
||||||
"${DOTFILES}/tools/logger.sh" "beacon" "$1"
|
"${DOTFILES}/tools/logger.sh" "beacon" "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
apost_beacon()
|
apost_beacon()
|
||||||
|
|
|
@ -40,10 +40,11 @@ init_uuid()
|
||||||
post_beacon()
|
post_beacon()
|
||||||
{
|
{
|
||||||
local beacon_type=$1
|
local beacon_type=$1
|
||||||
|
local meta=$2
|
||||||
if [[ -z "$beacon_type" ]]; then
|
if [[ -z "$beacon_type" ]]; then
|
||||||
fmt_fatal "beacon type is required"
|
fmt_fatal "beacon type is required"
|
||||||
fi
|
fi
|
||||||
resp=$(curl -sSL -X POST "https://api.beardic.cn/post-beacon?hostname=$hostname&beacon=$beacon_type")
|
resp=$(curl -sSL -X POST -H "Content-Type: text/plain" -d "$meta" "https://api.beardic.cn/post-beacon?hostname=$hostname&beacon=$beacon_type")
|
||||||
if grep -q "200" <<< "$resp"; then
|
if grep -q "200" <<< "$resp"; then
|
||||||
echo $resp
|
echo $resp
|
||||||
else
|
else
|
||||||
|
@ -59,7 +60,7 @@ post_log()
|
||||||
fmt_fatal "log content is required"
|
fmt_fatal "log content is required"
|
||||||
fi
|
fi
|
||||||
init_uuid
|
init_uuid
|
||||||
resp=$(curl -sSL -X POST -H "Content-Type: text/plain" -d "$1" "https://api.beardic.cn/post-log?hostname=$hostname&uuid=$uuid")
|
resp=$(curl -sSL -X POST -H "Content-Type: text/plain" -d "$log_content" "https://api.beardic.cn/post-log?hostname=$hostname&uuid=$uuid")
|
||||||
if grep -q "200" <<< "$resp"; then
|
if grep -q "200" <<< "$resp"; then
|
||||||
echo $resp
|
echo $resp
|
||||||
elif grep -q "403" <<< "$resp"; then
|
elif grep -q "403" <<< "$resp"; then
|
||||||
|
@ -81,7 +82,7 @@ print_help()
|
||||||
|
|
||||||
router()
|
router()
|
||||||
{
|
{
|
||||||
if [[ $# != 2 ]]; then
|
if [[ $# < 2 ]]; then
|
||||||
print_help >&2
|
print_help >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -91,7 +92,7 @@ router()
|
||||||
fmt_info "usage: $0 <beacon|log> <beacon_type|log_content>"
|
fmt_info "usage: $0 <beacon|log> <beacon_type|log_content>"
|
||||||
;;
|
;;
|
||||||
beacon)
|
beacon)
|
||||||
post_beacon "$2"
|
post_beacon "$2" "$3"
|
||||||
;;
|
;;
|
||||||
log)
|
log)
|
||||||
post_log "$2"
|
post_log "$2"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user