class Comuna::Config
Attributes
interfaces[R]
matches[R]
upstream[R]
Public Class Methods
new()
click to toggle source
# File lib/comuna/config.rb, line 8 def initialize load! end
Public Instance Methods
extract_with_defaults!(config)
click to toggle source
# File lib/comuna/config.rb, line 31 def extract_with_defaults!(config) port = config.fetch('port', 5300) @interfaces = config.fetch('interfaces', [[:udp, '0.0.0.0', port], [:tcp, '0.0.0.0', port]]) @upstream = config.fetch('upstream', [[:udp, '8.8.8.8', 53], [:tcp, '8.8.8.8', 53]]) @matches = config.fetch('matches', {myself: '0.0.0.0'}) end
load!()
click to toggle source
# File lib/comuna/config.rb, line 12 def load! extract_with_defaults!(parsed) end
parsed()
click to toggle source
# File lib/comuna/config.rb, line 26 def parsed read = YAML.load(raw) read.is_a?(Hash) ? read : {} end
raw()
click to toggle source
# File lib/comuna/config.rb, line 16 def raw if File.exist?('config.yml') File.read('config.yml') elsif File.exist?('config.yaml') File.read('config.yaml') else '' end end