Ejemplo n.º 1
0
 private void OnValidateAuthTicketResponse(ulong SteamId, ulong OwnerId, ServerAuth.Status Status)
 {
     if (Auth_Steam.ValidateConnecting(SteamId, OwnerId, Status))
     {
         return;
     }
     Network.Connection connection = ((IEnumerable <Network.Connection>)((Network.Server)Network.Net.sv).connections).FirstOrDefault <Network.Connection>((Func <Network.Connection, bool>)(x => x.userid == (long)SteamId));
     if (connection == null)
     {
         Debug.LogWarning((object)("Steam gave us a " + (object)Status + " ticket response for unconnected id " + (object)SteamId));
     }
     else if (Status == null)
     {
         Debug.LogWarning((object)("Steam gave us a 'ok' ticket response for already connected id " + (object)SteamId));
     }
     else
     {
         if (Status == 5)
         {
             return;
         }
         connection.authStatus = (__Null)Status.ToString();
         ((Network.Server)Network.Net.sv).Kick(connection, "Steam: " + Status.ToString());
     }
 }
        private void OnSteamAuthChange(ulong steamId, ulong ownerSteamId, ServerAuth.Status authSessionResponse)
        {
            m_Logger.LogDebug($"Authentication result for \"{steamId}\": {authSessionResponse.ToString()}");

            if (!m_PendingAuthentications.ContainsKey(steamId))
            {
                return;
            }

            var peer = m_PendingAuthentications[steamId];

            m_PendingAuthentications.Remove(steamId);

            if (authSessionResponse != ServerAuth.Status.OK)
            {
                if (authSessionResponse != ServerAuth.Status.AuthTicketCanceled)
                {
                    m_Logger.LogWarning($"Authentication failed for {peer}: {authSessionResponse.ToString()}");
                }

                peer.IsAuthenticated = false;
                m_ServerConnectionHandler.Disconnect(peer, authSessionResponse);
                return;
            }

            peer.SteamId         = steamId;
            peer.IsAuthenticated = true;

            m_ServerConnectionHandler.Send(new OutgoingPacket
            {
                PacketId          = (byte)PacketType.Authenticated,
                PacketDescription = m_ServerConnectionHandler.GetPacketDescription((byte)PacketType.Authenticated),
                Data  = new byte[0],
                Peers = new[] { peer }
            });

            var mapPacket = new MapChangePacket {
                MapName = m_MapManager.CurrentMap
            };

            m_ServerConnectionHandler.Send(peer, mapPacket);

            m_EventBus.Emit(this, new PeerAuthenicatedEvent(peer));
        }
Ejemplo n.º 3
0
        private void OnSteamAuthChange(ulong steamId, ulong ownerId, ServerAuth.Status status)
        {
            var pendingConnection = pendingConnections.FirstOrDefault(conn => conn.SteamId == steamId);
            var connection        = pendingConnection?.Client ?? Players.FirstOrDefault(plr => plr.Value.SteamId == ownerId).Key;

            if (connection == null || connection.Status != NetConnectionStatus.Connected) // Return if connection got kicked or disconnected between connecting and receiving steam auth status.
            {
                return;
            }

            if (steamId != ownerId)
            {
                KickConnection(connection, DisconnectReason.InvalidSteamSession, "Invalid steam id");
                return;
            }

            if (status == ServerAuth.Status.OK)
            {
                if (pendingConnection != null)
                {
                    if (SteamIdBanned(steamId, out var playerBan))
                    {
                        KickConnection(connection, DisconnectReason.Banned, playerBan.GetReasonWithExpiration());
                        return;
                    }

                    pendingConnections.Remove(pendingConnection);
                    Logger.LogDebug($"Got valid steam auth from {connection.RemoteEndPoint}");
                    AcceptConnection(connection, pendingConnection.PlayerName, pendingConnection.Movement, pendingConnection.SteamId, 0);

                    SteamServer.Stats.Refresh(ownerId, (ownerId2, success) =>
                    {
                        if (!Players.ContainsKey(connection) || connection.Status != NetConnectionStatus.Connected)
                        {
                            return;
                        }

                        if (!success)
                        {
                            Logger.LogError($"Failed to refresh stats for steamid {ownerId2}.");
                            return;
                        }

                        int totalWins = SteamServer.Stats.GetInt(ownerId2, "wins");
                        Players[connection].SetWins(totalWins, !developerSteamIds.Contains(ownerId)); // Only update goldness if this user is not a developer (otherwise the goldness will be changed from 1).
                    });
                }
            }
            else
            {
                KickConnection(connection, DisconnectReason.InvalidSteamSession, status.ToString());
            }
        }
Ejemplo n.º 4
0
    public static bool ValidateConnecting(
        ulong steamid,
        ulong ownerSteamID,
        ServerAuth.Status response)
    {
        Connection connection = Auth_Steam.waitingList.Find((Predicate <Connection>)(x => x.userid == (long)steamid));

        if (connection == null)
        {
            return(false);
        }
        connection.ownerid = (__Null)(long)ownerSteamID;
        if (ServerUsers.Is(ownerSteamID, ServerUsers.UserGroup.Banned) || ServerUsers.Is(steamid, ServerUsers.UserGroup.Banned))
        {
            connection.authStatus = (__Null)"banned";
            return(true);
        }
        if (response == null)
        {
            connection.authStatus = (__Null)"ok";
            return(true);
        }
        if (response == 3)
        {
            connection.authStatus = (__Null)"vacbanned";
            return(true);
        }
        if (response == 9)
        {
            connection.authStatus = (__Null)"gamebanned";
            return(true);
        }
        if (response == 5)
        {
            connection.authStatus = (__Null)"ok";
            return(true);
        }
        connection.authStatus = (__Null)response.ToString();
        return(true);
    }
Ejemplo n.º 5
0
        private void OnAuthChange(ulong steamId, ulong ownerId, ServerAuth.Status status)
        {
            ConnectionOperation waitingUser = _waitingUser;

            // 인증 진행중인 유저에 대한 이벤트일 때
            if (waitingUser != null && steamId == waitingUser.steamId)
            {
                // 인증 대기 목록에서 제거
                ResetServerAuthWaitingStatus();

                switch (status)
                {
                case ServerAuth.Status.OK:
                    AcceptUser(waitingUser);
                    break;

                case ServerAuth.Status.AuthTicketCanceled:
                    Debug.LogWarning("Auth ticket canceled while doing user auth.");
                    break;

                default:
                    var message = string.Format("Steam auth failed. ({0}): {1}", waitingUser.username, status.ToString());
                    RejectUser(waitingUser.peer, message);
                    break;
                }
            }
            else
            {
                switch (status)
                {
                case ServerAuth.Status.AuthTicketCanceled:
                    Debug.Log("Auth ticket canceled. (" + steamId + ")");
                    break;

                default:
                    Debug.Log("Steam auth changed. (" + steamId + ")");
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        private void OnAuthChange(ulong steamID, ulong ownerID, ServerAuth.Status 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 != ServerAuth.Status.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))
            {
                RemovePendingClient(pendingClient, DisconnectReason.Banned, "SteamID banned");
                return;
            }

            if (status == ServerAuth.Status.OK)
            {
                pendingClient.InitializationStep = serverSettings.HasPassword ? ConnectionInitialization.Password : ConnectionInitialization.Success;
                pendingClient.UpdateTime         = Timing.TotalTime;
            }
            else
            {
                RemovePendingClient(pendingClient, DisconnectReason.SteamAuthenticationFailed, "Steam authentication failed: " + status.ToString());
                return;
            }
        }