subnet_calc 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/subnet_calc.rb +11 -13
- metadata +1 -1
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1eddfe72b1f9709ba8dc4bba337acb4e3b5948
|
4
|
+
data.tar.gz: d110a0f4455a9cb344f6b18e03f8606682b59139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1c0bb55656d10d346dd5b4f18d68a54ab0f7a867c26bb3830a2954cd38b94a7730addca35430085b4999f68a02e4cc6ca24233b79d39bb20e5fe6c10551e08
|
7
|
+
data.tar.gz: b98f890520e115843b3a2f1bcadce7b92d2606594d27b8122106f54de778856ae74b094a09b18aa9ada1f8f360536ee187588e0a7d079432682a7e05c20da2d2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/subnet_calc.rb
CHANGED
@@ -70,7 +70,7 @@ class SubnetCalc
|
|
70
70
|
# ------------------------------------
|
71
71
|
|
72
72
|
|
73
|
-
octet_n,
|
73
|
+
octet_n, bit_n, class_type = if hosts then
|
74
74
|
|
75
75
|
hosts_per_subnet = octets.flat_map.with_index do |octet,i|
|
76
76
|
octet.bits.map.with_index {|y,j| [i, j, y.hosts_per_subnet] }
|
@@ -132,16 +132,15 @@ class SubnetCalc
|
|
132
132
|
end
|
133
133
|
|
134
134
|
|
135
|
-
bit = octets[octet_n].bits[
|
135
|
+
bit = octets[octet_n].bits[bit_n]
|
136
136
|
|
137
137
|
magic_number, hosts_per_subnet, prefix = bit.decimal,
|
138
138
|
bit.hosts_per_subnet, bit.prefix
|
139
139
|
|
140
|
-
n = col
|
141
140
|
|
142
141
|
# add the new mask to the octet
|
143
142
|
|
144
|
-
octets[octet_n].mask = octets[octet_n].bits.map(&:decimal)[0..
|
143
|
+
octets[octet_n].mask = octets[octet_n].bits.map(&:decimal)[0..bit_n].inject(:+)
|
145
144
|
subnet_mask = octets.map(&:mask).join('.')
|
146
145
|
|
147
146
|
subnet_bits = (subnet_mask.split('.')[class_n]).to_i.to_s(2).count("1")
|
@@ -170,8 +169,7 @@ class SubnetCalc
|
|
170
169
|
magic_number: magic_number,
|
171
170
|
hosts: hosts_per_subnet - 2,
|
172
171
|
subnet_mask: subnet_mask,
|
173
|
-
subnet_bitmask: subnet_mask.split('.').map
|
174
|
-
{|x| ('0' * 7 + x.to_i.to_s(2))[-8..-1]},
|
172
|
+
subnet_bitmask: subnet_mask.split('.').map {|x| "%08d" % x.to_i.to_s(2)},
|
175
173
|
prefix: prefix,
|
176
174
|
subnets: subnets,
|
177
175
|
range: "%s-%s" % [first_ip, last_ip],
|
@@ -288,9 +286,9 @@ EOF
|
|
288
286
|
class_subnets(n, block_size) do |network, first, last, broadcast|
|
289
287
|
|
290
288
|
{
|
291
|
-
|
292
|
-
|
293
|
-
|
289
|
+
network: [network, 0].join('.'),
|
290
|
+
first: [network, 1].join('.'),
|
291
|
+
last: [broadcast, 254].join('.'),
|
294
292
|
broadcast: [broadcast, 255].join('.')
|
295
293
|
}
|
296
294
|
|
@@ -303,15 +301,15 @@ EOF
|
|
303
301
|
class_subnets(n, block_size) do |network, first, last, broadcast|
|
304
302
|
|
305
303
|
{
|
306
|
-
|
307
|
-
|
308
|
-
|
304
|
+
network: [network, 0, 0].join('.'),
|
305
|
+
first: [network, 1, 1].join('.'),
|
306
|
+
last: [broadcast, 255, 254].join('.'),
|
309
307
|
broadcast: [broadcast, 255, 255].join('.')
|
310
308
|
}
|
311
309
|
|
312
310
|
end
|
313
311
|
|
314
|
-
end
|
312
|
+
end
|
315
313
|
|
316
314
|
def indent(s, i=2)
|
317
315
|
s.lines.map{|x| ' ' * i + x}.join
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
��e<�Zך?�����T˒3 �Z/ձ���w��:
|
2
|
+
����4����ѷ�^T�A������k5�sk6m9�����syyM����ފ�-�8�{߱�(�'���3<�l�N�h��)�ў��\8�����~r���P�ay�N"� ul�-�3��J4f�L�]O"#J�<����h+�Bf�!�K�{������e0��f�́y���1.������:ԯ��z-;���� ���Kj�[
|