ao-space / gt

Fast WebSocket(s)/HTTP(s)/TCP relay proxy for making tunnels to localhost.
https://ao.space
Apache License 2.0
121 stars 34 forks source link

Question: Are there any examples of implementing WebRTC peer-to-peer connections? #24

Closed mmabluesky closed 1 year ago

mmabluesky commented 1 year ago

hi : the document mentions supporting WebRTC peer-to-peer connections. ,so, how can I achieve WebRTC peer-to-peer connection using GT ?

vyloy commented 1 year ago

Currently, P2P connections with GT Client can be established between ao.space clients (iOS, Android, Web) and GT Client.

GT Client establishes a P2P connection with GT Client:

. /linux-arm64-client -local http://127.0.0.1:80/ -remote tcp://example.com:8080 -remoteSTUN stun:example.com:3478 -id id1 -secret secret1
. /linux-arm64-client -local http://127.0.0.1:80/ -remote tcp://example.com:8080 -remoteSTUN stun:example.com:3478 -id id2 -secret secret2 - tcpForwardAddr 127.0.0.1:10000 -tcpForwardHostPrefix id1

Traffic sent to 127.0.0.1:10000 will be forwarded to another GT Client via P2P. This is an experimental feature, and there are plans to implement it in the future with better design.

Next week, we will add sample code to show how to establish P2P connection between Web and GT Client, please stay tuned.

vyloy commented 1 year ago

Here is the example about how to build WebRTC P2P connection with GT client on Web by using JavaScript:

https://github.com/ao-space/gt/blob/dev/example/dev/web/p2p.js

yuandaqing2009 commented 1 year ago

The question has been answered and this issue is closed