Exemple #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="clientApp"></param>
 public ClientBLData(ClientApp clientApp)
     : base(clientApp)
 {
 }
Exemple #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="clientApp"></param>
 /// <param name="appID">AppID,应用程序标识</param>
 public ClientBLData(ClientApp clientApp, int appID)
     : base(clientApp, appID)
 {
 }
        public async Task <InvokeResult> AddClientAppAsync(ClientApp clientApp, EntityHeader org, EntityHeader user)
        {
            ValidationCheck(clientApp, Actions.Create);

            await AuthorizeAsync(clientApp, AuthorizeResult.AuthorizeActions.Create, user, org);

            var primaryAddResult = await _secureStorage.AddSecretAsync(org, clientApp.AppAuthKeyPrimary);

            if (!primaryAddResult.Successful)
            {
                return(primaryAddResult.ToInvokeResult());
            }

            var secondaryAddResult = await _secureStorage.AddSecretAsync(org, clientApp.AppAuthKeySecondary);

            if (!secondaryAddResult.Successful)
            {
                return(secondaryAddResult.ToInvokeResult());
            }

            clientApp.AppAuthKeyPrimarySecureId = primaryAddResult.Result;
            clientApp.AppAuthKeyPrimary         = null;

            clientApp.AppAuthKeySecondarySecureId = secondaryAddResult.Result;
            clientApp.AppAuthKeySecondary         = null;

            var clientAppUserId = Guid.NewGuid().ToId();

            clientApp.ClientAppUser = EntityHeader.Create(clientAppUserId, $"{clientApp.Key} Service Account");

            var fullOrg = await _orgManager.GetOrganizationAsync(org.Id, org, user);

            var clientAppEmail = $"{fullOrg.Namespace}.{clientApp.Key}@nodomain.cantlogin";

            var result = await _userManager.CreateAsync(new UserAdmin.Models.Users.AppUser()
            {
                CurrentOrganization = org,
                Email                = clientAppEmail,
                FirstName            = clientApp.Name,
                LastName             = "Service Account",
                Id                   = clientAppUserId,
                UserName             = clientAppEmail,
                OwnerOrganization    = org,
                IsAppBuilder         = true,
                IsOrgAdmin           = false,
                IsSystemAdmin        = false,
                IsRuntimeuser        = true,
                PhoneNumberConfirmed = true,
                EmailConfirmed       = true,
                CreationDate         = clientApp.CreationDate,
                LastUpdatedDate      = clientApp.CreationDate,
                LastUpdatedBy        = user,
                CreatedBy            = user,
                IsAccountDisabled    = false,
                Name                 = clientApp.ClientAppUser.Text,
                PhoneNumber          = "612 555-1212",
            }, $"NuvI0Tabc{Guid.NewGuid().ToId()}");


            if (!result.Successful)
            {
                return(result);
            }

            await _orgManager.AddUserToOrgAsync(org.Id, clientAppUserId, org, user);

            await _repo.AddClientAppAsync(clientApp);

            return(InvokeResult.Success);
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Software"/> class.
        /// </summary>
        /// <param name="peerId">The peer id.</param>
        internal Software(BEncodedString peerId)
        {
            Match m;

            this.peerId = peerId;
            var idAsText = peerId.Text;

            if (idAsText.StartsWith("-WebSeed-", System.StringComparison.Ordinal))
            {
                this.shortId = "WebSeed";
                this.client  = ClientApp.WebSeed;
                return;
            }

            #region Standard style peers
            if ((m = standard.Match(idAsText)).Success)
            {
                this.shortId = m.Groups[1].Value;
                switch (m.Groups[2].Value)
                {
                case ("AG"):
                case ("A~"):
                    this.client = ClientApp.Ares;
                    break;

                case ("AR"):
                    this.client = ClientApp.Artic;
                    break;

                case ("AT"):
                    this.client = ClientApp.Artemis;
                    break;

                case ("AX"):
                    this.client = ClientApp.BitPump;
                    break;

                case ("AV"):
                    this.client = ClientApp.Avicora;
                    break;

                case ("AZ"):
                    this.client = ClientApp.Azureus;
                    break;

                case ("BB"):
                    this.client = ClientApp.BitBuddy;
                    break;

                case ("BC"):
                    this.client = ClientApp.BitComet;
                    break;

                case ("BF"):
                    this.client = ClientApp.Bitflu;
                    break;

                case ("BS"):
                    this.client = ClientApp.BTSlave;
                    break;

                case ("BX"):
                    this.client = ClientApp.BitTorrentX;
                    break;

                case ("CD"):
                    this.client = ClientApp.EnhancedCTorrent;
                    break;

                case ("CT"):
                    this.client = ClientApp.CTorrent;
                    break;

                case ("DE"):
                    this.client = ClientApp.DelugeTorrent;
                    break;

                case ("EB"):
                    this.client = ClientApp.EBit;
                    break;

                case ("ES"):
                    this.client = ClientApp.ElectricSheep;
                    break;

                case ("KT"):
                    this.client = ClientApp.KTorrent;
                    break;

                case ("LP"):
                    this.client = ClientApp.Lphant;
                    break;

                case ("lt"):
                case ("LT"):
                    this.client = ClientApp.LibTorrent;
                    break;

                case ("MP"):
                    this.client = ClientApp.MooPolice;
                    break;

                case ("MO"):
                    this.client = ClientApp.MonoTorrent;
                    break;

                case ("MT"):
                    this.client = ClientApp.MoonlightTorrent;
                    break;

                case ("qB"):
                    this.client = ClientApp.qBittorrent;
                    break;

                case ("QT"):
                    this.client = ClientApp.Qt4Torrent;
                    break;

                case ("RT"):
                    this.client = ClientApp.Retriever;
                    break;

                case ("SB"):
                    this.client = ClientApp.Swiftbit;
                    break;

                case ("SS"):
                    this.client = ClientApp.SwarmScope;
                    break;

                case ("SZ"):
                    this.client = ClientApp.Shareaza;
                    break;

                case ("TN"):
                    this.client = ClientApp.TorrentDotNET;
                    break;

                case ("TR"):
                    this.client = ClientApp.Transmission;
                    break;

                case ("TS"):
                    this.client = ClientApp.Torrentstorm;
                    break;

                case ("UL"):
                    this.client = ClientApp.uLeecher;
                    break;

                case ("UT"):
                    this.client = ClientApp.uTorrent;
                    break;

                case ("XT"):
                    this.client = ClientApp.XanTorrent;
                    break;

                case ("ZT"):
                    this.client = ClientApp.ZipTorrent;
                    break;

                default:
                    System.Diagnostics.Trace.WriteLine("Unsupported standard style: " + m.Groups[2].Value);
                    client = ClientApp.Unknown;
                    break;
                }
                return;
            }
            #endregion

            #region Shadows Style
            if ((m = shadows.Match(idAsText)).Success)
            {
                this.shortId = m.Groups[1].Value;
                switch (m.Groups[2].Value)
                {
                case ("A"):
                    this.client = ClientApp.ABC;
                    break;

                case ("O"):
                    this.client = ClientApp.OspreyPermaseed;
                    break;

                case ("R"):
                    this.client = ClientApp.Tribler;
                    break;

                case ("S"):
                    this.client = ClientApp.ShadowsClient;
                    break;

                case ("T"):
                    this.client = ClientApp.BitTornado;
                    break;

                case ("U"):
                    this.client = ClientApp.UPnPNatBitTorrent;
                    break;

                default:
                    this.client = ClientApp.Unknown;
                    break;
                }
                return;
            }
            #endregion

            #region Brams Client
            if ((m = brahms.Match(idAsText)).Success)
            {
                this.shortId = "M";
                this.client  = ClientApp.BitTorrent;
                return;
            }
            #endregion

            #region BitLord
            if ((m = bitlord.Match(idAsText)).Success)
            {
                this.client  = ClientApp.BitLord;
                this.shortId = "lord";
                return;
            }
            #endregion

            #region BitComet
            if ((m = bitcomet.Match(idAsText)).Success)
            {
                this.client  = ClientApp.BitComet;
                this.shortId = "BC";
                return;
            }
            #endregion

            #region XBT
            if ((m = xbt.Match(idAsText)).Success)
            {
                this.client  = ClientApp.XBTClient;
                this.shortId = "XBT";
                return;
            }
            #endregion

            #region Opera
            if ((m = opera.Match(idAsText)).Success)
            {
                this.client  = ClientApp.Opera;
                this.shortId = "OP";
            }
            #endregion

            #region MLDonkey
            if ((m = mldonkey.Match(idAsText)).Success)
            {
                this.client  = ClientApp.MLDonkey;
                this.shortId = "ML";
                return;
            }
            #endregion

            #region Bits on wheels
            if ((m = bow.Match(idAsText)).Success)
            {
                this.client  = ClientApp.BitsOnWheels;
                this.shortId = "BOW";
                return;
            }
            #endregion

            #region Queen Bee
            if ((m = queenbee.Match(idAsText)).Success)
            {
                this.client  = ClientApp.QueenBee;
                this.shortId = "Q";
                return;
            }
            #endregion

            #region BitTornado special style
            if ((m = bittornado.Match(idAsText)).Success)
            {
                this.shortId = m.Groups[1].Value;
                this.client  = ClientApp.BitTornado;
                return;
            }
            #endregion

            this.client  = ClientApp.Unknown;
            this.shortId = idAsText;
        }
Exemple #5
0
 void Awake()
 {
     client   = gameObject;
     Instance = this;
     DontDestroyOnLoad(this.gameObject);
 }
Exemple #6
0
        private async Task OpenTrasferation(int appId, TcpClient providerClient)
        {
            TcpClient toTargetServer = new TcpClient();

            //事件循环2
            try
            {
                byte[]        buffer = new byte[1];
                NetworkStream providerClientStream = providerClient.GetStream();
                //接收首条消息,首条消息中返回的是appid和客户端
                //TODO 消费端长连接,需要在server端保活
                // providerClient.keep
                // providerClient.Client.

                try
                {
                    int readByteCount = await providerClientStream.ReadAsync(buffer, 0, buffer.Length);

                    if (readByteCount == 0)
                    {
                        //TODO XXX
                        //抛出错误以便上层重启客户端。
                        _waiter.TrySetResult(new Exception($"连接{appId}被服务器主动切断,已断开连接"));
                        return;
                    }
                }
                catch (Exception ex)
                {
                    //反弹连接出错为致命错误
                    //此处出错后,应用程序需要重置,并重启
                    _waiter.TrySetResult(ex);
                    throw;
                }

                //TODO 遗留代码,待优化
                //连接后设置client为null
                if (ConnectionManager.ExistClient(appId, providerClient))
                {
                    var removedClient = ConnectionManager.RemoveClient(appId, providerClient);
                    if (removedClient == false)
                    {
                        Router.Logger.Debug($"没有移除{appId}任何的对象,对象不存在. hash:{providerClient.GetHashCode()}");
                        return;
                    }
                }
                else
                {
                    Router.Logger.Debug($"已无法在{appId}中找到客户端 hash:{providerClient.GetHashCode()}.");
                    return;
                }
                //每移除一个链接则发起一个新的链接
                Router.Logger.Debug(appId + "接收到连接请求");
                //根据clientid_appid发送到固定的端口
                //TODO 序列没有匹配元素?
                ClientApp item = ClientConfig.Clients.First((obj) => obj.AppId == appId);

                //向服务端发起一次长连接,没有接收任何外来连接请求时,
                //该方法会在write处会阻塞。
                await ConnectionManager.ConnectAppToServer(appId);

                Router.Logger.Debug("已建立反向连接:" + appId);
                // item1:app编号,item2:ip地址,item3:目标服务端口
                try
                {
                    toTargetServer.Connect(item.IP, item.TargetServicePort);
                }
                catch
                {
                    throw new Exception($"对内网服务的 {item.IP}:{item.TargetServicePort} 连接失败。");
                }
                string epString = item.IP.ToString() + ":" + item.TargetServicePort.ToString();
                Router.Logger.Debug("已连接目标服务:" + epString);

                NetworkStream targetServerStream = toTargetServer.GetStream();
                //targetServerStream.Write(buffer, 0, readByteCount);
                TcpTransferAsync(providerClientStream, targetServerStream, providerClient, toTargetServer, epString);
                //already close connection
            }
            catch (Exception ex)
            {
                Logger.Debug("传输时出错:" + ex);
                //关闭传输连接,服务端也会相应处理,把0request发送给消费端
                //TODO ***: 连接时出错,重启客户端
                toTargetServer.Close();
                providerClient.Close();
                throw;
            }
        }
 public MidApplicationOAuthProvider(ClientApp clientApp, UserApp userApp)
 {
     _clientApp = clientApp;
     _userApp   = userApp;
 }
Exemple #8
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public FilterForm(ClientApp clientApp)
        {
            this.mClientApp = clientApp;

            this.InitializeComponent();
        }
Exemple #9
0
 public Task <InvokeResult> UpdateClientAppAsync([FromBody] ClientApp container)
 {
     SetUpdatedProperties(container);
     return(_clientAppManager.UpdateClientAppAsync(container, OrgEntityHeader, UserEntityHeader));
 }
Exemple #10
0
 public Task <InvokeResult> AddClientAppAsync([FromBody] ClientApp clientApp)
 {
     return(_clientAppManager.AddClientAppAsync(clientApp, OrgEntityHeader, UserEntityHeader));
 }
Exemple #11
0
        static void Main(string[] args)
        {
            var print = new Print();

            var client = new ClientApp();

            client.Startup();

            var installer = new InstallerApp();

            installer.EncryptForClient();

            installer.GenerateCodeForClient();


            client.GetEncryptions(installer.GetEncryptions());

            var(hashList, final, shared, sha, streamHash, positionsHash) = installer.CreateLock();

            client.ArmLock(hashList, final, shared, sha, streamHash, positionsHash);



            //Adds decryptor needed for position values using client and installer.

            var truth = new TruthApp();

            var gather = new Portocall.Truth.Gather();



            var(encryptedPositions, decryptKey1, decryptKey2) = installer.SendInfoToTruth();

            gather.FromClientEncryptedPositions(encryptedPositions);

            gather.FromInstallerDecryptionNumbers(decryptKey1, decryptKey2);

            truth.GetInstallerInfo(encryptedPositions, decryptKey1, decryptKey2);



            string encryptedDecryptor = installer.SendTruthDecryptionToClient();

            client.GetTruthDecryptionFromInstaller(encryptedDecryptor);

            string decryptionPositions = client.SendToTruth();

            truth.CreateDecryption(decryptionPositions);



            truth.DecryptPositions();

            installer.ClearData();

            client.Decrypt(Strings.EncryptedDecryptionLayer2Client);

            installer.SendDataToClient();

            installer.CompleteTransmission();

            client.TryLock();

            client.AfterUnlock();
        }
 /// <summary>
 /// Generates a session ID and stores it in the client application
 /// </summary>
 protected void GenerateSessionId()
 {
     ClientApp.Resolve <ClientSessionIdRepository>().StoreSessionId(
         ServerSessionIdRepository.GenerateSessionId()
         );
 }
Exemple #13
0
 public virtual void destroy()
 {
     ClientApp.intstance = null;
 }