mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 09:13:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2023 muink https://github.com/muink
|
||||
#
|
||||
# Client listen port refresh script
|
||||
#
|
||||
# depends jsonfilter
|
||||
|
||||
. /usr/lib/natmap/common.sh
|
||||
|
||||
# http_request <cookie> <data>
|
||||
http_request() {
|
||||
$CURL $retry --compressed -L -X POST \
|
||||
-b "$1" -H "Content-Type: application/json" \
|
||||
-d "$2" \
|
||||
--url ${scheme}://${host}:${web_port}/json
|
||||
}
|
||||
|
||||
start() {
|
||||
local retry='--connect-timeout 1 --retry 0'
|
||||
local cookie="$($CURL $retry --compressed -L -i \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"method": "auth.login", "params": ["'"${password}"'"], "id": 1}' \
|
||||
--url ${scheme}://${host}:${web_port}/json \
|
||||
| grep -i set-cookie | sed -En 's|^.*(_session_id=\S+);.*|\1|p')"
|
||||
local connected="$(http_request "$cookie" '{"method": "web.connected", "params": [], "id": 1}' | jsonfilter -qe '@.result')"
|
||||
if [ "$connected" = "true" ]; then
|
||||
http_request "$cookie" '{"method": "core.set_config", "params": [{"random_port": false}], "id": 1}'
|
||||
http_request "$cookie" '{"method": "core.set_config", "params": [{"listen_ports": ["'"${port}"'","'"${port}"'"]}], "id": 1}'
|
||||
fi
|
||||
http_request "$cookie" '{"method": "auth.delete_session", "params": [], "id": 1}'
|
||||
}
|
||||
|
||||
|
||||
# All external parameters required
|
||||
ALL_PARAMS="host port scheme web_port username password"
|
||||
eval "$(JSON_EXPORT "$1")"; shift
|
||||
start "$@"
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2023 muink https://github.com/muink
|
||||
#
|
||||
# Client listen port refresh script
|
||||
#
|
||||
# depends
|
||||
|
||||
. /usr/lib/natmap/common.sh
|
||||
|
||||
start() {
|
||||
local retry='--connect-timeout 1 --retry 0'
|
||||
scheme='http' # only supports http
|
||||
local sid="$($CURL $retry -L \
|
||||
-u ${username}:${password} \
|
||||
--url ${scheme}://${host}:${web_port}/transmission/rpc \
|
||||
| sed 's|.*<code>||g;s|</code>.*||g')"
|
||||
$CURL $retry -L -X POST \
|
||||
-H "$sid" -u ${username}:${password} \
|
||||
-d '{"method":"session-set","arguments":{"peer-port":"'"${port}"'"}}' \
|
||||
--url ${scheme}://${host}:${web_port}/transmission/rpc
|
||||
}
|
||||
|
||||
|
||||
# All external parameters required
|
||||
ALL_PARAMS="host port scheme web_port username password"
|
||||
eval "$(JSON_EXPORT "$1")"; shift
|
||||
start "$@"
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2023-2025 muink https://github.com/muink
|
||||
#
|
||||
# Client listen port refresh script
|
||||
#
|
||||
# depends
|
||||
|
||||
. /usr/lib/natmap/common.sh
|
||||
|
||||
start() {
|
||||
local retry='--connect-timeout 1 --retry 0'
|
||||
local self_signed='-k'
|
||||
local payload
|
||||
case "$(basename "$0")" in
|
||||
qBittorrent)
|
||||
payload='json={"listen_port":'"${port}"'}';;
|
||||
qBittorrent-announce_port)
|
||||
payload='json={"announce_port":'"${port}"'}';;
|
||||
*)
|
||||
payload='json={"listen_port":'"${port}"'}';;
|
||||
esac
|
||||
local cookie="$($CURL $retry $self_signed -L -i \
|
||||
-H "Referer: ${scheme}://${host}:${web_port}" \
|
||||
-d "username=${username}&password=${password}" \
|
||||
--url ${scheme}://${host}:${web_port}/api/v2/auth/login \
|
||||
| grep -i set-cookie | sed -En 's|^.*(SID=\S+);.*|\1|p')"
|
||||
$CURL $retry $self_signed -L -X POST \
|
||||
-b "$cookie" \
|
||||
-d "$payload" \
|
||||
--url ${scheme}://${host}:${web_port}/api/v2/app/setPreferences
|
||||
$CURL $retry $self_signed -L -I \
|
||||
--cookie "$cookie" \
|
||||
--url ${scheme}://${host}:${web_port}/api/v2/auth/logout
|
||||
}
|
||||
|
||||
|
||||
# All external parameters required
|
||||
ALL_PARAMS="host port scheme web_port username password"
|
||||
eval "$(JSON_EXPORT "$1")"; shift
|
||||
start "$@"
|
||||
Reference in new issue
Block a user