Commit Graph
1262 Commits
Author SHA1 Message Date
Jeff Hill a456c2011f Add configurable recv limits to protect against malicious peer
RecvBufferSize
RecvBufferMessages
RecvMaxMessageSize

P4:7421829,7421830
2022-08-06 14:25:21 -07:00
Fletcher Dunn a6486a7def Bring cert tool up-to-date with Steam version
Some new SDR-specific stuff was added to the Steam version.

P4:7421828
2022-08-06 14:16:05 -07:00
Fletcher Dunn f83a17416b Tweak asserts and stuff
- Do not define DBGFLAG_ASSERT if _CERT is defined.
- Tweak how/when STEAMNETWORKINGSOCKETS_SNP_PARANOIA and
  STEAMNETWORKINGSOCKETS_USE_GNU_DEBUG_MAP are defined.
- Fix compile error in Assert if DBGFLAG_ASSERT isn't defined

P4:7380968
2022-07-15 19:02:58 -07:00
Fletcher Dunn 26c66445f5 Fix unused variable warnings when asserts are disabled
P4:7380965
2022-07-15 18:57:45 -07:00
Fletcher Dunn b8acef56c9 Don't #define VALVE_POSIX
I changed the Steam headers that were checking this (they are not used
in the opensource code) and it is no longer needed.

P4:7380958,7380960
2022-07-15 18:51:55 -07:00
Fletcher Dunn c93996ee94 Sync up with Steam
Merge back some minor textual differences

P4:7380945,7380941
2022-07-15 18:32:55 -07:00
Fletcher Dunn 5a895baaef Do not rely on the app to call CCrypto::Init().
We will do one-time init the first time any crypto algorithms are needed.

P4:7380940
2022-07-15 18:23:45 -07:00
Fletcher Dunn 14e894d673 Add some checks and error handling to the libsodium code
P4:7370215
2022-07-08 16:45:31 -07:00
Sam V 505c697d0a Fix incorrect nonempty check in ICE initialization v1.4.1 2022-06-16 07:39:44 -07:00
Sam V ef4ed2e8d8 Add missing override specifier 2022-06-16 07:39:12 -07:00
Fletcher Dunn 226eb10818 Add BEGIN_TIER1_NAMESPACE around CUtlBuffer code
This is to help avoid name collisions when static linking.
(See 53bff2cc0d)

P4:7324330
2022-06-15 13:12:31 -07:00
Fletcher Dunn 7012a24e0d A few more platform fixes
- minbase_identify will now check for _GAMING_XBOX_XBOXONE and
  _GAMING_XBOX_SCARLETT.  (And also _GAMING_XBOX)
- Added IsXboxScarlett() and IsXbox()
- A few places in the low level code need to be tweaked based on IsXbox()
  instead of _XBOX_ONE
- Added IsIOS() and IsTVOS()

Deleted some code that was disabling warnings, I don't think it's needed
anymore.

Tweak defines in CSteamNetworkingUtils::GetPlatformString

PS4/PS5 need Microsoft-style __declspec(dllexport)

P4:7324318
2022-06-15 13:09:27 -07:00
Fletcher Dunn 63dadf6492 Do not #define STEAMNETWORKINGSOCKETS_ENABLE_STEAMNETWORKINGMESSAGES by default on console
We really, *really* would prefer people to use the connection-oriented APIs.

P4:7324311
2022-06-15 13:07:14 -07:00
Fletcher Dunn 4e961ee0f2 Add a cast for Nintendo
They insist on using "enum class" and making their parallel version of
Berkely sockets, and I am 100% confident that literally not one single
person actually wants this.

P4:7324300
2022-06-15 13:06:00 -07:00
Sam V bbdb0774ed Mark all directories as safe so CI builds don't fail with "unsafe repository" errors 2022-06-15 12:54:05 -07:00
Sam V 1593fb4fa9 Update checkout action to use main branch instead of master 2022-06-15 06:43:37 -07:00
Fletcher Dunn 83bf588179 Don't customize OpenSSL rand if >= OpenSSL 3.0
The functions are deprecreated and it's breaking the build.

Should fix #236
2022-06-14 17:51:54 -07:00
Fletcher Dunn 09871d2dc4 Improve platform compatibility
Replace a bunch of non-standard defines with standard ones

Don't #define POSIX in public header or test for it.  Fixes #228.
(We shoulkd probably also make this change to Steamworks headers.)

Use IsLinux(), IsPosix(), etc instead of #ifdef LINUX or #ifdef POSIX

Moved some platform socket stuff out of steamnetworkingsockets_platform.h
and into platform_sockets.h.  (none of this is actually particular to
steamnetworkingsockets.)

Some platforms don't have IPv6 support.
2022-06-14 12:04:10 -07:00
Fletcher Dunn 78481e083d Inverted logic in auth caching
P4:7320764
2022-06-14 11:42:35 -07:00
Fletcher Dunn 3f2cc6ea76 Clear the poll list and mark it as needing rebuild in a few key places
This is in case the library is shutdown and re-initialized.

