gethomepage / homepage

A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.
https://gethomepage.dev
GNU General Public License v3.0
19.48k stars 1.16k forks source link

[Bug] Downloadstation widget can't connect to my NAS #768

Closed Oupsman closed 1 year ago

Oupsman commented 1 year ago

Description

I've added a DownloadStation widget to my configuration to get informations on the download currently running on my NAS and I don't get any data.

The logs display the following message :

[2023-01-03T17:49:53.043Z] warn: Unable to login. Code: 103

Which seems to mean "Method not allowed" according to the DownloadStation API reference.

My NAS is a DS216+ with 7.1.1-42962 Update 1 and up to date DownloadStation package.

On my developpement version (I'm working on a diskstation widget), I changed the authApi constant to

const authApi = {url}/webapi/entry.cgi?api=SYNO.API.Auth&version=3&method=login&account={username}&passwd={password}&session=DownloadStation&format=cookie

and it seems to solve the problem.

But I'm not sure that it will not break compatibility with NAS running lower firmware versions.

Steps to reproduce

Activate a downloadstation widget :

homepage version

v0.5.9 (f6b1304, Dec 31, 2022)

Installation method

Docker

Configuration

No response

Container Logs

No response

Browser Logs

No response

Other

No response

Before submitting, I have made sure to

shamoon commented 1 year ago

Yea, I dont like having widgets I cant test myself. There were others in the initial thread that reported similar. Ideally the widget could detect the version and switch if this endpoint is incompatible with older versions, but of course I cant verify either way.

Perhaps @JazzFisch can take a look when he's back online.

Oupsman commented 1 year ago

I may have a solution because on my diskstation widget, I used a method to dynamically construct the authApi url.

I first call the SYNO.API.Info API to get informations about the API I want, then I use those informations to construct the URL :

const [path, minVersion, maxVersion] = await getApiInfo("SYNO.API.Auth", widget); const authApi = {url}/webapi/${path}?api=SYNO.API.Auth&version=${maxVersion}&method=login&account={username}&passwd={password}&session=DownloadStation&format=cookie const loginUrl = formatApiCall(authApi, widget);

the getApiInfo function is as such (I'm not proud of the code so far) :

async function getApiInfo(api, widget) { const infoAPI = "{url}/webapi/entry.cgi?api=SYNO.API.Info&version=1&method=query" const infoUrl = formatApiCall(infoAPI, widget); // eslint-disable-next-line no-unused-vars const [status, contentType, data] = await httpProxy(infoUrl);

let path = "Method unavailable"; let minVersion = 0; let maxVersion = 0; if (status === 200) { const json = JSON.parse(data.toString()); if (json.data[api]) { path = json.data[api].path; minVersion = json.data[api].minVersion; maxVersion = json.data[api].maxVersion; } }

return [path, minVersion, maxVersion]; }

shamoon commented 1 year ago

Their API docs still show /webapi/auth.cgi https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/DownloadStation/All/enu/Synology_Download_Station_Web_API.pdf

Oupsman commented 1 year ago

I've struggled for a while on this until I used the SYNO.API.Info api to get the right path and the right version parameter.

I can't explain why.

Oupsman commented 1 year ago

@Shamoon, if you want an access to a Synology with DownloadStation installed, reach with me in private, I can give you an access to a testing NAS of mine.

shamoon commented 1 year ago

Thanks for the offer. Only trouble is I suppose we need access to both versions, again I’m not even clear if there was a breaking change somewhere in their API or what

Oupsman commented 1 year ago

It seems there is a change between DSM 6 and DSM 7 : I have both at home (the testing NAS I can give you access to is running DSM 6) and with the change in the authApi, I can't connect to it. Without change, I can.

The code I pushed on my repo can connect to both versions and retrieve informations from DownloadStation.

shamoon commented 1 year ago

Oh great. Perhaps you can supply the relevant API output for both and then I can play with your code a bit if you make a PR?

Oupsman commented 1 year ago

Maybe I can give you access to both versions remotely ? It will take me an hour or so, nothing very complicated for me in fact.

shamoon commented 1 year ago

Sure if you’re comfortable with that, I hereby publicly promise to not abuse the privilege :)

Oupsman commented 1 year ago

I don't propose something I'm not comfortable with :) Both access are ready, let me try them before giving them to you.

Oupsman commented 1 year ago

It works, I can send you a services.yaml file for you to try.

shamoon commented 1 year ago

Got it thanks! I will find some time to test soon, are you OK if I handle the PR?

Oupsman commented 1 year ago

Please do. Try the code on both NAS boxes and create the PR if everything if OK for you.

github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns.