sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
291 stars 27 forks source link

Login in is broken with glib2 >2.68 #226

Closed Thaodan closed 2 years ago

Thaodan commented 2 years ago

Login with glib2 >2.68 is broken. On Arch Linux for example there is glib2 2.70

[16:58:56] >>> ((null)) discord_http_get 217
About to send HTTP request:
GET /api/gateway HTTP/1.1
Host: discordapp.com
User-Agent: Bitlbee-Discord
Content-Type: application/json
authorization: 
<you wish you had it>

HTTP response headers:
HTTP/1.1 200 OK
Date: date
Content-Type: application/json
Content-Length: 35
Connection: keep-alive
strict-transport-security: max-age=31536000; includeSubDomains
x-envoy-upstream-service-time: 10
Via: 1.1 google
Alt-Svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400
CF-Cache-Status: HIT
Age: 82315
Expires: date
Cache-Control: public, max-age=30
Accept-Ranges: bytes
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=foobar"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY:foobar

Finishing HTTP request with status: 200 OK
[16:58:56] <<< ((null)) discord_http_gateway_cb [200] 35
{"url": "wss://gateway.discord.gg"}

[16:58:57] <<< ((null)) discord_ws_in_cb switching failure. buf:
HTTP/1.1 400 Bad Request
Server: cloudflare
Date: Wed, 22 Sep 2021 13:58:57 GMT
Content-Type: text/html
Content-Length: 155
Connection: close
CF-RAY: -

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
sm00th commented 2 years ago

Interesting. Since you have the environment set up, could you please try running (with debug enabled) a build with eb768b4 included with both glib versions and see if there are any differences in requests bitlbee-discord sends?

Thaodan commented 2 years ago

I can. Just as a note: I build the bitllbee- discord package I currently use with glib2 2.70 installed, downgrading to 2.68 before or aftter building doesn't seem to make a difference.

sm00th commented 2 years ago

Yeah, makes sense. No need to rebuild it the second time, just make sure that commit is included and then you can switch glib versions without a rebuild.

Thaodan commented 2 years ago

2.68: [17:29:33] >>> ((null)) discord_ws_connected_cb 254

2.70: [17:40:21] >>> ((null)) discord_ws_connected_cb 235

sm00th commented 2 years ago

After these lines there should be a request body starting with "GET blabla HTTP/1.1", thats the important part

Thaodan commented 2 years ago

2.68:

[17:41:46] >>> ((null)) discord_ws_connected_cb 254 GET /?encoding=json&v=6 HTTP/1.1 Host: gateway.discord.gg Connection: keep-alive, Upgrade Upgrade: websocket Origin: discordapp.com Pragma: no-cache Cache-Control: no-cache Sec-WebSocket-Version: 13 Sec-WebSocket-Key: foobar

2.70: [17:41:07] >>> ((null)) discord_ws_connected_cb 235 GET HTTP/1.1 Host: gateway.discord.gg Connection: keep-alive, Upgrade Upgrade: websocket Origin: discordapp.com Pragma: no-cache Cache-Control: no-cache Sec-WebSocket-Version: 13 Sec-WebSocket-Key: foobar

sm00th commented 2 years ago

Apparently starting with glib 2.69 g_match_info_fetch() now returns an empty string instead of NULL on failed match. https://gitlab.gnome.org/GNOME/glib/-/issues/229

This throws discord_http_gateway_cb() off.

sm00th commented 2 years ago

Please try https://github.com/sm00th/bitlbee-discord/commit/607f9887ca85f246e970778e3d40aa5c346365a7 with glib2.70.

Wibjarm commented 2 years ago

Just saw this and tested, that commit fixes it on 2.70 for me.

drshapeless commented 2 years ago

Just tested, it works flawlessly with glib 2.70 on Arch.

sm00th commented 2 years ago

Thanks for the feedback. Going to close this issue now.