ping-rb 0.2.1 → 0.2.3

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 +4 -4
  2. data/lib/ping-rb.rb +143 -114
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb9fbaafbe7636ddbe0340b495d22a90a2811358efee8247b64fb026a0cc4b92
4
- data.tar.gz: 3f969184976b09f57a5ef0cbb23236cd1bdff060d2633a608eec02f148f9e8bb
3
+ metadata.gz: a9d360ddbe9b6d5b06ca72a8645a469e8b3a5803e8cd03e087295b0b7243396b
4
+ data.tar.gz: 21b13a2c0588618f94408028f6b7432da881f9bb5145e54bc3d092dba664f200
5
5
  SHA512:
6
- metadata.gz: 484c4784937f73e7bfd39eda6d7c830a7ac37ca8674414ff03ca3e0a913ba7b665bd11ab5f898dd3f5b067114a7cd23c70ed8433b6490499ea7557b9128a5ddc
7
- data.tar.gz: 795335dd142d9fda3dff7f13fdff63f820254680899732448ab3321a915bbb0a38e29536d7a6caa832c99889dbae90b20e6db298b939f786aeb7c88e7e6a66b9
6
+ metadata.gz: 3f958f32d88a5d2bf8e7f5def7a9a1d18af32e3bcbcd3dbf7674d8e88230a69138979808a81748b69228dff9fc3b06378c55d2d7d16e9d9910c40894b0c7c6d3
7
+ data.tar.gz: a89d4f542c845268dbed564453ff19789c3cb8c0d4404fb1f931476ed822757c28cbfa98db4116e1194ec7def2e407afab9076d9014ee7f297a0372b2bef39e3
data/lib/ping-rb.rb CHANGED
@@ -4,109 +4,126 @@ require 'colorize'
4
4
 
5
5
  options = {}
6
6
  OptionParser.new do |opts|
7
+
7
8
  # NOTE: Explain the Ping-rb
8
- opts.banner = "Explain: Send ICMP ECHO_REQUEST to network hosts\n------------------------------------------------\nAuthor: Meisam Heidari\nGithub: https://github.com/Mr-Fox-h\nGitlab: https://gitlab.com/mr-fox-h\nBitbucket: https://bitbucket.org/mr-fox-h\n------------------------------------------------\n"
9
+ opts.banner = "Explain: Send ICMP ECHO_REQUEST to network hosts\nVERSION 0.2.2\n------------------------------------------------\nAuthor: Meisam Heidari\nGithub: https://github.com/Mr-Fox-h\nGitlab: https://gitlab.com/mr-fox-h\nBitbucket: https://bitbucket.org/mr-fox-h\n------------------------------------------------\n"
10
+
9
11
  # NOTE: Ping the external IP/DNS
10
12
  opts.on('-e', '--external NAME', 'External ping') do |host_external_option|
11
13
  puts "\nPing the external IP\n----------------------------------\n"
12
- print 'Count: '
13
- count = gets.chomp.to_s
14
- puts "IP\t\t\t statuse\n----------------|-----------------"
15
- if %w[l L loop Loop LOOP].include?(count)
16
- loop do
17
- check = Net::Ping::External.new(host_external_option)
18
- if check.ping? == true
19
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
20
- else
21
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
22
- end
23
- end
24
- else
25
- count.to_i.times do
26
- check = Net::Ping::External.new(host_external_option)
27
- if check.ping? == true
28
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
29
- else
30
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
31
- end
14
+ 4.times do
15
+ check = Net::Ping::External.new(host_external_option)
16
+ if check.ping? == true
17
+ puts "\aADDRESS IS " + host_external_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
18
+ sleep 1
19
+ else
20
+ puts "\aADDRESS IS " + host_external_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
21
+ sleep 1
32
22
  end
33
23
  end
34
24
  end
25
+
35
26
  # NOTE: Ping the HTTP address
36
27
  opts.on('-h', '--http NAME', 'HTTP ping') do |host_http_option|
37
28
  puts "\nPing the HTTP ADDRESS\n----------------------------------\n"
