thecore_tcp_debug 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +2 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/rails_admin/custom/thecore/tcp_debug.js +42 -0
- data/app/assets/stylesheets/rails_admin/custom/thecore/tcp_debug.scss +76 -0
- data/app/views/rails_admin/main/tcp_debug.html.erb +33 -0
- data/config/initializers/add_to_db_migration.rb +2 -0
- data/config/initializers/after_initialize.rb +42 -0
- data/config/initializers/assets.rb +4 -0
- data/config/locales/en.thecore_tcp_debug.yml +15 -0
- data/config/locales/it.thecore_tcp_debug.yml +15 -0
- data/db/seeds.rb +1 -0
- data/lib/thecore_tcp_debug/engine.rb +4 -0
- data/lib/thecore_tcp_debug/version.rb +3 -0
- data/lib/thecore_tcp_debug.rb +9 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c26466ceff75475d4cd1dabd0ac92d59cced444666871c2078d307c0d97d9c71
|
4
|
+
data.tar.gz: f9a99ca911c2ab999a4f7a7e8b0d17dafd7eb21013e05986be0603af30678e3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 36f0cd125fccb64f3ac05272af574893b7e81785ad678ea6e24eb9cb0637fff6f4a28b08365c1620b6278f8e8bce88249da7950c91b02c5a4cad029c137db9be
|
7
|
+
data.tar.gz: e43bff307ec595fc3beac4c4d01e82e515f1a0d5c52c8db3a970093321727a9b6339ae4d763c49756c7e2ec8a2cafe82f597171d2ce4ec260364635b585082bd
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Gabriele Tassoni
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ThecoreTcpDebug'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
$(document).on('turbo:load', function (event) {
|
3
|
+
currentURL = new URL(event.originalEvent.detail.url);
|
4
|
+
if(currentURL.pathname.endsWith("tcp_debug")){
|
5
|
+
hideLoader();
|
6
|
+
}
|
7
|
+
$("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
|
8
|
+
$("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
9
|
+
$("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
10
|
+
});
|
11
|
+
|
12
|
+
function hideLoader() {
|
13
|
+
$(".loader").hide();
|
14
|
+
$(".tcp-debug-response").show();
|
15
|
+
}
|
16
|
+
|
17
|
+
function showLoader() {
|
18
|
+
$(".loader").show();
|
19
|
+
$(".tcp-debug-response").hide();
|
20
|
+
}
|
21
|
+
|
22
|
+
function startTest(element) {
|
23
|
+
$("#response").empty();
|
24
|
+
typeOfTest = $(element).attr("id");
|
25
|
+
host = $(`#${typeOfTest}-host`).val();
|
26
|
+
port = $(`#${typeOfTest}-port`).val();
|
27
|
+
// console.log(typeOfTest)
|
28
|
+
// console.log(host)
|
29
|
+
// console.log(port)
|
30
|
+
showLoader();
|
31
|
+
$.get("#{rails_admin.send('tcp_debug_path')}", {
|
32
|
+
test: typeOfTest,
|
33
|
+
host: host,
|
34
|
+
port: port
|
35
|
+
}).then(function (params) {
|
36
|
+
// console.log("OK", params)
|
37
|
+
$("#response").html(params["debug_status"]).removeClass("bg-danger").addClass("bg-success");
|
38
|
+
}).catch(function (params) {
|
39
|
+
// console.log("KO", params)
|
40
|
+
$("#response").html(params["responseJSON"]["debug_status"]).removeClass("bg-success").addClass("bg-danger");
|
41
|
+
}).always(hideLoader);
|
42
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
@import 'thecore_ui_commons/variables';
|
2
|
+
|
3
|
+
// Spinner
|
4
|
+
|
5
|
+
.loader {
|
6
|
+
width: 40px;
|
7
|
+
height: 40px;
|
8
|
+
|
9
|
+
position: relative;
|
10
|
+
margin: 0 auto;
|
11
|
+
}
|
12
|
+
|
13
|
+
.double-bounce1,
|
14
|
+
.double-bounce2 {
|
15
|
+
width: 100%;
|
16
|
+
height: 100%;
|
17
|
+
border-radius: 50%;
|
18
|
+
background-color: #333;
|
19
|
+
opacity: 0.6;
|
20
|
+
position: absolute;
|
21
|
+
top: 0;
|
22
|
+
left: 0;
|
23
|
+
|
24
|
+
-webkit-animation: sk-bounce 2.0s infinite ease-in-out;
|
25
|
+
animation: sk-bounce 2.0s infinite ease-in-out;
|
26
|
+
}
|
27
|
+
|
28
|
+
.double-bounce2 {
|
29
|
+
-webkit-animation-delay: -1.0s;
|
30
|
+
animation-delay: -1.0s;
|
31
|
+
}
|
32
|
+
|
33
|
+
@-webkit-keyframes sk-bounce {
|
34
|
+
|
35
|
+
0%,
|
36
|
+
100% {
|
37
|
+
-webkit-transform: scale(0.0)
|
38
|
+
}
|
39
|
+
|
40
|
+
50% {
|
41
|
+
-webkit-transform: scale(1.0)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
@keyframes sk-bounce {
|
46
|
+
|
47
|
+
0%,
|
48
|
+
100% {
|
49
|
+
transform: scale(0.0);
|
50
|
+
-webkit-transform: scale(0.0);
|
51
|
+
}
|
52
|
+
|
53
|
+
50% {
|
54
|
+
transform: scale(1.0);
|
55
|
+
-webkit-transform: scale(1.0);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// End Spinner
|
60
|
+
|
61
|
+
div.row.tcp-debug {
|
62
|
+
margin-bottom: 1em;
|
63
|
+
}
|
64
|
+
|
65
|
+
.tcp-debug-response {
|
66
|
+
width: 100%;
|
67
|
+
margin-left: 0.1em;
|
68
|
+
height: 4em;
|
69
|
+
}
|
70
|
+
|
71
|
+
#response {
|
72
|
+
border-radius: 1em;
|
73
|
+
display: flex;
|
74
|
+
flex-direction: column;
|
75
|
+
justify-content: center;
|
76
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div class="row tcp-debug">
|
2
|
+
<div class="input-group">
|
3
|
+
<div class="input-group-prepend">
|
4
|
+
<span class="input-group-text"><%=t :tcp_address_and_port%></span>
|
5
|
+
</div>
|
6
|
+
<input type="text" class="form-control" id="telnet-host" placeholder="Host" aria-label="Host">
|
7
|
+
<input type="text" class="form-control" id="telnet-port" placeholder="Port" aria-label="Port">
|
8
|
+
<div class="input-group-append">
|
9
|
+
<button class="btn btn-outline-secondary" type="button" id="telnet" onclick="startTest(this)"><%=t :test_it %></button>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<div class="row tcp-debug">
|
14
|
+
<div class="input-group">
|
15
|
+
<div class="input-group-prepend">
|
16
|
+
<span class="input-group-text"><%=t :ping_address %></span>
|
17
|
+
</div>
|
18
|
+
<input type="text" class="form-control" id="ping-host" placeholder="Host" aria-label="Host">
|
19
|
+
<div class="input-group-append">
|
20
|
+
<button class="btn btn-outline-secondary" type="button" id="ping" onclick="startTest(this)"><%=t :test_it%></button>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="row tcp-debug-response">
|
26
|
+
<p id="response" class="response">
|
27
|
+
</p>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div class="loader">
|
31
|
+
<div class="double-bounce1"></div>
|
32
|
+
<div class="double-bounce2"></div>
|
33
|
+
</div>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.after_initialize do
|
3
|
+
RailsAdmin::Config::Actions.add_action "tcp_debug", :base, :root do
|
4
|
+
show_in_sidebar true
|
5
|
+
show_in_navigation false
|
6
|
+
breadcrumb_parent [nil]
|
7
|
+
# This ensures the action only shows up for Users
|
8
|
+
# visible? authorized?
|
9
|
+
# Not a member action
|
10
|
+
member false
|
11
|
+
# Not a colleciton action
|
12
|
+
collection false
|
13
|
+
|
14
|
+
link_icon 'fas fa-heartbeat'
|
15
|
+
|
16
|
+
# You may or may not want pjax for your action
|
17
|
+
# pjax? true
|
18
|
+
|
19
|
+
http_methods [:get]
|
20
|
+
# Adding the controller which is needed to compute calls from the ui
|
21
|
+
controller do
|
22
|
+
proc do # This is needed because we need that this code is re-evaluated each time is called
|
23
|
+
if request.xhr?
|
24
|
+
case params["test"]
|
25
|
+
when "telnet"
|
26
|
+
port_is_open = Socket.tcp(params["host"], params["port"], connect_timeout: 5) { true } rescue false
|
27
|
+
message, status = { debug_status: I18n.t("tcp_debug_telnet_ko", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 503
|
28
|
+
message, status = { debug_status: I18n.t("tcp_debug_telnet_ok", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 200 if port_is_open
|
29
|
+
when "ping"
|
30
|
+
check = Net::Ping::External.new(params["host"])
|
31
|
+
message, status = { debug_status: I18n.t("tcp_debug_ping_ko", host: params["host"].presence || "-") }, 503
|
32
|
+
message, status = { debug_status: I18n.t("tcp_debug_ping_ok", host: params["host"].presence || "-") }, 200 if check.ping?
|
33
|
+
else
|
34
|
+
message, status = { debug_status: I18n.t("invalid_test", host: params["host"]) }, 400
|
35
|
+
end
|
36
|
+
render json: message.to_json, status: status
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
tcp_debug_telnet_ko: The network address %{host} on port %{port} did not respond before timeout, please check that it is online and the service on the indicated port is active.
|
3
|
+
tcp_debug_telnet_ok: The network address %{host} on port %{port} responded successfully.
|
4
|
+
tcp_debug_ping_ko: The network address %{host} is not responding to ping.
|
5
|
+
tcp_debug_ping_ok: The network address %{host} pinged successfully.
|
6
|
+
ping_address: Ping an address
|
7
|
+
tcp_address_and_port: TCP Port Test
|
8
|
+
test_it: Run the test
|
9
|
+
invalid_test: The requested test does not exist among those available.
|
10
|
+
admin:
|
11
|
+
actions:
|
12
|
+
tcp_debug:
|
13
|
+
breadcrumb: Network Debug
|
14
|
+
menu: Network Debug
|
15
|
+
title: Network Debug
|
@@ -0,0 +1,15 @@
|
|
1
|
+
it:
|
2
|
+
tcp_debug_telnet_ko: L'indirizzo di rete %{host} sulla porta %{port} non ha risposto prima del timeout, controllare che sia online e il servizio sulla porta indicata sia attivo.
|
3
|
+
tcp_debug_telnet_ok: L'indirizzo di rete %{host} sulla porta %{port} ha risposto correttamente.
|
4
|
+
tcp_debug_ping_ko: L'indirizzo di rete %{host} non risponde al ping.
|
5
|
+
tcp_debug_ping_ok: L'indirizzo di rete %{host} ha risposto correttamente al ping.
|
6
|
+
ping_address: Ping di un indirizzo
|
7
|
+
tcp_address_and_port: Test di una porta
|
8
|
+
test_it: Avvia il test
|
9
|
+
invalid_test: Il test richiesto non esiste fra quelli disponibili.
|
10
|
+
admin:
|
11
|
+
actions:
|
12
|
+
thecore_tcp_debug:
|
13
|
+
breadcrumb: Network Debug
|
14
|
+
menu: Network Debug
|
15
|
+
title: Network Debug
|
data/db/seeds.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts "Seeding from Thecore TCP Debug"
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thecore_tcp_debug
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriele Tassoni
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-22 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
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thecore_ui_rails_admin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description: In this gem all the CSS overrides wil be tracked.
|
42
|
+
email:
|
43
|
+
- gabrieletassoni@alchemic.it
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/javascripts/rails_admin/custom/thecore/tcp_debug.js
|
52
|
+
- app/assets/stylesheets/rails_admin/custom/thecore/tcp_debug.scss
|
53
|
+
- app/views/rails_admin/main/tcp_debug.html.erb
|
54
|
+
- config/initializers/add_to_db_migration.rb
|
55
|
+
- config/initializers/after_initialize.rb
|
56
|
+
- config/initializers/assets.rb
|
57
|
+
- config/locales/en.thecore_tcp_debug.yml
|
58
|
+
- config/locales/it.thecore_tcp_debug.yml
|
59
|
+
- db/seeds.rb
|
60
|
+
- lib/thecore_tcp_debug.rb
|
61
|
+
- lib/thecore_tcp_debug/engine.rb
|
62
|
+
- lib/thecore_tcp_debug/version.rb
|
63
|
+
homepage: https://devops.bancolini.com/dev/spot/backend/wrappers/thecore-spot-overrides
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
allowed_push_host: https://rubygems.org
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.3.26
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Gemt o collect UI overrides.
|
87
|
+
test_files: []
|