@@ -45,6 +45,7 @@ class Gem::ConfigFile
4545 DEFAULT_UPDATE_SOURCES = true
4646 DEFAULT_CONCURRENT_DOWNLOADS = 8
4747 DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
48+ DEFAULT_IPV4_FALLBACK_ENABLED = false
4849
4950 ##
5051 # For Ruby packagers to set configuration defaults. Set in
@@ -140,6 +141,12 @@ class Gem::ConfigFile
140141
141142 attr_accessor :cert_expiration_length_days
142143
144+ ##
145+ # == Experimental ==
146+ # Fallback to IPv4 when IPv6 is not reachable or slow (default: false)
147+
148+ attr_accessor :ipv4_fallback_enabled
149+
143150 ##
144151 # Path name of directory or file of openssl client certificate, used for remote https connection with client authentication
145152
@@ -175,6 +182,7 @@ def initialize(args)
175182 @update_sources = DEFAULT_UPDATE_SOURCES
176183 @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
177184 @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS
185+ @ipv4_fallback_enabled = ENV [ 'IPV4_FALLBACK_ENABLED' ] == 'true' || DEFAULT_IPV4_FALLBACK_ENABLED
178186
179187 operating_system_config = Marshal . load Marshal . dump ( OPERATING_SYSTEM_DEFAULTS )
180188 platform_config = Marshal . load Marshal . dump ( PLATFORM_DEFAULTS )
@@ -203,6 +211,7 @@ def initialize(args)
203211 @disable_default_gem_server = @hash [ :disable_default_gem_server ] if @hash . key? :disable_default_gem_server
204212 @sources = @hash [ :sources ] if @hash . key? :sources
205213 @cert_expiration_length_days = @hash [ :cert_expiration_length_days ] if @hash . key? :cert_expiration_length_days
214+ @ipv4_fallback_enabled = @hash [ :ipv4_fallback_enabled ] if @hash . key? :ipv4_fallback_enabled
206215
207216 @ssl_verify_mode = @hash [ :ssl_verify_mode ] if @hash . key? :ssl_verify_mode
208217 @ssl_ca_cert = @hash [ :ssl_ca_cert ] if @hash . key? :ssl_ca_cert
0 commit comments