42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.56k stars 617 forks source link

Regression on Whatsapp access #2178

Closed christianlupus closed 2 weeks ago

christianlupus commented 2 weeks ago

Describe the bug I am failing to run a bridge with a Whatsapp gateway installed. The configuration was running previously and I know from my Matrix server I am running, that Whatsapp has updated the API in the last few days.

To Reproduce Steps to reproduce the behavior:

I am using a custom docker container to run the matterbridge. The Dockerfile looks like this:

FROM alpinelinux/golang AS builder

RUN go install -tags nomsteams,whatsappmulti github.com/42wim/matterbridge@master

FROM alpine

COPY --from=builder /home/build/go/bin/matterbridge /usr/bin

RUN mkdir /config
VOLUME /config

WORKDIR /config

CMD ["/usr/bin/matterbridge"]

I just need to run this container and mount a matterbridge.toml in /config/matterbridge.toml.

I recreated the container just 5 min ago. The problem just appears when starting the container.

Expected behavior The container runs and bridges the messages successfully.

Screenshots/debug logs If applicable, add screenshots to help explain your problem. Use logs from running matterbridge -debug if possible.

/usr/bin/matterbridge -conf /config/matterbridge.toml -debug
[0000]  INFO main:         [setupLogger:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/matterbridge.go:104] Enabling debug logging.
[0000]  INFO main:         [main:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/matterbridge.go:44] Running version 1.26.1-dev 
[0000]  INFO main:         [main:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/matterbridge.go:46] WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.
[0000] DEBUG discord:      [New:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/discord/discord.go:62] Using automatic webhooks
[0000]  INFO router:       [Start:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/gateway/router.go:66] Parsing gateway RuR Main Bridge
[0000]  INFO router:       [Start:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/gateway/router.go:66] Parsing gateway RuR Schulung
[0000]  INFO router:       [Start:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/gateway/router.go:75] Starting bridge: matrix.bot_matrixorg 
[0000]  INFO matrix:       [Connect:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/matrix/matrix.go:92] Connecting https://matrix.org
[0000]  INFO matrix:       [Connect:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/matrix/matrix.go:118] Connection succeeded
[0000]  INFO matrix:       [joinChannels:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/bridge.go:77] matrix.bot_matrixorg: joining #rauf-und-runter-gaming:matrix.org (ID: #rauf-und-runter-gaming:matrix.orgmatrix.bot_matrixorg)
[0000]  INFO matrix:       [joinChannels:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/bridge.go:77] matrix.bot_matrixorg: joining #rauf-und-runter-schulung-kommunikation:matrix.org (ID: #rauf-und-runter-schulung-kommunikation:matrix.orgmatrix.bot_matrixorg)
[0000]  INFO router:       [Start:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/gateway/router.go:75] Starting bridge: whatsapp.bot 
[0002] DEBUG whatsapp:     [Connect:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/whatsappmulti/whatsapp.go:81] Connecting to WhatsApp..
17:04:11.137 [Client ERROR] Client outdated (405) connect failure (client version: 2.2412.50)
[0004]  INFO whatsapp:     [Connect:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/whatsappmulti/whatsapp.go:106] QR channel result: err-client-outdated
[0005]  INFO whatsapp:     [Connect:/home/build/go/pkg/mod/github.com/42wim/matterbridge@v1.26.1-0.20240524210809-d16645c9527a/bridge/whatsappmulti/whatsapp.go:123] WhatsApp connection successful
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x144a962]

Environment (please complete the following information):

Additional context Please add your configuration file (be sure to exclude or anonymize private data (tokens/passwords))

Mattermost config ```toml [whatsapp] [whatsapp.privat] # Number you will use as a relay bot. Tip: Get some disposable sim card, don't rely on # your own number. Number="+49178xxx" # First time that you login you will need to scan QR code, then credentials will be saved in # a session file. # If you won't set SessionFile then you will need to scan QR code on every restart. # optional (by default the session is stored only in memory, till restarting matterbridge) SessionFile="session-49178xxx.gob" # If your terminal is white we need to invert QR code in order for it to be scanned properly # optional (default false) QrOnWhiteTerminal=false # Messages will be seen by other WhatsApp contacts as coming from the bridge. # Original nick will be part of the message. RemoteNickFormat="[{NICK}@{PROTOCOL}] " [whatsapp.bot] # Number you will use as a relay bot. Tip: Get some disposable sim card, don't rely on # your own number. Number="+49155yyyy" # First time that you login you will need to scan QR code, then credentials will be saved in # a session file. # If you won't set SessionFile then you will need to scan QR code on every restart. # optional (by default the session is stored only in memory, till restarting matterbridge) SessionFile="session-49155yyyy.gob" # If your terminal is white we need to invert QR code in order for it to be scanned properly # optional (default false) QrOnWhiteTerminal=false # Messages will be seen by other WhatsApp contacts as coming from the bridge. # Original nick will be part of the message. RemoteNickFormat="[{NICK}@{PROTOCOL}] " [discord] [discord.rur] Token="XXXX Server="1225702406466175006" AutoWebhooks=true RemoteNickFormat="[{NICK}@{PROTOCOL}] " # Map threads from other bridges on discord replies PreserveThreading=true [matrix] [matrix.bot_matrixorg] # Matterbridge does not support encrypted rooms in matrix. # Do a MITM attack against the protocol using pantalaimon #Server = "http://pantalaimon:8008" Server = "https://matrix.org" Login="rur-bot" Password="XXXX" RemoteNickFormat="[{NICK}:{PROTOCOL}] " #Whether to send the homeserver suffix. eg ":matrix.org" in @username:matrix.org #to other bridges, or only send "username".(true only sends username) NoHomeServerSuffix=false #HTMLDisable=true [[gateway]] name = "Test Bridge" enable = false [[gateway.inout]] account = "whatsapp.privat" channel = "120363281608671177@g.us" [[gateway.inout]] account = "discord.rur" channel = "ID:1231638192705372340" [[gateway.inout]] account = "matrix.bot_matrixorg" channel = "#rur-test-nenc-room:matrix.org" [[gateway]] name = "RuR Main Bridge" enable = true [[gateway.inout]] account = "whatsapp.bot" channel = "120363237270484683@g.us" [[gateway.inout]] account = "discord.rur" channel = "ID:1225702406923358219" [[gateway.inout]] account = "matrix.bot_matrixorg" channel = "#rauf-und-runter-gaming:matrix.org" [[gateway]] name = "RuR Schulung" enable = true [[gateway.inout]] account = "discord.rur" channel = "ID:1256315520102432829" [[gateway.inout]] account = "matrix.bot_matrixorg" channel = "#rauf-und-runter-schulung-kommunikation:matrix.org" [[gateway.inout]] account = "whatsapp.bot" channel = "120363297310100165@g.us" ```
IntGrah commented 2 weeks ago

Possible duplicate of #2175; have you tried updating the Whatsapp version number in vendor/go.mau.fi/whatsmeow/store/clientpayload.go to

var waVersion = WAVersionContainer{2, 3000, 1015853550}

?

christianlupus commented 2 weeks ago

Hello @IntGrah,

~as I wrote, I am basically using the command go install -tags nomsteams,whatsappmulti github.com/42wim/matterbridge@master to build the go app. Honestly, I am no go developer so I am a bit lost on what was required in order to manually build from the source with the same tags. In fact, I just copied the command from the documentation/wiki/internet.~

~Can you give me a hint on this? I assume, I have to git clone the repo first, then patch said file. How to trigger the build itself?~

In the linked issue I found some hint on how to build a checked out source tree. With the patch as provided by you I was able to at least make whatsapp accept the client again. However, it would be nice if I would not have to patch manually in order to fix this issue :wink:.

IntGrah commented 2 weeks ago

Glad you got it sorted. The proper solution would be to update the whatsmeow package, but there are still issues with breaking API changes. The dirty patch is good enough for me and most people for the moment.