I believe this fixes #230.

P4: 7317139
2022-06-13 11:24:52 -07:00
Fletcher Dunn 0d45cffe03 Include specific libsodium headers instead of monolith 2022-06-13 11:24:16 -07:00
Sam V f6a8c0365d Rework protobuf dependency to use import library
ValveSoftware/GameNetworkingSockets#233
2022-06-13 11:18:32 -07:00
Sam V db3a9f70f7 Set OPENSSL_MSVC_STATIC_RT to value of MSVC_CRT_STATIC and update manual windows building instructions
ValveSoftware/GameNetworkingSockets#232
2022-06-13 09:29:46 -07:00
past-due 9a61630e5e [CMake] Explicitly specify CXX_EXTENSIONS ON 2022-06-13 09:13:53 -07:00
Fletcher Dunn b221ac1a1c Fix incorrect comment describing lan priority
Fixes issue #224
2022-06-08 11:11:36 -07:00
Fletcher Dunn 0a42a43bc1 Add CCryptoKeyBase_RawBuffer::EnsureRawDataPtrAvailable
Remove asserts in OpenSSL EVP implemtnation of CEC25519KeyBase::Wipe.  We
might have a raw copy, and that's OK.

(This change was needed to fix some bugs in code that is not part of the
opensource code.)

P4:7307240
2022-06-08 10:59:36 -07:00
Fletcher Dunn 6e8928b2af Add CCryptoKeyBase::BMatchesRawData
Fix bug in SteamNetworkingSockets::InternalSetCertificate incorrectly assuming
that GetRawDataPtr was always available.  It only works for some crypto
implementations.

P4: 7307233
2022-06-08 10:57:07 -07:00
Fletcher Dunn 1838b62e8f Break out code that sets/wipes the raw buffer into separate functions
This is so that derived classes can use them more easily.  (Specifically, to
be able to set the raw buffer without the virtual Wipe() being called.)

Also: WIPE NEEDS TO SECURELY WIPE, not just free the buffer!

P4:7307228
2022-06-08 10:56:12 -07:00
Fletcher Dunn a1ec9538af Refactor code that sets identity and certificates.
This is to enable cacfhing of certificates and relay tickets to a durable
cache, especially on consoles.

- InternalClearIdentity is virtual, this will give the SDR class a chance
  to nuke any existing tickets when we reset our identity.
- Added InternalOnGotIdentity
- Refactored SetCertificate and added some flags so that we can control
  how it interacts with the cache.  Things can get a bit tangled because
  in some sitautions the certificate is how we learn what our identity
  is.

P4:7307221
2022-06-08 10:51:11 -07:00
Fletcher Dunn d9a7295c8c Fix for rare deadlock with P2P callbacks.
When looking up connections by their handle, take both the table and the connection
lock using a timeout.  If we fail, release both locks and start all over.
This will proptect against a deadlock if we take the locks in the opposite order.
We currently don't ever encounter this situation solely within this library.  However,
we did come across a case with P2P callbacks calling into a custom signal handler.
We could probably fix the custom signal handler to not do this, but it seems like
there are going to be other edge cases, and this change is low risk because contention
is low and most lock attempts will succeed immediately.  And deadlocks are very
hard to reproduce and debug.

CR:saml

P4:7307214
2022-06-08 10:47:45 -07:00
Fletcher Dunn a581422fe4 Fix incorrect comment
P4:7307208
2022-06-08 10:45:50 -07:00
Fletcher Dunn c26b044fb3 Add extern "C"
P4:7307202
2022-06-08 10:43:27 -07:00
Fletcher Dunn 53bff2cc0d Add some namespaces around tier0 and tier1 stuff.
This minimizes the chance of name collision when statically linking.
(Especially if game is using some iteration of the Source engine!)

P4:7307196
2022-06-08 10:41:36 -07:00
Fletcher Dunn 3849f3a2c7 Fix for Switch
P4:7248965
2022-06-08 10:39:47 -07:00
Fletcher Dunn 644eeb6872 Delete some dead code
P4:7248965
2022-06-08 10:38:05 -07:00
Fletcher Dunn 0e7cd2c79d Fix some silly cosmetic things with IPv6 printing/parsing
Touch up some comments

P4:7246923
2022-06-08 10:34:17 -07:00
Fletcher Dunn 517f463d29 IPv6 text parsing now supports IPv4 dotted decimal
E.g. ::ffff:192.168.2.1

P4:7246897
2022-05-11 09:47:47 -07:00
Fletcher Dunn 792532352e Try to detect if RTTI is enabled at compile time
If not enabled don't use dynamic_cast.  (We only use it for certain debugging
checks.)

It is important to me that you be able to use this lib without RTTI enabled.

