Sha256: adf30f877e8121b6de78bbc197c9a99954f32b939a5b97c01a958bd2f88774b8

Contents?: true

Size: 931 Bytes

Versions: 7

Compression:

Stored size: 931 Bytes

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

cs__scoped_require 'contrast/api/socket'

module Contrast
  module Api
    # This class allows us to create a TCP Socket to communicate to the Service
    # (Speed Racer). Either it or the Unix Socket will be used, as determined
    # by the configuration options set for Service communication.
    class TcpSocket
      include Contrast::Api::Socket

      LOCAL_HOSTS = %w[localhost 127.0.0.1 0.0.0.0 ::1].cs__freeze

      attr_reader :host, :port

      # Create the socket
      # @param host [String] socket target hostname or IP address
      # @param port [String,Integer] socket target port
      def initialize host, port
        @host = host.to_s
        @port = port.to_i
      end

      def new_socket
        ::TCPSocket.new(host, port)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contrast-agent-3.10.2 lib/contrast/api/tcp_socket.rb
contrast-agent-3.10.1 lib/contrast/api/tcp_socket.rb
contrast-agent-3.10.0 lib/contrast/api/tcp_socket.rb
contrast-agent-3.9.1 lib/contrast/api/tcp_socket.rb
contrast-agent-3.9.0 lib/contrast/api/tcp_socket.rb
contrast-agent-3.8.5 lib/contrast/api/tcp_socket.rb
contrast-agent-3.8.4 lib/contrast/api/tcp_socket.rb