remote_syslog_sender 1.1.2 → 1.1.3

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: ca5b6ec6c42fc7554d4d3318c6f267d1a3f8a508
4
- data.tar.gz: cdb652566a198fa60e5a54487e4ea8e371c07011
3
+ metadata.gz: 05d03966e485764b3f9a76b96a15d5bd3ed63185
4
+ data.tar.gz: a0781e58be56ae8206b93e9c60f7fe9bef5654bd
5
5
  SHA512:
6
- metadata.gz: d8fe3ae5a16f8695e96cde2d60166013ab09037e8a4e671217123aa1cee487b7d170c84b814b43a2fd4f476d05502d4e807099fb12875278c6b39d8acaed0bdf
7
- data.tar.gz: 5ad178f44071790a783d33869c578c3a02218a6200d805c2cce3558a431375fcef924f1bdb2193eb26ffe5ce56355b8283c874faf29a946cf0927b8c21d631e6
6
+ metadata.gz: 4086fc64db33dc77af8eddc63c17822440ef83ef82b14cd2131ca424b9e40c57c86caca741e561aed41defbbef36d8952ab5c6dfdbfcce43888ab44bc5ab92a1
7
+ data.tar.gz: 15ca1c0a228a16b1480bf5eeb1763487f5f0be02e998a5e454a0e24e9f92893851a501fde875237ef168e47d43a4f2bd0917e5510f6c94954bd16c9dea509d13
@@ -35,27 +35,50 @@ module RemoteSyslogSender
35
35
  connect
36
36
  end
37
37
 
38
+ def close
39
+ @socket.close if @socket
40
+ @tcp_socket.close if @tcp_socket
41
+ end
42
+
38
43
  private
39
44
 
40
45
  def connect
41
- sock = TCPSocket.new(@remote_hostname, @remote_port)
42
- if @keep_alive
43
- sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
44
- sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, @keep_alive_idle) if @keep_alive_idle
45
- sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, @keep_alive_cnt) if @keep_alive_cnt
46
- sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, @keep_alive_intvl) if @keep_alive_intvl
47
- end
48
- if @tls
49
- require 'openssl'
50
- context = OpenSSL::SSL::SSLContext.new(@ssl_method)
51
- context.ca_file = @ca_file if @ca_file
52
- context.verify_mode = @verify_mode if @verify_mode
53
- @socket = OpenSSL::SSL::SSLSocket.new(sock, context)
54
- @socket.connect
55
- @socket.post_connection_check(@remote_hostname)
56
- raise "verification error" if @socket.verify_result != OpenSSL::X509::V_OK
57
- else
58
- @socket = sock
46
+ connect_retry_count = 0
47
+ connect_retry_limit = 2
48
+ connect_retry_interval = 1
49
+ begin
50
+ sock = TCPSocket.new(@remote_hostname, @remote_port)
51
+
52
+ if @keep_alive
53
+ sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
54
+ sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, @keep_alive_idle) if @keep_alive_idle
55
+ sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, @keep_alive_cnt) if @keep_alive_cnt
56
+ sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, @keep_alive_intvl) if @keep_alive_intvl
57
+ end
58
+ if @tls
59
+ require 'openssl'
60
+ context = OpenSSL::SSL::SSLContext.new(@ssl_method)
61
+ context.ca_file = @ca_file if @ca_file
62
+ context.verify_mode = @verify_mode if @verify_mode
63
+
64
+ @tcp_socket = sock
65
+ @socket = OpenSSL::SSL::SSLSocket.new(sock, context)
66
+ @socket.connect
67
+ @socket.post_connection_check(@remote_hostname)
68
+ raise "test" if connect_retry_count < 1
69
+ raise "verification error" if @socket.verify_result != OpenSSL::X509::V_OK
70
+ else
71
+ @socket = sock
72
+ end
73
+ rescue => e
74
+ close
75
+ if connect_retry_count < connect_retry_limit
76
+ sleep connect_retry_interval
77
+ connect_retry_count += 1
78
+ retry
79
+ else
80
+ raise
81
+ end
59
82
  end
60
83
  end
61
84
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'remote_syslog_sender'
3
- s.version = '1.1.2'
3
+ s.version = '1.1.3'
4
4
  s.summary = "Message sender that sends directly to a remote syslog endpoint"
5
5
  s.description = "Message sender that sends directly to a remote syslog endpoint (Support UDP, TCP, TCP+TLS)"
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_syslog_sender
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomohiro Hashidate