Skip to content

[Feature]: ISSUE_WHATSAPP_PROXY #23500

Description

@SoHuDrgon

Summary

## Feature Description

Add support for configuring a proxy for WhatsApp connections, similar to the existing proxy support for Telegram.

## Use Case

Users in regions where WhatsApp is blocked (e.g., China mainland) need to use a proxy to connect to WhatsApp Web. Currently, Telegram already supports proxy configuration via `channels.telegram.proxy`, but WhatsApp does not have this option.

## Proposed Solution

Add a `proxy` configuration option to `WhatsAppConfig` in `src/config/types.whatsapp.ts`, similar to how it's implemented for Telegram:

```typescript
// In WhatsAppConfig:
proxy?: string;

Then pass this proxy to the Baileys makeWASocket function in src/web/session.ts:

import { ProxyAgent } from "undici";

const sock = makeWASocket({
  // ... existing options
  fetchAgent: new ProxyAgent(proxyUrl),
});

Why This Works

  • The @whiskeysockets/baileys library supports proxy via the fetchAgent option
  • Telegram already has a working proxy implementation in src/telegram/proxy.ts using undici's ProxyAgent
  • This approach is consistent with the existing Telegram proxy feature

Additional Context



### Problem to solve

## Why This Works

- The `@whiskeysockets/baileys` library supports proxy via the `fetchAgent` option
- Telegram already has a working proxy implementation in `src/telegram/proxy.ts` using `undici`'s `ProxyAgent`
- This approach is consistent with the existing Telegram proxy feature

## Additional Context

- Telegram proxy config: `channels.telegram.proxy`
- Telegram proxy implementation: `src/telegram/monitor.ts` (line ~120)
- Baileys documentation: https://github.com/WhiskeySockets/Baileys#using-a-proxy

### Proposed solution

## Proposed Solution

Add a `proxy` configuration option to `WhatsAppConfig` in `src/config/types.whatsapp.ts`, similar to how it's implemented for Telegram:

```typescript
// In WhatsAppConfig:
proxy?: string;

Then pass this proxy to the Baileys makeWASocket function in src/web/session.ts:

import { ProxyAgent } from "undici";

const sock = makeWASocket({
  // ... existing options
  fetchAgent: new ProxyAgent(proxyUrl),
});

Alternatives considered

No response

Impact

Additional Context

Evidence/examples

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions