local_tunnel 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/local_tunnel.rb +23 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c75c2ae76223c464f75b320ac8c2c83b89df0d28
4
- data.tar.gz: a0287328a60f77bac3804e94e806a1994ecef37a
3
+ metadata.gz: 96c12f590b7b9d79fd509c9ec3325baaee4a2533
4
+ data.tar.gz: 9ee604bcb6ce9820519d01ba77d046534567e531
5
5
  SHA512:
6
- metadata.gz: fe0494ba97d055c80ca2e8f5d07395e07cf347da78e3180a44173eda505c82d115e13239a55724af00e1cd25760c7d552ee326aa272671f647a43ffbee821068
7
- data.tar.gz: 9886b4f3ca7d2134237024e76fffc5309d53ea7c978df9fb2e39905abbedf4ed7d6c7a1c57c199a0e8f687fd3d01fec2b3a04065c0f68bcfe330372cd1b8b243
6
+ metadata.gz: 17db5e979202f9a959da3b65eee3a699f6a680a8942529e82efb8f58c01bc5a0f1b2c4346d1fa117a8883acb945fc5676ccf27771a1fa81b4ec6b74037b89f1a
7
+ data.tar.gz: c90b9ef592b97c4eea1d148876ccd09e6e457a2e13133a2cae11ae01c067b8e9e5aa5fd076cd7c62bb71c19653f0955beef2bd9f14dc93ab754ec36879d26daa
@@ -32,13 +32,19 @@ module LocalTunnel
32
32
  def start
33
33
  @rconn = rconnect
34
34
  @lconn = lconnect
35
+ bail = false
35
36
 
36
37
  @lrthr = Thread.new do
37
38
  buf = String.new(capacity: 1024)
38
- loop do
39
+ until bail
39
40
  begin
40
41
  logger.debug(format("%03d lr: attempting read", @id))
41
42
  @lconn.readpartial(1024, buf)
43
+ rescue Errno::ECONNRESET
44
+ logger.debug(format("%03d lr: read failed, connection reset by peer", @id))
45
+ @lconn.close
46
+ bail = true
47
+ break
42
48
  rescue EOFError
43
49
  logger.debug(format("%03d lr: read failed, reconnecting", @id))
44
50
  @lconn.close
@@ -50,6 +56,11 @@ module LocalTunnel
50
56
  begin
51
57
  logger.debug(format("%03d lr: attempting write", @id))
52
58
  s = @rconn.write(buf)
59
+ rescue Errno::ECONNRESET
60
+ logger.debug(format("%03d lr: write failed, connection reset by peer", @id))
61
+ @lconn.close
62
+ bail = true
63
+ break
53
64
  rescue IOError
54
65
  logger.debug(format("%03d lr: write failed, reconnecting", @id))
55
66
  @rconn.close
@@ -66,10 +77,15 @@ module LocalTunnel
66
77
 
67
78
  @rlthr = Thread.new do
68
79
  buf = String.new(capacity: 1024)
69
- loop do
80
+ until bail
70
81
  begin
71
82
  logger.debug(format("%03d rl: attempting read", @id))
72
83
  @rconn.readpartial(1024, buf)
84
+ rescue Errno::ECONNRESET
85
+ logger.debug(format("%03d rl: read failed, connection reset by peer", @id))
86
+ @lconn.close
87
+ bail = true
88
+ break
73
89
  rescue EOFError
74
90
  logger.debug(format("%03d rl: read failed, reconnecting", @id))
75
91
  @rconn.close
@@ -81,6 +97,11 @@ module LocalTunnel
81
97
  begin
82
98
  logger.debug(format("%03d rl: attempting write", @id))
83
99
  s = @lconn.write(buf)
100
+ rescue Errno::ECONNRESET
101
+ logger.debug(format("%03d rl: write failed, connection reset by peer", @id))
102
+ @lconn.close
103
+ bail = true
104
+ break
84
105
  rescue IOError
85
106
  logger.debug(format("%03d rl: write failed, reconnecting", @id))
86
107
  @lconn.close
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loic Nageleisen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest