1632 Commits

Author SHA1 Message Date
Fletcher Dunn 98d8d95aa1 Fix -Wundef warning for TARGET_OS_IOS on older Apple SDKs 2026-05-28 19:38:49 -07:00
Fletcher Dunn 39a50f40f7 Fix compiler warnings if DBGFLAG_ASSERT not defined 2026-05-28 19:31:14 -07:00
Fletcher Dunn e9832ac1af Don't use make_unique, we want to support cxx11 as long as we can 2026-05-28 19:27:03 -07:00
Fletcher Dunn 91465451d0 vcpkg fixes
vcpkg manigest:
- Add vcpkg-cmake as dependency of this project
- Don't support bcrypt as vcpkg feature.  Nobody using vcpkg wants bcrypt,
  so this is just a trap.

Local/test overlay port:
- Fix how we are setting SOURCE_PATH
- Add symlink to out vcpkg.json manifest, since a port needs one

Chat example built using vcpkg:
- Add GNS_LINK_STATIC option to vcpkg_example_chat project so I can test
  an app linking against static or dynamic lib.
2026-05-28 14:41:44 -07:00
Fletcher Dunn 495094583f Correct version in our vcpkg manifest 2026-05-28 09:42:16 -07:00
Fletcher Dunn c9d48c76d0 Fix windows 2026-05-27 23:35:24 -07:00
Fletcher Dunn f539edb097 ICE client: fix retrigger
Sometimes the RFC algorithm wants you to immediately 'retrigger' a
candidate check.  The previous code was deleting the previous request
and creating a new one.  But this means that any reply that comes in
cannot get matched up, because the new request will get a new
transaction ID.  In general, I think any time we cancel a request and
throw it away, it is probably a mistake, because the reply that comes
back contains useful information, and if we throw away the request, we
won't be able to match it up by transaction ID and remember what we were
doing, so we lose that information.

This can be catastrophic.  The Mac CI was failing because of a timing
issue where each side would 'retrigger' its request just before the
reply to the previous request arrived.  All of the responses were
getting dropped because they could not be matched up by transaction ID.

The new code just resets the retransmission timer, causing us to send it
immediately and also resets the exponential backoff schedule.

Also, simplify some logic and tweak formatting.
2026-05-27 22:53:43 -07:00
Fletcher Dunn 85be74feee ICE client: tweak spew 2026-05-27 21:15:06 -07:00
Fletcher Dunn bde7c7b858 test_p2p.py: Add symmetric test that requires TURN 2026-05-27 20:57:23 -07:00
Fletcher Dunn 311ce2ea50 ICE client: Apply two candidate processing rules from the RFC 2026-05-27 20:57:18 -07:00
Fletcher Dunn 6776f82e78 ICE client: Fix route determination
It needs the local candidate (with the relay, if present), not just the
interface.  And check for either candidate being relayed, then route is
relayed.
2026-05-27 20:55:29 -07:00
Fletcher Dunn 53b6ca0a22 Test STUN/TURN server: Add --relay-latency arg, use 75ms in tests
This helps make sure that relayed routes don't win a race, and we
can use the naive RFC algorithm and confirm that we get the route
type that we expect
2026-05-27 20:55:29 -07:00
Fletcher Dunn da51fe5665 ICE client: Basic TURN server support is working 2026-05-27 20:54:19 -07:00
Fletcher Dunn 19be4d372a ICE client: more progress on TURN server support
Add ICELocalCandidate.  This was deleted earlier, because it had a bunch
of extra stuff that we don't care about when comparing if two local
candidates are the same.  Essentially if we send diretcly from our
socket, then we don't really care what kind of candidate it is to the
peer.  But we do really need to distinguish between local candidates
that are relayed.

Add ICESessionInterface::SendPacketGather, which knows how to wrap a
data packet in a k_nTURN_SendIndication

Check for k_nTURN_DataIndication from TURN servers.  This doesn't work
fully right now.
2026-05-27 16:08:50 -07:00
Fletcher Dunn ea2b3842c6 ICE client: Small cleanup
Delete unused function
Don't dynamically allocate any attributes passed to SendSTUNResponsePacket
2026-05-27 16:01:18 -07:00
Fletcher Dunn 9aed2eb8c2 ICE client refactor: simplify packet sending
Really, the separation between CSteamNetworkingICESession and
CConnectionTransportP2PICE_Valve is just not very useful and
those classes should be merged.
2026-05-27 11:54:27 -07:00
Fletcher Dunn f266d3138b ICE client: Send TURN CreatePermission requests 2026-05-27 11:16:30 -07:00
Fletcher Dunn e09fbc9616 ICE client: simplify STUN/TURN requests
- Move 'factory' functions to be methods on ICESessionInterface
- Delete CRecvSTUNPktCallback, callback can be just a simple pointer to
  method
- Serialize the request once instead of saving off attributes and
  complicated memorty management.
2026-05-27 10:10:37 -07:00
Fletcher Dunn d41a4db85c ICE client: Add logic to gather relay candidates from TURN servers 2026-05-27 08:39:55 -07:00
Fletcher Dunn ea9c4ade95 test_p2p.cpp now understands --turn-server 2026-05-27 08:33:55 -07:00
Fletcher Dunn 75f621aadb Test STUN server now supports minimal TURN features 2026-05-27 08:33:52 -07:00
Fletcher Dunn e5b4615d2e ICE client refactor: Delete list of local candidates
And we don't need ICELocalCandidate at all any more.
This is so much simpler.
2026-05-26 23:45:40 -07:00
Fletcher Dunn 6f6419084e ICE client refactor: Simplify
Delete UpdateHostCandidates, just create the host candidate immediately
when we create the interface.

Also delete ICECandidateBase::CalcPriority.  We only called that when
adding a new local candidate, so just do the work directly in the
constructor.
2026-05-25 23:35:12 -07:00
Fletcher Dunn e735bc0329 ICE client refactor: ICECandidatePair stores local interface
Not the local candidate!  A "local candidate" is a thing that we need to
tell our peer about, but when we need to send or receive packets, we
use a socket.  When a socket has a host candidate, a server reflexive
candidate, etc, we don't really know or care which of those candidates
the peer used to talk to us.

Also, deleted IsCandidatePermitted.  We need this, but the place we were
calling it was wrong.
2026-05-25 23:35:12 -07:00
Fletcher Dunn fd500ef8ba ICE client refactor: simplify parsing flow
Delete UnpackSTUNHeader and IsValidSTUNHeader.  Combine them and
expand them inline at the only place we need to do this.

Rename DecodeSTUNPacket to ParseSTUNAttributes.  It will get a copy
of the header already parsed, and will assume that the packet has
already been verified to be STUN.

Rename CSteamNetworkingSocketsSTUNRequest::OnPacketReceived to
ReplyPacketReceived and pass in what we have already parsed.
Delete return value, which was unused by only call site also
referred to silly nonsensical constants
2026-05-25 23:35:14 -07:00
Fletcher Dunn 60314c1606 ICE client refactor: Each Interface knows what session owns it
Socket callback will be the interface pointer, which gives us
a little bit more context and makes a few things simpler.
2026-05-25 23:35:13 -07:00
Fletcher Dunn 2a9bedc599 ICE client refactor: Delete ICELocalCandidate::m_base 2026-05-25 18:00:38 -07:00
Fletcher Dunn 3d29fc0a08 ICE client refactor: local candidates remember the interface
This removes several places where we need to lookup the interface.
But since we are storing a pointer, it means now we need to make sure
and carefully cleanup if an interface drops out of the interface list.
2026-05-25 17:52:31 -07:00
Fletcher Dunn 14e01af87d ICE client refactor: Move m_base to local candidate only 2026-05-25 17:52:28 -07:00
Fletcher Dunn 47300da67b ICE client refactor: candidate type from address not base 2026-05-25 17:52:27 -07:00
Fletcher Dunn 9032a75a17 ICE client refactor: Candidate type enum
There was a nested type CSteamNetworkingICESession::ICECandidateType,
which was named very confusingly similar to EICECandidateType.  That
type uses different enum values based on the address family.

