New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support tls in syslog #2399
Merged
Merged
Support tls in syslog #2399
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ class SyslogInput < Input | |
desc 'The prefix of the tag. The tag itself is generated by the tag prefix, facility level, and priority.' | ||
config_param :tag, :string | ||
desc 'The transport protocol used to receive logs.(udp, tcp)' | ||
config_param :protocol_type, :enum, list: [:tcp, :udp], default: :udp | ||
config_param :protocol_type, :enum, list: [:tcp, :udp], default: nil | ||
desc 'The message frame type.(traditional, octet_count)' | ||
config_param :frame_type, :enum, list: [:traditional, :octet_count], default: :traditional | ||
|
||
|
@@ -131,6 +131,10 @@ def configure(conf) | |
end | ||
end | ||
|
||
if @protocol_type | ||
log.warn("protocol_type is deprecated. Use transport directive.") | ||
end | ||
|
||
@_event_loop_run_timeout = @blocking_timeout | ||
end | ||
|
||
|
@@ -141,12 +145,13 @@ def multi_workers_ready? | |
def start | ||
super | ||
|
||
log.info "listening syslog socket on #{@bind}:#{@port} with #{@protocol_type}" | ||
case @protocol_type | ||
log.info "listening syslog socket on #{@bind}:#{@port} with #{@protocol_type || @transport_config.protocol}" | ||
case @protocol_type || @transport_config.protocol | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch 🙏 |
||
when :udp then start_udp_server | ||
when :tcp then start_tcp_server | ||
when :tls then start_tcp_server(tls: true) | ||
else | ||
raise "BUG: invalid protocol_type value:#{@protocol_type}" | ||
raise "BUG: invalid transport value: #{@protocol_type || @transport_config.protocol}" | ||
end | ||
end | ||
|
||
|
@@ -156,12 +161,12 @@ def start_udp_server | |
end | ||
end | ||
|
||
def start_tcp_server | ||
def start_tcp_server(tls: false) | ||
octet_count_frame = @frame_type == :octet_count | ||
|
||
delimiter = octet_count_frame ? " " : @delimiter | ||
delimiter_size = delimiter.size | ||
server_create_connection(:in_syslog_tcp_server, @port, bind: @bind, resolve_name: @resolve_hostname) do |conn| | ||
server_create_connection(tls ? :in_syslog_tls_server : :in_syslog_tcp_server, @port, bind: @bind, resolve_name: @resolve_hostname) do |conn| | ||
conn.data do |data| | ||
buffer = conn.buffer | ||
buffer << data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For deprecated parameter, use
deprecated: