ddig 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a776d193cef1eb47509ef1979fe17267088c418c89320e1f6db61da04e8d5f4c
4
- data.tar.gz: 463dc9f0efa82b6b1bde2e7641fe2fe866b470faae033fbadd8eadca72479a81
3
+ metadata.gz: c5f4f760504764961fc5ed63cf451342c21363dda09f7019b069b39b07f1f285
4
+ data.tar.gz: ea12f744a8ece727434e35109a4bbc47432e758aa9a316ed5e6188e87782b44d
5
5
  SHA512:
6
- metadata.gz: 175b5193ff75e92e5a5d3a07f9589918a6a943dae64b6002b5ead5f3af205cbbd6d49512d5607c86ed55e5afcbca4d40ee89de5a2095161c1eb3ebe67415c1d8
7
- data.tar.gz: c633c6733c13cc5363e176bb3d7bb9dac66e14b0fea6072729d6d1692e2517a7d4d1ac68b818b342c4ff24d33958753e701e8916fdd48d00ec169492b16778fc
6
+ metadata.gz: 2a6ee4074192640bd558b7b8bb01667f870e96f76ce7be977278eceeeb9898e209a20fb8ad629ec17d315848e2b36d94cf4efd775735e4a57f792120b17e1779
7
+ data.tar.gz: 21fefdd3bad1ad544b33c7e02c9dfd1a27dbe2b2791c8a552e701ef403ad915d3c98cc39e42f9ae2219f71fa175310d917fbb1b2b0d3cd7fe2fed04fbf0d9a1d
data/lib/ddig/cli.rb CHANGED
@@ -86,7 +86,8 @@ module Ddig
86
86
  @ddig = Ddig.lookup(@hostname, nameservers: @options[:nameserver], use_ipv4: @use_ipv4, use_ipv6: @use_ipv6)
87
87
 
88
88
  if @options[:format] == 'json'
89
- # TODO: to_json
89
+ puts @ddig.to_json
90
+
90
91
  else
91
92
  unless @ddig[:do53][:ipv4].nil?
92
93
  puts "# Do53 (IPv4)"
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Ddig
2
4
  class Ddr
3
5
  class DesignatedResolver
@@ -61,6 +63,27 @@ module Ddig
61
63
  end
62
64
  end
63
65
 
66
+ def as_json(*)
67
+ {
68
+ unencrypted_resolver: @unencrypted_resolver,
69
+ target: @target,
70
+ protocol: @protocol,
71
+ port: @port,
72
+ dohpath: @dohpath,
73
+ address: @address,
74
+ ip: @ip,
75
+ verify: @verify_cert&.verify,
76
+ hostname: @hostname,
77
+ a: @a,
78
+ aaaa: @aaaa,
79
+ errors: @errors,
80
+ }
81
+ end
82
+
83
+ def to_json(*args)
84
+ as_json.to_json
85
+ end
86
+
64
87
  def to_cli
65
88
  @resolver.to_cli
66
89
  end
data/lib/ddig/ddr.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'resolv'
2
+ require 'json'
2
3
 
3
4
  require_relative "ddr/verify_cert"
4
5
  require_relative "ddr/designated_resolver"
@@ -129,6 +130,19 @@ module Ddig
129
130
  end
130
131
  end
131
132
 
133
+ def as_json(*)
134
+ {
135
+ designated_resolvers: @designated_resolvers.map { |designated_resolver| designated_resolver.as_json },
136
+ hostname: @hostname,
137
+ nameservers: @nameservers,
138
+ ip: @ip,
139
+ }
140
+ end
141
+
142
+ def to_json(*args)
143
+ as_json.to_json
144
+ end
145
+
132
146
  def to_cli
133
147
  @designated_resolvers.each do |designated_resolver|
134
148
  puts designated_resolver.to_s
@@ -1,4 +1,5 @@
1
1
  require 'resolv'
2
+ require 'json'
2
3
 
3
4
  module Ddig
4
5
  module Resolver
@@ -33,6 +34,20 @@ module Ddig
33
34
  self
34
35
  end
35
36
 
37
+ def as_json(*)
38
+ {
39
+ a: @a,
40
+ aaaa: @aaaa,
41
+ hostname: @hostname,
42
+ nameservers: @nameservers,
43
+ ip: @ip,
44
+ }
45
+ end
46
+
47
+ def to_json(*args)
48
+ as_json.to_json
49
+ end
50
+
36
51
  def to_cli
37
52
  @a.each do |address|
38
53
  rr_type = 'A'
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'resolv'
3
3
  require 'base64'
4
+ require 'json'
4
5
 
5
6
  require_relative 'dns_message'
6
7
 
@@ -57,6 +58,22 @@ module Ddig
57
58
  end
58
59
  end
59
60
 
61
+ def as_json(*)
62
+ {
63
+ a: @a,
64
+ aaaa: @aaaa,
65
+ hostname: @hostname,
66
+ server: @server,
67
+ address: @address,
68
+ dohpath: @dohpath,
69
+ port: @port,
70
+ }
71
+ end
72
+
73
+ def to_json(*args)
74
+ as_json.to_json
75
+ end
76
+
60
77
  def to_cli
61
78
  @a.each do |address|
62
79
  rr_type = 'A'
@@ -1,5 +1,6 @@
1
1
  require 'openssl'
2
2
  require 'resolv'
3
+ require 'json'
3
4
 
4
5
  require_relative 'dns_message'
5
6
 
@@ -75,6 +76,21 @@ module Ddig
75
76
  end
76
77
  end
77
78
 
79
+ def as_json(*)
80
+ {
81
+ a: @a,
82
+ aaaa: @aaaa,
83
+ hostname: @hostname,
84
+ server: @server,
85
+ server_name: @server_name,
86
+ port: @port,
87
+ }
88
+ end
89
+
90
+ def to_json(*args)
91
+ as_json.to_json
92
+ end
93
+
78
94
  def to_cli
79
95
  @a.each do |address|
80
96
  rr_type = 'A'
data/lib/ddig/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ddig
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,27 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taketo Takashima
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
10
+ date: 2025-01-23 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: resolv
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: 0.3.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: 0.3.0
27
26
  - !ruby/object:Gem::Dependency
@@ -71,7 +70,6 @@ metadata:
71
70
  homepage_uri: https://github.com/taketo1113/ddig
72
71
  source_code_uri: https://github.com/taketo1113/ddig
73
72
  changelog_uri: https://github.com/taketo1113/ddig/releases
74
- post_install_message:
75
73
  rdoc_options: []
76
74
  require_paths:
77
75
  - lib
@@ -86,8 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
84
  - !ruby/object:Gem::Version
87
85
  version: '0'
88
86
  requirements: []
89
- rubygems_version: 3.5.9
90
- signing_key:
87
+ rubygems_version: 3.6.2
91
88
  specification_version: 4
92
89
  summary: DNS lookup utility for Ruby
93
90
  test_files: []