<commit_before># Copyright 2014 <NAME>.
#
# This file is a modification of code from Logstash Forwarder.
# Copyright 2012-2013 <NAME> and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'socket'
require 'thread'
require 'openssl'

module LogCourier
  # TLS transport implementation
  class ClientTls
    def initialize(options = {})
      @options = {
        :logger             => nil,
        :port               => nil,
        :addresses          => [],
        :ssl_ca             => nil,
        :ssl_certificate    => nil,
        :ssl_key            => nil,
        :ssl_key_passphrase => nil
      }.merge(options)

      @logger = @options[:logger]

      [:port, :ssl_ca].each do |k|
        raise "[LogCourierClientTLS] '#{k}' is required" if @options[k].nil?
      end

      raise '[LogCourierClientTLS] \'addresses\' must contain at least one address' @options[:addresses].empty?

      c = 0
      [:ssl_certificate, :ssl_key].each do
        c += 1
      end

      raise '[LogCourierClientTLS] \'ssl_certificate\' and \'ssl_key\' must be specified together' if c == 1
    end

    def connect(io_control)
      begin
        tls_connect
      rescue ClientShutdownSignal
        raise
      rescue
        # TODO: Make this configurable
        sleep 5<commit_msg>Fix syntax error<commit_after># Copyright 2014 <NAME>.
#
# This file is a modification of code from Logstash Forwarder.
# Copyright 2012-2013 <NAME> and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'socket'
require 'thread'
require 'openssl'

module LogCourier
  # TLS transport implementation
  class ClientTls
    def initialize(options = {})
      @options = {
        :logger             => nil,
        :port               => nil,
        :addresses          => [],
        :ssl_ca             => nil,
        :ssl_certificate    => nil,
        :ssl_key            => nil,
        :ssl_key_passphrase => nil
      }.merge(options)

      @logger = @options[:logger]

      [:port, :ssl_ca].each do |k|
        raise "[LogCourierClientTLS] '#{k}' is required" if @options[k].nil?
      end

      raise '[LogCourierClientTLS] \'addresses\' must contain at least one address' if @options[:addresses].empty?

      c = 0
      [:ssl_certificate, :ssl_key].each do
        c += 1
      end

      raise '[LogCourierClientTLS] \'ssl_certificate\' and \'ssl_key\' must be specified together' if c == 1
    end

    def connect(io_control)
      begin
        tls_connect
      rescue ClientShutdownSignal
        raise
      rescue
        # TODO: Make this configurable
        sleep 5
{'fraction_non_alphanumeric': 0.09317803660565724, 'fraction_numerical': 0.011092623405435386, 'mean_word_length': 2.5087548638132295, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7123624', 'n_tokens_mistral': 1040, 'n_tokens_neox': 973, 'n_words': 374}