nesser 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 7c6c93d335d6983d60154b25ed5251f122a30534
4
- data.tar.gz: 4d8dca606688b56847e0e82712e92b5467173659
3
+ metadata.gz: 268e527319ed6991bec2ba743f29b161cf759ef9
4
+ data.tar.gz: 451ee70bbc0032ff146f19eaff3ab97b4dbe400c
5
5
  SHA512:
6
- metadata.gz: c048c7eccf69dcd6091308ab2d95b485a3706a02749b5b20ef97f15c104dec50eb56ae20f52df64dd2d1f2bba2faf9cd0c5092f07922ffd2491b7431a88c5017
7
- data.tar.gz: 0d18a1aee601408787d45d87bd3f0477ed89219cf5e7baa08db44115d27a333390647a27ec318311890a2922f4e448cb72f5c58db1267e70dec6ac7dab0e357c
6
+ metadata.gz: 29782f61da9adf57d73bc80aa750459abb02a5f74b654410793b6bf5637240da703b88f08affd3d31b0015e940fd64f62126c0c1246064c7e0dcb9b1c41abbb0
7
+ data.tar.gz: af31ebdbce5c02e2f58a4804b4d400be0d0b9b52ebfdba45cf4e47590a2b433a1d7a44bf469f238de3eae3f6b0327bb6244fb4836ec64dd611446626cb6e5ba6
data/README.md CHANGED
@@ -175,5 +175,8 @@ when necessary!
175
175
  ## Version history / changelog
176
176
 
177
177
  * 0.0.1 - Test deploy
178
- * 0.0.2 - Code complete
178
+ * 0.0.2 - Basically code complete
179
179
  * 0.0.3 - First actual release
180
+ * 0.0.4
181
+ ** Implement transaction.passthrough!()
182
+ ** Fix a bug where numbers would cause a validation error in DNS names
data/lib/nesser.rb CHANGED
@@ -96,7 +96,7 @@ module Nesser
96
96
 
97
97
  begin
98
98
  proc.call(transaction)
99
- rescue Exception => e
99
+ rescue StandardError => e
100
100
  logger.error("Error thrown while processing the DNS packet: %s" % e.to_s())
101
101
  logger.info(e.backtrace().join("\n"))
102
102
 
@@ -18,7 +18,7 @@ module Nesser
18
18
  LEGAL_CHARACTERS = (
19
19
  ('a'..'z').to_a +
20
20
  ('A'..'Z').to_a +
21
- (0..9).to_a +
21
+ ('0'..'9').to_a +
22
22
  ['-', '.']
23
23
  )
24
24
  MAX_SEGMENT_LENGTH = 63
@@ -39,7 +39,7 @@ module Nesser
39
39
  private
40
40
  def validate!(name)
41
41
  if name.chars.detect { |ch| !LEGAL_CHARACTERS.include?(ch) }
42
- raise(DnsException, "DNS name contains illegal characters")
42
+ raise(DnsException, "DNS name contains illegal characters: #{name}")
43
43
  end
44
44
  if name.length > 253
45
45
  raise(DnsException, "DNS name can't be longer than 253 characters")
@@ -22,6 +22,8 @@
22
22
  # complex and generally not needed.
23
23
  ##
24
24
 
25
+ require 'socket'
26
+
25
27
  module Nesser
26
28
  class Transaction
27
29
  attr_reader :request, :sent
@@ -87,35 +89,42 @@ module Nesser
87
89
  reply!()
88
90
  end
89
91
 
90
- # public
91
- # def passthrough!(pt_host, pt_port, callback = nil)
92
- # not_sent!()
93
- #
94
- # Nesser.query(@request.questions[0].name, {
95
- # :server => pt_host,
96
- # :port => pt_port,
97
- # :type => @request.questions[0].type,
98
- # :cls => @request.questions[0].cls,
99
- # :timeout => 3,
100
- # }
101
- # ) do |response|
102
- # # If there was a timeout, handle it
103
- # if(response.nil?)
104
- # response = @response
105
- # response.rcode = Nesser::Packet::RCODE_SERVER_FAILURE
106
- # end
107
- #
108
- # response.trn_id = @request.trn_id
109
- # @s.send(response.serialize(), 0, @host, @port)
110
- #
111
- # # Let the callback know if anybody registered one
112
- # if(callback)
113
- # callback.call(response)
114
- # end
115
- # end
116
- #
117
- # @sent = true
118
- # end
92
+ ##
93
+ # Send the request upstream.
94
+ #
95
+ # Note that this requires a socket, and that it can't be the same socket
96
+ # as the rest of the transaction (since we don't do any kind of
97
+ # multiplexing). If you don't specify a socket, one will be provided to
98
+ # you at no extra cost (financially, anyways).
99
+ ##
100
+ public
101
+ def passthrough!(host:'8.8.8.8', port:53)
102
+ not_sent!()
103
+
104
+ # Get a local handle to the socket
105
+ s = @s
106
+
107
+ Thread.new() do
108
+ begin
109
+ response = Nesser.query(
110
+ s: s,
111
+ hostname: @request.questions[0].name,
112
+ server: host,
113
+ port: port,
114
+ type: @request.questions[0].type,
115
+ cls: @request.questions[0].cls,
116
+ )
117
+
118
+ if response.rcode != RCODE_SUCCESS
119
+ error!(response.rcode)
120
+ else
121
+ answer!(response.answers)
122
+ end
123
+ rescue StandardError
124
+ error!(RCODE_SERVER_FAILURE)
125
+ end
126
+ end
127
+ end
119
128
 
120
129
  ##
121
130
  # Reply with the response packet, in whatever state it's in. While this is
@@ -1,3 +1,3 @@
1
1
  module Nesser
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nesser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - iagox86
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-09 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler