ping-rb 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/ping-rb.rb +184 -199
- metadata +53 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb9fbaafbe7636ddbe0340b495d22a90a2811358efee8247b64fb026a0cc4b92
|
4
|
+
data.tar.gz: 3f969184976b09f57a5ef0cbb23236cd1bdff060d2633a608eec02f148f9e8bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484c4784937f73e7bfd39eda6d7c830a7ac37ca8674414ff03ca3e0a913ba7b665bd11ab5f898dd3f5b067114a7cd23c70ed8433b6490499ea7557b9128a5ddc
|
7
|
+
data.tar.gz: 795335dd142d9fda3dff7f13fdff63f820254680899732448ab3321a915bbb0a38e29536d7a6caa832c99889dbae90b20e6db298b939f786aeb7c88e7e6a66b9
|
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
|
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
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
36
|
-
opts.on('-h', '--http NAME', 'HTTP ping
|
37
|
-
puts "\nPing the HTTP ADDRESS
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
62
|
-
opts.on('-t', '--tcp NAME', 'TCP ping
|
63
|
-
puts "\nPing the ADDRESS/IP
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
88
|
-
opts.on('-u', '--udp NAME', '
|
89
|
-
puts "\nPing the ADDRESS/IP
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
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
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
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,15 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ping-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meisam Heidari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-ping
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.8
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.8
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: optparse
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.2.0
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.2.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: colorize
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.1
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.8.1
|
13
61
|
description: It's a simple CLI tool, but it is a useful tool to ping computers and
|
14
62
|
systems.
|
15
63
|
email: mr.fox@iran.ir
|
@@ -20,7 +68,7 @@ extra_rdoc_files: []
|
|
20
68
|
files:
|
21
69
|
- bin/ping-rb
|
22
70
|
- lib/ping-rb.rb
|
23
|
-
homepage: https://
|
71
|
+
homepage: https://github.com/Mr-Fox-h/Ping-rb
|
24
72
|
licenses:
|
25
73
|
- MIT
|
26
74
|
metadata: {}
|
@@ -39,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
87
|
- !ruby/object:Gem::Version
|
40
88
|
version: 1.8.11
|
41
89
|
requirements: []
|
42
|
-
rubygems_version: 3.3.
|
90
|
+
rubygems_version: 3.3.5
|
43
91
|
signing_key:
|
44
92
|
specification_version: 4
|
45
93
|
summary: Ping with Ruby!
|