Ejemplo n.º 1
0
        /// <summary>
        /// Logs the client into the Steam3 network as an anonymous game server.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="appId">The AppID served by this game server, or 0 for the default.</param>
        public void LogOnAnonymous(uint appId = 0)
        {
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new SteamUser.LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID gsId = new SteamID(0, 0, Client.ConnectedUniverse, EAccountType.AnonGameServer);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )appId;
            logon.Body.machine_id         = MachineIdUtils.GenerateMachineID();

            this.Client.Send(logon);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="System.ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="System.ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (string.IsNullOrEmpty(details.Token))
            {
                throw new ArgumentException("LogOn requires a game server token to be set in 'details'.");
            }

            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new SteamUser.LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogonGameServer);

            SteamID gsId = new SteamID(0, 0, Client.ConnectedUniverse, EAccountType.GameServer);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = gsId.ConvertToUInt64();

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id         = MachineIdUtils.GenerateMachineID();

            logon.Body.game_server_token = details.Token;

            this.Client.Send(logon);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Logs the client into the Steam3 network as an anonymous user.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        public void LogOnAnonymous(AnonymousLogOnDetails details)
        {
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID auId = new SteamID(0, 0, Client.ConnectedUniverse, EAccountType.AnonUser);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = auId.ConvertToUInt64();

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = ( uint )details.ClientOSType;
            logon.Body.client_language  = details.ClientLanguage;
            logon.Body.cell_id          = details.CellID;

            logon.Body.machine_id = MachineIdUtils.GenerateMachineID();

            this.Client.Send(logon);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (string.IsNullOrEmpty(details.Username) || (string.IsNullOrEmpty(details.Password) && string.IsNullOrEmpty(details.LoginKey)))
            {
                throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
            }
            if (!string.IsNullOrEmpty(details.LoginKey) && !details.ShouldRememberPassword)
            {
                // Prevent consumers from screwing this up.
                // If should_remember_password is false, the login_key is ignored server-side.
                // The inverse is not applicable (you can log in with should_remember_password and no login_key).
                throw new ArgumentException("ShouldRememberPassword is required to be set to true in order to use LoginKey.");
            }
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new LoggedOnCallback(EResult.NoConnection));
                return;
            }

            var logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

            SteamID steamId = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual);

            uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid          = steamId.ConvertToUInt64();

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.account_name             = details.Username;
            logon.Body.password                 = details.Password;
            logon.Body.should_remember_password = details.ShouldRememberPassword;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = ( uint )details.ClientOSType;
            logon.Body.client_language  = details.ClientLanguage;
            logon.Body.cell_id          = details.CellID;

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required
            logon.Body.machine_id             = MachineIdUtils.GenerateMachineID();

            // steam guard
            logon.Body.auth_code       = details.AuthCode;
            logon.Body.two_factor_code = details.TwoFactorCode;

            logon.Body.login_key = details.LoginKey;

            logon.Body.sha_sentryfile     = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )(details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound);


            this.Client.Send(logon);
        }