AsyncDNS-cr  Diff

Differences From Artifact [a3be16cbc5]:

To Artifact [5585feb972]:


1
2
3
4



5

6

7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module AsyncDNS
  class Settings
    @local_domain : String?




    property :static_hosts, :nameservers, :local_domain, :search_domains,

      :uses_tcp, :reload_period

    getter :timeout, :max_attempts, :abs_num_dots


    def timeout=(timeout)
      if timeout < Time::Span.zero
        raise ArgumentError.new("timeout must be positive")
      end

      @timeout = timeout
    end

    def max_attempts=(max_attempts)
      if max_attempts < 0
        raise ArgumentError.new("max_attempts must be positive")
      end

      @max_attempts = max_attempts
    end

    def abs_num_dots=(abs_num_dots)
      if abs_num_dots < 0
        raise ArgumentError.new("abs_num_dots must be positive")
      end

      @abs_num_dots = abs_num_dots
    end





>
>
>
|
>
|
>
|
>

|







|







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module AsyncDNS
  class Settings
    @local_domain : String?

    property static_hosts : Hash(String, Array(String))
    property nameservers : Array(String)
    property local_domain : String?
    property search_domains : Array(String)
    property uses_tcp : Bool
    property reload_period : Time::Span
    getter timeout : Time::Span
    getter max_attempts : Int32
    getter abs_num_dots : Int32

    def timeout=(timeout : Time::Span)
      if timeout < Time::Span.zero
        raise ArgumentError.new("timeout must be positive")
      end

      @timeout = timeout
    end

    def max_attempts=(max_attempts : Int32)
      if max_attempts < 0
        raise ArgumentError.new("max_attempts must be positive")
      end

      @max_attempts = max_attempts
    end

    def abs_num_dots=(abs_num_dots : Int32)
      if abs_num_dots < 0
        raise ArgumentError.new("abs_num_dots must be positive")
      end

      @abs_num_dots = abs_num_dots
    end

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
      {% else %}
        {% raise "Your OS is not supported by AsyncDNS" %}
      {% end %}

      @last_reload = Time.monotonic
    end

    def parse_hosts(path)
      @static_hosts.clear

      File.each_line(path, chomp: true) do |line|
        pos = line.index('#')
        line = line[0, pos] if pos

        split = line.split(/[ \t]/, remove_empty: true)







|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
      {% else %}
        {% raise "Your OS is not supported by AsyncDNS" %}
      {% end %}

      @last_reload = Time.monotonic
    end

    private def parse_hosts(path)
      @static_hosts.clear

      File.each_line(path, chomp: true) do |line|
        pos = line.index('#')
        line = line[0, pos] if pos

        split = line.split(/[ \t]/, remove_empty: true)
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
          end

          addresses << address
        end
      end
    end

    def parse_resolv_conf(path)
      @nameservers.clear
      @local_domain = nil
      @search_domains.clear

      File.each_line(path, chomp: true) do |line|
        pos = line.index(/[#;]/)
        line = line[0, pos] if pos







|







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
          end

          addresses << address
        end
      end
    end

    private def parse_resolv_conf(path)
      @nameservers.clear
      @local_domain = nil
      @search_domains.clear

      File.each_line(path, chomp: true) do |line|
        pos = line.index(/[#;]/)
        line = line[0, pos] if pos