Commit Graph
398 Commits
Author SHA1 Message Date
Fletcher Dunn 42e8c60a9e Clean out minbase.h. Improve Xbox and Switch compat. 2019-09-02 10:24:36 -07:00
Fletcher Dunn 71d662012d More progress compiling in other environments. 2019-09-02 10:20:12 -07:00
Fletcher Dunn e8bba6ade1 Added interface for app to provision cert.
Also:
- STEAMNETWORKINGSOCKETS_STEAM now mens "running on steam", not "running using
  the steam client".  STEAMNETWORKINGSOCKETS_STEAMCLIENT is for that.
- Refactored stats stuff, moved it into the namespace.  At one point I thought
  I might expose some stuff in a public interface.  For now, keeping it internal.
- Removed concept of Steam "universe" from this branch of the code.
- Don't use OVERRIDE, override works.
2019-08-29 13:42:17 -07:00
Fletcher Dunn caf727f998 Fix meson build script. 2019-08-29 13:37:08 -07:00
Fletcher Dunn 8d58fa9d65 Comment out unused stuff 2019-08-29 13:22:39 -07:00
Fletcher Dunn 0f734b40b1 Fix CMakefile.
Well, we still aren't building.  But at least cmake doesn't fail.
2019-08-28 15:40:25 -07:00
Fletcher Dunn 08a2541e33 Don't use configure script for crypto.
Just set defines and include sources directly.
Also fix ome bcrypt compile issues.
2019-08-28 15:24:02 -07:00
Fletcher Dunn b795a21127 Take out the garbage.
Deleted a ton of old unused cruft left behind when I ripped this out from Steam.

Don't use tchar for all of our asserts.  I don't know why this was done, but it
 is dumb, and wasn't finished anyway.  We'll just use unicode when interacting
 with WIn32 APIs in UNICODE mode.  (For XboxOne.)
2019-08-28 13:45:30 -07:00
Fletcher Dunn e36a93fdba Just use printf for this command line tool 2019-08-28 13:42:02 -07:00
Fletcher Dunn d7bdca1350 Sync netadr_t with Steam's version.
I really ought to just get rid of this entirely, and use SteamNetworkingIPAddr everywhere.
2019-08-28 13:40:24 -07:00
Fletcher Dunn ae9de182a6 Change plumbing for appid and time.
These will be provided by SteamNetworkingUtils, which makes it easier
to customize them per-platform.
2019-08-28 13:37:01 -07:00
Steven Noonan 42d3ab872b travis: add libasan/libubsan dependencies for Fedora builds
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2019-06-11 08:34:38 -07:00
Steven Noonan 6b897cb39d travis: add CAP_SYS_PTRACE for docker, to ensure sanitizers work
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2019-06-11 08:34:26 -07:00
Steven Noonan 157476d587 travis: move Ubuntu to using rolling tags
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2019-06-11 08:33:45 -07:00
Fletcher Dunn f3a157a0f2 Merge pull request #67 from msinilo/patch-1
Fixed StopSteamDatagramThread not releasing all sockets
2019-05-15 09:38:55 -07:00
Maciej Sinilo d938b30c1d Fixed StopSteamDatagramThread not releasing all sockets
Fixed a copy-paste bug in StopSteamDatagramThread, it would never release s_hSockWakeThreadWrite properly (was testing s_hSockWakeThreadRead)
2019-05-14 20:48:14 -04:00
Fletcher Dunn d3c92a1ba0 Fix CUtlHashMap initialization bug.
Fix a pretty sharp edge: when inserting into CUtlHashMap with a function that
only takes a key and inserts the default value, we were using "default
initialization" ("new T"), which does not initialize PODs.  Switch to
"value initialization" ("new T{}").

Also some minor compiler compatibility fixes.  The version of gcc we're using
here didn't like the {}-style call of the base class constructor, so use ()
instead.  *shrug*

Also deleted a kludge for an older version of Visual Studio.  We were
supporting that for a while in Steam, but we've upgraded our min specs and
so I'm doing the same here.
2019-05-09 16:19:20 -07:00
Fletcher Dunn 4c2272ec66 Some improvemenets to CUtlMap.
Inline a bunch of stuff in the internal implementtion.  This can make a big
difference in the debug build.

A much simpler, saner iterator implementation.  We don't need full STL
iterator functionality.  We just want range-based for loops to work.  And we
don't want to expose a non-const reference to the key!!!!!

And some other stuff from Steam branch.
2019-05-08 13:45:58 -07:00
Fletcher Dunn 5415f36a10 Improve handling of unsigned certs.
Added AllowLocalUnsignedCert virtual function so connections can customize
this behaviour.  Don't read IP_AllowWithoutAuth in base class, that is only
applicable for UDP connections.

