lib/fluent/plugin/output_node.rb in fluent-plugin-secure-forward-0.3.3dev2 vs lib/fluent/plugin/output_node.rb in fluent-plugin-secure-forward-0.3.3

- old
+ new

@@ -2,10 +2,12 @@ # require 'socket' # require 'openssl' # require 'digest' # require 'resolve/hostname' +require 'proxifier' + require_relative 'openssl_util' class Fluent::SecureForwardOutput::Node attr_accessor :host, :port, :hostlabel, :shared_key, :username, :password, :standby @@ -25,10 +27,12 @@ @hostlabel = conf.hostlabel || conf.host @username = conf.username @password = conf.password @standby = conf.standby + @proxy_uri = conf.proxy_uri + @keepalive = sender.keepalive @authentication = nil @writing = false @@ -51,11 +55,11 @@ end def dup renewed = self.class.new( @sender, - Fluent::Config::Section.new({host: @host, port: @port, hostlabel: @hostlabel, username: @username, password: @password, shared_key: @shared_key, standby: @standby}) + Fluent::Config::Section.new({host: @host, port: @port, hostlabel: @hostlabel, username: @username, password: @password, shared_key: @shared_key, standby: @standby, proxy_uri: @proxy_uri}) ) renewed end def start @@ -215,11 +219,17 @@ Thread.current.abort_on_exception = true log.debug "starting client" addr = @sender.hostname_resolver.getaddress(@host) log.debug "create tcp socket to node", host: @host, address: addr, port: @port + begin - sock = TCPSocket.new(addr, @port) + if @proxy_uri.nil? then + sock = TCPSocket.new(addr, @port) + else + proxy = Proxifier::Proxy(@proxy_uri) + sock = proxy.open(addr, @port) + end rescue => e log.warn "failed to connect for secure-forward", error_class: e.class, error: e, host: @host, address: addr, port: @port @state = :failed return end