remote_syslog_sender 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/remote_syslog_sender/tcp_sender.rb +41 -34
- data/remote_syslog_sender.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16108731d2d7b6e31e5af7c7ece9e4eeee102f8
|
4
|
+
data.tar.gz: 486189b1bb483e7febc18cc678f7a95c7df589a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1decdb20cd350dd7bb3c5b25a1b0082479ec065854e1ffa9aa80f35658d766657ea0709d2ce4032f5ce69c2ec185606ada0079e09ecc5c1d4c80a85b3a9c85f6
|
7
|
+
data.tar.gz: e74dd3847e4ecb0cb63c77238d3fff45aec2798213e679c991c895a95ae21ce7fe28163569e89fc2f3fc331825e768b2c17cd3edc690522860ef5b80a3b0803e
|
@@ -16,9 +16,10 @@ module RemoteSyslogSender
|
|
16
16
|
@ssl_method = options[:ssl_method] || 'TLSv1_2'
|
17
17
|
@ca_file = options[:ca_file]
|
18
18
|
@verify_mode = options[:verify_mode]
|
19
|
-
@timeout = options[:timeout]
|
19
|
+
@timeout = options[:timeout] || 600
|
20
20
|
@timeout_exception = !!options[:timeout_exception]
|
21
21
|
@exponential_backoff = !!options[:exponential_backoff]
|
22
|
+
@connect_mutex = Mutex.new
|
22
23
|
|
23
24
|
if [:SOL_SOCKET, :SO_KEEPALIVE, :IPPROTO_TCP, :TCP_KEEPIDLE].all? {|c| Socket.const_defined? c}
|
24
25
|
@keep_alive = options[:keep_alive]
|
@@ -44,40 +45,40 @@ module RemoteSyslogSender
|
|
44
45
|
|
45
46
|
def connect
|
46
47
|
connect_retry_count = 0
|
47
|
-
connect_retry_limit =
|
48
|
+
connect_retry_limit = 3
|
48
49
|
connect_retry_interval = 1
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
50
|
+
@connect_mutex.synchronize do
|
51
|
+
begin
|
52
|
+
@tcp_socket = TCPSocket.new(@remote_hostname, @remote_port)
|
53
|
+
|
54
|
+
if @keep_alive
|
55
|
+
@tcp_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
|
56
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, @keep_alive_idle) if @keep_alive_idle
|
57
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, @keep_alive_cnt) if @keep_alive_cnt
|
58
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, @keep_alive_intvl) if @keep_alive_intvl
|
59
|
+
end
|
60
|
+
if @tls
|
61
|
+
require 'openssl'
|
62
|
+
context = OpenSSL::SSL::SSLContext.new(@ssl_method)
|
63
|
+
context.ca_file = @ca_file if @ca_file
|
64
|
+
context.verify_mode = @verify_mode if @verify_mode
|
65
|
+
|
66
|
+
@socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, context)
|
67
|
+
@socket.connect
|
68
|
+
@socket.post_connection_check(@remote_hostname)
|
69
|
+
raise "verification error" if @socket.verify_result != OpenSSL::X509::V_OK
|
70
|
+
else
|
71
|
+
@socket = @tcp_socket
|
72
|
+
end
|
73
|
+
rescue
|
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
|
81
82
|
end
|
82
83
|
end
|
83
84
|
end
|
@@ -103,6 +104,12 @@ module RemoteSyslogSender
|
|
103
104
|
result = @socket.__send__(method, payload)
|
104
105
|
payload_size -= result
|
105
106
|
payload.slice!(0, result) if payload_size > 0
|
107
|
+
rescue IO::WaitReadable
|
108
|
+
timeout_wait = @timeout - (get_time - start)
|
109
|
+
retry if IO.select([@socket], nil, nil, timeout_wait)
|
110
|
+
|
111
|
+
raise NonBlockingTimeout if @timeout_exception
|
112
|
+
break
|
106
113
|
rescue IO::WaitWritable
|
107
114
|
timeout_wait = @timeout - (get_time - start)
|
108
115
|
retry if IO.select(nil, [@socket], nil, timeout_wait)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'remote_syslog_sender'
|
3
|
-
s.version = '1.1.
|
3
|
+
s.version = '1.1.4'
|
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
|
|