EionRobb / purple-discord

A libpurple/Pidgin plugin for Discord
GNU General Public License v3.0
381 stars 43 forks source link

Plugin has started getting Pidgin clients blocked. #423

Open Zombie-Ryushu opened 2 years ago

Zombie-Ryushu commented 2 years ago

This plugin has started causing Discord to trigger API rate abuse.

"You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward."

El13B commented 2 years ago

Could you elaborate further on the issue? What version of the plugin are you using? did you load years worth of messages in seconds?

Zombie-Ryushu commented 2 years ago

No, I was using the latest github compile (master branch.) and all I did was connect. A few minutes after connecting, this happened. The block was lifted after about 4 hours after I stopped using the plugin. I rolled back to the 11/21/2021 Build I was using before and the problem stopped/

El13B commented 2 years ago

Attempted to reproduce the issue but was unable to reproduce after multiple reconnections attempts and now 22h straight of connection.

My suspicion is that you got mentioned on some channel and fetched the whole server history.

Zombie-Ryushu commented 2 years ago

How do you prevent the plugin from doing that?

El13B commented 2 years ago

check in the account advanced settings

Personally I've disabled "fetching unread messages when account connects" as I have noticed the plugin doesn't seem to mark the messages as read so when I open some chats it starts requesting ungodly amounts of messages

Zombie-Ryushu commented 2 years ago

This seems to be a Spectrum2 issue. I am having issues passing these parameters to Spectrum2.

Zombie-Ryushu commented 2 years ago

odules] No updates to install [Modules] Checking for host updates. Error downloading with electron net: HTTP Error: Status Code 429 Falling back to node net library.. [Updates] Error fetching https://discord.com/api/updates/stable?platform=linux&version=0.0.20: HTTP Error: Status Code 429 [Modules] Host update failed: Error: HTTP Error: Status Code 429 [Modules] Checking for host updates. Error downloading with electron net: HTTP Error: Status Code 429 Falling back to node net library.. [Updates] Error fetching https://discord.com/api/updates/stable?platform=linux&version=0.0.20: HTTP Error: Status Code 429 [Modules] Host update failed: Error: HTTP Error: Status Code 429

dlmarquis commented 2 years ago

I just pushed some changes that fixes one source of 429 errors. Does it work for you with the latest version?

Zombie-Ryushu commented 2 years ago

Let me trigger a recompile.

Zombie-Ryushu commented 2 years ago

Problem persists.

dlmarquis commented 2 years ago

I'm not familiar with Spectrum2 or how it works. Do you have a log from pidgin I can look at as well? From the log you posted, it looks like Discord might be trying to send you an official app update, which makes no sense.

Zombie-Ryushu commented 2 years ago

Thats right, that error is generated by the official Discord Client. Upon updating the module, around an hour after I start using the module, Discord begins blocking me with that error. Here is how Spectrum 2 Works:

Spectrum 2 Connects to an XMPP Server, usually Prosody, in Component mode. and then connects as a Pidgin Client to various services, like Discord, Skype, Escargot, etc. Spectrum 2 Maintains a mapping database in MariaDB of different users. It creates XMPP Clone Avatars of each Legacy user. (It can also clone entire Chatrooms.)

XMPP Clients, such as Conversations on Android, can connect to the XMPP server and interact with the XMPP Avatars of users. Spectrum 2 will pass messages between the XMPP Users, and other Legacy networks.

This serves a few useful purposes: This is a way that platforms, such as Android, that don't support Pidgin, can use Pidgin indirectly. Applications such as the Android Discord application which may have user Hostile Geo-location features are defeated this way. Applications which may track multiple connections of multiple clients (devices) will only see one connection, the connection from the Spectrum 2 Server. Multiple Clients (Other Pidgin Desktop Clients, Android Clients) are kept Consistent via XMPP Carbons. Also, if a device is stolen, only Authentication info for the XMPP server needs to be reset. I don't have a log for you. I get completely blocked every time I activate the new plugin. I keep having to roll back the plugin to the version on 11/21/2021 build from Rosa Linux.

dlmarquis commented 2 years ago

I'm still poking around the Spectrum2 source trying to figure out how it might be handling things differently than pidgin, but I stumbled upon this advice for blocking updates in the official client that might be of some use to you:

For everyone looking how to do that - in the discord app folder (~/.config/discord/ on linux (or in your xdg config folder), in appdata I think on Windows, no clue about mac) there is a settings.json file - you can add those lines:

"SKIP_HOST_UPDATE": true,

"SKIP_MODULE_UPDATE": true,

after the first line with the {

No idea for how long it was there, but this prevents discord from refusing to start unless you update it as well as from those random updates everyone here wants to get rid off.

The log excerpt you posted makes references to host vs module updates, and also mentions electron, the wrapper the official client uses. Does Spectrum2 make any calls to official clients? Is Discord running at startup for you and somehow interfering?

Zombie-Ryushu commented 2 years ago

The updates have nothing to do with it. Spectrum2 does not interact with the Official Client in any way. I have several releases of the plugin. (my Underlying OS is OpenSuse 15.3) The version that works, and is stable is version 11/21/2021. Spectrum 2 works fine with that release. Any later and Error 429 pops up. When a newer version of the module gets used, on the server side, Discord does a Host level Block. At which point I cannot use Discord at all, by any means, Spectrum 2, official Client, or Web Browser.

dlmarquis commented 2 years ago

My concern is with what's different between Spectrum2's and Pidgin's handling. The merge immediately after 11/21/2021 (#382) is readability improvements, some user status tweaks, and---most importantly, I think---an update to the capabilities flags during auth. Dropping the flags back down to 61 isn't a viable option because we'd lose access to the new features and api updates Discord has put out. Spectrum2 is triggering something Pidgin isn't, and since Discord's user API is undocumented, I'm just throwing things at the wall and seeing what sticks.

Do you have an untruncated Spectrum2 log where you experience the issue? That might help narrow things down.

beadon commented 1 year ago

I wanted to flag that I am experiencing this exact issue. I expect that the API calls getting made to Discord servers need to have verbose logging enabled, and purple-discord needs to implement rate limiting these calls.

It's possible that the error messages thrown by the API calls to discord's servers indicate an acceptable rate limit. I am not familiar with these messages, but if someone is familiar with these details that's where to start looking. I have opened up a parallel thread because I believe this is also having knock-on effects where history of channels / messages are not getting loaded. I can't pin this to the cause of missing history, but it is very feasible.

Zombie-Ryushu commented 1 year ago

While I still use the plugin, I have to use an old version because this is still a problem.