diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 638d85afc2..ca05e327b9 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -118,7 +118,8 @@ private static void add_or_remove_licensed_source(ChocolateyLicense license, Con Value = ApplicationParameters.ChocolateyLicensedFeedSource, UserName = "customer", Password = NugetEncryptionUtility.EncryptString(license.Id), - Priority = 10 + Priority = 10, + BypassProxy = false, }; if (addOrUpdate && !sources.Any(s => @@ -180,7 +181,8 @@ private static void set_machine_sources(ChocolateyConfiguration config, ConfigFi EncryptedPassword = source.Password, Certificate = source.Certificate, EncryptedCertificatePassword = source.CertificatePassword, - Priority = source.Priority + Priority = source.Priority, + BypassProxy = source.BypassProxy, }); } } diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs index 93e7c29024..f63c5c17b2 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs @@ -62,7 +62,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon option => configuration.SourceCommand.CertificatePassword = option.remove_surrounding_quotes()) .Add("priority=", "Priority - The priority order of this source as compared to other sources, lower is better. Defaults to 0 (no priority). All priorities above 0 will be evaluated first, then zero-based values will be evaluated in config file order. Available in 0.9.9.9+.", - option => configuration.SourceCommand.Priority = int.Parse(option.remove_surrounding_quotes())) + option => configuration.SourceCommand.Priority = int.Parse(option.remove_surrounding_quotes())) + .Add("bypassProxy", + "BypassProxy - Should this source explicitly bypass any explicitly or system configured proxies? Defaults to false. Available in 0.10.4+.", + option => configuration.SourceCommand.BypassProxy = option != null) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 6e1b491d13..1aea25fed2 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -415,6 +415,7 @@ public sealed class SourcesCommandConfiguration public int Priority { get; set; } public string Certificate { get; set; } public string CertificatePassword { get; set; } + public bool BypassProxy { get; set; } } [Serializable] @@ -427,6 +428,7 @@ public sealed class MachineSourceConfiguration public int Priority { get; set; } public string Certificate { get; set; } public string EncryptedCertificatePassword { get; set; } + public bool BypassProxy { get; set; } } [Serializable] @@ -470,5 +472,6 @@ public sealed class ProxyConfiguration public string Location { get; set; } public string User { get; set; } public string EncryptedPassword { get; set; } + public string BypassList { get; set; } } } \ No newline at end of file diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateySource.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateySource.cs index a9eb754a16..289bf8e03a 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateySource.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateySource.cs @@ -23,7 +23,9 @@ public class ChocolateySource public bool Disabled { get; set; } - public bool Authenticated { get; set; } + public bool Authenticated { get; set; } + + public bool BypassProxy { get; set; } public int Priority { get; set; } } diff --git a/src/chocolatey/infrastructure.app/configuration/ConfigFileSourceSetting.cs b/src/chocolatey/infrastructure.app/configuration/ConfigFileSourceSetting.cs index d1ae12b44f..bc56e5328f 100644 --- a/src/chocolatey/infrastructure.app/configuration/ConfigFileSourceSetting.cs +++ b/src/chocolatey/infrastructure.app/configuration/ConfigFileSourceSetting.cs @@ -34,6 +34,9 @@ public sealed class ConfigFileSourceSetting [XmlAttribute(AttributeName = "disabled")] public bool Disabled { get; set; } + [XmlAttribute(AttributeName = "bypassProxy")] + public bool BypassProxy { get; set; } + [XmlAttribute(AttributeName = "user")] public string UserName { get; set; } diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index e4e7c3073b..c91a47e5fe 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -80,12 +80,21 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con { var source = sourceValue; - if (configuration.MachineSources.Any(m => m.Name.is_equal_to(source))) + var bypassProxy = false; + if (configuration.MachineSources.Any(m => m.Name.is_equal_to(source) || m.Key.is_equal_to(source))) { - "chocolatey".Log().Debug("Switching source name {0} to actual source value.".format_with(sourceValue)); + try { - source = configuration.MachineSources.FirstOrDefault(m => m.Name.is_equal_to(source)).Key; + var machineSource = configuration.MachineSources.FirstOrDefault(m => m.Key.is_equal_to(source)); + if (machineSource == null) + { + machineSource = configuration.MachineSources.FirstOrDefault(m => m.Name.is_equal_to(source)); + "chocolatey".Log().Debug("Switching source name {0} to actual source value '{1}'.".format_with(sourceValue, machineSource.Key.to_string())); + source = machineSource.Key; + } + + if (machineSource != null) bypassProxy = machineSource.BypassProxy; } catch (Exception ex) { @@ -104,7 +113,7 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con } else { - repositories.Add(new DataServicePackageRepository(new RedirectedHttpClient(uri))); + repositories.Add(new DataServicePackageRepository(new RedirectedHttpClient(uri, bypassProxy))); } } catch (Exception) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs index 0da71c0f7b..5942d89f50 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs @@ -52,19 +52,21 @@ public IEnumerable source_list(ChocolateyConfiguration configu foreach (var source in configFileSettings.Sources) { if (!configuration.QuietOutput) { - this.Log().Info(() => "{0}{1} - {2} {3}| Priority {4}.".format_with( + this.Log().Info(() => "{0}{1} - {2} {3}| Priority {4}|Bypass Proxy - {5}.".format_with( source.Id, source.Disabled ? " [Disabled]" : string.Empty, source.Value, (string.IsNullOrWhiteSpace(source.UserName) && string.IsNullOrWhiteSpace(source.Certificate)) ? string.Empty : "(Authenticated)", - source.Priority)); + source.Priority, + source.BypassProxy.to_string())); } list.Add(new ChocolateySource { Id = source.Id, Value = source.Value, Disabled = source.Disabled, Authenticated = !(string.IsNullOrWhiteSpace(source.UserName) && string.IsNullOrWhiteSpace(source.Certificate)), - Priority = source.Priority + Priority = source.Priority, + BypassProxy = source.BypassProxy, }); } return list; @@ -83,7 +85,8 @@ public void source_add(ChocolateyConfiguration configuration) Password = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.Password), Certificate = configuration.SourceCommand.Certificate, CertificatePassword = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.CertificatePassword), - Priority = configuration.SourceCommand.Priority + Priority = configuration.SourceCommand.Priority, + BypassProxy = configuration.SourceCommand.BypassProxy, }; configFileSettings.Sources.Add(source); @@ -99,7 +102,8 @@ public void source_add(ChocolateyConfiguration configuration) configuration.SourceCommand.Username.is_equal_to(source.UserName) && configuration.SourceCommand.Password.is_equal_to(currentPassword) && configuration.SourceCommand.CertificatePassword.is_equal_to(currentCertificatePassword) && - configuration.SourceCommand.Certificate.is_equal_to(source.Certificate) + configuration.SourceCommand.Certificate.is_equal_to(source.Certificate) && + configuration.SourceCommand.BypassProxy == source.BypassProxy ) { if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE); @@ -112,6 +116,7 @@ public void source_add(ChocolateyConfiguration configuration) source.Password = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.Password); source.CertificatePassword = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.CertificatePassword); source.Certificate = configuration.SourceCommand.Certificate; + source.BypassProxy = configuration.SourceCommand.BypassProxy; _xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation); if (!configuration.QuietOutput) this.Log().Warn(() => "Updated {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));