canals 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c5a0098eb37586fc451b6ded6e126205695f128
4
- data.tar.gz: cdda79e8d846034aba75aec28266cedd3d1ff029
3
+ metadata.gz: 2179ce68e3cee069eb408e8c56e62f1d337d4d1d
4
+ data.tar.gz: 4ab74cae9daa9230751e6d97268047eee0a8ee60
5
5
  SHA512:
6
- metadata.gz: 3c6825603f60c7768e126a119b838fc2c5bbf47087dacf956b1154cec4ed0aaec69b49f8ac92206e8351d4398e8108976c67ba125b7b4f914cd841843ed95a42
7
- data.tar.gz: 80c3806fd808fffe57d718d04eb277ebd5ea2977b484f7bf5117774d1baef42478f51972d38760216bbe6da3893bf9efab9d977a876051f8d15333544b7388c6
6
+ metadata.gz: 734ff1e2b875610c63750e3fcc41d2249bd962ea126ac1b8b0348949fe053879c9e5f54409727fd3816cd3a0d2fa32008f2b947d32cb066bbdcc4690f898bce7
7
+ data.tar.gz: 7c21330f7e538c8d12f73c52f0cd21814b6e5686bfa8f0ca47aa826da35962d41048a4a38b2e5bc52d8f8fe1612ff506dae394e31ff6f5a2092f12a05a7a4ed0
@@ -16,6 +16,11 @@ module Canals
16
16
  tunnel = Canals.repository.get(name)
17
17
  say "Created tunnel #{name.inspect} with pid #{pid}. You can access it using '#{tunnel.bind_address}:#{tunnel.local_port}'"
18
18
  pid
19
+ rescue Canals::Exception => e
20
+ tunnel = Canals.repository.get(name)
21
+ isalive = Canals.isalive? tunnel
22
+ say "Unable to create tunnel #{name.inspect}#{isalive ? ', A tunnel for ' + name.inspect + ' Already exists.' : ''}", :red
23
+ 0
19
24
  end
20
25
 
21
26
  def trestart(name)
data/lib/canals/core.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'open3'
2
2
 
3
3
  module Canals
4
+
5
+ class Exception < ::RuntimeError; end
6
+
4
7
  class << self
5
8
 
6
9
  def create_tunnel(tunnel_opts)
@@ -11,7 +14,8 @@ module Canals
11
14
  if tunnel_opts.instance_of? String
12
15
  tunnel_opts = Canals.repository.get(tunnel_opts)
13
16
  end
14
- tunnel_start(tunnel_opts)
17
+ exit_code = tunnel_start(tunnel_opts)
18
+ raise Canals::Exception, "could not start tunnel" unless exit_code.success?
15
19
  pid = tunnel_pid(tunnel_opts)
16
20
  Canals.session.add({name: tunnel_opts.name, pid: pid, socket: socket_file(tunnel_opts)})
17
21
  pid.to_i
@@ -45,8 +49,9 @@ module Canals
45
49
 
46
50
  def tunnel_start(tunnel_opts)
47
51
  FileUtils.mkdir_p("/tmp/canals")
48
- cmd = "ssh -M -S #{socket_file(tunnel_opts)} -fnNT -L #{tunnel_opts.bind_address}:#{tunnel_opts.local_port}:#{tunnel_opts.remote_host}:#{tunnel_opts.remote_port} #{tunnel_opts.proxy}"
52
+ cmd = "ssh -M -S #{socket_file(tunnel_opts)} -o 'ExitOnForwardFailure yes' -fnNT -L #{tunnel_opts.bind_address}:#{tunnel_opts.local_port}:#{tunnel_opts.remote_host}:#{tunnel_opts.remote_port} #{tunnel_opts.proxy}"
49
53
  system(cmd)
54
+ $?
50
55
  end
51
56
 
52
57
  def tunnel_check(tunnel_opts)
@@ -1,6 +1,6 @@
1
1
  module Canals
2
2
 
3
3
  # Canals gem current version
4
- VERSION = "0.8.6"
4
+ VERSION = "0.8.7"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ido Abramovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor