Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341NotifyMultipleItems(V131SessionHeader header, V341NotifyMultipleItems body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.DispatchAsyncRecvNotifyMultipleItems(new PackageNotifyMultipleItems(connection.ClientId, header, body));
     }
 }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341CompletionResult(V131SessionHeader header, V341CompletionResult body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.DispatchAsyncRecvCompletionResult(
             new PackageCompletionResult(connection.ClientId, new PackageHeader(header), body.Success, body.Result, body.Message));
     }
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341SelectMultipleItems(V131SessionHeader header, V341SelectMultipleItems body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.DispatchAsyncRecvSelectMultipleItems(
             new PackageSelectMultipleItems(connection.ClientId, new PackageHeader(header), new PackageSelectItemsQuery(body)));
     }
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341CancelSubscription(V131SessionHeader header, V341CancelSubscription body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.DispatchAsyncRecvCancelSubscription(
             new PackageCancelSubscription(connection.ClientId, new PackageHeader(header), body.SubscriptionId));
     }
 }
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341CreateSubscription(V131SessionHeader header, V341CreateSubscription body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.DispatchAsyncRecvCreateSubscription(
             new PackageCreateSubscription(
                 connection.ClientId, new PackageHeader(header), new PackageSubscriptionQuery(body), body.ExpiryTime));
     }
 }
