jjj333-p / dendrite-admin-interface

[Early Developmentt] A bot interface for administrating a Dendrite server using the administration api and some database interfacing
https://matrix.to/#/#admin-interface-support:pain.agency
GNU Affero General Public License v3.0
6 stars 0 forks source link

Bot crashes when cannot reach dendrite on localhost #15

Closed anton-molyboha closed 6 months ago

anton-molyboha commented 8 months ago

(edit: I have realized that the root cause is completely different, and is mostly on my side: my dendrite is not listening on localhost)

I run dendrite on an yggdrasil interface, and as a result, it is not listening on localhost. It seems that the bot does not support this configuration.

For example, if I try to deactivate a (non-existent) user, after I confirm the action, the bot sends two messages to the admin room:

❌ | could not make http://localhost:8008/_dendrite/admin/resetPassword/@nonexistent1:rendezvous.anton.molyboha.me request with error



TypeError: fetch failed

and

Ran http://localhost:8008/_dendrite/admin/resetPassword/@nonexistent1:rendezvous.anton.molyboha.me with response 

undefined

The bot's output on the console:

file:///opt/dendrite-admin-interface/dendrite-admin-interface/index.js:445
    let userToken = response["access_token"]
                            ^

TypeError: Cannot read properties of undefined (reading 'access_token')
    at queuedConfirmation (file:///opt/dendrite-admin-interface/dendrite-admin-interface/index.js:445:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.6.1

Would be nice to have some better diagnostics, and either not crash, or refuse to start in such configuration.

anton-molyboha commented 8 months ago

Sorry, when I first filed this issue, I did not realize that the problem was caused by my dendrite not listening on localhost, and the bot is just not designed for such configuration. Given it is in a pre-alpha stage, it is totally understandable if it crashes.

jjj333-p commented 8 months ago

reopening this because there are some issues here, at least from my standpoint...

the

TypeError: Cannot read properties of undefined (reading 'access_token')

is an error that should be caught regardless because this isn't the only possible cause. the issue is it fails to make the fetch and it just blindly parces the curl result for the access token and expects it to be there. this error would likely be caused even if you could connect to dendrite if the user doesn't exist. god i hate js sometimes.

as for it not running on localhost the reason i assumed the bot will be running connecting via localhost is because i was told explicitly by till (one of the main dendrite devs) that he does not recommend exposing the admin endpoints to anything other than localhost. i never knew hosting over yggdrasil was a thing (or even what that is) but now I've heard of it twice in the last 24h, so perhaps i should allow it to be more customizable. i just know that at least for my configuration which is pretty stock dendrite is only reachable by localhost.

is yggdrasil a common use case?

anton-molyboha commented 8 months ago

yggdrasil is an "overlay mesh network": like any mesh network, it consists of computers that connect to a small number of "neighbors" but can transmit information through each other from any participant of the network to any other participant of the network. It is "overlay", because the individual connections mostly happen over regular internet. Yggdrasil was also the basis on which Pinecone was built, and Pinecone is what dendrite p2p uses.

In my case, I use yggdrasil as a sort-of VPN: the domain rendezvous.anton.molyboha.me points to a cheap-ish VPS, but the reverse proxy on the VPS just redirects all matrix requests to my home computer over yggdrasil. So, I don't think that yggdrasil is that common of a use-case, but I do think that others might use VPN in a similar situation, and then have a similar problem.

jjj333-p commented 8 months ago

ah. yeah i guess i expected you to run it from the same machine as dendrite, because with features comming soon it will need to be so it can touch the db and media repo itself

anton-molyboha commented 8 months ago

Yes, I do run the bot from the same machine as dendrite. What I have is that:

"normal clients" connect to
VPS (has static IP that DNS points to, SSL certs, reverse proxy) connects via yggdrasil (but could be VPN) to

home box (has dendrite, postgres, dendrite-admin-interface bot, etc)

For this to work, I need dendrite to listen on the yggdrasil interface. But I don't want it to listen on the wifi interface, that's why dendrite only listens on the yggdrasil interface - and not on localhost. Somehow, dendrite commandline only lets me specify a single interface to listen on.

jjj333-p commented 8 months ago

hm this is interesting, im thinking of how i have it where it listens on one port and then caddy proxies the address into that port. who knows :shrug:

jjj333-p commented 6 months ago

Heya, sorry its been a hot minute, i got busy with uni shit.

see if this is still an issue on the latest master with commit https://github.com/jjj333-p/dendrite-admin-interface/commit/ad68b61ad1aa5a1ba3eff872547439f8998b3178

jjj333-p commented 6 months ago

closing this issue as im pretty sure that will fix it, reopen if there continues to be issues

anton-molyboha commented 6 months ago

Confirming that it does work for me. Thanks!