thecore_tcp_debug 3.0.4 → 3.0.6
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/app/assets/javascripts/main_tcp_debug.js +56 -0
- data/app/assets/stylesheets/{rails_admin/custom/thecore/tcp_debug.scss → main_tcp_debug.scss} +0 -4
- data/app/views/rails_admin/main/tcp_debug.html.erb +32 -25
- data/config/initializers/after_initialize.rb +1 -40
- data/config/initializers/assets.rb +2 -2
- data/lib/root_actions/tcp_debug.rb +37 -0
- data/lib/thecore_tcp_debug/version.rb +2 -1
- metadata +6 -5
- data/app/assets/javascripts/rails_admin/custom/thecore/tcp_debug.js +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36f3657411177dd44a9a1911dfad3b6594059bea036e1ae4b6e1a2a5c26068e8
|
4
|
+
data.tar.gz: 2d552dba7192edc5ac828b23ff8ac3fa384d85431e3845be13effa9a0ab0ba6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf956de3a9e5be545697770600452f8e72a404290ebe4b2cccf77ca8bc06624bb328160053ae96dddf6c2a8423d467cc56051ad4dcadde122a379dafe741beb5
|
7
|
+
data.tar.gz: 501d6df8ed627e2204dee88cfe60d899754e333df07596cab98cd41e918c54dfd6b112009578997f30e04650b93073a656a67081f1286167ce9e24439e91d1fe
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
$(document).on('turbo:load', function (event) {
|
3
|
+
hideLoader();
|
4
|
+
|
5
|
+
console.log("Into TCP Debug");
|
6
|
+
// Action cable Websocket
|
7
|
+
App.cable.subscriptions.create("ActivityLogChannel", {
|
8
|
+
connected() {
|
9
|
+
console.log("Connected to the channel:", this);
|
10
|
+
this.send({ message: 'TCP Debug Client is connected', topic: "tcp_debug", namespace: "subscriptions" });
|
11
|
+
},
|
12
|
+
disconnected() {
|
13
|
+
console.log("TCP Debug Client Disconnected");
|
14
|
+
},
|
15
|
+
received(data) {
|
16
|
+
if(data["topic"] == "tcp_debug")
|
17
|
+
console.log("TCP DEBUG", data);
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
$("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
|
22
|
+
$("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
23
|
+
$("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
24
|
+
});
|
25
|
+
|
26
|
+
function hideLoader() {
|
27
|
+
$(".loader").hide();
|
28
|
+
$(".tcp-debug-response").show();
|
29
|
+
}
|
30
|
+
|
31
|
+
function showLoader() {
|
32
|
+
$(".loader").show();
|
33
|
+
$(".tcp-debug-response").hide();
|
34
|
+
}
|
35
|
+
|
36
|
+
function startTest(element) {
|
37
|
+
$("#response").empty();
|
38
|
+
typeOfTest = $(element).attr("id");
|
39
|
+
host = $(`#${typeOfTest}-host`).val();
|
40
|
+
port = $(`#${typeOfTest}-port`).val();
|
41
|
+
// console.log(typeOfTest)
|
42
|
+
// console.log(host)
|
43
|
+
// console.log(port)
|
44
|
+
showLoader();
|
45
|
+
$.get("#{rails_admin.send('tcp_debug_path')}", {
|
46
|
+
test: typeOfTest,
|
47
|
+
host: host,
|
48
|
+
port: port
|
49
|
+
}).then(function (params) {
|
50
|
+
// console.log("OK", params)
|
51
|
+
$("#response").html(params["debug_status"]).removeClass("text-danger").addClass("text-success");
|
52
|
+
}).catch(function (params) {
|
53
|
+
// console.log("KO", params)
|
54
|
+
$("#response").html(params["responseJSON"]["debug_status"]).removeClass("text-success").addClass("text-danger");
|
55
|
+
}).always(hideLoader);
|
56
|
+
}
|
@@ -1,33 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
|
2
|
+
<div class="card mb-3">
|
3
|
+
<div class="card-body">
|
4
|
+
<div class="row tcp-debug">
|
5
|
+
<div class="input-group">
|
6
|
+
<div class="input-group-prepend">
|
7
|
+
<span class="input-group-text"><%=t :tcp_address_and_port%></span>
|
8
|
+
</div>
|
9
|
+
<input type="text" class="form-control" id="telnet-host" placeholder="Host" aria-label="Host">
|
10
|
+
<input type="text" class="form-control" id="telnet-port" placeholder="Port" aria-label="Port">
|
11
|
+
<div class="input-group-append">
|
12
|
+
<button class="btn btn-outline-secondary" type="button" id="telnet" onclick="startTest(this)"><%=t :test_it %></button>
|
13
|
+
</div>
|
14
|
+
</div>
|
5
15
|
</div>
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
16
|
+
<div class="row tcp-debug">
|
17
|
+
<div class="input-group">
|
18
|
+
<div class="input-group-prepend">
|
19
|
+
<span class="input-group-text"><%=t :ping_address %></span>
|
20
|
+
</div>
|
21
|
+
<input type="text" class="form-control" id="ping-host" placeholder="Host" aria-label="Host">
|
22
|
+
<div class="input-group-append">
|
23
|
+
<button class="btn btn-outline-secondary" type="button" id="ping" onclick="startTest(this)"><%=t :test_it%></button>
|
24
|
+
</div>
|
25
|
+
</div>
|
10
26
|
</div>
|
11
27
|
</div>
|
12
28
|
</div>
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
29
|
+
|
30
|
+
<div class="card mb-3">
|
31
|
+
<div class="card-body">
|
32
|
+
<div class="response tcp-debug-response" id="response">
|
17
33
|
</div>
|
18
|
-
|
19
|
-
<div class="
|
20
|
-
<
|
34
|
+
|
35
|
+
<div class="loader">
|
36
|
+
<div class="double-bounce1"></div>
|
37
|
+
<div class="double-bounce2"></div>
|
21
38
|
</div>
|
22
39
|
</div>
|
23
40
|
</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>
|
@@ -1,44 +1,5 @@
|
|
1
1
|
Rails.application.configure do
|
2
2
|
config.after_initialize do
|
3
|
-
|
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
|
-
|
37
|
-
ActionCable.server.broadcast("messages", { topic: :tcp_debug, status: status, message: message})
|
38
|
-
render json: message.to_json, status: status
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
3
|
+
require 'root_actions/tcp_debug'
|
43
4
|
end
|
44
5
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RailsAdmin::Config::Actions.add_action "tcp_debug", :base, :root do
|
2
|
+
show_in_sidebar true
|
3
|
+
show_in_navigation false
|
4
|
+
breadcrumb_parent [nil]
|
5
|
+
# This ensures the action only shows up for Users
|
6
|
+
# visible? authorized?
|
7
|
+
# Not a member action
|
8
|
+
member false
|
9
|
+
# Not a colleciton action
|
10
|
+
collection false
|
11
|
+
|
12
|
+
link_icon 'fas fa-heartbeat'
|
13
|
+
|
14
|
+
http_methods [:get]
|
15
|
+
# Adding the controller which is needed to compute calls from the ui
|
16
|
+
controller do
|
17
|
+
proc do # This is needed because we need that this code is re-evaluated each time is called
|
18
|
+
if request.xhr?
|
19
|
+
case params["test"]
|
20
|
+
when "telnet"
|
21
|
+
port_is_open = Socket.tcp(params["host"], params["port"], connect_timeout: 5) { true } rescue false
|
22
|
+
message, status = { debug_status: I18n.t("tcp_debug_telnet_ko", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 503
|
23
|
+
message, status = { debug_status: I18n.t("tcp_debug_telnet_ok", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 200 if port_is_open
|
24
|
+
when "ping"
|
25
|
+
check = Net::Ping::External.new(params["host"])
|
26
|
+
message, status = { debug_status: I18n.t("tcp_debug_ping_ko", host: params["host"].presence || "-") }, 503
|
27
|
+
message, status = { debug_status: I18n.t("tcp_debug_ping_ok", host: params["host"].presence || "-") }, 200 if check.ping?
|
28
|
+
else
|
29
|
+
message, status = { debug_status: I18n.t("invalid_test", host: params["host"]) }, 400
|
30
|
+
end
|
31
|
+
|
32
|
+
ActionCable.server.broadcast("messages", { topic: :tcp_debug, status: status, message: message})
|
33
|
+
render json: message.to_json, status: status
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thecore_tcp_debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ping
|
@@ -48,8 +48,8 @@ files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
-
- app/assets/javascripts/
|
52
|
-
- app/assets/stylesheets/
|
51
|
+
- app/assets/javascripts/main_tcp_debug.js
|
52
|
+
- app/assets/stylesheets/main_tcp_debug.scss
|
53
53
|
- app/views/rails_admin/main/tcp_debug.html.erb
|
54
54
|
- config/initializers/add_to_db_migration.rb
|
55
55
|
- config/initializers/after_initialize.rb
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- config/locales/en.thecore_tcp_debug.yml
|
58
58
|
- config/locales/it.thecore_tcp_debug.yml
|
59
59
|
- db/seeds.rb
|
60
|
+
- lib/root_actions/tcp_debug.rb
|
60
61
|
- lib/thecore_tcp_debug.rb
|
61
62
|
- lib/thecore_tcp_debug/engine.rb
|
62
63
|
- lib/thecore_tcp_debug/version.rb
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.4.10
|
84
85
|
signing_key:
|
85
86
|
specification_version: 4
|
86
87
|
summary: Gemt o collect UI overrides.
|
@@ -1,59 +0,0 @@
|
|
1
|
-
|
2
|
-
$(document).on('turbo:load', function (event) {
|
3
|
-
// Event
|
4
|
-
currentURL = new URL(event.originalEvent.detail.url);
|
5
|
-
if(currentURL.pathname.endsWith("tcp_debug")){
|
6
|
-
hideLoader();
|
7
|
-
|
8
|
-
// Action cable Websocket
|
9
|
-
App.cable.subscriptions.create("ActivityLogChannel", {
|
10
|
-
connected() {
|
11
|
-
console.log("Connected to the channel:", this);
|
12
|
-
this.send({ message: 'TCP Debug Client is connected', topic: "tcp_debug", namespace: "subscriptions" });
|
13
|
-
},
|
14
|
-
disconnected() {
|
15
|
-
console.log("Disconnected");
|
16
|
-
},
|
17
|
-
received(data) {
|
18
|
-
if(data["topic"] == "tcp_debug")
|
19
|
-
console.log("TCP DEBUG", data);
|
20
|
-
}
|
21
|
-
});
|
22
|
-
|
23
|
-
$("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
|
24
|
-
$("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
25
|
-
$("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
function hideLoader() {
|
30
|
-
$(".loader").hide();
|
31
|
-
$(".tcp-debug-response").show();
|
32
|
-
}
|
33
|
-
|
34
|
-
function showLoader() {
|
35
|
-
$(".loader").show();
|
36
|
-
$(".tcp-debug-response").hide();
|
37
|
-
}
|
38
|
-
|
39
|
-
function startTest(element) {
|
40
|
-
$("#response").empty();
|
41
|
-
typeOfTest = $(element).attr("id");
|
42
|
-
host = $(`#${typeOfTest}-host`).val();
|
43
|
-
port = $(`#${typeOfTest}-port`).val();
|
44
|
-
// console.log(typeOfTest)
|
45
|
-
// console.log(host)
|
46
|
-
// console.log(port)
|
47
|
-
showLoader();
|
48
|
-
$.get("#{rails_admin.send('tcp_debug_path')}", {
|
49
|
-
test: typeOfTest,
|
50
|
-
host: host,
|
51
|
-
port: port
|
52
|
-
}).then(function (params) {
|
53
|
-
// console.log("OK", params)
|
54
|
-
$("#response").html(params["debug_status"]).removeClass("bg-danger").addClass("bg-success");
|
55
|
-
}).catch(function (params) {
|
56
|
-
// console.log("KO", params)
|
57
|
-
$("#response").html(params["responseJSON"]["debug_status"]).removeClass("bg-success").addClass("bg-danger");
|
58
|
-
}).always(hideLoader);
|
59
|
-
}
|