2
0
Fork 0

fix: #6 - qbt_login fails if qbittorrent has CSRF disabled

This commit is contained in:
s0x 2023-04-18 23:52:56 +01:00
parent db5f6f70e8
commit d620a34060
1 changed files with 5 additions and 1 deletions

View File

@ -18,7 +18,7 @@ findactiveport() {
} }
qbt_login() { qbt_login() {
curl -s -i --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --data "username=${QBITTORRENT_USER}&password=${QBITTORRENT_PASS}" http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/auth/login | grep -oP '(?!set-cookie:.)SID=.*(?=\;.HttpOnly\;.path=\/\;)' curl -s -i --header "Referer: http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}" --data "username=${QBITTORRENT_USER}&password=${QBITTORRENT_PASS}" http://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/auth/login | grep -oP '(?!set-cookie:.)SID=.*(?=\;.HttpOnly\;)'
} }
qbt_changeport(){ qbt_changeport(){
@ -62,6 +62,10 @@ get_portmap() {
if ! qbt_checksid; then if ! qbt_checksid; then
echo "$(timestamp) | qBittorrent Cookie invalid, getting new SessionID" echo "$(timestamp) | qBittorrent Cookie invalid, getting new SessionID"
qbt_sid=$(qbt_login) qbt_sid=$(qbt_login)
if [ -z "${qbt_sid}" ]; then
echo "$(timestamp) | Failed getting new SessionID from qBittorrent"
return 1
fi
else else
echo "$(timestamp) | qBittorrent SessionID Ok!" echo "$(timestamp) | qBittorrent SessionID Ok!"
fi fi