private async Task LoginAsync(LoginInfo info) { uint instance = 0; if (info.AccountId != 0) { instance = 2; } else if (info.AccountType != AccountType.AnonUser) { instance = 1; } await NetLog.InfoAsync($"Logging in as {info.Username ?? (instance == 0 ? "an anonymous user" : "a console user")}").ConfigureAwait(false); byte[] machineId = await HardwareUtils.GetMachineId().ConfigureAwait(false); // while we set up the logon object, we will start to get the machine ID var body = new CMsgClientLogon { protocol_version = 65579, client_os_type = (uint)(info.AccountId == 0 ? HardwareUtils.GetCurrentOsType() : OsType.PS3), client_language = GetConfig <SteamNetworkConfig>().Language.GetApiLanguageCode(), cell_id = (uint)GetConfig <SteamNetworkConfig>().CellId, }; if (machineId != null && machineId.Length != 0) { body.machine_id = machineId; } if (info.AccountType != AccountType.AnonUser) { body.account_name = info.Username; body.password = info.Password; body.should_remember_password = info.ShouldRememberPassword; body.steam2_ticket_request = info.RequestSteam2Ticket; body.two_factor_code = info.TwoFactorCode; body.auth_code = info.AuthCode; body.login_key = info.LoginKey; body.sha_sentryfile = info.SentryFileHash; body.eresult_sentryfile = (int)(info.SentryFileHash is null ? Result.FileNotFound : Result.OK); body.client_package_version = 1771; body.obfustucated_private_ip = (uint)(GetConfig <SteamNetworkConfig>().LoginId < 0 ? LocalIp.ToUInt32() ^ _obfuscationMask : GetConfig <SteamNetworkConfig>().LoginId); body.supports_rate_limit_response = true; } var logon = NetworkMessage .CreateProtobufMessage(MessageType.ClientLogon, body) .WithClientInfo(new SteamId(info.AccountId, GetConfig <SteamNetworkConfig>().DefaultUniverse, info.AccountType, instance), 0); await SendAsync(logon.Serialize()).ConfigureAwait(false); }
/// <summary> /// Logs into the Steam network as an anonymous game server /// </summary> /// <param name="appId"></param> /// <returns></returns> public async Task LoginGameServerAnonymousAsync(int appId) { CMsgClientLogon logon = new CMsgClientLogon() { protocol_version = _currentProtocolVer, obfustucated_private_ip = (uint)(GetConfig <SteamNetworkConfig>().LoginId < 0 ? LocalIp.ToUInt32() ^ _obfuscationMask : GetConfig <SteamNetworkConfig>().LoginId), client_os_type = (uint)HardwareUtils.GetCurrentOsType(), game_server_app_id = appId, machine_id = await HardwareUtils.GetMachineId().ConfigureAwait(false), }; NetworkMessage message = NetworkMessage .CreateProtobufMessage(MessageType.ClientLogon, logon) .WithClientInfo(SteamId.CreateAnonymousGameServer(GetConfig <SteamNetworkConfig>().DefaultUniverse), 0); await SendAsync(message.Serialize()).ConfigureAwait(false); }
/// <summary> /// Logs into the Steam network as a game server /// </summary> /// <param name="appId"></param> /// <param name="token"></param> /// <returns></returns> public async Task LoginGameServerAsync(int appId, string token) { if (string.IsNullOrWhiteSpace(token)) { throw new ArgumentException("The token cannot be null or whitespace", nameof(token)); } CMsgClientLogon logon = new CMsgClientLogon() { protocol_version = _currentProtocolVer, obfustucated_private_ip = (uint)(GetConfig <SteamNetworkConfig>().LoginId < 0 ? LocalIp.ToUInt32() ^ _obfuscationMask : GetConfig <SteamNetworkConfig>().LoginId), client_os_type = (uint)HardwareUtils.GetCurrentOsType(), game_server_app_id = appId, machine_id = await HardwareUtils.GetMachineId().ConfigureAwait(false), game_server_token = token }; NetworkMessage message = NetworkMessage .CreateProtobufMessage(MessageType.ClientLogonGameServer, logon) .WithClientInfo(new SteamId(0, GetConfig <SteamNetworkConfig>().DefaultUniverse, AccountType.GameServer, 0), 0); await SendAsync(message.Serialize()).ConfigureAwait(false); }