Sha256: 218a4e91960c2985b8b5b7252550b0a48e1700641ddfc572d3bffacb37796114

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require "yaml"
require "dry-configurable"

module Matchd
  module Config
    DEFAULT_PORT = 15353
    DEFAULT_DOT_DIR = File.join(ENV["HOME"], ".matchd")
    DEFAULT_CONFIG_FILE = File.join(DEFAULT_DOT_DIR, "config.yml")

    extend Dry::Configurable

    # Base directory for config and daemon files
    setting(:dot_dir, DEFAULT_DOT_DIR, reader: true) { |f| File.expand_path(f) }

    # where the server will listen on
    setting(
      :listen,
      [
        { "protocol" => "udp", "ip" => "127.0.0.1", "port" => DEFAULT_PORT },
        { "protocol" => "udp", "ip" => "::1",       "port" => DEFAULT_PORT }
      ],
      reader: true
    )

    # The upstream resolver for passthrough requests.
    # "system" will try to read your systems DNS setup.
    # Give a specific config like this:
    #
    #   [{"protocol" => "udp", "ip" => "1.1.1.1", "port" => 53},
    #    {"protocol" => "tcp", "ip" => "1.1.1.1", "port" => 53}]
    #
    setting(:resolver, "system", reader: true)

    setting(:registry_file, "registry.yml")
    def self.registry_file
      File.expand_path(config.registry_file, dot_dir)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
matchd-0.1.0 lib/matchd/config.rb