38
- print 'Count: '
39
- count = gets.chomp.to_s
40
- puts "Address\t\t\t statuse\n----------------|-----------------"
41
- if %w[l L loop Loop LOOP].include?(count)
42
- loop do
43
- check = Net::Ping::External.new(host_http_option)
44
- if check.ping? == true
45
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
46
- else
47
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
48
- end
49
- end
50
- else
51
- count.to_i.times do
52
- check = Net::Ping::External.new(host_http_option)
53
- if check.ping? == true
54
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
55
- else
56
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
57
- end
29
+ 4.times do
30
+ check = Net::Ping::External.new(host_http_option)
31
+ if check.ping? == true
32
+ puts "\aADDRESS IS " + host_http_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
33
+ sleep 1
34
+ else
35
+ puts "\aADDRESS IS " + host_http_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
36
+ sleep 1
58
37
  end
59
38
  end
60
39
  end
40
+
61
41
  # NOTE: Ping the TCP ADDRESS/IP
62
42
  opts.on('-t', '--tcp NAME', 'TCP ping') do |host_tcp_option|
63
- puts "\nPing the ADDRESS/IP\n----------------------------------\n"
64
- print 'Count: '
65
- count = gets.chomp.to_s
66
- puts "Address/IP\t\t statuse\n----------------|-----------------"
67
- if %w[l L loop Loop LOOP].include?(count)
68
- loop do
69
- check = Net::Ping::External.new(host_tcp_option)
70
- if check.ping? == true
71
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
72
- else
73
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
74
- end
75
- end
76
- else
77
- count.to_i.times do
78
- check = Net::Ping::External.new(host_tcp_option)
79
- if check.ping? == true
80
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
81
- else
82
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
83
- end
43
+ puts "\nPing the TCP ADDRESS/IP\n----------------------------------\n"
44
+ 4.to_i.times do
45
+ check = Net::Ping::External.new(host_tcp_option)
46
+ if check.ping? == true
47
+ puts "\aADDRESS IS " + host_tcp_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
48
+ sleep 1
49
+ else
50
+ puts "\aADDRESS IS " + host_tcp_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
51
+ sleep 1
84
52
  end
85
53
  end
86
54
  end
55
+
87
56
  # NOTE: Ping the UDP ADDRESS/IP
88
57
  opts.on('-u', '--udp NAME', 'UDP ping') do |host_udp_option|
89
- puts "\nPing the ADDRESS/IP\n----------------------------------\n"
90
- print 'Count: '
91
- count = gets.chomp.to_s
92
- puts "Address/IP\t\t statuse\n----------------|-----------------"
93
- if %w[l L loop Loop LOOP].include?(count)
94
- loop do
95
- check = Net::Ping::External.new(host_udp_option)
96
- if check.ping? == true
97
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
98
- else
99
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
100
- end
58
+ puts "\nPing the UDP ADDRESS/IP\n----------------------------------\n"
59
+ 4.to_i.times do
60
+ check = Net::Ping::External.new(host_udp_option)
61
+ if check.ping? == true
62
+ puts "\aADDRESS IS " + host_udp_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
63
+ sleep 1
64
+ else
65
+ puts "\aADDRESS IS " + host_udp_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
66
+ sleep 1
101
67
  end
