dizby 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dizby/distributed/object.rb +5 -1
- data/lib/dizby/distributed/proxy.rb +5 -1
- data/lib/dizby/protocols/secure.rb +2 -2
- data/lib/dizby/tunnel/abstract.rb +19 -11
- data/lib/dizby/tunnel/basic_spawn.rb +2 -2
- data/lib/dizby/tunnel/bidirectional_strategy.rb +2 -0
- data/lib/dizby/tunnel/local_strategy.rb +2 -0
- data/lib/dizby/tunnel/spawn_command.rb +7 -6
- data/lib/dizby/tunnel/spawned.rb +3 -2
- data/lib/dizby/version.rb +1 -1
- 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: 0b885bb489fe18e78bb9813c27dc0f3ebfac80f6
|
4
|
+
data.tar.gz: 93737792f91064f3100c5a82447acd49e6987f21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dacc04d4adc114372d745b41757386e22b9f3f6b8fe7407ae0c52095eaaf6e423cc00e52d53a10bcc8b7f6c185371901579322d0dcaab1020c152998a747ab8e
|
7
|
+
data.tar.gz: fa557fb76b9aae31c94061820e880f423dc4b44b64e3359079dfe0903f9954e2914f12a4dd3c75c984d2e03c0791b84fbd0773c5d77cdee49aa36cf4107f8036
|
@@ -30,7 +30,7 @@ module Dizby
|
|
30
30
|
end
|
31
31
|
# rubocop:enable Style/MethodMissing
|
32
32
|
|
33
|
-
def
|
33
|
+
def respond_to?(msg_id, priv = false)
|
34
34
|
responds =
|
35
35
|
case msg_id
|
36
36
|
when :_dump
|
@@ -45,6 +45,10 @@ module Dizby
|
|
45
45
|
responds
|
46
46
|
end
|
47
47
|
|
48
|
+
# rubocop:disable Style/Alias
|
49
|
+
alias_method(:respond_to_missing?, :respond_to?)
|
50
|
+
# rubocop:enable Style/Alias
|
51
|
+
|
48
52
|
undef :to_s
|
49
53
|
end
|
50
54
|
end
|
@@ -28,10 +28,14 @@ module Dizby
|
|
28
28
|
end
|
29
29
|
# rubocop:enable Style/MethodMissing
|
30
30
|
|
31
|
-
def
|
31
|
+
def respond_to?(msg_id, priv = false)
|
32
32
|
method_missing(:respond_to?, msg_id, priv)
|
33
33
|
end
|
34
34
|
|
35
|
+
# rubocop:disable Style/Alias
|
36
|
+
alias_method(:respond_to_missing?, :respond_to?)
|
37
|
+
# rubocop:enable Style/Alias
|
38
|
+
|
35
39
|
undef :to_s
|
36
40
|
end
|
37
41
|
|
@@ -24,7 +24,7 @@ module Dizby
|
|
24
24
|
:spawn,
|
25
25
|
"#{scheme}://%{user}?%{host}%{port}?%{query}?"
|
26
26
|
) do |args, server, (user, host, port, query)|
|
27
|
-
port
|
27
|
+
port = port.to_i
|
28
28
|
|
29
29
|
factory = TunnelFactory.new(server, port)
|
30
30
|
tunnel = factory.create(BasicSpawnTunnel).with(user, host, args)
|
@@ -46,7 +46,7 @@ module Dizby
|
|
46
46
|
:client,
|
47
47
|
"#{scheme}://%{user}?%{host}%{port}%{query}?"
|
48
48
|
) do |args, server, (user, host, port, query)|
|
49
|
-
port
|
49
|
+
port = port.to_i
|
50
50
|
|
51
51
|
factory = TunnelFactory.new(server, port)
|
52
52
|
tunnel = factory.create(BasicTunnel).with(user, host, args)
|
@@ -14,16 +14,7 @@ module Dizby
|
|
14
14
|
@config = [host, user, ssh_config]
|
15
15
|
@strategy = strategy
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
@thread =
|
20
|
-
Thread.start(Net::SSH.start(*@config)) do |ssh|
|
21
|
-
loop_ssh(ssh, writer)
|
22
|
-
writer.close
|
23
|
-
end
|
24
|
-
|
25
|
-
read_ports(reader)
|
26
|
-
reader.close
|
17
|
+
open_ssh_tunnel
|
27
18
|
end
|
28
19
|
|
29
20
|
# wait(ssh) is not defined in this class
|
@@ -31,6 +22,7 @@ module Dizby
|
|
31
22
|
get_and_write_ports(ssh, output)
|
32
23
|
wait(ssh)
|
33
24
|
ensure
|
25
|
+
output.close
|
34
26
|
ssh.close if ssh
|
35
27
|
end
|
36
28
|
|
@@ -42,8 +34,24 @@ module Dizby
|
|
42
34
|
@strategy.write(ssh, output)
|
43
35
|
end
|
44
36
|
|
37
|
+
def open_ssh_tunnel
|
38
|
+
reader, writer = IO.pipe
|
39
|
+
|
40
|
+
@thread =
|
41
|
+
Thread.start(Net::SSH.start(*@config)) do |ssh|
|
42
|
+
loop_ssh(ssh, writer)
|
43
|
+
end
|
44
|
+
|
45
|
+
read_ports(reader)
|
46
|
+
rescue
|
47
|
+
@thread.abort_on_exception = true
|
48
|
+
close
|
49
|
+
ensure
|
50
|
+
reader.close
|
51
|
+
end
|
52
|
+
|
45
53
|
def close
|
46
|
-
@thread.join
|
54
|
+
@thread.join if @thread && @thread.alive?
|
47
55
|
end
|
48
56
|
|
49
57
|
attr_reader :local_port, :remote_port
|
@@ -16,7 +16,7 @@ module Dizby
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get_and_write_ports(ssh, output)
|
19
|
-
@command.set_dynamic_mode
|
19
|
+
@command.set_dynamic_mode if @strategy.server_port.zero?
|
20
20
|
|
21
21
|
@channel =
|
22
22
|
ssh.open_channel do |ch|
|
@@ -39,7 +39,7 @@ module Dizby
|
|
39
39
|
ch[:triggered] = false
|
40
40
|
|
41
41
|
ch.on_data { |_, data| ch[:data] << data }
|
42
|
-
ch.on_extended_data { |_, _, data| @server.log(data.inspect) }
|
42
|
+
ch.on_extended_data { |_, _, data| @server.log.error(data.inspect) }
|
43
43
|
|
44
44
|
ch.on_process do |_|
|
45
45
|
if !ch[:triggered] && ch[:data] =~ /Running on port (\d+)\./
|
@@ -4,14 +4,12 @@
|
|
4
4
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
5
5
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
6
6
|
|
7
|
-
require 'shellwords'
|
8
|
-
|
9
7
|
module Dizby
|
10
8
|
class SpawnCommand
|
11
9
|
TEMPLATE =
|
12
10
|
"require'dizby/tunnel/spawned';Dizby::Spawned.%s('%s',%s){%s}".freeze
|
13
11
|
|
14
|
-
def initialize(data, config
|
12
|
+
def initialize(data, **config)
|
15
13
|
@data = data
|
16
14
|
@ruby_cmd = 'ruby'
|
17
15
|
@uri = 'drb://'
|
@@ -30,9 +28,12 @@ module Dizby
|
|
30
28
|
attr_accessor :ruby_cmd, :config, :uri
|
31
29
|
|
32
30
|
def to_cmd
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
<<~EOF
|
32
|
+
#{@ruby_cmd} -e "$(cat <<DIZBY
|
33
|
+
#{format(TEMPLATE, @mode, @uri, @config.inspect, @data)}
|
34
|
+
DIZBY
|
35
|
+
)"
|
36
|
+
EOF
|
36
37
|
end
|
37
38
|
alias to_s to_cmd
|
38
39
|
|
data/lib/dizby/tunnel/spawned.rb
CHANGED
@@ -16,7 +16,8 @@ module Dizby
|
|
16
16
|
|
17
17
|
def self.dynamic(uri, config, &block)
|
18
18
|
handle_spawned(uri, config, block) do |service|
|
19
|
-
|
19
|
+
port = service.instance_variable_get(:@server).port
|
20
|
+
$stdout.puts "Running on port #{port}."
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -29,7 +30,7 @@ module Dizby
|
|
29
30
|
service.close if service
|
30
31
|
end
|
31
32
|
|
32
|
-
service = Service.new(uri, obj,
|
33
|
+
service = Service.new(uri: uri, front: obj, **config)
|
33
34
|
yield service if block_given?
|
34
35
|
ensure
|
35
36
|
service.wait if service
|
data/lib/dizby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dizby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Currier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|