We're still not totally locked down in all cases, because there are some
weird edge cases I am worried about breaking on Steam that I haven't
had a chance to test.

Do not automatically trust UDP connections to localhost.  That might be
another process, maybe a  MITM adversary!  Instead, move this custom trust
logic to CSteamNetworkConnectionlocalhostLoopback.

Also don't use OVERRIDE #define, use the override keyword directly.  We are
using all kinds of C++ 11 features, so I'd be really surprised if there exists
a compiler that 1.) Doesn't support override 2.) Supports everything else we
are using in the code 3.) We actually care about supporting.
2019-05-06 09:31:24 -07:00
Fletcher Dunn 5c8c286077 Add an assert; then comment it out.
There is something here to fix I think.  It hasn't been causing problems, but
I believe we should be more explicitly resetting the expected packet number
when a connection is initialized.  (And the first packet should be assigned
a packet number.)
2019-05-06 09:27:48 -07:00
Fletcher Dunn 93dacbd610 Delete g_sLauncherPartner.
That isn't a thing outside of Steam.
2019-05-06 09:25:43 -07:00
Fletcher Dunn f932e64ebc Fix memory leak.
Two changes to cleanup.  First, to it earlier, as soon as the connection
switches into a state where we know we will not need to send or receive
messages anymore.  (Don't wait until object destruction.)  Second, we
were not freeing up any queued messages in the m_messagesQueued linked
list.

Also fix a monir bug in the linger functionality.  The connection is still
"connected" for all internal purposes, it just is not visible to the API
anymore.  So we need our stats object to stay alive, and we expect our peer
to be replying in a timely manner.

Add some asserts and paranoia.
2019-05-06 09:14:14 -07:00
Fletcher Dunn ec286242b6 Add rudimentary PKI inspection.
Add CertStore_Print, which uses.....std::ostream (I know, gross).  std::ostream
uses.....***EXCEPTIONS*** (barf).  I wish there were a good generic way to
write to a stream without bringing in a bunch of dependencies.  (E.g. "use
boost" is not helpful.)  I'll probably end up adding a #define to disable this.

Also touched the trust code to make sure it always produces a message, even if
trust is calculated multiple times and the value changes.
2019-05-05 13:18:04 -07:00
Fletcher Dunn a92ea83420 Fix bug if linger functionality is used. 2019-05-02 14:21:48 -07:00
Fletcher Dunn f981ec1112 Fix bug with 32-bit time_t
There was a COMPILE_TIME_ASSERT that obviously anticipated this problem, but
it was sadly thwarted by C's arcane type rules.
2019-05-02 14:18:54 -07:00
Fletcher Dunn 06daa0fdea Tweak spew 2019-05-02 14:16:50 -07:00
Fletcher Dunn 530ba632da Fix bugs not properly piggy-backing tracer pings.
We were setting the flag too agressively, and not really allowing for any
opportunism.

Really, tracer pings in stats messages are not that useful end-to-end, and I
probably should delete them, because every single data packet has acks that
serve as ping measurements.  If the conversation is very thin, it is perhaps
possible that you could go a while without being able to use the acks for
latency measurement, and tracer ping requests would kick in.  But it's just
as likely that a plain old keepalive would end up be sent, too.

Tracer ping requests are much more useful for maintaining a latency
measurement with the relay, on relayed connections, because there is nothing
that happens constantly due to normal traffic that can be used to measure
latency with the relay.
2019-05-02 14:08:22 -07:00
Fletcher Dunn 02b94d4853 Fix shutdown order of operations bug.
Calling virtual functions in a destructor seems almost always bad, it should
generate a compiler warning.  Made destructors protected, replace direct
invocations of operator delete with an explicit Destroy() method, which
ends (in the base class implementation) by calling "delete this".
2019-04-29 14:35:16 -07:00
Fletcher Dunn 701c945dd1 Fix bug not marking cert trust as valid.
This is a pretty big perf issue, since it means every time we check *any*
cert, we re-evaluate all of the cert signatures in the entire cert store.
(The design assumes that the numbers of certs will be relatively few,
but this is still pretty bad.)
2019-04-25 14:15:54 -07:00
Fletcher Dunn b6aff321e3 Sync up with Steam.
Not really any iportant changes here for the opensource code.
2019-04-25 13:03:19 -07:00
Fletcher Dunn c03229b9ab Merge pull request #65 from bobsayshilol/remote-addr
Set the remote's address when initiating a direct UDP connection.
2019-04-17 21:23:42 -07:00
bobsayshilol be9fca1b37 Set the remote's address when initiating a direct UDP connection.
Without this, status change callbacks would always have an invalid remote
address if we were the one who initiated the connection.
2019-04-17 21:03:01 +01:00
bobsayshilol e25beb2e69 Don't attempt to accept a connection if we've just rejected it.
No functional change intended since any child connection would be
using the same CSharedSocket, and so the BBeginAccept() call that
follows would have failed anyway.
2019-04-17 20:58:28 +01:00
Fletcher Dunn 4ea37fb89b Updated README.
Split out building stuff to a separate file.
2019-04-16 10:44:39 -07:00
Fletcher Dunn 0da061c2ca Add some basic PKI tests.
Unfortunately, these don't actually compile right now under either meson
or CMake.  (We have our own bespoke project generator in Steam, which was
how these tests were created.)  I need some help getting the protobuf
and crypto dependency logic refactored and sharable, if we want to get
those compiling in this project.  But I figured I'd go ahead and checkin
the source.
2019-04-16 10:20:31 -07:00
Fletcher Dunn fd518e3362 Fix some minor bugs in cert store.
These bugs were discovered using the novel method of writing a test suite
and actually running it.  (Checking that in shortly.)

Also tweaked the #define that controls the single hardcoded root CA,
if any.  I do not have any test code for when we do not want to do this
right now.  For the open source code probably we want to leave it dynamic
by default.
2019-04-15 19:20:48 -07:00
Fletcher Dunn 38604eb2d9 Add --ca-priv-key option to cert tool. 2019-04-15 19:19:41 -07:00
Fletcher Dunn fac0fb86ad Merge branch 'master' of github.com:ValveSoftware/GameNetworkingSockets 2019-04-05 21:07:44 -07:00
Fletcher Dunn b7eb3b6088 Improve cert tool.
- Add gen_keyexchange_keypair command
- Tweak output
2019-04-05 21:06:25 -07:00
Fletcher Dunn b37e2f4d87 Fix bug using the same enum value twice.
Seems pretty clear that I need to write a test suite for the PKI.
2019-04-05 21:05:02 -07:00
Fletcher Dunn f899d414b5 Merge pull request #63 from bobsayshilol/more-pedantry
Use the correct macro to bswap a 32bit value
2019-04-04 16:07:55 -07:00
Fletcher Dunn 57be61155c Fix inverted logic with unsigned anonymous certs.
And at the same time, clarified the flow, and treat an
empty identity the same "local host", which is intended to be
used as "anonymous" in places where some identity data is required.
2019-04-04 15:59:49 -07:00
bobsayshilol 3d4a92fb61 Use LittleDWord() rather than LittleWord() to swap a 32bit value to the correct endianness. 2019-04-04 23:27:35 +01:00
Fletcher Dunn 5eea6fe642 Implement a rudimentary PKI.
Store a list of public keys and certs we have for them, and implement logic
to evaluate their trust.

New cert checking flow in the connection code.  I found a *tiny* bug where
we were not actually checking the signature of the connection crypt info
using the signature in the user cert (!).  We were checking to make sure that
the user cert was valid, but anybody in the middle could have substituted
their own ephemeral keypair for key exchange, and we wouldn't have known.

Certs can now be issued to multiple AppIDs.

Cert tool can now emit json output and bind certs to particular AppIDs.
2019-04-04 14:44:47 -07:00
Fletcher Dunn 1d59f21eca Make LinkStatsTracker::SetDisconnected virtual.
In a few places I need to call this through a base class pointer in
the Steam relay code.  Ths stats tracker heirarchy is really complicated.
Might be nice to clean it up and find a way that we never do virtual
function dispatch when we could have just inlined code.
2019-04-04 14:39:08 -07:00
Fletcher Dunn 37b37bdbd8 Refactor some key base64/PEM parsing code.
Shuffle some stuff around to expose some useful lower level primitives,
ahead of some PKI changes.
2019-04-04 14:31:05 -07:00
bobsayshilol 18691903ae Add missing break statement. Without this we fall through to the NA_IP case and overwrite 'result'. 2019-04-02 17:32:13 -07:00
Fletcher Dunn 44a776b8ad Delete unused file 2019-04-02 17:21:08 -07:00
Fletcher Dunn ce7c1735fb Delete a bunch of CPU info stuff.
We only needed to know if SSE2 support is present, only in 32-bit, and only
if you are using our 25519 code, which most people hopefully will *not* use.
(Use OpenSSL.)

To answer this one question in this one place, we were using a whole framework
to get a ton of other info, and all of the code had ben ripped out of Steam
and was really gross.
2019-04-02 17:06:12 -07:00
Fletcher Dunn 6d69d1c28b NOP sync with Steam.
Changes are not relevant to opensource code.
2019-04-02 17:02:02 -07:00