Module: Evesync::Utils

Defined in:
lib/evesync/utils.rb

Class Method Summary collapse

Class Method Details

.local_ipObject



14
15
16
# File 'lib/evesync/utils.rb', line 14

def local_ip
  local_ips.first
end

.local_ip?(ip) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
# 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_ipsObject



18
19
20
21
22
23
24
# File 'lib/evesync/utils.rb', line 18

def local_ips
  `ip a`
    .lines
    .grep(/inet/)
    .map(&:split)
    .map { |lines| lines[1].split('/')[0] }
end