Skip to content

Commit fdd3606

Browse files
eozturk1Ercan Ozturk
andauthored
Add whatsapp.net frontend and backend (#197)
Co-authored-by: Ercan Ozturk <[email protected]>
1 parent 8863495 commit fdd3606

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ You should see a message similar to `[+] Building 6.6s (18/18) FINISHED`. The co
8282
You can manually execute the Docker container with the following `docker` command
8383

8484
```bash
85-
docker run -it -p 80:80 -p 443:443 -p 5222:5222 -p 8080:8080 -p 8443:8443 -p 8222:8222 -p 8199:8199 whatsapp_proxy:1.0
85+
docker run -it -p 80:80 -p 443:443 -p 5222:5222 -p 8080:8080 -p 8443:8443 -p 8222:8222 -p 8199:8199 -p 587:587 -p 7777:7777 whatsapp_proxy:1.0
8686
```
8787

8888
You will see lines ending with `Certificate generation completed.`. The HAProxy is running in the background and will continue to do so until you close this process.
@@ -104,6 +104,7 @@ Depending on the scenario in which you utilize your proxy, the proxy container e
104104
1. 80: Standard web traffic (HTTP)
105105
2. 443: Standard web traffic, encrypted (HTTPS)
106106
3. 5222: Jabber protocol traffic (WhatsApp default)
107+
4. 587 or 7777: *.whatsapp.net traffic including media (HTTPS)
107108

108109
There are also ports configured which accept incoming [proxy headers](https://www.haproxy.com/blog/use-the-proxy-protocol-to-preserve-a-clients-ip-address/) (version 1 or 2)
109110
on connections. If you have a network load balancer you can preserve the client IP address if you want.

proxy/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ EXPOSE 8443/tcp
5151
EXPOSE 5222/tcp
5252
EXPOSE 8222/tcp
5353
EXPOSE 8199/tcp
54+
EXPOSE 587/tcp
55+
EXPOSE 7777/tcp
5456

5557
# This is the startup command which also runs a background job to manage the WAPOX IPs
5658
CMD /usr/local/bin/set_public_ip_and_start.sh

proxy/ops/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
- "8080:8080" # HTTP with accept-proxy processing
1818
- "8443:8443" # HTTPS with accept-proxy processing
1919
- "8222:8222" # JABBER with accept-proxy processing
20+
- "587:587" # whatsapp.net
21+
- "7777:7777" # whatsapp.net
2022
healthcheck:
2123
test: /usr/local/bin/healthcheck.sh
2224
interval: 10s

proxy/src/healthcheck.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ curl -s -w 2 "http://127.0.0.1:8199/;csv" > /tmp/stats.txt || exit 1
88

99
# First trim off the leading line which is just "#"
1010
# Then convert the ugly CSV to slightly less ugly JSON
11-
# Filter out the lines for g_whatsapp_net backend status
11+
# Filter out the lines for *.whatsapp_net backend status
1212
# Select the "check_desc" field (Description of the check result)
1313
# and take all results that do NOT equal "Layer4 check passed" from HAProxy
14-
RESULT=$(tail -n +1 /tmp/stats.txt | jq -R 'split(",")' | jq -c '. | select(.[1] | contains("g_whatsapp_net"))' | jq --raw-output '.[65]| select(. | test("Layer4 check passed") | not)')
14+
RESULT=$(tail -n +1 /tmp/stats.txt | jq -R 'split(",")' | jq -c '. | select(.[1] | contains("whatsapp_net"))' | jq --raw-output '.[65]| select(. | test("Layer4 check passed") | not)')
1515

1616
# # CSV output header row:
1717
# # ["# pxname","svname","qcur","qmax","scur","smax","slim","stot","bin","bout","dreq","dresp","ereq","econ","eresp","wretr","wredis","status","weight","act","bck","chkfail","chkdown","lastchg","downtime","qlimit","pid","iid","sid","throttle","lbtot","tracked","type","rate","rate_lim","rate_max","check_status","check_code","check_duration","hrsp_1xx","hrsp_2xx","hrsp_3xx","hrsp_4xx","hrsp_5xx","hrsp_other","hanafail","req_rate","req_rate_max","req_tot","cli_abrt","srv_abrt","comp_in","comp_out","comp_byp","comp_rsp","lastsess","last_chk","last_agt","qtime","ctime","rtime","ttime","agent_status","agent_code","agent_duration","check_desc","agent_desc","check_rise","check_fall","check_health","agent_rise","agent_fall","agent_health","addr","cookie","mode","algo","conn_rate","conn_rate_max","conn_tot","intercepted","dcon","dses","wrew","connect","reuse","cache_lookups","cache_hits","srv_icur","src_ilim","qtime_max","ctime_max","rtime_max","ttime_max","eint","idle_conn_cur","safe_conn_cur","used_conn_cur","need_conn_est","uweight","agg_server_check_status","-","ssl_sess","ssl_reused_sess","ssl_failed_handshake","h2_headers_rcvd","h2_data_rcvd","h2_settings_rcvd","h2_rst_stream_rcvd","h2_goaway_rcvd","h2_detected_conn_protocol_errors","h2_detected_strm_protocol_errors","h2_rst_stream_resp","h2_goaway_resp","h2_open_connections","h2_backend_open_streams","h2_total_connections","h2_backend_total_streams",""]
1818

1919
if [ "$RESULT" != "" ]
2020
then
21-
echo "[HEALTHCHECKER] Container failed healthchecks, L4 healthcheck on g.whatsapp.net failed"
21+
echo "[HEALTHCHECKER] Container failed healthchecks, L4 healthcheck on *.whatsapp.net failed"
2222
echo "[HEALTKCHECKER] Result $RESULT"
2323
exit -1;
2424
fi

proxy/src/proxy_config.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ frontend haproxy_v4_xmpp
8080

8181
default_backend wa
8282

83+
frontend haproxy_v4_whatsapp_net
84+
maxconn 27495
85+
#PUBLIC_IP
86+
87+
bind ipv4@*:587
88+
bind ipv4@*:7777
89+
90+
default_backend wa_whatsapp_net
91+
92+
backend wa_whatsapp_net
93+
default-server check inter 60000 observe layer4
94+
server whatsapp_net_443 whatsapp.net:443
95+
8396
backend wa
8497
default-server check inter 60000 observe layer4 send-proxy
8598
server g_whatsapp_net_5222 g.whatsapp.net:5222

0 commit comments

Comments
 (0)