Skip to content

Commit 77f1eb7

Browse files
authored
Merge pull request #1 from iamAzeem/feature-tls-support
Added TLS support.
2 parents 917fb18 + 84d3639 commit 77f1eb7

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* **Incoming Message Format**: Support for binary or JSON format (`Content-Type`: `application/octet-stream` or `application/json`)
99
* **Outgoing Message Format**: Support for binary or JSON format
1010
* **Message Types**: Single or Batch
11+
* **TLS Support**: Use `<transport tls> ... </transport>` section in configuration and `https://` URL protocol prefix. See this [example](https://docs.fluentd.org/plugin-helper-overview/api-plugin-helper-server#configuration-example) for more details.
1112

1213
## Installation
1314

fluent-plugin-protobuf-http.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
88
spec.email = ['[email protected]']
99

1010
spec.summary = 'fluentd HTTP Input Plugin for Protocol Buffers'
11-
spec.description = 'fluentd HTTP Input Plugin for Protocol Buffers with Single and Batch Messages Support]'
11+
spec.description = 'fluentd HTTP Input Plugin for Protocol Buffers with Single and Batch Messages Support'
1212
spec.homepage = 'https://github.com/iamAzeem/fluent-plugin-protobuf-http'
1313
spec.license = 'Apache-2.0'
1414

lib/fluent/plugin/in_protobuf_http.rb

+15-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class ProtobufHttpInput < Fluent::Plugin::Input
4242
desc 'The tag for the event.'
4343
config_param :tag, :string
4444

45+
config_section :transport, required: false, multi: false, init: true, param_name: :transport_config do
46+
config_argument :protocol, :enum, list: %i[tcp tls], default: :tcp
47+
end
48+
4549
def initialize
4650
super
4751

@@ -136,9 +140,18 @@ def start
136140
compile_protos
137141
populate_msgclass_lookup
138142

139-
log.info("Starting protobuf server [#{@bind}:#{@port}]...")
143+
# TLS check
144+
proto = :tcp
145+
tls_opts = nil
146+
if @transport_config && @transport_config.protocol == :tls
147+
proto = :tls
148+
tls_opts = @transport_config.to_h
149+
end
150+
151+
log.info("Starting protobuf #{proto == :tcp ? 'HTTP' : 'HTTPS'} server [#{@bind}:#{@port}]...")
152+
log.debug("TLS configuration:\n#{tls_opts}") if tls_opts
140153

141-
http_server_create_http_server(:protobuf_server, addr: @bind, port: @port, logger: log) do |server|
154+
http_server_create_http_server(:protobuf_server, addr: @bind, port: @port, logger: log, proto: proto, tls_opts: tls_opts) do |server|
142155
server.post("/#{tag}") do |req|
143156
peeraddr = "#{req.peeraddr[2]}:#{req.peeraddr[1]}".freeze # ip:port
144157
serialized_msg = req.body.freeze

0 commit comments

Comments
 (0)