checkforiceland 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/checkforiceland.rb +19 -0
- metadata +48 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
class CheckForIceland
|
2
|
+
def is_icelandic?(address)
|
3
|
+
address = IPAddr.new(address) unless address.class == IPAddr
|
4
|
+
address = address.native
|
5
|
+
|
6
|
+
Socket.getaddrinfo address.reverse.gsub("in-addr.arpa", "iceland.rix.is"), nil if address.ipv4?
|
7
|
+
Socket.getaddrinfo address.reverse.gsub("ip6.arpa", "iceland.rix.is"), nil if address.ipv6?
|
8
|
+
|
9
|
+
true
|
10
|
+
rescue SocketError => e
|
11
|
+
if e.to_s == "getaddrinfo: Name or service not known"
|
12
|
+
false
|
13
|
+
elsif e.to_s == "getaddrinfo: Temporary failure in name resolution"
|
14
|
+
nil
|
15
|
+
else
|
16
|
+
raise e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: checkforiceland
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anton Smári Gunnarsson
|
9
|
+
- Birkir Guðjónsson
|
10
|
+
- Gabríel A. Pétursson
|
11
|
+
- Gunnar Guðvarðarson
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
date: 2011-10-16 00:00:00.000000000Z
|
16
|
+
dependencies: []
|
17
|
+
description: Uses a DNS service, provided by RIX, to check if an IP address is Icelandic
|
18
|
+
email: gabriel@system.is
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/checkforiceland.rb
|
24
|
+
homepage: http://rubygems.org/gems/hola
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.10
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: Check for Iceland
|
48
|
+
test_files: []
|