remote_syslog_sender_ms 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +105 -0
- data/Rakefile +10 -0
- data/lib/remote_syslog_sender_ms.rb +15 -0
- data/lib/remote_syslog_sender_ms/sender.rb +73 -0
- data/lib/remote_syslog_sender_ms/tcp_sender.rb +157 -0
- data/lib/remote_syslog_sender_ms/udp_sender.rb +18 -0
- data/remote_syslog_sender_ms.gemspec +21 -0
- data/test/helper.rb +12 -0
- data/test/test_remote_syslog_logger.rb +66 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c293d5b6bca01f37f10bc8313a65b85cb499cf941ce0d214d971a7ac97d862b
|
4
|
+
data.tar.gz: 3801f0a6540c44f28e3459da2c678af6a9f44c2777c3ea4224208ce5d8e60f34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a1eaabdb44e22dc8927b18198bbc84165914ec80f937b6b5987050c5ec13441395b36f9f05aae203db74b496d665df488b1e8e90fb4cef4cb1df8568b475a42
|
7
|
+
data.tar.gz: 4e268997351dd9059c6107c205f3084bee515ca43afc59f55e028cb0d51a8ed389502f95fb63c4c8363239173a78d36ca1c019342b1ca53b4c088e15eb36236c
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 joker1007
|
4
|
+
Original Copyright (c) 2011 Eric Lindvall
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# Remote Syslog Sender
|
2
|
+
|
3
|
+
This gem is syslog sender that is extracted from [papertrail/remote_syslog_logger](https://github.com/papertrail/remote_syslog_logger)
|
4
|
+
|
5
|
+
This can send message to remote syslog server via UDP, TCP, TCP+TLS.
|
6
|
+
(Original does not support TCP, TCP+TLS protocol).
|
7
|
+
|
8
|
+
## Changes
|
9
|
+
|
10
|
+
Use [`syslog_protocol_ms`](https://github.com/torbencarstens/syslog_protocol_ms) instead of `syslog_protocol` ()
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
The easiest way to install `remote_syslog_sender_ms` is with Bundler. Add
|
15
|
+
`remote_syslog_sender_ms` to your `Gemfile`.
|
16
|
+
|
17
|
+
If you are not using a `Gemfile`, run:
|
18
|
+
|
19
|
+
$ [sudo] gem install remote_syslog_sender_ms
|
20
|
+
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
sender = RemoteSyslogSender.new('syslog.domain.com', 514) # default protocol is UDP
|
26
|
+
sender.transmit("message body")
|
27
|
+
# or
|
28
|
+
sender.write("message body")
|
29
|
+
|
30
|
+
## TCP
|
31
|
+
sender = RemoteSyslogSender.new('syslog.domain.com', 514, protocol: :tcp)
|
32
|
+
sender.transmit("message body")
|
33
|
+
|
34
|
+
## TCP+TLS
|
35
|
+
sender = RemoteSyslogSender.new('syslog.domain.com', 514, protocol: :tcp, tls: true, ca_file: "custom_ca.pem")
|
36
|
+
sender.transmit("message body")
|
37
|
+
```
|
38
|
+
|
39
|
+
To point the logs to your local system, use `localhost` and ensure that
|
40
|
+
the system's syslog daemon is bound to `127.0.0.1`.
|
41
|
+
|
42
|
+
|
43
|
+
## Limitations
|
44
|
+
|
45
|
+
If the specified host cannot be resolved, `syslog.domain.com` in the
|
46
|
+
example under the usage section above, `remote_syslog_sender_ms` will block
|
47
|
+
for approximately 20 seconds before displaying an error. This could
|
48
|
+
result in the application failing to start or even stopping responding.
|
49
|
+
|
50
|
+
Workarounds for this include:
|
51
|
+
|
52
|
+
* use an IP address instead of a hostname.
|
53
|
+
* put a hosts entry in `/etc/hosts` or equivalent, so that DNS is not
|
54
|
+
actually consulted
|
55
|
+
* instead of logging directly to the network, write to a file and
|
56
|
+
transmit new entries with a standalone daemon like
|
57
|
+
[remote_syslog](https://github.com/papertrail/remote_syslog),
|
58
|
+
|
59
|
+
## Message length
|
60
|
+
|
61
|
+
All log lines are truncated to a maximum of 1024 characters. This restriction
|
62
|
+
comes from [RFC 3164 section 4.1][rfc-limit]:
|
63
|
+
|
64
|
+
> The total length of the packet MUST be 1024 bytes or less.
|
65
|
+
|
66
|
+
Additionally, the generally-accepted [MTU][] of the Internet is 1500 bytes, so
|
67
|
+
regardless of the RFC, UDP syslog packets longer than 1500 bytes would not
|
68
|
+
arrive. For details or to use TCP syslog for longer messages, see
|
69
|
+
[help.papertrailapp.com][troubleshoot].
|
70
|
+
|
71
|
+
[rfc-limit]: https://tools.ietf.org/html/rfc3164#section-4.1
|
72
|
+
[MTU]: (https://en.wikipedia.org/wiki/Maximum_transmission_unit)
|
73
|
+
[troubleshoot]: http://help.papertrailapp.com/kb/configuration/troubleshooting-remote-syslog-reachability/#message-length
|
74
|
+
|
75
|
+
|
76
|
+
## Default program name
|
77
|
+
|
78
|
+
By default, the `program` value is set to the name and ID of the invoking
|
79
|
+
process. For example, `puma[12345]` or `rack[3456]`.
|
80
|
+
|
81
|
+
The `program` value is used to populate the syslog "tag" field, must be 32
|
82
|
+
or fewer characters. In a few cases, an artifact of how the app is launched
|
83
|
+
may lead to a default `program` value longer than 32 characters. For example,
|
84
|
+
the `thin` Web server may generate a default `program` value such
|
85
|
+
as:
|
86
|
+
|
87
|
+
thin server (0.0.0.0:3001)[11179]
|
88
|
+
|
89
|
+
If this occurs, the following exception will be raised when a
|
90
|
+
`RemoteSyslogSender` is instantiated:
|
91
|
+
|
92
|
+
Tag must not be longer than 32 characters (ArgumentError)
|
93
|
+
|
94
|
+
To remedy this, explicitly provide a `program` argument which is shorter than
|
95
|
+
32 characters. See [Usage](#usage).
|
96
|
+
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/torbencarstens/remote_syslog_sender_ms.
|
101
|
+
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'remote_syslog_sender_ms/udp_sender'
|
2
|
+
require 'remote_syslog_sender_ms/tcp_sender'
|
3
|
+
|
4
|
+
module RemoteSyslogSender
|
5
|
+
VERSION = '1.0.3'
|
6
|
+
|
7
|
+
def self.new(remote_hostname, remote_port, options = {})
|
8
|
+
protocol = options.delete(:protocol)
|
9
|
+
if protocol && protocol.to_sym == :tcp
|
10
|
+
TcpSender.new(remote_hostname, remote_port, options)
|
11
|
+
else
|
12
|
+
UdpSender.new(remote_hostname, remote_port, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'syslog_protocol_ms'
|
3
|
+
|
4
|
+
module RemoteSyslogSender
|
5
|
+
class Sender
|
6
|
+
# To suppress initialize warning
|
7
|
+
class Packet < SyslogProtocol::Packet
|
8
|
+
def initialize(*)
|
9
|
+
super
|
10
|
+
@time = nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :socket
|
15
|
+
attr_accessor :packet
|
16
|
+
|
17
|
+
def initialize(remote_hostname, remote_port, options = {})
|
18
|
+
@remote_hostname = remote_hostname
|
19
|
+
@remote_port = remote_port
|
20
|
+
@whinyerrors = options[:whinyerrors]
|
21
|
+
@packet_size = options[:packet_size] || 1024
|
22
|
+
|
23
|
+
@packet = Packet.new
|
24
|
+
|
25
|
+
local_hostname = options[:hostname] || options[:local_hostname] || (Socket.gethostname rescue `hostname`.chomp)
|
26
|
+
local_hostname = 'localhost' if local_hostname.nil? || local_hostname.empty?
|
27
|
+
@packet.hostname = local_hostname
|
28
|
+
|
29
|
+
@packet.facility = options[:facility] || 'user'
|
30
|
+
@packet.severity = options[:severity] || 'notice'
|
31
|
+
@packet.tag = options[:tag] || options[:program] || "#{File.basename($0)}[#{$$}]"
|
32
|
+
|
33
|
+
@socket = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def transmit(message, packet_options = nil)
|
37
|
+
message.split(/\r?\n/).each do |line|
|
38
|
+
begin
|
39
|
+
next if line =~ /^\s*$/
|
40
|
+
packet = @packet.dup
|
41
|
+
if packet_options
|
42
|
+
packet.tag = packet_options[:program] if packet_options[:program]
|
43
|
+
packet.hostname = packet_options[:local_hostname] if packet_options[:local_hostname]
|
44
|
+
%i(hostname facility severity tag).each do |key|
|
45
|
+
packet.send("#{key}=", packet_options[key]) if packet_options[key]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
packet.content = line
|
49
|
+
send_msg(packet.assemble(@packet_size))
|
50
|
+
rescue
|
51
|
+
if @whinyerrors
|
52
|
+
raise
|
53
|
+
else
|
54
|
+
$stderr.puts "#{self.class} error: #{$!.class}: #{$!}\nOriginal message: #{line}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Make this act a little bit like an `IO` object
|
61
|
+
alias_method :write, :transmit
|
62
|
+
|
63
|
+
def close
|
64
|
+
@socket.close
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def send_msg(payload)
|
70
|
+
raise NotImplementedError, "please override"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'syslog_protocol_ms'
|
3
|
+
require 'remote_syslog_sender_ms/sender'
|
4
|
+
|
5
|
+
module RemoteSyslogSender
|
6
|
+
class TcpSender < Sender
|
7
|
+
class NonBlockingTimeout < StandardError; end
|
8
|
+
|
9
|
+
def initialize(remote_hostname, remote_port, options = {})
|
10
|
+
super
|
11
|
+
@tls = options[:tls]
|
12
|
+
@retry_limit = options[:retry_limit] || 3
|
13
|
+
@retry_interval = options[:retry_interval] || 0.5
|
14
|
+
@remote_hostname = remote_hostname
|
15
|
+
@remote_port = remote_port
|
16
|
+
@ssl_method = options[:ssl_method] || 'TLSv1_2'
|
17
|
+
@ca_file = options[:ca_file]
|
18
|
+
@verify_mode = options[:verify_mode]
|
19
|
+
@timeout = options[:timeout] || 600
|
20
|
+
@timeout_exception = !!options[:timeout_exception]
|
21
|
+
@exponential_backoff = !!options[:exponential_backoff]
|
22
|
+
|
23
|
+
@mutex = Mutex.new
|
24
|
+
@tcp_socket = nil
|
25
|
+
|
26
|
+
if [:SOL_SOCKET, :SO_KEEPALIVE, :IPPROTO_TCP, :TCP_KEEPIDLE].all? {|c| Socket.const_defined? c}
|
27
|
+
@keep_alive = options[:keep_alive]
|
28
|
+
end
|
29
|
+
if Socket.const_defined?(:TCP_KEEPIDLE)
|
30
|
+
@keep_alive_idle = options[:keep_alive_idle]
|
31
|
+
end
|
32
|
+
if Socket.const_defined?(:TCP_KEEPCNT)
|
33
|
+
@keep_alive_cnt = options[:keep_alive_cnt]
|
34
|
+
end
|
35
|
+
if Socket.const_defined?(:TCP_KEEPINTVL)
|
36
|
+
@keep_alive_intvl = options[:keep_alive_intvl]
|
37
|
+
end
|
38
|
+
connect
|
39
|
+
end
|
40
|
+
|
41
|
+
def close
|
42
|
+
@socket.close if @socket
|
43
|
+
@tcp_socket.close if @tcp_socket
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def connect
|
49
|
+
connect_retry_count = 0
|
50
|
+
connect_retry_limit = 3
|
51
|
+
connect_retry_interval = 1
|
52
|
+
@mutex.synchronize do
|
53
|
+
begin
|
54
|
+
close
|
55
|
+
|
56
|
+
@tcp_socket = TCPSocket.new(@remote_hostname, @remote_port)
|
57
|
+
|
58
|
+
if @keep_alive
|
59
|
+
@tcp_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
|
60
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, @keep_alive_idle) if @keep_alive_idle
|
61
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, @keep_alive_cnt) if @keep_alive_cnt
|
62
|
+
@tcp_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, @keep_alive_intvl) if @keep_alive_intvl
|
63
|
+
end
|
64
|
+
if @tls
|
65
|
+
require 'openssl'
|
66
|
+
context = OpenSSL::SSL::SSLContext.new(@ssl_method)
|
67
|
+
context.ca_file = @ca_file if @ca_file
|
68
|
+
context.verify_mode = @verify_mode if @verify_mode
|
69
|
+
|
70
|
+
@socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, context)
|
71
|
+
@socket.connect
|
72
|
+
if @verify_mode != OpenSSL::SSL::VERIFY_NONE
|
73
|
+
@socket.post_connection_check(@remote_hostname)
|
74
|
+
raise "verification error" if @socket.verify_result != OpenSSL::X509::V_OK
|
75
|
+
end
|
76
|
+
else
|
77
|
+
@socket = @tcp_socket
|
78
|
+
end
|
79
|
+
rescue
|
80
|
+
if connect_retry_count < connect_retry_limit
|
81
|
+
sleep connect_retry_interval
|
82
|
+
connect_retry_count += 1
|
83
|
+
retry
|
84
|
+
else
|
85
|
+
raise
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def send_msg(payload)
|
92
|
+
if @timeout && @timeout >= 0
|
93
|
+
method = :write_nonblock
|
94
|
+
else
|
95
|
+
method = :write
|
96
|
+
end
|
97
|
+
|
98
|
+
retry_limit = @retry_limit.to_i
|
99
|
+
retry_interval = @retry_interval.to_f
|
100
|
+
retry_count = 0
|
101
|
+
|
102
|
+
payload << "\n"
|
103
|
+
payload.force_encoding(Encoding::ASCII_8BIT)
|
104
|
+
payload_size = payload.bytesize
|
105
|
+
|
106
|
+
until payload_size <= 0
|
107
|
+
start = get_time
|
108
|
+
begin
|
109
|
+
result = @mutex.synchronize { @socket.__send__(method, payload) }
|
110
|
+
payload_size -= result
|
111
|
+
payload.slice!(0, result) if payload_size > 0
|
112
|
+
rescue IO::WaitReadable
|
113
|
+
timeout_wait = @timeout - (get_time - start)
|
114
|
+
retry if IO.select([@socket], nil, nil, timeout_wait)
|
115
|
+
|
116
|
+
raise NonBlockingTimeout if @timeout_exception
|
117
|
+
break
|
118
|
+
rescue IO::WaitWritable
|
119
|
+
timeout_wait = @timeout - (get_time - start)
|
120
|
+
retry if IO.select(nil, [@socket], nil, timeout_wait)
|
121
|
+
|
122
|
+
raise NonBlockingTimeout if @timeout_exception
|
123
|
+
break
|
124
|
+
rescue
|
125
|
+
if retry_count < retry_limit
|
126
|
+
sleep retry_interval
|
127
|
+
retry_count += 1
|
128
|
+
retry_interval *= 2 if @exponential_backoff
|
129
|
+
connect
|
130
|
+
retry
|
131
|
+
else
|
132
|
+
raise
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
POSIX_CLOCK =
|
139
|
+
if defined?(Process::CLOCK_MONOTONIC_COARSE)
|
140
|
+
Process::CLOCK_MONOTONIC_COARSE
|
141
|
+
elsif defined?(Process::CLOCK_MONOTONIC)
|
142
|
+
Process::CLOCK_MONOTONIC
|
143
|
+
elsif defined?(Process::CLOCK_REALTIME_COARSE)
|
144
|
+
Process::CLOCK_REALTIME_COARSE
|
145
|
+
elsif defined?(Process::CLOCK_REALTIME)
|
146
|
+
Process::CLOCK_REALTIME
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_time
|
150
|
+
if POSIX_CLOCK
|
151
|
+
Process.clock_gettime(POSIX_CLOCK)
|
152
|
+
else
|
153
|
+
Time.now.to_f
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'syslog_protocol_ms'
|
3
|
+
require 'remote_syslog_sender_ms/sender'
|
4
|
+
|
5
|
+
module RemoteSyslogSender
|
6
|
+
class UdpSender < Sender
|
7
|
+
def initialize(remote_hostname, remote_port, options = {})
|
8
|
+
super
|
9
|
+
@socket = UDPSocket.new
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def send_msg(payload)
|
15
|
+
@socket.send(payload, 0, @remote_hostname, @remote_port)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'remote_syslog_sender_ms'
|
3
|
+
s.version = '1.3.0'
|
4
|
+
s.summary = "Message sender that sends directly to a remote syslog endpoint"
|
5
|
+
s.description = "Message sender that sends directly to a remote syslog endpoint (Support UDP, TCP, TCP+TLS)"
|
6
|
+
|
7
|
+
s.authors = ["Tomohiro Hashidate", "Eric Lindvall", "Torben Carstens"]
|
8
|
+
s.email = %w[kakyoin.hierophant@gmail.com rubygems@carstens.tech]
|
9
|
+
s.homepage = 'https://github.com/torbencarstens/remote_syslog_logger'
|
10
|
+
|
11
|
+
s.files = `git ls-files -z`.split("\x0")
|
12
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
13
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
s.require_paths = %w[lib]
|
15
|
+
|
16
|
+
s.add_runtime_dependency 'syslog_protocol_ms', '>= 0.10.0'
|
17
|
+
|
18
|
+
s.add_development_dependency "bundler", ">= 1.6", "< 3.0"
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "test-unit"
|
21
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestRemoteSyslogSender < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@server_port = rand(50000) + 1024
|
6
|
+
@socket = UDPSocket.new
|
7
|
+
@socket.bind('127.0.0.1', @server_port)
|
8
|
+
|
9
|
+
@tcp_server = TCPServer.open('127.0.0.1', 0)
|
10
|
+
@tcp_server_port = @tcp_server.addr[1]
|
11
|
+
|
12
|
+
@tcp_server_wait_thread = Thread.start do
|
13
|
+
@tcp_server.accept
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
@socket.close
|
19
|
+
@tcp_server.close
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_sender
|
23
|
+
@sender = RemoteSyslogSender.new('127.0.0.1', @server_port)
|
24
|
+
@sender.write "This is a test"
|
25
|
+
|
26
|
+
message, _ = *@socket.recvfrom(1024)
|
27
|
+
assert_match(/This is a test/, message)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_sender_long_payload
|
31
|
+
@sender = RemoteSyslogSender.new('127.0.0.1', @server_port, packet_size: 10240)
|
32
|
+
@sender.write "abcdefgh" * 1000
|
33
|
+
|
34
|
+
message, _ = *@socket.recvfrom(10240)
|
35
|
+
assert_match(/#{"abcdefgh" * 1000}/, message)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_sender_tcp
|
39
|
+
@sender = RemoteSyslogSender.new('127.0.0.1', @tcp_server_port, protocol: :tcp)
|
40
|
+
@sender.write "This is a test"
|
41
|
+
sock = @tcp_server_wait_thread.value
|
42
|
+
|
43
|
+
message, _ = *sock.recvfrom(1024)
|
44
|
+
assert_match(/This is a test/, message)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_sender_tcp_nonblock
|
48
|
+
@sender = RemoteSyslogSender.new('127.0.0.1', @tcp_server_port, protocol: :tcp, timeout: 20)
|
49
|
+
@sender.write "This is a test"
|
50
|
+
sock = @tcp_server_wait_thread.value
|
51
|
+
|
52
|
+
message, _ = *sock.recvfrom(1024)
|
53
|
+
assert_match(/This is a test/, message)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_sender_multiline
|
57
|
+
@sender = RemoteSyslogSender.new('127.0.0.1', @server_port)
|
58
|
+
@sender.write "This is a test\nThis is the second line"
|
59
|
+
|
60
|
+
message, _ = *@socket.recvfrom(1024)
|
61
|
+
assert_match(/This is a test/, message)
|
62
|
+
|
63
|
+
message, _ = *@socket.recvfrom(1024)
|
64
|
+
assert_match(/This is the second line/, message)
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remote_syslog_sender_ms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomohiro Hashidate
|
8
|
+
- Eric Lindvall
|
9
|
+
- Torben Carstens
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2021-08-03 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: syslog_protocol_ms
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 0.10.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '1.6'
|
36
|
+
- - "<"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '3.0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.6'
|
46
|
+
- - "<"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rake
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: test-unit
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
description: Message sender that sends directly to a remote syslog endpoint (Support
|
78
|
+
UDP, TCP, TCP+TLS)
|
79
|
+
email:
|
80
|
+
- kakyoin.hierophant@gmail.com
|
81
|
+
- rubygems@carstens.tech
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- ".gitignore"
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- lib/remote_syslog_sender_ms.rb
|
92
|
+
- lib/remote_syslog_sender_ms/sender.rb
|
93
|
+
- lib/remote_syslog_sender_ms/tcp_sender.rb
|
94
|
+
- lib/remote_syslog_sender_ms/udp_sender.rb
|
95
|
+
- remote_syslog_sender_ms.gemspec
|
96
|
+
- test/helper.rb
|
97
|
+
- test/test_remote_syslog_logger.rb
|
98
|
+
homepage: https://github.com/torbencarstens/remote_syslog_logger
|
99
|
+
licenses: []
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.2.15
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Message sender that sends directly to a remote syslog endpoint
|
120
|
+
test_files:
|
121
|
+
- test/helper.rb
|
122
|
+
- test/test_remote_syslog_logger.rb
|