ping-rb 0.1.1 → 0.2.0

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 +184 -199
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1de01bad3b59e55832e5e69bd9d20e5ba2df213333d3317367a6aa72ced8485
4
- data.tar.gz: 55602ede9ea703d6582ffe859dca657764b627d909ae64db0437aa6eb6a044a1
3
+ metadata.gz: 22cd77d2afc65caddf65c85a4b4eb564ace7de279aa2dad8a97a40e29b2e514e
4
+ data.tar.gz: 6a7198318548fdd5481184838e08a213ea6ed8f723a0853e2e8ba99aaa6418b6
5
5
  SHA512:
6
- metadata.gz: 226638bbc9e797a696fbe5dacb9648849e724a0cf7f06e8d2455f3e95cb6883d816ad9e258661a25e2c4d3b0a19018616e2c012bc0b355ff06d06ee7fcd24a47
7
- data.tar.gz: 434b3dcd81c2a31481ba8c91e15edbe264679c1813c3bb00bd5c1b80be68a521e44580b580823933c490cfec0ff2fb1955ee681342ad9951ac301f83922929d4
6
+ metadata.gz: fc2a5321fdec963edf85149f6015748aafa95920ab3414350680f026df54e98ced254a91e0886ef23a9b24bbff11d6ffcf3d95c7898c1d220b0481d9fb58c0e8
7
+ data.tar.gz: c64e133a6fd260c7250f646c5948da57e5a3e69a0f6900c226b8a3f969ff657461faae7280c3a0f1792b6db760516eb0b6495523e64fa8f882944109b8f4357c
data/lib/ping-rb.rb CHANGED
@@ -6,240 +6,225 @@ options = {}
6
6
  OptionParser.new do |opts|
7
7
  # NOTE: Explain the Ping-rb
8
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
- # NOTE: Ping the external IP (FOR 10 TIME)
9
+ # NOTE: Ping the external IP/DNS
10
10
  opts.on('-e', '--external NAME', 'External ping') do |host_external_option|
11
- puts "\nPing the external IP (FOR 10 TIME)\n----------------------------------\n"
11
+ puts "\nPing the external IP\n----------------------------------\n"
12
+ print 'Count: '
13
+ count = gets.chomp.to_s
12
14
  puts "IP\t\t\t statuse\n----------------|-----------------"
13
- 10.times do
14
- check = Net::Ping::External.new(host_external_option)
15
- if check.ping? == true
16
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
17
- else
18
- puts host_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
19
23
  end
20
- end
21
- end
22
- # NOTE: Ping the external IP (YOU CAN PING FOR EVER)
23
- opts.on('-E', '--external-loop NAME', 'External ping (LOOP)') do |host_external_loop_option|
24
- puts "\nPing the external IP (LOOP)\n----------------------------------\n"
25
- puts "IP\t\t\t statuse\n----------------|-----------------"
26
- loop do
27
- check = Net::Ping::External.new(host_external_loop_option)
28
- if check.ping? == true
29
- puts host_external_loop_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
30
- else
31
- puts host_external_loop_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
32
32
  end
33
33
  end
34
34
  end
35
- # NOTE: Ping the HTTP ADDRESS (FOR 10 TIMES)
36
- opts.on('-h', '--http NAME', 'HTTP ping (FOR 10 TIMES)') do |host_http_option|
37
- puts "\nPing the HTTP ADDRESS (FOR 10 TIME)\n----------------------------------\n"
35
+ # NOTE: Ping the HTTP address
36
+ opts.on('-h', '--http NAME', 'HTTP ping') do |host_http_option|
37
+ puts "\nPing the HTTP ADDRESS\n----------------------------------\n"
38
+ print 'Count: '
39
+ count = gets.chomp.to_s
38
40
  puts "Address\t\t\t statuse\n----------------|-----------------"
39
- 10.times do
40
- check = Net::Ping::HTTP.new(host_http_option)
41
- if check.ping? == true
42
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
43
- else
44
- puts host_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
45
49
  end
