Esempio n. 1
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            RemotePeer remotePeer = remotePeers.Find(p => p.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (remotePeer != null));

            if (remotePeer == null)
            {
                return;
            }

            if (remotePeer.Authenticated)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                }
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                remotePeer.Authenticated  = true;
                remotePeer.Authenticating = false;
                foreach (var msg in remotePeer.UnauthedMessages)
                {
                    byte[] msgToSend = (byte[])msg.Message.Buffer.Clone();
                    Array.Resize(ref msgToSend, msg.Message.LengthBytes);
                    ChildServerRelay.Write(msgToSend);
                }
                remotePeer.UnauthedMessages.Clear();
            }
            else
            {
                DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication failed: " + status.ToString());
                return;
            }
        }
Esempio n. 2
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            if (netServer == null)
            {
                return;
            }

            PendingClient pendingClient = pendingClients.Find(c => c.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (pendingClient != null));

            if (pendingClient == null)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    LidgrenConnection connection = connectedClients.Find(c => c.SteamID == steamID);
                    if (connection != null)
                    {
                        Disconnect(connection, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                    }
                }
                return;
            }

            if (serverSettings.BanList.IsBanned(pendingClient.Connection.RemoteEndPoint.Address, steamID, out string banReason))
            {
                RemovePendingClient(pendingClient, DisconnectReason.Banned, banReason);
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                pendingClient.InitializationStep = serverSettings.HasPassword ? ConnectionInitialization.Password : ConnectionInitialization.ContentPackageOrder;
                pendingClient.UpdateTime         = Timing.TotalTime;
            }
            else
            {
                RemovePendingClient(pendingClient, DisconnectReason.SteamAuthenticationFailed, "Steam authentication failed: " + status.ToString());
                return;
            }
        }
Esempio n. 3
0
        private void OnAuthChange(Steamworks.SteamId steamID, Steamworks.SteamId ownerID, Steamworks.AuthResponse status)
        {
            RemotePeer remotePeer = remotePeers.Find(p => p.SteamID == steamID);

            DebugConsole.Log(steamID + " validation: " + status + ", " + (remotePeer != null));

            if (remotePeer == null)
            {
                return;
            }

            if (remotePeer.Authenticated)
            {
                if (status != Steamworks.AuthResponse.OK)
                {
                    DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication status changed: " + status.ToString());
                }
                return;
            }

            if (status == Steamworks.AuthResponse.OK)
            {
                remotePeer.OwnerSteamID   = ownerID;
                remotePeer.Authenticated  = true;
                remotePeer.Authenticating = false;
                foreach (var msg in remotePeer.UnauthedMessages)
                {
                    //rewrite the owner id before
                    //forwarding the messages to
                    //the server, since it's only
                    //known now
                    int prevBitPosition = msg.Message.BitPosition;
                    msg.Message.BitPosition = sizeof(ulong) * 8;
                    msg.Message.Write(ownerID);
                    msg.Message.BitPosition = prevBitPosition;
                    byte[] msgToSend = (byte[])msg.Message.Buffer.Clone();
                    Array.Resize(ref msgToSend, msg.Message.LengthBytes);
                    ChildServerRelay.Write(msgToSend);
                }
                remotePeer.UnauthedMessages.Clear();
            }
            else
            {
                DisconnectPeer(remotePeer, DisconnectReason.SteamAuthenticationFailed.ToString() + "/ Steam authentication failed: " + status.ToString());
                return;
            }
        }
Esempio n. 4
0
    // This gets called on server once steam has checked the auth ticket
    private void OnValidateAuthTicketResponse(Steamworks.SteamId userId, Steamworks.SteamId ownerId, Steamworks.AuthResponse response)
    {
        string message  = "";
        bool   accepted = false;

        Debug.Log("[Server/Host] Validation response recieved: ");

        switch (response)
        {
        case Steamworks.AuthResponse.OK:
            message  = "Accepted!";
            accepted = true;
            break;

        case Steamworks.AuthResponse.UserNotConnectedToSteam:
            message  = "Not connected to Steam!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.NoLicenseOrExpired:
            message  = "No liscense or expired!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.VACBanned:
            message  = "VAC banned!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.LoggedInElseWhere:
            message  = "Logged in elsewhere!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.VACCheckTimedOut:
            message  = "VAC check timed out!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.AuthTicketCanceled:
            message  = "Auth ticket canceled!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.AuthTicketInvalidAlreadyUsed:
            message  = "Auth tiekcet invalid or already used!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.AuthTicketInvalid:
            message  = "Invalid auth ticket!";
            accepted = false;
            break;

        case Steamworks.AuthResponse.PublisherIssuedBan:
            message  = "Game ban!";
            accepted = false;
            break;

        default:
            break;
        }

        if (NetworkServer.active && !accepted)
        {
            return;
        }

        Debug.Log("[Server] Accepted: " + accepted + ", Message: " + message);


        AuthResponse msg = new AuthResponse
        {
            message  = message,
            accepted = accepted
        };


        // Now we need to find the connection associated with the steamid we need to respond to, and send the reponse

        foreach (var authUnit in currentAuthUnits)
        {
            if (userId == authUnit.playerData.id)
            {
                if (accepted)
                {
                    StartCoroutine(DelayAuthenticationApproval(.5f, authUnit, msg));
                }
                else
                {
                    FailAuthentication(authUnit.connection, msg);
                }


                // Remove auth unit from temporary list
                currentAuthUnits.Remove(authUnit);
                break;
            }
        }
    }