Renamed it to ICECandidateKind, made it an enum class, and promoted
to global scope.

Also, moved RFC5245CandidateAttr so we don't have to forward declare
it.
2026-05-25 17:52:24 -07:00
Fletcher Dunn bfdefb73af ICE client refactor: Handling of received peer candidates
RFC5245CandidateAttr now store the address directly, nor address string
and port.
AddPeerCandidate will receive this directly, and return the type
2026-05-25 17:52:23 -07:00
Fletcher Dunn 390d19d1ff ICE client refactor: Add ICELocalCandidate derived type 2026-05-25 17:52:23 -07:00
Fletcher Dunn 24dd247196 ICE client refactor: each interface owns 0/1 STUN requests
A STUN requests knows what interface it came from
No need for a separate list of STUN requests or keepalives
2026-05-25 15:00:50 -07:00
Fletcher Dunn d01e782ae8 ICE client refactor: Rename Interface to ICESessionInterface 2026-05-25 15:00:50 -07:00
Fletcher Dunn fdd7f515ed ICE client refactor: Don't store local address redundantly
The socket knows what address it was bound to.
Also added helper function IPAddrEqualIgnoringPort
2026-05-25 15:00:49 -07:00
Fletcher Dunn eb6d0678fa ICE client refactor: Interface owns the socket
Simplify GatherInterfaces

Store the interface vector indirectly.  This makes is so that we don't
have to define the move constructors/assignment, needed so that we can
remove items from the list.  Also, looking ahead, I want the callbacks
to have a pointer to their interface, which will remove a little bit
of lookup work, and this will require stable pointers.
2026-05-25 15:00:33 -07:00
Fletcher Dunn bf19de7778 ICE client refactor: delete m_vecHostCandidateSockets
Just store the socket in the corresponding Interface
2026-05-25 15:00:33 -07:00
Fletcher Dunn 9273c5bcc9 ICE client refactor: Delete unused function GetCandidates 2026-05-25 15:00:33 -07:00
Fletcher Dunn de47bdfa0b ICE client: delete dead code 2026-05-25 13:53:47 -07:00
Fletcher Dunn b7d60c2edf ICE client - document state variables 2026-05-24 18:47:57 -07:00
Fletcher Dunn b88a52c206 Fix dangling pointer bug
If there is more than one STUN server and the name is
shorter than std::string small string optimization size.
2026-05-22 22:22:02 -07:00
Fletcher Dunn 951a3a967b Remove unnecessary call to UpdateFakeRateLimitTokenBuckets
This just spends CPU time with no benefit, and also leads to a
(probably harmless) tsan warning
2026-05-22 21:39:19 -07:00
Fletcher Dunn 19fd53901c test_p2p now supports --repeat 2026-05-22 21:26:57 -07:00
Fletcher Dunn 2ca71d516f Add cases that require IPv6 server reflexive to work 2026-05-21 21:58:17 -07:00
Fletcher Dunn 491d224f10 ICE client supports IPv6 server reflexive candidates 2026-05-21 21:57:27 -07:00
Fletcher Dunn 98d4bada61 ResolveHostname can now accept a literal IP or IP:port 2026-05-21 21:56:19 -07:00
Fletcher Dunn 7a871443ed Test STUN server now supports IPv6 2026-05-21 21:54:09 -07:00
Fletcher Dunn 7db494c6e7 Compiler warnings
P4:10650618
(cherry picked from commit f7e8d96de3)
2026-05-18 15:43:46 -07:00
Fletcher Dunn 3ff74eae0e Setup loopback aliases for p2p tests properly 2026-05-18 07:34:44 -07:00