net-tns 1.0.1 → 1.1.0
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 +4 -4
- data/lib/net/tns/client.rb +1 -1
- data/lib/net/tns/connection.rb +21 -31
- data/lib/net/tns/exceptions.rb +6 -6
- data/lib/net/tns/gem_version.rb +1 -1
- data/lib/net/tns/packet.rb +5 -1
- data/lib/net/tti/client.rb +6 -6
- data/lib/net/tti/connection.rb +1 -1
- data/lib/net/tti/message.rb +2 -2
- data/lib/net/tti/messages/function_call.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae395e30d483af200c9eda9c522288af1cdad4e1
|
4
|
+
data.tar.gz: e4399ebb1818042b98d92b8e18e54de0e0b79d12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bc129315cca6f165f1fdecbb211b436034fdb8606083b7e5d1d1ae80a4bafe87447e1463f1a21042afdb68e8b016b6bb392955f0b7f83165924db4d18840a7c
|
7
|
+
data.tar.gz: f17cdca07bcc38a3199b30ded2eb9fe1384c892d43c8ff2d8865e746e1e8ff116763715cfde565ae339e8422670541a498333defaebd627ab86bdc7c9c57987f
|
data/lib/net/tns/client.rb
CHANGED
data/lib/net/tns/connection.rb
CHANGED
@@ -7,16 +7,17 @@ module Net
|
|
7
7
|
attr_reader :tns_protocol_version
|
8
8
|
|
9
9
|
def initialize(opts={})
|
10
|
-
opts = {
|
11
|
-
:port => 1521,
|
12
|
-
}.merge(opts)
|
13
|
-
|
14
10
|
@socket = nil
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
|
12
|
+
@host = opts.delete(:host)
|
13
|
+
@port = opts.delete(:port) || 1521
|
14
|
+
@new_socket_proc = opts.delete(:new_socket_proc)
|
18
15
|
|
19
16
|
raise ArgumentError.new("Unrecognized options: #{opts.keys}") unless opts.empty?
|
17
|
+
|
18
|
+
if @host.nil? == @new_socket_proc.nil?
|
19
|
+
raise ArgumentError.new("Invalid socket options. Need :host and :port, OR :new_socket_proc")
|
20
|
+
end
|
20
21
|
end
|
21
22
|
|
22
23
|
# This is a low-level function to directly open a socket for this connection.
|
@@ -26,19 +27,15 @@ module Net
|
|
26
27
|
Net::TNS.logger.debug("Connection#open_socket called")
|
27
28
|
close_socket()
|
28
29
|
|
29
|
-
if
|
30
|
-
if @socket_opts.has_key?(:get_socket_callback) || @socket_opts.has_key?(:close_socket_callback)
|
31
|
-
raise ArgumentError.new("Cannot specify :host/:port with :get_socket_callback/:close_socket_callback")
|
32
|
-
end
|
33
|
-
|
30
|
+
if @host
|
34
31
|
require "socket"
|
35
|
-
Net::TNS.logger.info("Creating new TCPSocket for #{host}:#{port}")
|
36
|
-
@socket = TCPSocket.new(host, port)
|
37
|
-
elsif
|
38
|
-
Net::TNS.logger.info("Calling
|
39
|
-
@socket =
|
32
|
+
Net::TNS.logger.info("Creating new TCPSocket for #{@host}:#{@port}")
|
33
|
+
@socket = TCPSocket.new(@host, @port)
|
34
|
+
elsif @new_socket_proc
|
35
|
+
Net::TNS.logger.info("Calling new-socket proc for new socket")
|
36
|
+
@socket = @new_socket_proc.call()
|
40
37
|
else
|
41
|
-
raise ArgumentError.new("
|
38
|
+
raise ArgumentError.new("Invalid socket options")
|
42
39
|
end
|
43
40
|
|
44
41
|
return
|
@@ -50,16 +47,9 @@ module Net
|
|
50
47
|
def close_socket
|
51
48
|
Net::TNS.logger.debug("Connection#close_socket called")
|
52
49
|
begin
|
53
|
-
unless @socket.nil?
|
54
|
-
|
55
|
-
|
56
|
-
close_cb.call(@socket)
|
57
|
-
else
|
58
|
-
unless @socket.closed?
|
59
|
-
Net::TNS.logger.info("Closing socket")
|
60
|
-
@socket.close
|
61
|
-
end
|
62
|
-
end
|
50
|
+
unless @socket.nil? or @socket.closed?
|
51
|
+
Net::TNS.logger.info("Closing socket")
|
52
|
+
@socket.close
|
63
53
|
end
|
64
54
|
ensure
|
65
55
|
@socket = nil
|
@@ -140,7 +130,7 @@ module Net
|
|
140
130
|
|
141
131
|
def resend_last_tns_packet
|
142
132
|
if @tns_last_sent_packet.nil?
|
143
|
-
raise Exceptions::
|
133
|
+
raise Exceptions::TNSException.new( "Resend received without a packet to resend" )
|
144
134
|
end
|
145
135
|
send_tns_packet( @tns_last_sent_packet )
|
146
136
|
end
|
@@ -154,7 +144,7 @@ module Net
|
|
154
144
|
# @return [Net::TNS::Packet]
|
155
145
|
# @raise [Net::TNS::Exceptions::RefuseMessageReceived] If the other side
|
156
146
|
# sent TNS refuse message.
|
157
|
-
# @raise [Net::TNS::Exceptions::
|
147
|
+
# @raise [Net::TNS::Exceptions::TNSException] If another unexpected
|
158
148
|
# state or action occurs.
|
159
149
|
def receive_tns_packet( waiting_for_error_message = false )
|
160
150
|
# This is structured as a loop in order to handle messages (e.g. Resends)
|
@@ -167,7 +157,7 @@ module Net
|
|
167
157
|
|
168
158
|
receive_count += 1
|
169
159
|
if ( receive_count >= 3 )
|
170
|
-
raise Exceptions::
|
160
|
+
raise Exceptions::TNSException.new( "Maximum receive attempts exceeded - too many Resends received." )
|
171
161
|
end
|
172
162
|
|
173
163
|
# Try to receive a TNS packet
|
data/lib/net/tns/exceptions.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Net::TNS
|
2
2
|
module Exceptions
|
3
|
-
class
|
3
|
+
class TNSException < StandardError
|
4
4
|
end
|
5
5
|
|
6
|
-
class ProtocolException <
|
6
|
+
class ProtocolException < TNSException
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
|
-
class ReceiveTimeoutExceeded <
|
10
|
+
class ReceiveTimeoutExceeded < TNSException
|
11
11
|
end
|
12
12
|
|
13
|
-
class ConnectionClosed <
|
13
|
+
class ConnectionClosed < TNSException
|
14
14
|
end
|
15
15
|
|
16
|
-
class RefuseMessageReceived <
|
16
|
+
class RefuseMessageReceived < TNSException
|
17
17
|
end
|
18
18
|
|
19
|
-
class RedirectMessageReceived <
|
19
|
+
class RedirectMessageReceived < TNSException
|
20
20
|
attr_reader :new_port
|
21
21
|
attr_reader :new_host
|
22
22
|
|
data/lib/net/tns/gem_version.rb
CHANGED
data/lib/net/tns/packet.rb
CHANGED
@@ -58,7 +58,11 @@ module Net
|
|
58
58
|
packet_raw = header_raw + payload_raw
|
59
59
|
|
60
60
|
unless payload_class = @@tns_packet_classes[ header.packet_type ]
|
61
|
-
raise Net::TNS::Exceptions::
|
61
|
+
raise Net::TNS::Exceptions::TNSException.new( "Unknown TNS packet type: #{header.packet_type}" )
|
62
|
+
end
|
63
|
+
|
64
|
+
unless packet_raw.length == header.packet_length
|
65
|
+
raise Net::TNS::Exceptions::ProtocolException
|
62
66
|
end
|
63
67
|
|
64
68
|
new_packet = payload_class.read( packet_raw )
|
data/lib/net/tti/client.rb
CHANGED
@@ -6,7 +6,7 @@ module Net
|
|
6
6
|
class Client
|
7
7
|
def connect(opts={})
|
8
8
|
socket_opts = {}
|
9
|
-
socket_opts_keys = [:host, :port]
|
9
|
+
socket_opts_keys = [:host, :port, :new_socket_proc]
|
10
10
|
socket_opts_keys.each {|key| socket_opts[key] = opts.delete(key) if opts.has_key?(key)}
|
11
11
|
|
12
12
|
connect_opts = {}
|
@@ -28,14 +28,14 @@ module Net
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def authenticate( username, password )
|
31
|
-
|
31
|
+
begin
|
32
|
+
pre_auth_request = get_pre_auth_request( username )
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
pre_auth_response_raw = @tti_conn.send_and_receive(pre_auth_request)
|
35
|
+
pre_auth_response = PreAuthenticationResponse.read(pre_auth_response_raw)
|
35
36
|
|
36
|
-
|
37
|
+
auth_request = get_auth_request(username, password, pre_auth_response)
|
37
38
|
|
38
|
-
begin
|
39
39
|
@tti_conn.send_and_receive(auth_request)
|
40
40
|
rescue Exceptions::ErrorMessageReceived => error
|
41
41
|
case error.error_code
|
data/lib/net/tti/connection.rb
CHANGED
@@ -79,7 +79,7 @@ module Net
|
|
79
79
|
while ( true )
|
80
80
|
receive_count += 1
|
81
81
|
if ( receive_count >= 3 )
|
82
|
-
raise Exceptions::
|
82
|
+
raise Exceptions::TNSException.new( "Maximum receive attempts exceeded - too many Markers received." )
|
83
83
|
end
|
84
84
|
|
85
85
|
Net::TTI.logger.debug("Attempting to receive packet (try ##{receive_count})")
|
data/lib/net/tti/message.rb
CHANGED
@@ -34,7 +34,7 @@ module Net
|
|
34
34
|
ttc_code = raw_message[0].unpack("C").first
|
35
35
|
|
36
36
|
unless message_class = @@ttc_classes[ ttc_code ]
|
37
|
-
raise Net::TNS::Exceptions::
|
37
|
+
raise Net::TNS::Exceptions::TNSException.new( "Unknown TTC code: #{ttc_code}" )
|
38
38
|
end
|
39
39
|
|
40
40
|
new_message = message_class.new
|
@@ -47,4 +47,4 @@ module Net
|
|
47
47
|
end
|
48
48
|
|
49
49
|
require "pathname"
|
50
|
-
Dir.glob("#{Pathname.new(__FILE__).dirname}/messages
|
50
|
+
Dir.glob("#{Pathname.new(__FILE__).dirname}/messages/*.rb") { |file| require file }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-tns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Woodbury
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bindata
|