microsoft / msquic

Cross-platform, C implementation of the IETF QUIC protocol, exposed to C, C++, C# and Rust.
MIT License
4.05k stars 530 forks source link

Support P2P NAT "Punch Through" #3251

Open GeneralFury opened 1 year ago

GeneralFury commented 1 year ago

Describe the feature you'd like supported

msquic used for p2p

Proposed solution

i have history udp net framework for nat。but i have no idea to use msquic for p2p 。

Additional context

No response

nibanks commented 1 year ago

We don't currently have any NAT punch through logic, but it would be possible to add. It would also be helpful if you could describe the scenario and any justification you have so we could plan and prioritize accordingly.

snltty commented 1 year ago

just need listener can be sent unconnect message

nibanks commented 1 year ago

Not receive them? It'd be great to have a clear, exhaustive list with exactly what's needed.

snltty commented 1 year ago

c# udp AT punch demo

UdpClient client1 = new UdpClient(5000);
UdpClient client2 = new UdpClient(5001);

var client1Endpoint = new IPEndPoint(IPAddress.Parse("client1 remote point"),5000);
var client2Endpoint = new IPEndPoint(IPAddress.Parse("client2 remote point"),5001);

//step1,client2 can not receive this message,but ,the router will establish the mapping
var anyMessage = new byte[0];
client1.Send(anyMessage ,anyMessage .Length, client2Endpoint );

//step2,client1 router establish the mapping,so,client1 can receive this message,maybe!
client2.Send(new byte[]{1,2,3},3, client1Endpoint );

so,quiclistener sent any message to “remote endpoint”, router establish mapping。 maybe can receive message from “remote endpoint”

or,just need quiclistener export socket SendTo API