Class: Middleman::PreviewServer::Checks::ServerNameResolvesToBindAddress
- Inherits:
-
BasicCheck
- Object
- BasicCheck
- Middleman::PreviewServer::Checks::ServerNameResolvesToBindAddress
- Defined in:
- lib/middleman-core/preview_server/checks.rb
Overview
This checks if the server name resolves to the bind_address
If the users enters:
- server_name: www.example.com (10.0.0.1)
- bind_address: 127.0.0.01
This validation will fail
Instance Method Summary collapse
-
#initialize ⇒ ServerNameResolvesToBindAddress
constructor
A new instance of ServerNameResolvesToBindAddress.
-
#validate(information) ⇒ Object
Validate.
Constructor Details
#initialize ⇒ ServerNameResolvesToBindAddress
Returns a new instance of ServerNameResolvesToBindAddress.
25 26 27 |
# File 'lib/middleman-core/preview_server/checks.rb', line 25 def initialize @resolver = DnsResolver.new end |
Instance Method Details
#validate(information) ⇒ Object
Validate
33 34 35 36 37 38 |
# File 'lib/middleman-core/preview_server/checks.rb', line 33 def validate(information) return if resolver.ips_for(information.server_name).include? information.bind_address information.valid = false information.reason = format('Server name "%s" does not resolve to bind address "%s"', information.server_name, information.bind_address) end |