You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+205-4Lines changed: 205 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,12 @@ Overlay networks based on WebRTC.
16
16
17
17
weron provides lean, fast & secure overlay networks based on WebRTC.
18
18
19
-
🚧 This project is a work-in-progress! Instructions will be added as soon as it is usable. 🚧
19
+
It enables you too ...
20
+
21
+
-**Access to nodes behind NAT**: Because weron uses WebRTC to establish connections between nodes, it can easily traverse corporate firewalls and NATs using STUN, or even use a TURN server to tunnel traffic. This can be very useful to i.e. SSH into your homelab without forwarding any ports on your router.
22
+
-**Secure your home network**: By using the inbuilt interactive TLS verification and running the signaling server locally, weron can be used to secure traffic between nodes in a LAN without depending on any external infrastructure.
23
+
-**Join local nodes into a cloud network**: If you run e.g. a Kubernetes cluster with nodes based on cloud instances but also want to join your on-prem nodes into it, you can use weron to create a trusted network for it.
24
+
-**Write your own peer-to-peer protocols**: The simple API makes writing distributed applications with automatic reconnects, multiple datachannels etc. approachable and fun!
It should now be reachable on `ws://localhost:1337/`.
85
90
86
-
To use it in production, put this signaling server behind a TLS-enabled reverse proxy such as [Caddy](https://caddyserver.com/) or [Traefik](https://traefik.io/). You may also either want to keep `API_PASSWORD` empty to disable the management API completely or use OpenID Connect to authenticate instead; for more information, see the [signaling server reference](#signaling-server). You can also embed the signaling server in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@v0.0.0-20220505182851-8eabe8595f05/pkg/wrtcsgl).
91
+
To use it in production, put this signaling server behind a TLS-enabled reverse proxy such as [Caddy](https://caddyserver.com/) or [Traefik](https://traefik.io/). You may also either want to keep `API_PASSWORD` empty to disable the management API completely or use OpenID Connect to authenticate instead; for more information, see the [signaling server reference](#signaling-server). You can also embed the signaling server in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcsgl).
87
92
88
-
### Manage Communities with `weron manager`
93
+
### 2. Manage Communities with `weron manager`
89
94
90
95
While it is possible to create ephermal communities on a signaling server without any kind of authorization, you probably want to create a persistent community for most applications. Ephermal communities get created and deleted automatically as clients join or leave, persistent communities will never get deleted automatically. You can manage these communities using the manager CLI.
91
96
@@ -129,7 +134,203 @@ It is also possible to delete communities using `weron delete`, which will also
129
134
$ weron manager delete --community mycommunity
130
135
```
131
136
132
-
For more information, see the [manager reference](#manager). You can also embed the manager in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/[email protected]/pkg/wrtcmgr).
137
+
For more information, see the [manager reference](#manager). You can also embed the manager in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcmgr).
138
+
139
+
### 3. Test the System with `weron chat`
140
+
141
+
The chat is an easy way to test if everything is working correctly. To join a chatroom, run the following:
You can now start sending and receiving messages or add new peers to your chatroom to test the network.
160
+
161
+
For more information, see the [chat reference](#chat). You can also embed the chat in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcchat).
162
+
163
+
### 4. Measure Latency with `weron utility latency`
164
+
165
+
An insightful metric of your network is it's latency, which you can measure with this utility; think of this as `ping`, but for WebRTC. First, start the latency measurement server like so:
On another peer, launch the client, which should start measuring the latency immediately; press <kbd>CTRL</kbd> <kbd>C</kbd> to stop it and get the total statistics:
For more information, see the [latency measurement utility reference](#latency-measurement-utility). You can also embed the utility in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcltc).
185
+
186
+
### 5. Measure Throughput with `weron utility throughput`
187
+
188
+
If you want to transfer large amounts of data, your network's throughput is a key characteristic. This utility allows you to measure this metric between two nodes; think of it as `iperf`, but for WebRTC. First, start the throughput measurement server like so:
On another peer, launch the client, which should start measuring the throughput immediately; press <kbd>CTRL</kbd> <kbd>C</kbd> to stop it and get the total statistics:
^CAverage throughput: 74.295 MB/s (594.359 Mb/s) (250 MB written in 3.364971672s) Min: 64.844 MB/s Max: 103.360 MB/s
205
+
```
206
+
207
+
For more information, see the [throughput measurement utility reference](#throughput-measurement-utility). You can also embed the utility in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcthr).
208
+
209
+
### 6. Create a Layer 3 (IP) Overlay Network with `weron vpn ip`
210
+
211
+
If you want to join multiple nodes into a overlay network, the IP VPN is the best choice. It works in a similar way to i.e. Tailscale/WireGuard and can either dynamically allocate an IP address from a CIDR notation or statically assign one for you. On Windows, make sure to install [TAP-Windows](https://duckduckgo.com/?q=TAP-Windows&t=h_&ia=web) first. To get started, launch the VPN on the first peer:
{"level":"info","addr":"wss://weron.herokuapp.com/","time":"2022-05-06T22:22:30+02:00","message":"Connecting to signaler"}
224
+
{"level":"info","id":"[\"2001:db8::b9/64\",\"192.0.2.186/24\"]","time":"2022-05-06T22:22:36+02:00","message":"Connected to signaler"}
225
+
{"level":"info","id":"[\"2001:db8::6a/64\",\"192.0.2.107/24\"]","time":"2022-05-06T22:22:36+02:00","message":"Connected to peer"}
226
+
```
227
+
228
+
You can now communicate between the peers:
229
+
230
+
```shell
231
+
$ ping 2001:db8::b9
232
+
PING 2001:db8::b9(2001:db8::b9) 56 data bytes
233
+
64 bytes from 2001:db8::b9: icmp_seq=1 ttl=64 time=1.07 ms
234
+
64 bytes from 2001:db8::b9: icmp_seq=2 ttl=64 time=1.36 ms
235
+
64 bytes from 2001:db8::b9: icmp_seq=3 ttl=64 time=1.20 ms
236
+
64 bytes from 2001:db8::b9: icmp_seq=4 ttl=64 time=1.10 ms
237
+
^C
238
+
--- 2001:db8::b9 ping statistics ---
239
+
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
240
+
rtt min/avg/max/mdev = 1.066/1.180/1.361/0.114 ms
241
+
```
242
+
243
+
If you temporarly loose the network connection, the network topology changes etc. it will automatically reconnect. For more information and limitations on proprietary operating systems like macOS, see the [IP VPN reference](#layer-3-ip-overlay-networks). You can also embed the utility in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcip).
244
+
245
+
### 7. Create a Layer 2 (Ethernet) Overlay Network with `weron vpn ethernet`
246
+
247
+
If you want more flexibility or work on non-IP networks, the ethernet VPN is a good choice. It works in a similar way to `n2n` or ZeroTier. Due to API restrictions, this VPN type [is not available on macOS](https://support.apple.com/guide/deployment/system-and-kernel-extensions-in-macos-depa5fb8376f/web); use [Asahi Linux](https://asahilinux.org/), a computer that respects your freedoms or the layer 3 (IP) VPN instead. To get started, launch the VPN on the first peer:
{"level":"info","addr":"wss://weron.herokuapp.com/","time":"2022-05-06T22:52:56+02:00","message":"Connecting to signaler"}
267
+
{"level":"info","id":"b2:ac:ae:b6:32:8c","time":"2022-05-06T22:52:57+02:00","message":"Connected to signaler"}
268
+
{"level":"info","id":"fe:60:a5:8b:81:36","time":"2022-05-06T22:52:57+02:00","message":"Connected to peer"}
269
+
```
270
+
271
+
And add the IP addresses:
272
+
273
+
```shell
274
+
$ sudo ip addr add 192.0.2.2/24 dev tap0
275
+
$ sudo ip addr add 2001:db8::2/32 dev tap0
276
+
```
277
+
278
+
You can now communicate between the peers:
279
+
280
+
```shell
281
+
$ ping 2001:db8::2
282
+
PING 2001:db8::2(2001:db8::2) 56 data bytes
283
+
64 bytes from 2001:db8::2: icmp_seq=1 ttl=64 time=1.20 ms
284
+
64 bytes from 2001:db8::2: icmp_seq=2 ttl=64 time=1.14 ms
285
+
64 bytes from 2001:db8::2: icmp_seq=3 ttl=64 time=1.24 ms
286
+
^C
287
+
--- 2001:db8::2 ping statistics ---
288
+
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
289
+
rtt min/avg/max/mdev = 1.136/1.193/1.239/0.042 ms
290
+
```
291
+
292
+
If you temporarly loose the network connection, the network topology changes etc. it will automatically reconnect. You can also embed the utility in your own application using it's [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtceth).
293
+
294
+
### 8. Write your own protocol with `wrtcconn`
295
+
296
+
It is almost trivial to build your own dstributed applications with weron, similarly to how [PeerJS](https://peerjs.com/) works. Here is the core logic behind a simple echo example:
297
+
298
+
```go
299
+
// ...
300
+
for {
301
+
select {
302
+
caseid:=<-ids:
303
+
log.Println("Connected to signaler", id)
304
+
casepeer:=<-adapter.Accept():
305
+
log.Println("Connected to peer", peer.PeerID, "and channel", peer.ChannelID)
306
+
307
+
gofunc() {
308
+
deferfunc() {
309
+
log.Println("Disconnected from peer", peer.PeerID, "and channel", peer.ChannelID)
You can either use the [minimal adapter](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcconn#Adapter) or the [named adapter](https://pkg.go.dev/github.com/pojntfx/weron@main/pkg/wrtcconn#NamedAdapter); the latter negotiates a username between the peers, while the former does not check for duplicates. For more information, check out the [Go API](https://pkg.go.dev/github.com/pojntfx/weron@main) and take a look at the other utilities and services in the package for examples.
0 commit comments