Sha256: 8a2475c93b9ad5e8a112a28f71af7b9d5b6c3dbbe5d77b3054ae9abf0025f43b
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module Sockit module Support def is_host_configured? (!config.host.nil? && !config.host.empty?) end def is_port_configured? (!config.port.nil? && !config.port.empty?) end def is_version_configured? ((config.version == 4) || (config.version == 5)) end def is_configured? (is_host_configured? && is_port_configured? && is_version_configured?) end def connect_via_socks?(host) (is_configured? && !config.ignore.flatten.any?{ |ignored_host| host =~ /#{ignored_host}/ } end def is_socks_v5? (is_configured? && config.version.to_i == 5) end def is_socks_v4? (is_configured? && config.version.to_i == 4) end def log(color, message) return if !config.debug timestamp = Time.now.utc puts("%s%s.%06d %s%s" % [COLORS[color], timestamp.strftime("%Y-%m-%d|%H:%M:%S"), timestamp.usec, message, COLORS[:reset]]) end def dump(action, data) return if !config.debug bytes = Array.new chars = Array.new for x in 0..(data.length - 1) do bytes << ("%03d" % data[x].ord) chars << ("%03s" % (data[x] =~ /^\w+$/ ? data[x].chr : "...")) end log(:blue, "#{action.to_s.upcase}: #{bytes.join(" ")}#{COLORS[:reset]}") log(:blue, "#{action.to_s.upcase}: #{chars.join(" ")}#{COLORS[:reset]}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sockit-1.2.0 | lib/sockit/support.rb |