102
- else
103
- count.to_i.times do
104
- check = Net::Ping::External.new(host_udp_option)
105
- if check.ping? == true
106
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
107
- else
108
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
109
- end
68
+ end
69
+ end
70
+
71
+ # NOTE: Ping the External IP/DNS (loop mode)
72
+ opts.on('--external-loop NAME', 'External ping (LOOP MODE)') do |host_external_loop_option|
73
+ puts "\nPing the external IP (LOOP MODE)\n----------------------------------\n"
74
+ loop do
75
+ check = Net::Ping::External.new(host_external_loop_option)
76
+ if check.ping? == true
77
+ puts "ADDRESS IS " + host_external_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
78
+ sleep 1
79
+ else
80
+ puts "ADDRESS IS " + host_external_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
81
+ sleep 1
82
+ end
83
+ end
84
+ end
85
+
86
+ # NOTE: Ping the HTTP address (loop mode)
87
+ opts.on('--http-loop NAME', 'HTTP ping (LOOP MODE)') do |host_http_loop_option|
88
+ puts "\nPing the HTTP ADDRESS (LOOP MODE)\n----------------------------------\n"
89
+ loop do
90
+ check = Net::Ping::External.new(host_http_loop_option)
91
+ if check.ping? == true
92
+ puts "ADDRESS IS " + host_http_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
93
+ sleep 1
94
+ else
95
+ puts "ADDRESS IS " + host_http_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
96
+ sleep 1
97
+ end
98
+ end
99
+ end
100
+
101
+ # NOTE: Ping the TCP address/IP (loop mode)
102
+ opts.on('--tcp-loop NAME', 'TCP ping (LOOP MODE)') do |host_tcp_loop_option|
103
+ puts "\nPing the TCP ADDRESS/IP (LOOP MODE)\n----------------------------------\n"
104
+ loop do
105
+ check = Net::Ping::External.new(host_tcp_loop_option)
106
+ if check.ping? == true
107
+ puts "ADDRESS IS " + host_tcp_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
108
+ sleep 1
109
+ else
110
+ puts "ADDRESS IS " + host_tcp_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
111
+ sleep 1
112
+ end
113
+ end
114
+ end
115
+
116
+ # NOTE: Ping the UDP ADDRESS/IP (loop mode)
117
+ opts.on('--udp-loop NAME', 'UDP ping (LOOP MODE)') do |host_udp_loop_option|
118
+ puts "\nPing the UDP ADDRESS/IP (LOOP MODE)\n----------------------------------\n"
119
+ loop do
120
+ check = Net::Ping::External.new(host_udp_loop_option)
121
+ if check.ping? == true
122
+ puts "ADDRESS IS " + host_udp_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "UP".colorize(:green)
123
+ sleep 1
124
+ else
125
+ puts "ADDRESS IS " + host_udp_loop_option.to_s.colorize(:light_blue) + "| STATUS IS " + "DOWN".colorize(:red)
126
+ sleep 1
110
127
  end
111
128
  end
112
129
  end
@@ -115,24 +132,26 @@ OptionParser.new do |opts|
115
132
  opts.on('--verbose-e NAME', 'Verbose output for External ping') do |host_verbose_external_option|
116
133
  check = Net::Ping::External.new(host_verbose_external_option)
117
134
  if check.ping? == true
118
- puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
119
- print 'Timeout:'
135
+ puts "Address: " + host_verbose_external_option.to_s.colorize(:light_blue)
136
+ puts "Status: " + "UP".colorize(:green)
137
+ print 'Timeout: '
120
138
  p check.timeout
121
- print 'Duration:'
139
+ print 'Duration: '
122
140
  p check.duration
123
- print 'Port:'
141
+ print 'Port: '
124
142
  p check.port
125
143
  print 'warning: '
126
144
  p check.warning
127
145
  print 'Exception: '
128
146
  p check.exception
129
147
  else
130
- puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
131
- print 'Timeout:'
148
+ puts "Address: " + host_verbose_external_option.to_s.colorize(:light_blue)
149
+ puts "Status: " + "DOWN".colorize(:red)
150
+ print 'Timeout: '
132
151
  p check.timeout
133
- print 'Duration:'
152
+ print 'Duration: '
134
153
  p check.duration
135
- print 'Port:'
154
+ print 'Port: '
136
155
  p check.port
137
156
  print 'warning: '
138
157
  p check.warning
@@ -140,28 +159,31 @@ OptionParser.new do |opts|
140
159
  p check.exception
141
160
  end
142
161
  end
162
+
143
163
  # NOTE: Verbose command for HTTP ping
144
164
  opts.on('--verbose-h NAME', 'Verbose output for HTTP ping') do |host_verbose_http_option|
145
165
  check = Net::Ping::HTTP.new(host_verbose_http_option)
146
166
  if check.ping? == true
147
- puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
148
- print 'Timeout:'
167
+ puts "Address: " + host_verbose_http_option.to_s.colorize(:light_blue)
168
+ puts "Status: " + "UP".colorize(:green)
169
+ print 'Timeout: '
149
170
  p check.timeout
150
- print 'Duration:'
171
+ print 'Duration: '
151
172
  p check.duration
152
- print 'Port:'
173
+ print 'Port: '
153
174
  p check.port
154
175
  print 'warning: '
155
176
  p check.warning
156
177
  print 'Exception: '
157
178
  p check.exception
158
179
  else
159
- puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
160
- print 'Timeout:'
180
+ puts "Address: " + host_verbose_http_option.to_s.colorize(:light_blue)
181
+ puts "Status: " + "DOWN".colorize(:red)
182
+ print 'Timeout: '
161
183
  p check.timeout
