wan-ip-gen 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/wan-ip-gen.rb +37 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c1a2e96fadf61c44a0dbbc81d5e1d59dc44df7c96833dd1edfe3ef6986f872cb
4
+ data.tar.gz: cfc8b40a1e2c26ef2019a74cd5c30ccd5ec161c33d6acbeaf84887be615c5b27
5
+ SHA512:
6
+ metadata.gz: e7767877bbb80e4fdd5d7fa7bf6f728eb23c89efeaa9eba443328886a190889b14aed1a01d96982a564e8d90f12146f6494db2d491c81b671fdb2517000149fd
7
+ data.tar.gz: d92441b1e3dc381a9248f189975155b729ad2e426f81927f3e7992f351a820fd308f9e450568b5085b0e8ce2fc940c346ddc8be516308989a54321cadcccd56d
data/lib/wan-ip-gen.rb ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ module IP
5
+ # WAN range IP generator
6
+ class RandomWAN
7
+ include Enumerable
8
+
9
+ RANDOM_RANGE = (0x01000000...0xffffffff).freeze # exclude current network and local broadcast
10
+ EXCLUDE_RANGES = [
11
+ (0xe0000000..0xefffffff), # 224.0.0.0 - 239.255.255.255
12
+ (0xf0000000..0xfffffffe), # 240.0.0.0 - 255.255.255.254
13
+ (0xA000000..0xAFFFFFF), # 10.0.0.0 - 10.255.255.255
14
+ (0x7F000000..0x7FFFFFFF), # 127.0.0.0 - 127.255.255.255
15
+ (0x64400000..0x647FFFFF), # 100.64.0.0 - 100.127.255.255
16
+ (0xAC100000..0xAC1FFFFF), # 172.16.0.0 - 172.31.255.255
17
+ (0xC6120000..0xC613FFFF), # 198.18.0.0 - 198.19.255.255
18
+ (0xA9FE0000..0xA9FEFFFF), # 169.254.0.0 - 169.254.255.255
19
+ (0xC0A80000..0xC0A8FFFF), # 192.168.0.0 - 192.168.255.255
20
+ (0xC0000000..0xC00000FF), # 192.0.0.0 - 192.0.0.255
21
+ (0xC0000200..0xC00002FF), # 192.0.2.0 - 192.0.2.255
22
+ (0xc0586300..0xc05863ff), # 192.88.99.0 - 192.88.99.255
23
+ (0xC6336400..0xC63364FF), # 198.51.100.0 - 198.51.100.255
24
+ (0xCB007100..0xCB0071FF), # 203.0.113.0 - 203.0.113.255
25
+ (0xe9fc0000..0xe9fc00ff) # 233.252.0.0 - 233.252.0.255
26
+ ].freeze
27
+
28
+ def each(&block)
29
+ loop do
30
+ intip = rand(RANDOM_RANGE)
31
+ next if EXCLUDE_RANGES.any? { |r| r.cover? intip }
32
+
33
+ block.call [intip].pack('N').unpack('CCCC').join('.')
34
+ end
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wan-ip-gen
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mikhail Yudin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: WAN range random IP generator
14
+ email: fagci.nsk@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/wan-ip-gen.rb
20
+ homepage: https://rubygems.org/gems/wan-ip-gen
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.3.23
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: WAN range random IP generator
43
+ test_files: []