Module: Ronin::CLI::HostAndPort Private

Included in:
Commands::BannerGrab, Commands::CertDump, Commands::CertGrab, Commands::Proxy
Defined in:
lib/ronin/cli/host_and_port.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Mixin which adds methods for parsing host:port pairs.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#host_and_port(string) ⇒ (String, Integer)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses a host:port pair.

Parameters:

  • string (String)

    The string containing the host:port pair.

Returns:

  • ((String, Integer))

    The parsed host and port.

Since:

  • 2.0.0



36
37
38
39
40
# File 'lib/ronin/cli/host_and_port.rb', line 36

def host_and_port(string)
  host, port = string.split(':',2)

  return host, port.to_i
end

#host_and_port_from_url(url) ⇒ (String, Integer)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses the host and port from the given URL.

Parameters:

  • url (String)

    The URL to parse.

Returns:

  • ((String, Integer))

    The host and port components of the URL.

Since:

  • 2.0.0



51
52
53
54
55
# File 'lib/ronin/cli/host_and_port.rb', line 51

def host_and_port_from_url(url)
  uri = Addressable::URI.parse(url)

  return uri.normalized_host, uri.inferred_port
end