Пример #1
0
        public static void PostCallback(int pipe_id, int user_id, int callback_id, Core.Util.Buffer b)
        {
            var new_callback = new InternalCallbackMsg
            {
                user_id     = user_id,
                callback_id = (uint)callback_id,
                data        = b.GetBuffer(),
            };

            if (PendingCallbacks.TryGetValue(pipe_id, out var cb_queue))
            {
                cb_queue.Enqueue(new_callback);
                return;
            }

            PendingCallbacks[pipe_id] = new Queue <InternalCallbackMsg>();
            PendingCallbacks[pipe_id].Enqueue(new_callback);
        }
Пример #2
0
        // TODO: this is part of the old client authentication api and as such shouldnt really be called anymore...
        public byte[] InitiateGameConnection(int max_buffer, SteamID game_server_id, GameID game_id, uint server_ip, ushort server_port, bool secure)
        {
            Log.WriteLine("InitiateGameConnection should no longer be called...");

            if (!game_server_id.IsValid)
            {
                Log.WriteLine("Invalid game server steam id passed to InitiateGameConnection");
                return(null);
            }

            // TODO: check whether server port / ip are valid

            var b = new Core.Util.Buffer();

            // TODO: write a real game connect token in here
            if (game_connect_tokens.Count > 0)
            {
                var token = GetGameConnectToken();
                b.Write(token.Length);
                b.Write(token);
            }
            else
            {
                // Write out the placeholder token
                b.Write(4u);
                b.Write(0u);
            }

            var ownership_ticket = GetAppOwnershipTicket(game_id.AppID);

            b.Write(ownership_ticket.Length);
            b.Write(ownership_ticket);

            // TODO: look at InternalUpdateClientGame and see whether there is anything else important
            // That needs to go here

            return(b.GetBuffer());
        }
Пример #3
0
        public int GetAuthSessionTicket(int app_id, int pipe)
        {
            Log.WriteLine("GetAuthSessionTicket for app_id {0}", app_id);
            var ownership_ticket = GetAppOwnershipTicket((uint)app_id);

            var client_ticket_buffer = new Core.Util.Buffer();

            // Write the token into the ticket
            var token = GetGameConnectToken();

            client_ticket_buffer.Write(token.Length);
            client_ticket_buffer.Write(token);

            // Size of header
            client_ticket_buffer.Write(0x18);

            // This is all copied from what the steamclient method does
            client_ticket_buffer.Write(1);
            client_ticket_buffer.Write(2);

            var ip_bytes = public_ip.GetAddressBytes();

            Array.Reverse(ip_bytes);
            client_ticket_buffer.Write(ip_bytes);

            client_ticket_buffer.Write(Instance.SteamClient.LocalIP.GetAddressBytes());
            client_ticket_buffer.Write(Core.Platform.MilisecondTime());
            client_ticket_buffer.Write(++ticket_request_count);

            var client_ticket_crc = BitConverter.ToUInt32(CryptoHelper.CRCHash(client_ticket_buffer.GetBuffer()), 0);

            auth_ticket_store.Add(new AuthTicket()
            {
                app_id    = app_id,
                pipe_id   = pipe,
                crc32     = client_ticket_crc,
                handle    = auth_ticket_store.Count + 1,
                ticket    = client_ticket_buffer.GetBuffer(),
                cancelled = false,
            });

            // Resend the auth list with our new ticket
            SendClientAuthList();


            // Create the ticket that will actually be sent to the server

            var server_ticket_buffer = new Core.Util.Buffer();

            var size = 8 + client_ticket_buffer.GetBuffer().Length + 4 + ownership_ticket.Length;

            server_ticket_buffer.Write((ushort)size);

            server_ticket_buffer.Write(steam_user.SteamID.ConvertToUInt64());

            server_ticket_buffer.Write(client_ticket_buffer.GetBuffer());

            // Write the ownership ticket data in here
            // We are just going to assume that our tickets are 100% correct...
            server_ticket_buffer.Write(ownership_ticket.Length);
            server_ticket_buffer.Write(ownership_ticket);

            var server_ticket_crc = BitConverter.ToUInt32(CryptoHelper.CRCHash(server_ticket_buffer.GetBuffer()), 0);

            auth_ticket_store.Add(new AuthTicket()
            {
                is_server_ticket = true,
                app_id           = app_id,
                pipe_id          = pipe,
                crc32            = server_ticket_crc,
                handle           = auth_ticket_store.Count + 1,
                ticket           = server_ticket_buffer.GetBuffer(),
                cancelled        = false,
            });

            return(auth_ticket_store.Count);
        }