Exemple #6
0
        public V131SessionReply BeginSessionV131(V131SessionHeader header, V131ClientInfo clientInfo)
        {
            // validate new client
            // - ensure configured client/server environments are the same
            if (CoreHelper.ToEnvId(clientInfo.ConfigEnv) != _serverCfg.ModuleInfo.ConfigEnv)
            {
                // not valid
                string msg =
                    $"Client environment ({clientInfo.ConfigEnv}) <> server environment ({_serverCfg.ModuleInfo.ConfigEnv})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // - ensure build environment is backward compatible
            if (CoreHelper.ToEnvId(clientInfo.BuildEnv) < _serverCfg.ModuleInfo.BuildEnv)
            {
                // not valid
                string msg =
                    $"Client build environment ({clientInfo.BuildEnv}) < server build environment ({_serverCfg.ModuleInfo.BuildEnv})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // - ensure STG/PRD environment servers only accessed by valid clients
            if ((_serverCfg.ModuleInfo.ConfigEnv >= EnvId.Stg_StagingLive) && (clientInfo.CompInfo.AssmPTok != _serverCfg.ModuleInfo.CorePTok))
            {
                Logger.LogDebug("Client signature ({0}) <> server signature ({1})!",
                                clientInfo.CompInfo.AssmPTok, _serverCfg.ModuleInfo.CorePTok);
            }
            // check client version
            const string requiredVersion = "2.2.1815.1";

            if (!V131Helpers.CheckRequiredFileVersion(Logger, requiredVersion, clientInfo.CompInfo.AssmFVer))
            {
                // not valid
                string msg = $"Client version ({clientInfo.CompInfo.AssmFVer}) < required version ({requiredVersion})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // valid client
            Guid sessionId = Guid.NewGuid();

            _connectionIndex.Locked(connections =>
            {
                // - update the connection
                connections[sessionId] = new V131ModuleInfo(clientInfo);
                if (header.DebugRequest)
                {
                    Logger.LogDebug("Connection (auto)");
                    Logger.LogDebug("  Identity   : {0} ({1})", clientInfo.UserInfo.UserIdentityName, clientInfo.UserInfo.UserFullName);
                    Logger.LogDebug("  Application: {0} V{1}/{2} ({3}/{4})", clientInfo.ApplInfo.AssmName, clientInfo.ApplInfo.AssmNVer, clientInfo.ApplInfo.AssmFVer, clientInfo.ApplInfo.AssmPTok, clientInfo.ApplInfo.AssmHash);
                    Logger.LogDebug("  Component  : {0} V{1}/{2} ({3}/{4})", clientInfo.CompInfo.AssmName, clientInfo.CompInfo.AssmNVer, clientInfo.CompInfo.AssmFVer, clientInfo.CompInfo.AssmPTok, clientInfo.CompInfo.AssmHash);
                    Logger.LogDebug("  Client Env.: {0} ({1} build)", clientInfo.ConfigEnv, clientInfo.BuildEnv);
                    Logger.LogDebug("  Other Addrs: {0} ({1},{2})", clientInfo.HostName, clientInfo.HostIpV4, String.Join(",", clientInfo.NetAddrs.ToArray()));
                    Logger.LogDebug("  Session Id.: {0}/{1}", sessionId, clientInfo.NodeGuid);
                }
            });
            return(new V131SessionReply(sessionId, null));
        }
Exemple #7
0
 // V1.3
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 public PackageHeader(V131SessionHeader header)
 {
     ClientId      = header.SessionId;
     RequestId     = header.RequestId;
     MoreFollowing = header.MoreFollowing;
     ReplyRequired = header.ReplyRequired;
     ReplyAddress  = header.ReplyAddress;
     ReplyContract = header.ReplyContract;
     DebugRequest  = header.DebugRequest;
 }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public void TransferV341ExtendSubscription(V131SessionHeader header, V341ExtendSubscription body)
 {
     if (TryGetValidConnection(header.SessionId, out var connection))
     {
         connection.ExtendExpiry();
         _cacheEngine.UpdateConnectionState(connection.ClientId, connection.ContractName, connection.ReplyAddress);
         connection.DispatchAsyncRecvExtendSubscription(
             new PackageExtendSubscription(
                 connection.ClientId, new PackageHeader(header), body.SubscriptionId, body.ExpiryTime));
     }
 }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="header"></param>
        public void CloseSessionV131(V131SessionHeader header)
        {
            // - remove the old connection (if any)
            IConnection connection = _connectionIndex.Remove(header.SessionId);

            if (connection != null)
            {
                _cacheEngine.DeleteConnectionState(connection.ClientId);
                Logger.LogDebug("Connection: '{0}' removed ({1})", connection.ClientId, connection.ReplyAddress);
            }
        }
Exemple #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientId"></param>
 /// <param name="header"></param>
 /// <param name="body"></param>
 public PackageNotifyMultipleItems(Guid clientId, V131SessionHeader header, V341NotifyMultipleItems body)
     : base(clientId, new PackageHeader(header))
 {
     foreach (V341TransportItem item in body.Items)
     {
         _Items.Add(new CommonItem(
                        item.ItemId, V341Helpers.ToItemKind(item.ItemKind),
                        item.Transient, item.ItemName,
                        new NamedValueSet(item.AppProps), item.DataType, item.AppScope,
                        new NamedValueSet(item.SysProps), item.NetScope,
                        item.Created, item.Expires,
                        item.YData, item.YSign, item.SourceUSN));
     }
 }
Exemple #11
0
 public void CloseSessionV131(V131SessionHeader header)
 {
     _connectionIndex.Locked(connections =>
     {
         // - remove the old connection (if any)
         if (connections.Remove(header.SessionId))
         {
             if (header.DebugRequest)
             {
                 Logger.LogDebug("Disconnected");
                 Logger.LogDebug("  Session Id.: {0}", header.SessionId);
             }
         }
     });
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 public void CloseSessionV131(V131SessionHeader header)
 {
     Channel.CloseSessionV131(header);
 }
 public void TransferV341NotifyMultipleItems(V131SessionHeader header, V341NotifyMultipleItems body)
 {
     Channel.TransferV341NotifyMultipleItems(header, body);
 }
 public void TransferV341CancelSubscription(V131SessionHeader header, V341CancelSubscription body)
 {
     Channel.TransferV341CancelSubscription(header, body);
 }
 public void TransferV341CompletionResult(V131SessionHeader header, V341CompletionResult body)
 {
     Channel.TransferV341CompletionResult(header, body);
 }
 public void TransferV341AnswerMultipleItems(V131SessionHeader header, V341AnswerMultipleItems body)
 {
     _channel.TransferV341AnswerMultipleItems(header, body);
 }
 public void TransferV341ExtendSubscription(V131SessionHeader header, V341ExtendSubscription body)
 {
     _channel.TransferV341ExtendSubscription(header, body);
 }
Exemple #18
0
        // Core V3.4 server implementation

        #region ISessCtrlV131 Members

        /// <summary>
        ///
        /// </summary>
        /// <param name="header"></param>
        /// <param name="clientInfo"></param>
        /// <returns></returns>
        public V131SessionReply BeginSessionV131(V131SessionHeader header, V131ClientInfo clientInfo)
        {
            // validate new client
            Guid clientId = clientInfo.NodeGuid;

            // - ensure configured client/server envs are the same
            if (CoreHelper.ToEnvId(clientInfo.ConfigEnv) != _serverCfg.ModuleInfo.ConfigEnv)
            {
                // not valid
                string msg =
                    $"Client environment ({clientInfo.ConfigEnv}) <> server environment ({_serverCfg.ModuleInfo.ConfigEnv})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // - ensure build environment is backward compatible
            if (CoreHelper.ToEnvId(clientInfo.BuildEnv) < _serverCfg.ModuleInfo.BuildEnv)
            {
                // not valid
                string msg =
                    $"Client build environment ({clientInfo.BuildEnv}) < server build environment ({_serverCfg.ModuleInfo.BuildEnv})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // - check client version
            const string minimumVersion = "3.4.1723.1"; // 1.1.1501.1  March 01, 2019
            const string optimalVersion = "3.4.1723.1";

            if (!V131Helpers.CheckRequiredFileVersion(Logger, minimumVersion, clientInfo.CompInfo.AssmFVer))
            {
                // older than minimum - reject connection
                string msg = $"Client version ({clientInfo.CompInfo.AssmFVer}) < minimum version ({minimumVersion})!";
                Logger.LogError(msg);
                Logger.LogDebug("Connection: '{0}' rejected ({1})", clientId, header.ReplyAddress);
                return(new V131SessionReply(msg));
            }
            if (!V131Helpers.CheckRequiredFileVersion(Logger, optimalVersion, clientInfo.CompInfo.AssmFVer))
            {
                // older than optimal - log warning
                string msg = $"Client version ({clientInfo.CompInfo.AssmFVer}) < optimal version ({optimalVersion})!";
                Logger.LogWarning(msg);
            }
            // - ensure STG/PRD envs servers only accessed by valid clients
            if (_serverCfg.ModuleInfo.ConfigEnv >= EnvId.Stg_StagingLive && (clientInfo.CompInfo.AssmPTok != _serverCfg.ModuleInfo.CorePTok))
            {
                string msg =
                    $"Client signature ({clientInfo.CompInfo.AssmPTok}) <> server signature ({_serverCfg.ModuleInfo.CorePTok})!";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // - ensure automated unit tests are not running integration tests
            if (_serverCfg.ModuleInfo.ConfigEnv >= EnvId.Sit_SystemTest &&
                clientInfo.ApplInfo.AssmName.Equals("QTAgent32", StringComparison.OrdinalIgnoreCase))
            {
                string msg =
                    $"Unauthorised client: {clientInfo.UserInfo.UserIdentityName} {clientInfo.HostName} {clientInfo.ApplInfo.AssmName}";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            IConnection newConnection;

            // build correct connection version
            if (header.ReplyContract == typeof(ITransferV341).FullName)
            {
                newConnection = new ConnectionV34(
                    Logger, _cacheEngine, _serverCfg, clientId, header.ReplyAddress, NodeType.Client);
            }
            else
            {
                // reply contract not supported
                string msg = $"ReplyContract not supported: {header.ReplyContract}";
                Logger.LogWarning(msg);
                return(new V131SessionReply(msg));
            }
            // success - grant access
            IConnection connection = _connectionIndex.GetOrSet(clientId, () => newConnection);

            connection.ReplyAddress = header.ReplyAddress;
            _cacheEngine.UpdateConnectionState(connection.ClientId, connection.ContractName, connection.ReplyAddress);
            // update who stats: domain/name/host/app
            StatsCountersDelta.AddToHierarchy(
                $"ConnUser.{clientInfo.UserInfo.UserIdentityName}.{clientInfo.HostName}.{clientInfo.ApplInfo.AssmName}");
            // update where stats: ip/host/app
            StatsCountersDelta.AddToHierarchy(
                $"ConnHost.{clientInfo.HostIpV4}.{clientInfo.HostName}.{clientInfo.ApplInfo.AssmName}");
            // update version stats:
            StatsCountersDelta.AddToHierarchy(
                $"CVersion.{clientInfo.BuildEnv}.{string.Join(".", clientInfo.CompInfo.AssmFVer.Split('.'), 0, 2).Replace('.', '_')}.{String.Join(".", clientInfo.CompInfo.AssmFVer.Split('.'), 2, 2).Replace('.', '_')}.{clientInfo.HostName}.{clientInfo.ApplInfo.AssmName}");
            Logger.LogDebug("Connection: '{0}' created ({1})", clientId, header.ReplyAddress);
            if (header.DebugRequest)
            {
                Logger.LogDebug("  Identity   : {0} ({1})", clientInfo.UserInfo.UserIdentityName, clientInfo.UserInfo.UserFullName);
                Logger.LogDebug("  Application: {0} V{1}/{2} ({3}/{4})", clientInfo.ApplInfo.AssmName, clientInfo.ApplInfo.AssmNVer, clientInfo.ApplInfo.AssmFVer, clientInfo.ApplInfo.AssmPTok, clientInfo.ApplInfo.AssmHash);
                Logger.LogDebug("  Component  : {0} V{1}/{2} ({3}/{4})", clientInfo.CompInfo.AssmName, clientInfo.CompInfo.AssmNVer, clientInfo.CompInfo.AssmFVer, clientInfo.CompInfo.AssmPTok, clientInfo.CompInfo.AssmHash);
                Logger.LogDebug("  Client Env.: {0} ({1} build)", clientInfo.ConfigEnv, clientInfo.BuildEnv);
                Logger.LogDebug("  Client Intf: {0}", header.ReplyContract);
                Logger.LogDebug("  Other Addrs: {0} ({1},{2})", clientInfo.HostName, clientInfo.HostIpV4, String.Join(",", clientInfo.NetAddrs.ToArray()));
            }
            return(new V131SessionReply(clientId, null));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="header"></param>
 /// <param name="clientInfo"></param>
 /// <returns></returns>
 public V131SessionReply BeginSessionV131(V131SessionHeader header, V131ClientInfo clientInfo)
 {
     return(_channel.BeginSessionV131(header, clientInfo));
 }