internal static void ApplyManualOverrides(Dictionary <string, ProxyDestination> proxyDestinations, string manualOverrides)
        {
            Regex regex  = new Regex("^\\+(.+)=(.+):(\\d+)");
            Regex regex2 = new Regex("^\\-(.+)");

            string[] array = manualOverrides.Split(new char[]
            {
                ';'
            });
            foreach (string input in array)
            {
                Match match = regex.Match(input);
                if (match.Success)
                {
                    string value  = match.Groups[1].Value;
                    string value2 = match.Groups[2].Value;
                    int    port;
                    if (int.TryParse(match.Groups[3].Value, out port))
                    {
                        proxyDestinations.Add(value, RpcHttpProxyRules.CreateFixedDestination(Server.E15MinVersion, value2, port));
                    }
                }
                Match match2 = regex2.Match(input);
                if (match2.Success)
                {
                    string value3 = match2.Groups[1].Value;
                    proxyDestinations.Remove(value3);
                }
            }
        }
示例#2
0
 internal RpcHttpRequestHandler(RpcHttpProxyRules rule)
 {
     this.proxyRules = rule;
 }
 private void RefreshServerList(object stateInfo)
 {
     ADSite[]            adsites            = this.directory.GetADSites();
     ClientAccessArray[] clientAccessArrays = this.directory.GetClientAccessArrays();
     Server[]            servers            = this.directory.GetServers();
     if (adsites != null && servers != null)
     {
         Dictionary <string, ProxyDestination> dictionary = new Dictionary <string, ProxyDestination>(StringComparer.OrdinalIgnoreCase);
         foreach (Server server5 in from s in servers
                  where s.IsE15OrLater && s.IsMailboxServer
                  select s)
         {
             RpcHttpProxyRules.AddTwoMapsOfDestinations(dictionary, server5, RpcHttpProxyRules.CreateFixedDestination(Server.E15MinVersion, server5.Fqdn, 444));
         }
         ADSite[] array = adsites;
         for (int i = 0; i < array.Length; i++)
         {
             ADSite site = array[i];
             IEnumerable <Server> source = from s in servers
                                           where s.ServerSite != null && s.ServerSite.Name == site.Name
                                           select s;
             IEnumerable <Server> enumerable = from s in source
                                               where s.IsE14OrLater && !s.IsE15OrLater && s.IsClientAccessServer
                                               select s;
             IEnumerable <Server> source2 = from s in enumerable
                                            where !(bool)s[ActiveDirectoryServerSchema.IsOutOfService]
                                            select s;
             ProxyDestination proxyDestination = null;
             if (source2.Count <Server>() > 0)
             {
                 proxyDestination = new ProxyDestination(Server.E14MinVersion, 443, (from server in enumerable
                                                                                     select server.Fqdn).OrderBy((string str) => str, StringComparer.OrdinalIgnoreCase).ToArray <string>(), (from server in source2
                                                                                                                                                                                             select server.Fqdn).OrderBy((string str) => str, StringComparer.OrdinalIgnoreCase).ToArray <string>());
             }
             foreach (Server server2 in enumerable)
             {
                 RpcHttpProxyRules.AddTwoMapsOfDestinations(dictionary, server2, RpcHttpProxyRules.CreateFixedDestination(Server.E14MinVersion, server2.Fqdn, 443));
             }
             if (proxyDestination != null)
             {
                 foreach (Server server3 in from s in source
                          where s.IsE14OrLater && !s.IsE15OrLater && !s.IsClientAccessServer && s.IsMailboxServer
                          select s)
                 {
                     RpcHttpProxyRules.AddTwoMapsOfDestinations(dictionary, server3, proxyDestination);
                 }
                 if (clientAccessArrays != null && clientAccessArrays.Count <ClientAccessArray>() > 0)
                 {
                     foreach (ClientAccessArray clientAccessArray in from arr in clientAccessArrays
                              where arr.SiteName == site.Name
                              select arr)
                     {
                         dictionary[clientAccessArray.Fqdn] = proxyDestination;
                     }
                 }
             }
             IEnumerable <Server> source3 = from s in source
                                            where !s.IsE14OrLater && s.IsExchange2007OrLater && s.IsClientAccessServer
                                            select s;
             ProxyDestination proxyDestination2 = null;
             if (source3.Count <Server>() > 0)
             {
                 string[] array2 = (from server in source3
                                    select server.Fqdn).OrderBy((string str) => str, StringComparer.OrdinalIgnoreCase).ToArray <string>();
                 proxyDestination2 = new ProxyDestination(Server.E2007MinVersion, 443, array2, array2);
             }
             else if (proxyDestination != null)
             {
                 proxyDestination2 = proxyDestination;
             }
             if (proxyDestination2 != null)
             {
                 foreach (Server server4 in from s in source
                          where s.IsExchange2007OrLater && !s.IsE14OrLater && s.IsMailboxServer
                          select s)
                 {
                     RpcHttpProxyRules.AddTwoMapsOfDestinations(dictionary, server4, proxyDestination2);
                 }
             }
         }
         string text = WebConfigurationManager.AppSettings["OverrideProxyingRules"];
         if (!string.IsNullOrEmpty(text))
         {
             RpcHttpProxyRules.ApplyManualOverrides(dictionary, text);
         }
         this.proxyDestinations = dictionary;
     }
     if (this.refreshTimer != null)
     {
         this.refreshTimer.Change((int)RpcHttpProxyRules.TopologyRefreshInterval.TotalMilliseconds, -1);
         return;
     }
     this.refreshTimer = new Timer(new TimerCallback(this.RefreshServerList), null, (int)RpcHttpProxyRules.TopologyRefreshInterval.TotalMilliseconds, -1);
 }