46
- end
47
- end
48
- # NOTE: Ping the HTTP ADDRESS (LOOP)
49
- opts.on('-H', '--http-loop NAME', 'HTTP ping (LOOP)') do |host_http_loop_option|
50
- puts "\nPing the HTTP ADDRESS (LOOP)\n----------------------------------\n"
51
- puts "Address\t\t\t statuse\n----------------|-----------------"
52
- loop do
53
- check = Net::Ping::HTTP.new(host_http_loop_option)
54
- if check.ping? == true
55
- puts host_http_loop_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
56
- else
57
- puts host_http_loop_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
58
58
  end
59
59
  end
60
60
  end
61
- # NOTE: Ping the TCP ADDRESS/IP (FOR 10 TIMES)
62
- opts.on('-t', '--tcp NAME', 'TCP ping (FOR 10 TIMES)') do |host_tcp_option|
63
- puts "\nPing the ADDRESS/IP (FOR 10 TIMES)\n----------------------------------\n"
61
+ # NOTE: Ping the TCP ADDRESS/IP
62
+ 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
64
66
  puts "Address/IP\t\t statuse\n----------------|-----------------"
65
- 10.times do
66
- check = Net::Ping::TCP.new(host_tcp_option)
67
- if check.ping? == true
68
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
69
- else
70
- puts host_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
71
75
  end
72
- end
73
- end
74
- # NOTE: Ping the TCP ADDRESS/IP (LOOP)
75
- opts.on('-T', '--tcp-loop NAME', 'TCP ping (LOOP)') do |_host_tcp_Loop_option|
76
- puts "\nPing the ADDRESS/IP (LOOP)\n----------------------------------\n"
77
- puts "Address/IP\t\t statuse\n----------------|-----------------"
78
- loop do
79
- check = Net::Ping::TCP.new(host_tcp_loop_option)
80
- if check.ping? == true
81
- puts host_tcp_loop_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
82
- else
83
- puts host_tcp_loop_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
84
84
  end
85
85
  end
86
86
  end
87
- # NOTE: Ping the UDP ADDRESS/IP (FOR 10 TIMES)
88
- opts.on('-u', '--udp NAME', 'TCP ping (FOR 10 TIMES)') do |host_udp_option|
89
- puts "\nPing the ADDRESS/IP (FOR 10 TIMES)\n----------------------------------\n"
87
+ # NOTE: Ping the UDP ADDRESS/IP
88
+ 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
90
92
  puts "Address/IP\t\t statuse\n----------------|-----------------"
91
- 10.times do
92
- check = Net::Ping::UDP.new(host_udp_option)
93
- if check.ping? == true
94
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
95
- else
96
- puts host_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
97
101
  end
98
- end
99
- end
100
- # NOTE: Ping the UDP ADDRESS/IP (LOOP)
101
- opts.on('-u', '--udp NAME', 'TCP ping (LOOP)') do |host_udp_loop_option|
102
- puts "\nPing the ADDRESS/IP (LOOP)\n----------------------------------\n"
103
- puts "Address/IP\t\t statuse\n----------------|-----------------"
104
- loop do
105
- check = Net::Ping::UDP.new(host_udp_option)
106
- if check.ping? == true
107
- puts host_udp_loop_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
108
- else
109
- puts host_udp_loop_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
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
110
110
  end
111
111
  end
112
112
  end
113
+
113
114
  # NOTE: Verbose command for external ping
114
115
  opts.on('--verbose-e NAME', 'Verbose output for External ping') do |host_verbose_external_option|
