Skip to content

Commit

Permalink
e2ee: update websocket url for instagram
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Nov 21, 2024
1 parent 13a1a71 commit 2daa7fd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/zyedidia/clipboard v1.0.4
go.mau.fi/libsignal v0.1.1
go.mau.fi/util v0.8.2
go.mau.fi/whatsmeow v0.0.0-20241116141054-92458da42ba3
go.mau.fi/whatsmeow v0.0.0-20241121132808-ae900cb6bee4
golang.org/x/crypto v0.29.0
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
golang.org/x/image v0.22.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ go.mau.fi/libsignal v0.1.1 h1:m/0PGBh4QKP/I1MQ44ti4C0fMbLMuHb95cmDw01FIpI=
go.mau.fi/libsignal v0.1.1/go.mod h1:QLs89F/OA3ThdSL2Wz2p+o+fi8uuQUz0e1BRa6ExdBw=
go.mau.fi/util v0.8.2 h1:zWbVHwdRKwI6U9AusmZ8bwgcLosikwbb4GGqLrNr1YE=
go.mau.fi/util v0.8.2/go.mod h1:BHHC9R2WLMJd1bwTZfTcFxUgRFmUgUmiWcT4RbzUgiA=
go.mau.fi/whatsmeow v0.0.0-20241116141054-92458da42ba3 h1:5BTCMPMvWcEJ+BIvci8S2+yqe09XIRqRYPt4SgB9y5o=
go.mau.fi/whatsmeow v0.0.0-20241116141054-92458da42ba3/go.mod h1:iB+F/NVNOnyumU2p/TKTSSdBhH05GHFG36diYuFp9VQ=
go.mau.fi/whatsmeow v0.0.0-20241121132808-ae900cb6bee4 h1:fb3X+Us6dDmXWZJt7H9o9P+pSiEq9Fut1jLqurVPpVc=
go.mau.fi/whatsmeow v0.0.0-20241121132808-ae900cb6bee4/go.mod h1:iB+F/NVNOnyumU2p/TKTSSdBhH05GHFG36diYuFp9VQ=
go.mau.fi/zeroconfig v0.1.3 h1:As9wYDKmktjmNZW5i1vn8zvJlmGKHeVxHVIBMXsm4kM=
go.mau.fi/zeroconfig v0.1.3/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
Expand Down
1 change: 1 addition & 0 deletions pkg/messagix/data/endpoints/facebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func makeFacebookEndpoints(host string) map[string]string {
"media_upload": baseURL + "/ajax/mercury/upload.php?",
"web_push": baseURL + "/push/register/service_worker/",

"e2ee_ws_url": "wss://web-chat-e2ee.facebook.com/ws/chat",
"icdc_fetch": "https://reg-e2ee.facebook.com/v2/fb_icdc_fetch",
"icdc_register": "https://reg-e2ee.facebook.com/v2/fb_register_v2",
}
Expand Down
1 change: 1 addition & 0 deletions pkg/messagix/data/endpoints/instagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var InstagramEndpoints = map[string]string{
"cookie_consent": "https://graphql.instagram.com/graphql/",
"default_graphql": "https://graphql.instagram.com/graphql/",

"e2ee_ws_url": "wss://web-chat-e2ee.instagram.com/ws/chat",
"icdc_fetch": "https://reg-e2ee.instagram.com/v2/fb_icdc_fetch",
"icdc_register": "https://reg-e2ee.instagram.com/v2/fb_register_v2",

Expand Down
5 changes: 3 additions & 2 deletions pkg/messagix/e2ee-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ func (c *Client) PrepareE2EEClient() *whatsmeow.Client {
e2eeClient := whatsmeow.NewClient(c.device, waLog.Zerolog(c.Logger.With().Str("component", "whatsmeow").Logger()))
e2eeClient.GetClientPayload = c.getClientPayload
e2eeClient.MessengerConfig = &whatsmeow.MessengerConfig{
UserAgent: UserAgent,
BaseURL: c.getEndpoint("base_url"),
UserAgent: UserAgent,
BaseURL: c.getEndpoint("base_url"),
WebsocketURL: c.getEndpoint("e2ee_ws_url"),
}
e2eeClient.RefreshCAT = c.refreshCAT
return e2eeClient
Expand Down
6 changes: 3 additions & 3 deletions pkg/messagix/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ func (s *Socket) getConnHeaders() http.Header {
h.Set("cookie", s.client.cookies.String())
h.Set("user-agent", UserAgent)
h.Set("origin", s.client.getEndpoint("base_url"))
h.Set("Sec-Fetch-Dest", "empty")
h.Set("Sec-Fetch-Mode", "websocket")
h.Set("Sec-Fetch-Site", "same-site")
//h.Set("Sec-Fetch-Dest", "empty")
//h.Set("Sec-Fetch-Mode", "websocket")
//h.Set("Sec-Fetch-Site", "same-site")

return h
}
Expand Down

0 comments on commit 2daa7fd

Please sign in to comment.