Skip to content

Commit 1bef5f2

Browse files
Implement WebSocket reverse proxy support
1 parent c82869e commit 1bef5f2

File tree

9 files changed

+492
-45
lines changed

9 files changed

+492
-45
lines changed

Cargo.lock

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ trust-dns-resolver = { version = "0.20", optional = true }
4545
# quic deps
4646
quinn = { version = "0.7", optional = true }
4747

48+
# websocket deps
49+
tokio-tungstenite = { version = "0.14", optional = true }
50+
4851
[features]
49-
default = ["incoming", "outgoing", "quic", "logging"]
52+
default = ["incoming", "outgoing", "quic", "websocket", "logging"]
5053
#default = ["incoming", "outgoing"]
5154
#default = ["incoming", "quic"]
5255
#default = ["outgoing", "quic"]
@@ -56,4 +59,5 @@ default = ["incoming", "outgoing", "quic", "logging"]
5659
incoming = ["tokio-rustls"]
5760
outgoing = ["tokio-rustls", "trust-dns-resolver", "webpki-roots", "lazy_static"]
5861
quic = ["quinn"]
62+
websocket = ["tokio-tungstenite"]
5963
logging = ["rand", "env_logger"]

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
[![Build Status](https://ci.moparisthe.best/job/moparisthebest/job/xmpp-proxy/job/master/badge/icon%3Fstyle=plastic)](https://ci.moparisthe.best/job/moparisthebest/job/xmpp-proxy/job/master/)
44

55
xmpp-proxy is a reverse proxy and outgoing proxy for XMPP servers and clients, providing STARTTLS,
6-
[Direct TLS](https://xmpp.org/extensions/xep-0368.html), and [QUIC](https://datatracker.ietf.org/doc/html/draft-ietf-quic-transport)
7-
connectivity to plain-text XMPP servers and clients and limiting stanza sizes without an XML parser.
6+
[Direct TLS](https://xmpp.org/extensions/xep-0368.html), [QUIC](https://datatracker.ietf.org/doc/html/draft-ietf-quic-transport),
7+
and [WebSocket](https://datatracker.ietf.org/doc/html/rfc7395) connectivity to plain-text XMPP servers and clients and
8+
limiting stanza sizes without an XML parser.
89

910
xmpp-proxy in reverse proxy (incoming) mode will:
1011
1. listen on any number of interfaces/ports
11-
2. accept any STARTTLS, Direct TLS, or QUIC c2s or s2s connections from the internet
12+
2. accept any STARTTLS, Direct TLS, QUIC, or WebSocket c2s or s2s connections from the internet
1213
3. terminate TLS
1314
4. connect them to a local real XMPP server over plain-text TCP
1415
5. send the [PROXY protocol](https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt) v1 header if configured, so the
@@ -125,10 +126,12 @@ s2s_ports = {15268}
125126
If you are a grumpy power user who wants to build xmpp-proxy with exactly the features you want, nothing less, nothing
126127
more, this section is for you!
127128

128-
xmpp-proxy has 3 compile-time features:
129+
xmpp-proxy has 5 compile-time features:
129130
1. `incoming` - enables `incoming_listen` config option for reverse proxy STARTTLS/TLS
130131
2. `outgoing` - enables `outgoing_listen` config option for outgoing proxy STARTTLS/TLS
131132
3. `quic` - enables `quic_listen` config option for reverse proxy QUIC, and QUIC support for `outgoing` if it is enabled
133+
4. `websocket` - enables `websocket_listen` config option for reverse proxy WebSocket
134+
5. `logging` - enables configurable logging
132135

133136
So to build only supporting reverse proxy STARTTLS/TLS, no QUIC, run: `cargo build --release --no-default-features --features incoming`
134137
To build a reverse proxy only, but supporting all of STARTTLS/TLS/QUIC, run: `cargo build --release --no-default-features --features incoming,quic`
@@ -140,4 +143,5 @@ Thanks [rxml](https://github.com/horazont/rxml) for afl-fuzz seeds
140143

141144
#### todo
142145
1. sasl external for s2s, initiating and receiving
143-
2. websocket incoming and outgoing, maybe even for s2s
146+
2. websocket outgoing
147+
3. XEP for XMPP-over-QUIC and XMPP-S2S-over-WebSocket

0 commit comments

Comments
 (0)