Sha256: 71db25315efcca27319acedb131e63188297a6066b845ee26c0804bedf3c4e62

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true
require 'socket'

module Netchk
  class IpVerifier
    def verify
      socket = Socket.ip_address_list
      addresses = socket.reject(&:ipv4_loopback?)
      addresses.reject!(&:ipv6_loopback?)
      addresses.filter!(&:ipv4?)
      addresses.map!(&:inspect_sockaddr)

      if addresses.empty?
        $stderr.puts 'No IPv4 address found. Verify your connection to your router.'
      else
        puts "Found IP addresses #{addresses.join(', ')}."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netchk-0.0.1 lib/netchk/ip_verifier.rb