p4:7246870
2022-05-11 09:42:55 -07:00
Fletcher Dunn eb09e02ee3 Fix ICE/P2P cmake stuff
ENABLE_ICE means "enable any ICE support, including the native client"
and is on by default.  (Because the native client is not much code.)

Try to build the trivial_signling_server if we are building either
examples or tests, and ENABLE_ICE is set.  The P2P test needs it.
2022-04-26 19:05:57 -07:00
Fletcher Dunn 7d0128ed44 Fix allowed range of P2P_Transport_ICE_Implementation 2022-04-26 19:05:56 -07:00
Gary Wang cf10980a51 fix build under Windows with MSYS2 MinGW64 2022-04-26 18:04:54 -07:00
Fletcher Dunn 41c7d2b76c Link windows system lib using #pragma lib 2022-04-26 17:40:59 -07:00
Fletcher Dunn 365d8cdd80 Update vcpkg commit to build from.
This should fix windows CI I think.  Not sure if I should just delete this
and always use HEAD of vcpkg?
2022-04-26 16:19:39 -07:00
Fletcher Dunn a39de80f9b Fix a bug which would trigger under very high packet loss.
The basic problem was that we were using m_statsEndToEnd.m_nMaxRecvPktNum
for two purposes:
- The highest numbered we have received, for purposes of jitter calculations
  and duplicate packet rejection.
- The highest numbered packet we want to ack.

But if we decide to drop a packet (to protect against a malicious sender, etc)
and intentionally not ack it, these values won't be the same!  This means we
might be acking packets that we did not actually process!  Fortunately, it only
happened if the fragmentation was extremely high, which only happens when there
is extrenely high packet loss.  Also, only certain cases of "don't ack this"
can cause any problems other than asserts.

The "soak" connection test has been detecting this bug for a while, but I
haven't had a chance to investigate, since it only triggered underly insanely
high packet loss (whichthe test simulates).  But now the soak test passes,
which....is good!

With this change, the role of m_statsEndToEnd.m_nMaxRecvPktNum is only for
duplicate detection.  We track the highest numbered packet that we wish to ack
in the sentinel in m_receiverState.m_mapPacketGaps.  The time when that packet
was received will also be tracked there.  This change actually simplified some
code.

One more change: how we protect against a malicious sender causing our packet gap
map to be too large.  When we go to add a new gap, previously if we were already
at the max, we would immediately abort the function.  Now, we move the handling
of "too many gaps" to be later in the function, and we try to select the "best"
gap to erase, with the goal of minimizing the degregation (very possibly none)
caused by us starting to nack a block of packets that were actually received
(and in fact perhaps previousally acked).

P4:7219136
2022-04-26 16:12:15 -07:00
Fletcher Dunn ab091afd62 Fixes to connection test
- Make sure we tell the connection what send buffer size to use, and then
  don't exceed it.
- Rename some stuff to be more clear

P4:7219096
2022-04-26 15:59:46 -07:00
Fletcher Dunn 0301b8a961 Fix relatively rare packet timing/accounting bug
If there's a packet number lurch and we reset the last received packet
number, we should mark the time when it was received.  Otherwise our
jitter calculations will be off

P4:7219094
2022-04-26 15:58:04 -07:00
Fletcher Dunn 6974c9a15b Disable auth in test when running with Steam support
(Not relevant to opensoruce code)
2022-04-26 15:56:55 -07:00
Fletcher Dunn 3d470655bc Improved platform compatibility layer
Deleted several places where we were using this pattern:

   <platform 1 code>
   <platform 2 code>
   ... etc

This is a pain when you have some platforms that are under NDA and you
cannot share the code.  Instead I introduced some abstractions that made
it possible to move all of the platform-specific code (at least for NDA
platforms, which are my primary concern right now) to a separate file.
This way, we can just exclude particular files from distribution, rather
that have files that actually differ.

Also changed some platform-defines to more "functional" defines (USE_POLL,
USE_EPOLL, WAKE_THREAD_USING_EVENT, WAKE_THREAD_USING_SOCKET_PAIR) that
make it clear the reason for the #ifdef.  This also means on platforms
that support multiple methods (e.g. Linux) we could switch those options.

Finally, renamed a few things with "SteamDatagram" in the name to
"SteamNetworkingSockets".  I'm trying to have "datagram" refer exclusively
to the relay network, which is only available to Steam partners, and
thus in general should not be present in the opensource code.

P4:7219053,7219056,7219071
2022-04-26 15:47:22 -07:00
Fletcher Dunn b90a657997 Tweaking platform compatibility
Don't #define or check for GAME_CONSOLE.  That's what IsConsole() is for.
Add PS5 defines, add a few PS5 tweaks
Delete some PS3/Xbox360 stuff

P4:7219035
2022-04-26 15:27:02 -07:00
Fletcher Dunn b610cfeafe Only #include <dlfcn.h> if we're gonna actually try to load a library.
(We aren't going to do this on game consoles, where it doesn't exist.)

P4:7218729
2022-04-26 14:05:56 -07:00