lib/rex/socket/parameters.rb in librex-0.0.65 vs lib/rex/socket/parameters.rb in librex-0.0.66

- old
+ new

@@ -1,5 +1,6 @@ +# -*- coding: binary -*- require 'rex/socket' ### # # This class represents the set of parameters that are used to create @@ -60,11 +61,11 @@ # Whether or not SSL should be used. # # SSLVersion # # Specify SSL2, SSL3, or TLS1 (SSL3 is default) - # + # # SSLCert # # A file containing an SSL certificate (for server sockets) # # Proxies @@ -95,11 +96,11 @@ # # Timeout # # The number of seconds before a connection should time out # - + def initialize(hash) if (hash['PeerHost']) self.peerhost = hash['PeerHost'] elsif (hash['PeerAddr']) self.peerhost = hash['PeerAddr'] @@ -136,27 +137,27 @@ if (hash['SSL'] and hash['SSL'].to_s =~ /^(t|y|1)/i) self.ssl = true else self.ssl = false end - + if (hash['SSLVersion'] and hash['SSLVersion'].to_s =~ /^(SSL2|SSL3|TLS1)$/i) self.ssl_version = hash['SSLVersion'] end - + if (hash['SSLCert'] and ::File.file?(hash['SSLCert'])) begin self.ssl_cert = ::File.read(hash['SSLCert']) rescue ::Exception => e elog("Failed to read cert: #{e.class}: #{e}", LogSource) end end - - if hash['Proxies'] + + if hash['Proxies'] self.proxies = hash['Proxies'].split('-').map{|a| a.strip}.map{|a| a.split(':').map{|b| b.strip}} end - + # The protocol this socket will be using if (hash['Proto']) self.proto = hash['Proto'].downcase else self.proto = 'tcp' @@ -168,11 +169,11 @@ # The communication subsystem to use to create the socket self.comm = hash['Comm'] # The context that was passed in, if any. self.context = hash['Context'] || {} - + # If no comm was supplied, try to use the comm that is best fit to # handle the provided host based on the current routing table. if( self.server ) if (self.comm == nil and self.localhost) self.comm = Rex::Socket::SwitchBoard.best_comm(self.localhost) @@ -183,17 +184,17 @@ end end # If we still haven't found a comm, we default to the local comm. self.comm = Rex::Socket::Comm::Local if (self.comm == nil) - - # If we are a UDP server, turn off the server flag as it was only set when + + # If we are a UDP server, turn off the server flag as it was only set when # creating the UDP socket in order to avail of the switch board above. if( self.server and self.proto == 'udp' ) self.server = false end - + # The number of connection retries to make (client only) if hash['Retries'] self.retries = hash['Retries'].to_i else self.retries = 0 @@ -203,11 +204,11 @@ if hash['Timeout'] self.timeout = hash['Timeout'].to_i else self.timeout = 5 end - + # Whether to force IPv6 addressing self.v6 = hash['IPv6'] || false end ## @@ -248,11 +249,11 @@ # Returns true if the protocol for the parameters is IP. # def ip? return (proto == 'ip') end - + # # Returns true if the socket is a bare socket that does not inherit from # any extended Rex classes. # def bare? @@ -352,10 +353,10 @@ ## # # Synonyms # ## - + alias peeraddr peerhost alias localaddr localhost end