module Evesync::Utils

Public Class Methods

local_ip() click to toggle source
# File lib/evesync/utils.rb, line 14
def local_ip
  local_ips.first
end
local_ip?(ip) click to toggle source
# File lib/evesync/utils.rb, line 4
def local_ip?(ip)
  ips = `getent hosts #{ip}`
          .lines
          .map(&:split)
          .map(&:first)
  loc_ips = local_ips

  !(ips & loc_ips).empty?
end
local_ips() click to toggle source
# File lib/evesync/utils.rb, line 18
def local_ips
  `ip a`
    .lines
    .grep(/inet/)
    .map(&:split)
    .map { |lines| lines[1].split('/')[0] }
end