예제 #1
0
 private void SavePCList()
 {
     lock (_PersonalClouds)
     {
         ConfigStorage.SaveCloud(_PersonalClouds.Select(x => PersonalCloudInfo.FromPersonalCloud(x)));
     }
 }
예제 #2
0
        public async Task <PersonalCloudInfo> GetCloudInfo()
        {
            try
            {
                var pcid = HttpContext.Request.Headers[AuthDefinitions.AuthenticationPCId].Trim();
                if (string.IsNullOrWhiteSpace(pcid))
                {
                    await HttpContext.SendStandardHtmlAsync((int)HttpStatusCode.NotFound).ConfigureAwait(false);

                    return(null);
                }

                var pc = pCService.PersonalClouds.First(x => x.Id == pcid);
                if (pc == null)
                {
                    await HttpContext.SendStandardHtmlAsync((int)HttpStatusCode.NotFound).ConfigureAwait(false);

                    return(null);
                }
                return(PersonalCloudInfo.FromPersonalCloud(pc));
            }
            catch
            {
                await HttpContext.SendStandardHtmlAsync((int)HttpStatusCode.InternalServerError).ConfigureAwait(false);

                return(null);
            }
        }
예제 #3
0
 public PersonalCloudInfo GetCloudInfo(string id, [QueryField("ts", false)] long?ts, [QueryField("hash", false)] ulong?hash)
 {
     if (ts.HasValue && hash.HasValue)
     {
         var pc = LocalService.PersonalClouds.First(x => x.Id == id);
         if (pc == null)
         {
             return(null);
         }
         var data     = BitConverter.GetBytes(ts.Value + int.Parse(pc.CurrentShareCode, CultureInfo.InvariantCulture));
         var newhcode = xxHash64.ComputeHash(data, data.Length);
         if (newhcode == hash.Value)
         {
             var pci = PersonalCloudInfo.FromPersonalCloud(pc);
             pci.NodeGuid = LocalService.NodeId;
             return(pci);
         }
     }
     return(null);
 }