public MainAboutModel(RootModel root, ConnectionService connectionService, IAppEnvironment environment, IdService idService, CoreData coreData) { Root = root; _connectionService = connectionService; _environment = environment; _idService = idService; _coreData = coreData; CopyToClipboard = () => DoCopyToClipboard(); Version = ClientVersionHelper.GetVersion(); var assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.LICENSE.txt")) using (StreamReader reader = new StreamReader(stream)) { License = reader.ReadToEnd(); } using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.CREDITS.txt")) using (StreamReader reader = new StreamReader(stream)) { Credits = reader.ReadToEnd(); } FeedbackSend = () => _ = SendFeedback(); }
public LoginModel(RootModel root, MainModel main, UpdateModel updateModel, LocalSettingsService settingsService, ConnectionService connectionService, NotificationService notificationService, IAppEnvironment environment, IdService idService) { Root = root; _settingsService = settingsService; _connectionService = connectionService; _notificationService = notificationService; _main = main; _updateModel = updateModel; _environment = environment; _idService = idService; var s = settingsService.Settings; SavePassword = s.SavePassword; UserName = s.UserName; Password = s.Password; UserRegistered = s.UserRegistered; Version = ClientVersionHelper.GetVersion(); DoLogin = async() => await LoginAsync(true); DoAnonymousLogin = async() => await LoginAsync(false); if (s.AutoLogon && s.SavePassword && s.UserRegistered) { _ = DoAutoLogin(); } }
public void Start() { AsUnregistered.Value = _connectionService.UserName == null; try { _environment.GetObsVersions(out var obs, out var obsCam); SystemInfos.Value = new[] { new SystemInfoItem { Name = "Logged as", Value = _connectionService.UserName ?? "Unregistered" }, new SystemInfoItem { Name = "Processor", Value = _environment.GetProcessorName() }, new SystemInfoItem { Name = "Device Id", Value = _idService.GetDeviceId() }, new SystemInfoItem { Name = "OS", Value = System.Runtime.InteropServices.RuntimeInformation.OSDescription }, new SystemInfoItem { Name = "Start time UTC", Value = DateTime.UtcNow.ToString() }, new SystemInfoItem { Name = "Server", Value = _connectionService.ConnectionServer.Split(':')[0] }, new SystemInfoItem { Name = "App version", Value = ClientVersionHelper.GetVersion() }, new SystemInfoItem { Name = "OBS version", Value = obs }, new SystemInfoItem { Name = "OBS Cam version", Value = obsCam } }.Where(s => s.Value != null).ToArray(); SystemInfos.Value.Where(s => s.Id != null).ToList().ForEach(s => Log.Information($"SystemInfo {{{s.Id}}}", s.Value)); } catch (Exception e) { Log.Error(e, "Failed to get system info"); } }
public LogService(IAppEnvironment environment, Func <HubConnectionService> hubConnectionServiceFactory) { Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(_switch) #if DEBUG //.WriteTo.Async(a => //{ // a.Debug(outputTemplate: "[{Timestamp:dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"); //}) #endif .WriteTo.File(path: $"{environment.GetStorageFolder()}\\Logs\\Client.txt", fileSizeLimitBytes: 10_000_000, retainedFileCountLimit: 2, rollOnFileSizeLimit: true, // flushToDiskInterval: TimeSpan.Zero, outputTemplate: "[{Timestamp:dd HH:mm:ss.fff}] {Level:u3}]: {Message:lj}{NewLine}{Exception}") .WriteTo.ServerLog(hubConnectionServiceFactory) .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Log.Information($"Application started '{ClientVersionHelper.GetVersion()}'"); }
private async Task <string> AuthenticateAsync(string server, NetworkCredential credential) { using (var client = GetHttpClient(false)) { var host = $"https://{server}:{ClientConstants.AuthorizationServerPort}/connect/token"; Log.Information($"Authenticating at {host}"); var parameters = new Dictionary <string, string>() { { ClientConstants.DeviceIdClaim, _idService.GetDeviceId() }, { ClientConstants.VersionClaim, ClientVersionHelper.GetVersion() } }; if (_domain != null) { parameters.Add(ClientConstants.DomainClaim, _domain); } TokenResponse tokenResponse = null; if (credential != null) { UserName = credential.UserName; tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = host, ClientId = _environment.GetClientId(), ClientSecret = "xtreamer.id", UserName = _appResources.AppData.UserNamePrefix + credential.UserName, Password = credential.Password, Scope = ClientConstants.ConnectionServerApi, Parameters = parameters }); } else { UserName = null; tokenResponse = await client.RequestTokenAsync(new TokenRequest { Address = host, ClientId = _environment.GetClientId(), ClientSecret = "xtreamer.id", GrantType = ClientConstants.AnonymousGrandType, Parameters = parameters }); } if (tokenResponse.IsError) { if (tokenResponse.ErrorType == ResponseErrorType.Exception && tokenResponse.Exception is HttpRequestException && tokenResponse.Exception.InnerException is SocketException) { throw new ConnectionServiceException("Connection to the service failed. Please check your internet connection.", tokenResponse.Exception); } else if (credential != null && tokenResponse.ErrorType == ResponseErrorType.Protocol && tokenResponse.HttpResponse?.StatusCode == HttpStatusCode.BadRequest && tokenResponse.ErrorDescription == "invalid_username_or_password") { throw new WrongUserNamePasswordException(); } else { throw new ConnectionServiceException($"Unknown error occured ({tokenResponse.Error}). Please contact service administrator.", tokenResponse.Exception); } } var jwt = tokenResponse.AccessToken; var handler = new JwtSecurityTokenHandler(); var token = handler.ReadJwtToken(jwt); Claims = new ClientClaims(token.Claims); if (Claims.IsDebug) { _logService.EnableDebug(); } return(tokenResponse.AccessToken); } }