162
- print 'Duration:'
184
+ print 'Duration: '
163
185
  p check.duration
164
- print 'Port:'
186
+ print 'Port: '
165
187
  p check.port
166
188
  print 'warning: '
167
189
  p check.warning
@@ -169,28 +191,31 @@ OptionParser.new do |opts|
169
191
  p check.exception
170
192
  end
171
193
  end
194
+
172
195
  # NOTE: Verbose command for TCP ping
173
196
  opts.on('--verbose-t NAME', 'Verbose output for TCP ping') do |host_verbose_tcp_option|
174
197
  check = Net::Ping::TCP.new(host_verbose_tcp_option)
175
198
  if check.ping? == true
176
- puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
177
- print 'Timeout:'
199
+ puts "Address: " + host_verbose_tcp_option.to_s.colorize(:light_blue)
200
+ puts "Status: " + "UP".colorize(:green)
201
+ print 'Timeout: '
178
202
  p check.timeout
179
- print 'Duration:'
203
+ print 'Duration: '
180
204
  p check.duration
181
- print 'Port:'
205
+ print 'Port: '
182
206
  p check.port
183
207
  print 'warning: '
184
208
  p check.warning
185
209
  print 'Exception: '
186
210
  p check.exception
187
211
  else
188
- puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
189
- print 'Timeout:'
212
+ puts "Address: " + host_verbose_tcp_option.to_s.colorize(:light_blue)
213
+ puts "Status: " + "DOWN".colorize(:red)
214
+ print 'Timeout: '
190
215
  p check.timeout
191
- print 'Duration:'
216
+ print 'Duration: '
192
217
  p check.duration
193
- print 'Port:'
218
+ print 'Port: '
194
219
  p check.port
195
220
  print 'warning: '
196
221
  p check.warning
@@ -198,28 +223,31 @@ OptionParser.new do |opts|
198
223
  p check.exception
199
224
  end
200
225
  end
226
+
201
227
  # NOTE: Verbose command for UDP ping
202
228
  opts.on('--verbose-u NAME', 'Verbose output for UDP ping') do |host_verbose_udp_option|
203
229
  check = Net::Ping::TCP.new(host_verbose_udp_option)
204
230
  if check.ping? == true
205
- puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
206
- print 'Timeout:'
231
+ puts "Address: " + host_verbose_udp_option.to_s.colorize(:light_blue)
232
+ puts "Status: " + "UP".colorize(:green)
233
+ print 'Timeout: '
207
234
  p check.timeout
208
- print 'Duration:'
235
+ print 'Duration: '
209
236
  p check.duration
210
- print 'Port:'
237
+ print 'Port: '
211
238
  p check.port
212
239
  print 'warning: '
213
240
  p check.warning
214
241
  print 'Exception: '
215
242
  p check.exception
216
243
  else
217
- puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
218
- print 'Timeout:'
244
+ puts "Address: " + host_verbose_udp_option.to_s.colorize(:light_blue)
245
+ puts "Status: " + "DOWN".colorize(:red)
246
+ print 'Timeout: '
219
247
  p check.timeout
220
- print 'Duration:'
248
+ print 'Duration: '
221
249
  p check.duration
222
- print 'Port:'
250
+ print 'Port: '
223
251
  p check.port
224
252
  print 'warning: '
225
253
  p check.warning
@@ -227,6 +255,7 @@ OptionParser.new do |opts|
227
255
  p check.exception
228
256
  end
229
257
  end
258
+
230
259
  # NOTE: Help option
231
260
  opts.on('-a', '--aid', '--help', 'Print this help') do
232
261
  puts opts
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ping-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meisam Heidari
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2023-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ping
@@ -72,7 +72,7 @@ homepage: https://github.com/Mr-Fox-h/Ping-rb
72
72
  licenses:
73
73
  - MIT
74
74
  metadata: {}
75
- post_install_message:
75
+ post_install_message:
76
76
  rdoc_options: []
77
77
  require_paths:
78
78
  - lib
@@ -87,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.8.11
89
89
  requirements: []
90
- rubygems_version: 3.3.5
91
- signing_key:
90
+ rubygems_version: 3.3.15
91
+ signing_key:
92
92
  specification_version: 4
93
93
  summary: Ping with Ruby!
94
94
  test_files: []