115
- 5.times do
116
- check = Net::Ping::External.new(host_verbose_external_option)
117
- if check.ping? == true
118
- puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
119
- print 'Timeout:'
120
- p check.timeout
121
- print 'Duration:'
122
- p check.duration
123
- print 'Port:'
124
- p check.port
125
- print 'warning: '
126
- p check.warning
127
- print 'Exception: '
128
- p check.exception
129
- puts '-------------------------------------------------------------------------------------------'
130
- else
131
- puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
132
- print 'Timeout:'
133
- p check.timeout
134
- print 'Duration:'
135
- p check.duration
136
- print 'Port:'
137
- p check.port
138
- print 'warning: '
139
- p check.warning
140
- print 'Exception: '
141
- p check.exception
142
- puts '-------------------------------------------------------------------------------------------'
143
- end
116
+ check = Net::Ping::External.new(host_verbose_external_option)
117
+ if check.ping? == true
118
+ puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
119
+ print 'Timeout:'
120
+ p check.timeout
121
+ print 'Duration:'
122
+ p check.duration
123
+ print 'Port:'
124
+ p check.port
125
+ print 'warning: '
126
+ p check.warning
127
+ print 'Exception: '
128
+ p check.exception
129
+ else
130
+ puts host_verbose_external_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
131
+ print 'Timeout:'
132
+ p check.timeout
133
+ print 'Duration:'
134
+ p check.duration
135
+ print 'Port:'
136
+ p check.port
137
+ print 'warning: '
138
+ p check.warning
139
+ print 'Exception: '
140
+ p check.exception
144
141
  end
145
142
  end
146
143
  # NOTE: Verbose command for HTTP ping
147
144
  opts.on('--verbose-h NAME', 'Verbose output for HTTP ping') do |host_verbose_http_option|
148
- 5.times do
149
- check = Net::Ping::HTTP.new(host_verbose_http_option)
150
- if check.ping? == true
151
- puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
152
- print 'Timeout:'
153
- p check.timeout
154
- print 'Duration:'
155
- p check.duration
156
- print 'Port:'
157
- p check.port
158
- print 'warning: '
159
- p check.warning
160
- print 'Exception: '
161
- p check.exception
162
- puts '-------------------------------------------------------------------------------------------'
163
- else
164
- puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
165
- print 'Timeout:'
166
- p check.timeout
167
- print 'Duration:'
168
- p check.duration
169
- print 'Port:'
170
- p check.port
171
- print 'warning: '
172
- p check.warning
173
- print 'Exception: '
174
- p check.exception
175
- puts '-------------------------------------------------------------------------------------------'
176
- end
145
+ check = Net::Ping::HTTP.new(host_verbose_http_option)
146
+ if check.ping? == true
147
+ puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
148
+ print 'Timeout:'
149
+ p check.timeout
150
+ print 'Duration:'
151
+ p check.duration
152
+ print 'Port:'
153
+ p check.port
154
+ print 'warning: '
155
+ p check.warning
156
+ print 'Exception: '
157
+ p check.exception
158
+ else
159
+ puts host_verbose_http_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
160
+ print 'Timeout:'
161
+ p check.timeout
162
+ print 'Duration:'
163
+ p check.duration
164
+ print 'Port:'
165
+ p check.port
166
+ print 'warning: '
167
+ p check.warning
168
+ print 'Exception: '
169
+ p check.exception
177
170
  end
178
171
  end
179
172
  # NOTE: Verbose command for TCP ping
180
173
  opts.on('--verbose-t NAME', 'Verbose output for TCP ping') do |host_verbose_tcp_option|
