News for hackers. Stuff that matters.
Re:A simple C implementation to stream H.264 to browser usin... by jcelerier on Thursday April 08, 2021 @03:04AM (#26735915)
... how is STUN pure p2p ? you still need to have a STUN server somewhere no ?
Re:A simple C implementation to stream H.264 to browser usin... by j1elo on Thursday April 08, 2021 @03:36AM (#26736083)
STUN is just for punching holes in your NAT router, and also discovering what is your public IP address. Both things will be needed for the other peer to know where to reach you. And the other way around.

Once this NAT thing has been done by both parts, and the actual communication has started directly P2P, STUN is not needed any more.

Re:A simple C implementation to stream H.264 to browser usin... by noseratio on Thursday April 08, 2021 @06:19AM (#26737062)
You'd also need a TURN server if both peers are behind NAT without UPnP, which is very common. STUN alone wouldn't be enough.
Re:A simple C implementation to stream H.264 to browser usin... by callesgg on Thursday April 08, 2021 @07:55AM (#26737646)
That is partially incorrect, STUN can punch a hole through even when both sides uses NAT in many cases. That is what I would classify as STUN’s main feature.
Re:A simple C implementation to stream H.264 to browser usin... by rashkov on Thursday April 08, 2021 @09:30AM (#26738461)
Note that parent said “ if both peers are behind NAT without UPnP”. As far as I know, there’s no way to punch holes / open ports automatically without UPnP.
Re:A simple C implementation to stream H.264 to browser usin... by callesgg on Thursday April 08, 2021 @04:55PM (#26743653)
Go read about stun.

You send outgoing packets simultaneously from both sides. Causing both sides to add nat translation entry’s to their nat tables. When the packets arrive both sides already have nat translation entries and the packets go right through the nat.

Re:A simple C implementation to stream H.264 to browser usin... by uuidgen on Thursday April 08, 2021 @09:44AM (#26738584)
Punching holes doesn't work only when network devices in between are broken or are actively preventing it.

From the network point of view it looks the same as two hosts starting an outgoing TCP connection through nat - if that works then hole punching should work too.

Re:A simple C implementation to stream H.264 to browser usin... by labawi on Thursday April 08, 2021 @03:55PM (#26743011)
Not TCP. UDP - there are no connection in UDP, so the routers / firewalls don't really differentiate between a new connection and packets that happen to have the correct ip+port.

Some are trickier than others, as there are 2 IPs and 2 ports in a packet (at any point), and it can be hard to match all of them for the stricter devices, esp. on NATs that do source port randomization.

Re:A simple C implementation to stream H.264 to browser usin... by a1369209993 on Thursday April 08, 2021 @04:15PM (#26743210)
> when network devices in between are broken or are [maliciously] actively preventing it.

Those are called "middleboxes" (IIRC) and they're unfortunately somewhat pervasive.

Re:A simple C implementation to stream H.264 to browser usin... by jcelerier on Thursday April 08, 2021 @03:41AM (#26736110)
> STUN is just for punching holes in your NAT router, and also discovering what is your public IP address.

I know, but what I mean is that "true P2P" on our current internet architecture is not possible, you always need the help of a third party

Re:A simple C implementation to stream H.264 to browser usin... by bodegajed on Thursday April 08, 2021 @03:51AM (#26736159)
If we are still in the 90's that definition of "true p2p" would be: two computers with both having public IPs and transferring packets via TCP. But nowadays we are always behind NATs so we became less strict with the definition of what is true p2p
Re:A simple C implementation to stream H.264 to browser usin... by BlueTemplar on Friday April 09, 2021 @05:45AM (#26748522)
IPv6 is slowly taking over, hopefully in the near future being behind a NAT will be considered abnormal (just like happened with Unicode, we're around 35% = "Unicode 2009", popularity-wise).
Re:A simple C implementation to stream H.264 to browser usin... by the8472 on Thursday April 08, 2021 @04:23AM (#26736356)
Then bittorrent is transcendent p2p?
Re:A simple C implementation to stream H.264 to browser usin... by fulafel on Thursday April 08, 2021 @06:25AM (#26737092)
Your p2p nodes might not be behind NAT. In a lot of populations you can rely on everyone having working v6 for example.

I think the question of what's "pure" p2p is somewhat academic. If your app uses DNS, is it p2p, isn't DNS just a distributed p2p database? Does p2p require that every aspect of your app right down to discovery is distributed among nodes running your app? Is it cheating to use an existing DHT? etc.

Re:A simple C implementation to stream H.264 to browser usin... by bodegajed on Thursday April 08, 2021 @03:11AM (#26735950)
You can just use google stun servers they are free to use
Re:A simple C implementation to stream H.264 to browser usin... by _joel on Thursday April 08, 2021 @06:06AM (#26736986)
Here's a list of public STUN servers (non google too) https://www.voip-info.org/stun/