Class: VagrantDNS::Config
- Inherits:
-
Object
- Object
- VagrantDNS::Config
- Defined in:
- lib/vagrant-dns/config.rb
Class Attribute Summary collapse
-
.auto_run ⇒ Object
Returns the value of attribute auto_run.
-
.check_public_suffix ⇒ Object
Returns the value of attribute check_public_suffix.
- .listen ⇒ Object
-
.logger ⇒ Object
Returns the value of attribute logger.
- .passthrough ⇒ Object
- .passthrough_resolver ⇒ Object
- .ttl ⇒ Object
Instance Attribute Summary collapse
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#patterns ⇒ Object
readonly
Returns the value of attribute patterns.
-
#records ⇒ Object
Returns the value of attribute records.
-
#tlds ⇒ Object
readonly
Returns the value of attribute tlds.
Class Method Summary collapse
Instance Method Summary collapse
- #pattern=(pattern) ⇒ Object (also: #patterns=)
- #tld=(tld) ⇒ Object
-
#to_hash ⇒ Object
explicit hash, to get symbols in hash keys.
- #validate(machine) ⇒ Object
- #validate_check_public_suffix(errors, machine) ⇒ Object
Class Attribute Details
.auto_run ⇒ Object
Returns the value of attribute auto_run.
7 8 9 |
# File 'lib/vagrant-dns/config.rb', line 7 def auto_run @auto_run end |
.check_public_suffix ⇒ Object
Returns the value of attribute check_public_suffix.
7 8 9 |
# File 'lib/vagrant-dns/config.rb', line 7 def check_public_suffix @check_public_suffix end |
.listen ⇒ Object
9 10 11 |
# File 'lib/vagrant-dns/config.rb', line 9 def listen @listen ||= [[:udp, "127.0.0.1", 5300]] end |
.logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/vagrant-dns/config.rb', line 7 def logger @logger end |
.passthrough ⇒ Object
17 18 19 20 |
# File 'lib/vagrant-dns/config.rb', line 17 def passthrough return true if @passthrough.nil? @passthrough end |
.passthrough_resolver ⇒ Object
22 23 24 |
# File 'lib/vagrant-dns/config.rb', line 22 def passthrough_resolver @passthrough_resolver ||= :system end |
.ttl ⇒ Object
13 14 15 |
# File 'lib/vagrant-dns/config.rb', line 13 def ttl @ttl ||= 300 end |
Instance Attribute Details
#ip ⇒ Object
Returns the value of attribute ip.
63 64 65 |
# File 'lib/vagrant-dns/config.rb', line 63 def ip @ip end |
#patterns ⇒ Object (readonly)
Returns the value of attribute patterns.
64 65 66 |
# File 'lib/vagrant-dns/config.rb', line 64 def patterns @patterns end |
#records ⇒ Object
Returns the value of attribute records.
63 64 65 |
# File 'lib/vagrant-dns/config.rb', line 63 def records @records end |
#tlds ⇒ Object (readonly)
Returns the value of attribute tlds.
64 65 66 |
# File 'lib/vagrant-dns/config.rb', line 64 def tlds @tlds end |
Class Method Details
.validate_tlds(vm) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vagrant-dns/config.rb', line 36 def validate_tlds(vm) return [true, nil] unless check_public_suffix require "public_suffix" # Don't include private domains in the list, we are only interested in TLDs and such list = PublicSuffix::List.parse( File.read(PublicSuffix::List::DEFAULT_LIST_PATH), private_domains: false ) failed_tlds = vm.config.dns.tlds.select { |tld| list.find(tld, default: false) } err = if failed_tlds.any? "tlds include a public suffix: #{failed_tlds.join(", ")}" end if err && check_public_suffix.to_s == "error" [false, err] elsif err [true, err] else [true, nil] end end |
Instance Method Details
#pattern=(pattern) ⇒ Object Also known as: patterns=
66 67 68 |
# File 'lib/vagrant-dns/config.rb', line 66 def pattern=(pattern) @patterns = (pattern ? Array(pattern) : pattern) end |
#tld=(tld) ⇒ Object
71 72 73 |
# File 'lib/vagrant-dns/config.rb', line 71 def tld=(tld) @tlds = Array(tld) end |
#to_hash ⇒ Object
explicit hash, to get symbols in hash keys
80 81 82 |
# File 'lib/vagrant-dns/config.rb', line 80 def to_hash { patterns: patterns, records: records, tlds: tlds, ip: ip } end |
#validate(machine) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/vagrant-dns/config.rb', line 84 def validate(machine) errors = _detected_errors errors = validate_check_public_suffix(errors, machine) { "vagrant_dns" => errors } end |
#validate_check_public_suffix(errors, machine) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/vagrant-dns/config.rb', line 92 def validate_check_public_suffix(errors, machine) valid, err = self.class.validate_tlds(machine) if !valid errors << err elsif err machine.ui.warn(err) end errors end |