181
- 5.times do
182
- check = Net::Ping::TCP.new(host_verbose_tcp_option)
183
- if check.ping? == true
184
- puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
185
- print 'Timeout:'
186
- p check.timeout
187
- print 'Duration:'
188
- p check.duration
189
- print 'Port:'
190
- p check.port
191
- print 'warning: '
192
- p check.warning
193
- print 'Exception: '
194
- p check.exception
195
- puts '-------------------------------------------------------------------------------------------'
196
- else
197
- puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
198
- print 'Timeout:'
199
- p check.timeout
200
- print 'Duration:'
201
- p check.duration
202
- print 'Port:'
203
- p check.port
204
- print 'warning: '
205
- p check.warning
206
- print 'Exception: '
207
- p check.exception
208
- puts '-------------------------------------------------------------------------------------------'
209
- end
174
+ check = Net::Ping::TCP.new(host_verbose_tcp_option)
175
+ if check.ping? == true
176
+ puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
177
+ print 'Timeout:'
178
+ p check.timeout
179
+ print 'Duration:'
180
+ p check.duration
181
+ print 'Port:'
182
+ p check.port
183
+ print 'warning: '
184
+ p check.warning
185
+ print 'Exception: '
186
+ p check.exception
187
+ else
188
+ puts host_verbose_tcp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
189
+ print 'Timeout:'
190
+ p check.timeout
191
+ print 'Duration:'
192
+ p check.duration
193
+ print 'Port:'
194
+ p check.port
195
+ print 'warning: '
196
+ p check.warning
197
+ print 'Exception: '
198
+ p check.exception
210
199
  end
211
200
  end
212
201
  # NOTE: Verbose command for UDP ping
213
202
  opts.on('--verbose-u NAME', 'Verbose output for UDP ping') do |host_verbose_udp_option|
214
- 5.times do
215
- check = Net::Ping::TCP.new(host_verbose_udp_option)
216
- if check.ping? == true
217
- puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
218
- print 'Timeout:'
219
- p check.timeout
220
- print 'Duration:'
221
- p check.duration
222
- print 'Port:'
223
- p check.port
224
- print 'warning: '
225
- p check.warning
226
- print 'Exception: '
227
- p check.exception
228
- puts '-------------------------------------------------------------------------------------------'
229
- else
230
- puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
231
- print 'Timeout:'
232
- p check.timeout
233
- print 'Duration:'
234
- p check.duration
235
- print 'Port:'
236
- p check.port
237
- print 'warning: '
238
- p check.warning
239
- print 'Exception: '
240
- p check.exception
241
- puts '-------------------------------------------------------------------------------------------'
242
- end
203
+ check = Net::Ping::TCP.new(host_verbose_udp_option)
204
+ if check.ping? == true
205
+ puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tUP".colorize(:green)
206
+ print 'Timeout:'
207
+ p check.timeout
208
+ print 'Duration:'
209
+ p check.duration
210
+ print 'Port:'
211
+ p check.port
212
+ print 'warning: '
213
+ p check.warning
214
+ print 'Exception: '
215
+ p check.exception
216
+ else
217
+ puts host_verbose_udp_option.to_s.colorize(:light_blue) + "\t\t\tDOWN".colorize(:red)
218
+ print 'Timeout:'
219
+ p check.timeout
220
+ print 'Duration:'
221
+ p check.duration
222
+ print 'Port:'
223
+ p check.port
224
+ print 'warning: '
225
+ p check.warning
226
+ print 'Exception: '
227
+ p check.exception
243
228
  end
244
229
  end
245
230
  # NOTE: Help option
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.1.1
4
+ version: 0.2.0
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-07-29 00:00:00.000000000 Z
11
+ date: 2022-08-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: It's a simple CLI tool, but it is a useful tool to ping computers and
14
14
  systems.
@@ -20,11 +20,11 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - bin/ping-rb
22
22
  - lib/ping-rb.rb
23
- homepage: https://rubygems.org/gems/ping-rb
23
+ homepage: https://github.com/Mr-Fox-h/Ping-rb
24
24
  licenses:
25
25
  - MIT
26
26
  metadata: {}
27
- post_install_message:
27
+ post_install_message:
28
28
  rdoc_options: []
29
29
  require_paths:
30
30
  - lib
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: 1.8.11
41
41
  requirements: []
42
42
  rubygems_version: 3.3.15
43
- signing_key:
43
+ signing_key:
44
44
  specification_version: 4
45
45
  summary: Ping with Ruby!
46
46
  test_files: []