Esempio n. 1
0
        private void ConfigureOnPremisesConnectors()
        {
            switch (this.sendConnectorOperation)
            {
            case MailFlowTask.Operation.New:
                this.sendConnector = base.OnPremisesSession.NewSendConnector(this.BuildExpectedSendConnector());
                break;

            case MailFlowTask.Operation.Update:
                this.sendConnector.UpdateFrom(this.BuildExpectedSendConnector());
                base.OnPremisesSession.SetSendConnector(this.sendConnector);
                break;
            }
            if (this.receiveConnectorOperation == MailFlowTask.Operation.Update)
            {
                foreach (ADObjectId adobjectId in this.ReceivingTransportServers)
                {
                    Tuple <MailFlowTask.Operation, IReceiveConnector> tuple = this.receiveConnectorsByTransportServer[adobjectId.Name];
                    MailFlowTask.Operation item = tuple.Item1;
                    if (item == MailFlowTask.Operation.Update)
                    {
                        IReceiveConnector item2 = tuple.Item2;
                        item2.UpdateFrom(this.BuildExpectedReceiveConnector(adobjectId));
                        base.OnPremisesSession.SetReceiveConnector(item2);
                    }
                }
                foreach (ADObjectId adobjectId2 in this.EdgeTransportServers)
                {
                    string identity = string.Format("Default Frontend {0}", adobjectId2.ToString());
                    base.TaskContext.Warnings.Add(HybridStrings.WarningEdgeReceiveConnector(adobjectId2.ToString(), identity, this.TlsCertificateSubjectDomainName.Replace("*", "mail")));
                    this.edgeReceiveConnectorsWarningDisplayed = true;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Connects a new receive endpoint to the host, and creates a <see cref="IClientFactory"/>.
        /// </summary>
        /// <param name="connector">The host to connect the new receive endpoint</param>
        /// <param name="destinationAddress">The request service address</param>
        /// <param name="timeout">The default request timeout</param>
        /// <returns></returns>
        public static async Task <IRequestClient <T> > CreateRequestClient <T>(this IReceiveConnector connector, Uri destinationAddress, RequestTimeout timeout = default)
            where T : class
        {
            var clientFactory = await CreateClientFactory(connector, timeout).ConfigureAwait(false);

            return(clientFactory.CreateRequestClient <T>(destinationAddress));
        }
        /// <summary>
        /// Connects a new receive endpoint to the host, and creates a <see cref="IClientFactory" />.
        /// </summary>
        /// <param name="connector">The host to connect the new receive endpoint</param>
        /// <param name="timeout">The default request timeout</param>
        /// <returns></returns>
        public static Task <IClientFactory> ConnectClientFactory(this IReceiveConnector connector, RequestTimeout timeout = default)
        {
            var endpointDefinition = new TemporaryEndpointDefinition();

            var receiveEndpointHandle = connector.ConnectReceiveEndpoint(endpointDefinition, KebabCaseEndpointNameFormatter.Instance);

            return(receiveEndpointHandle.CreateClientFactory(timeout));
        }
Esempio n. 4
0
        public static ReceiveConnector FromOther(IReceiveConnector source)
        {
            var target = new ReceiveConnector();

            source.CopyTo(target);

            return(target);
        }
Esempio n. 5
0
        public static T ConvertTo <T>(this IReceiveConnector source)
            where T : IReceiveConnector, new()
        {
            var target = new T();

            source.CopyTo(target);

            return(target);
        }
Esempio n. 6
0
        public void SetReceiveConnector(IReceiveConnector configuration)
        {
            SessionParameters sessionParameters = new SessionParameters();

            if (configuration.Identity != null)
            {
                sessionParameters.Set("Identity", configuration.Identity.ToString());
            }
            sessionParameters.Set("TLSCertificateName", TaskCommon.ToStringOrNull(configuration.TlsCertificateName));
            sessionParameters.Set("TLSDomainCapabilities", TaskCommon.ToStringOrNull(configuration.TlsDomainCapabilities));
            base.RemotePowershellSession.RunOneCommand("Set-ReceiveConnector", sessionParameters, false);
        }
Esempio n. 7
0
        public SMTPService(IReceiveConnector connector, SMTPServer smtpServer, CompositionContainer container)
        {
            _container    = container;
            LocalEndpoint = new IPEndPoint(connector.Address, connector.Port);
            SMTPServer    = smtpServer;

            Connector = connector;
            Settings  = new DefaultReceiveSettings(connector);

            _greylistingManager   = new GreylistingManager(connector.GreylistingTime ?? TimeSpan.Zero);
            SMTPServer.OnConnect += SMTPServerOnOnConnect;

            _container.SatisfyImportsOnce(this);
        }
Esempio n. 8
0
 public static void CopyTo(this IReceiveConnector source, IReceiveConnector target)
 {
     target.Id              = source.Id;
     target.Address         = source.Address;
     target.AuthPassword    = source.AuthPassword;
     target.AuthUsername    = source.AuthUsername;
     target.Banner          = source.Banner;
     target.Enabled         = source.Enabled;
     target.GreylistingTime = source.GreylistingTime;
     target.Name            = source.Name;
     target.Port            = source.Port;
     target.RemoteIPRanges  = source.RemoteIPRanges;
     target.RequireAuth     = source.RequireAuth;
     target.TLSSettings     = source.TLSSettings; // TODO
 }
Esempio n. 9
0
        private bool DoOnPremisesReceiveConnectorNeedConfiguration()
        {
            this.receiveConnectorOperation = MailFlowTask.Operation.NOP;
            if (this.ReceivingTransportServers.Count > 0)
            {
                using (MultiValuedProperty <ADObjectId> .Enumerator enumerator = this.ReceivingTransportServers.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ADObjectId        adobjectId       = enumerator.Current;
                        IReceiveConnector obj              = this.BuildExpectedReceiveConnector(adobjectId);
                        IReceiveConnector receiveConnector = base.OnPremisesSession.GetReceiveConnector(adobjectId);
                        if (receiveConnector == null)
                        {
                            throw new LocalizedException(HybridStrings.ErrorDefaultReceieveConnectorNotFound(adobjectId.Name));
                        }
                        Tuple <MailFlowTask.Operation, IReceiveConnector> value;
                        if (receiveConnector.Equals(obj))
                        {
                            value = new Tuple <MailFlowTask.Operation, IReceiveConnector>(MailFlowTask.Operation.NOP, receiveConnector);
                        }
                        else
                        {
                            this.receiveConnectorOperation = MailFlowTask.Operation.Update;
                            value = new Tuple <MailFlowTask.Operation, IReceiveConnector>(MailFlowTask.Operation.Update, receiveConnector);
                        }
                        this.receiveConnectorsByTransportServer[adobjectId.Name] = value;
                    }
                    goto IL_C2;
                }
            }
            if (this.EdgeTransportServers.Count > 0 && !this.edgeReceiveConnectorsWarningDisplayed)
            {
                this.receiveConnectorOperation = MailFlowTask.Operation.Update;
            }
IL_C2:
            return(this.receiveConnectorOperation != MailFlowTask.Operation.NOP);
        }
 /// <summary>
 /// Connect an endpoint for the host
 /// </summary>
 /// <param name="connector">The host to connect</param>
 /// <param name="configureEndpoint">The configuration callback</param>
 public static HostReceiveEndpointHandle ConnectReceiveEndpoint(this IReceiveConnector connector, Action <IReceiveEndpointConfigurator>
                                                                configureEndpoint = null)
 {
     return(connector.ConnectReceiveEndpoint(new TemporaryEndpointDefinition(), null, configureEndpoint));
 }
 /// <summary>
 /// Connect a response endpoint for the host
 /// </summary>
 /// <param name="connector">The host to connect</param>
 /// <param name="endpointNameFormatter"></param>
 /// <param name="configureEndpoint">The configuration callback</param>
 public static HostReceiveEndpointHandle ConnectResponseEndpoint(this IReceiveConnector connector, IEndpointNameFormatter endpointNameFormatter = null,
                                                                 Action <IReceiveEndpointConfigurator> configureEndpoint = null)
 {
     return(connector.ConnectReceiveEndpoint(new ResponseEndpointDefinition(), endpointNameFormatter, configureEndpoint));
 }
        /// <summary>
        /// Connects a new receive endpoint to the host, and creates a <see cref="IClientFactory" />.
        /// </summary>
        /// <param name="connector">The host to connect the new receive endpoint</param>
        /// <param name="timeout">The default request timeout</param>
        /// <returns></returns>
        public static Task <IClientFactory> CreateClientFactory(this IReceiveConnector connector, RequestTimeout timeout = default)
        {
            var receiveEndpointHandle = connector.ConnectResponseEndpoint();

            return(receiveEndpointHandle.CreateClientFactory(timeout));
        }
Esempio n. 13
0
 /// <summary>
 /// Creates a new RPC client factory on RabbitMQ using the direct reply-to feature
 /// </summary>
 /// <param name="connector">The connector, typically the bus instance</param>
 /// <param name="timeout">The default request timeout</param>
 /// <returns></returns>
 public static Task <IClientFactory> CreateReplyToClientFactory(this IReceiveConnector connector, RequestTimeout timeout = default)
 {
     var endpointDefinition = new ReplyToEndpointDefinition(default, 1000);
Esempio n. 14
0
 public DefaultReceiveSettings(IReceiveConnector connector)
 {
     _connector = connector;
 }