publish_to_web 2.2.4 → 2.2.5

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: af20d39a6389731ea92171a36742afcfe9d8463e
4
- data.tar.gz: d6f36d48e84d510f2cb22f8c08ff37ccc607bca9
3
+ metadata.gz: 513b504f81cdb70f0107f978e0d93c2dae1f2ed9
4
+ data.tar.gz: caa4ed5aabeb33272237bc04ec6dbff7e25c346b
5
5
  SHA512:
6
- metadata.gz: 9f4da0373aacaca26d89457a39658fa3d744b44a35d1d71015fa764e45c35e77c9d9a3f2001a4676a2ca17a6bb498e980129a87780ca8356d38a3fddfd417b47
7
- data.tar.gz: b1da80d1eec22a95212c34bd1a86f6d1268a3a99373c2ddf9eb50f9351a913c677888587b5746ef70a318e1a33b06b41c70aa34b03eda637ca9be64b915f58e8
6
+ metadata.gz: 4953c26f10375bdfb879e11ecc1dc556c30a59608d93df432a345e2535b24e952176d2e8acb3fc87cfc61b3afbf45e5848a5d7343490ae45d88b175456157dc4
7
+ data.tar.gz: 6bcb83fb8a83c50ed286b7ddd6559358602a24a099f7cfa6e3bc2398ca8cd5fde6be1832cd1347073fc292f3c5d493265c193162c192cb9942523c139bfd9b12
@@ -66,11 +66,12 @@ class PublishToWeb
66
66
  check_local_endpoint
67
67
  end
68
68
 
69
+ SLD = Regexp.escape '.protonet.info'
69
70
  def prepare_directory(fail_gracefully = true)
70
71
  config.success = config.error = nil
71
72
 
72
73
  if node_name = config.node_name
73
- unless ["#{node_name}", "#{node_name}.protonet.info"].include? directory.node_name
74
+ if /^#{ Regexp.escape node_name }(#{ SLD })?$/ !~ directory.node_name
74
75
  directory.set_node_name node_name
75
76
  end
76
77
  end
@@ -89,14 +90,20 @@ class PublishToWeb
89
90
  raise unless fail_gracefully
90
91
  end
91
92
 
92
- def stop_tunnel
93
+ def stop_tunnel(*join_args)
93
94
  tunnel.stop
94
- @thread.try :join
95
+ @thread.join *join_args if @thread
95
96
  end
96
97
 
97
- def start_tunnel(blocking = true)
98
+ def start_tunnel(blocking: true)
98
99
  unless blocking
99
- @thread = Thread.new start_tunnel true
100
+ @thread = Thread.new do
101
+ begin
102
+ start_tunnel blocking: true
103
+ logger.warn "Tunnel closed... :/"
104
+ end while tunnel.running? and sleep(5)
105
+ end
106
+ @thread.abort_on_exception = true
100
107
  return
101
108
  end
102
109
 
@@ -107,15 +114,24 @@ class PublishToWeb
107
114
  tunnel.start { config.success = "connection_established" }
108
115
 
109
116
  rescue Net::SSH::AuthenticationFailed => err
117
+
110
118
  logger.warn "#{err.class}: #{err}"
111
119
  logger.warn "Probably the SSH key is not deployed on the proxy server yet, retrying in a bit"
112
120
 
113
121
  sleep 30
114
122
  retry
115
123
 
116
- rescue PublishToWeb::Directory::HttpResponseError => err
124
+ rescue PublishToWeb::Directory::HttpResponseError
125
+
126
+ # already handled by #prepare_directory, we just need to wait and retry...
127
+
117
128
  sleep 30
118
129
  retry
130
+
131
+ rescue => error
132
+
133
+ logger.error error
134
+
119
135
  end
120
136
 
121
137
  private
@@ -126,12 +142,12 @@ class PublishToWeb
126
142
 
127
143
  def tunnel
128
144
  @tunnel ||= Tunnel.new proxy_host: proxy_host,
129
- proxy_user: proxy_user,
130
- proxy_port: proxy_port,
131
- identity: directory.private_key,
132
- bind_host: bind_host,
133
- remote_port: directory.remote_port,
145
+ proxy_user: proxy_user,
146
+ proxy_port: proxy_port,
147
+ identity: directory.private_key,
148
+ bind_host: bind_host,
149
+ remote_port: directory.remote_port,
134
150
  forward_port: forward_port,
135
- logger: self.class.create_logger
151
+ logger: self.class.create_logger
136
152
  end
137
- end
153
+ end
@@ -15,6 +15,7 @@ class PublishToWeb
15
15
 
16
16
  def ssh_options
17
17
  @ssh_options ||= {
18
+ keepalive: true,
18
19
  keepalive_interval: 5,
19
20
  paranoid: false,
20
21
  # ExitOnForwardFailure ??
@@ -44,6 +45,10 @@ class PublishToWeb
44
45
  @running = false
45
46
  end
46
47
 
48
+ def running?
49
+ @running
50
+ end
51
+
47
52
  def start
48
53
  Net::SSH.start proxy_host, proxy_user, ssh_options do |ssh|
49
54
  ssh.forward.remote forward_port, bind_host, remote_port do |real_remote_port|
@@ -1,3 +1,3 @@
1
1
  class PublishToWeb
2
- VERSION = "2.2.4"
2
+ VERSION = "2.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publish_to_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh