Class: Mongo::Address::IPv6
- Inherits:
-
Object
- Object
- Mongo::Address::IPv6
- Defined in:
- lib/mongo/address/ipv6.rb
Overview
Sets up resolution with IPv6 support if the address is an ip address.
Constant Summary collapse
- MATCH =
The regular expression to use to match an IPv6 ip address.
Regexp.new('::').freeze
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
Host The host.
-
#host_name ⇒ String
readonly
Host_name The original host name.
-
#port ⇒ Integer
readonly
Port The port.
Class Method Summary collapse
-
.parse(address) ⇒ Array<String, Integer>
Parse an IPv6 address into its host and port.
Instance Method Summary collapse
-
#initialize(host, port, host_name = nil) ⇒ IPv6
constructor
Initialize the IPv6 resolver.
-
#socket(timeout, ssl_options = {}) ⇒ Pool::Socket::SSL, Pool::Socket::TCP
Get a socket for the provided address type, given the options.
Constructor Details
#initialize(host, port, host_name = nil) ⇒ IPv6
Initialize the IPv6 resolver.
64 65 66 67 68 |
# File 'lib/mongo/address/ipv6.rb', line 64 def initialize(host, port, host_name=nil) @host = host @port = port @host_name = host_name end |
Instance Attribute Details
#host ⇒ String (readonly)
Returns host The host.
25 26 27 |
# File 'lib/mongo/address/ipv6.rb', line 25 def host @host end |
#host_name ⇒ String (readonly)
Returns host_name The original host name.
28 29 30 |
# File 'lib/mongo/address/ipv6.rb', line 28 def host_name @host_name end |
#port ⇒ Integer (readonly)
Returns port The port.
31 32 33 |
# File 'lib/mongo/address/ipv6.rb', line 31 def port @port end |
Class Method Details
.parse(address) ⇒ Array<String, Integer>
Parse an IPv6 address into its host and port.
48 49 50 51 52 53 |
# File 'lib/mongo/address/ipv6.rb', line 48 def self.parse(address) parts = address.match(/\[(.+)\]:?(.+)?/) host = parts[1] port = (parts[2] || 27017).to_i [ host, port ] end |
Instance Method Details
#socket(timeout, ssl_options = {}) ⇒ Pool::Socket::SSL, Pool::Socket::TCP
Get a socket for the provided address type, given the options.
81 82 83 84 85 86 87 |
# File 'lib/mongo/address/ipv6.rb', line 81 def socket(timeout, = {}) unless .empty? Socket::SSL.new(host, port, host_name, timeout, Socket::PF_INET6, ) else Socket::TCP.new(host, port, timeout, Socket::PF_INET6) end end |