Sha256: bbe7569379c46eeb3f7d87bd066e6319923a2f2da613a78db93ede26a75c704c
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
RailsAdmin::Config::Actions.add_action "tcp_debug", :base, :root do show_in_sidebar true show_in_navigation false breadcrumb_parent [nil] # This ensures the action only shows up for Users # visible? authorized? # Not a member action member false # Not a colleciton action collection false link_icon 'fas fa-heartbeat' http_methods [:get] # Adding the controller which is needed to compute calls from the ui controller do proc do # This is needed because we need that this code is re-evaluated each time is called if request.xhr? case params["test"] when "telnet" port_is_open = Socket.tcp(params["host"], params["port"], connect_timeout: 5) { true } rescue false message, status = { debug_status: I18n.t("tcp_debug_telnet_ko", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 503 message, status = { debug_status: I18n.t("tcp_debug_telnet_ok", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 200 if port_is_open when "ping" check = Net::Ping::External.new(params["host"]) message, status = { debug_status: I18n.t("tcp_debug_ping_ko", host: params["host"].presence || "-") }, 503 message, status = { debug_status: I18n.t("tcp_debug_ping_ok", host: params["host"].presence || "-") }, 200 if check.ping? else message, status = { debug_status: I18n.t("invalid_test", host: params["host"]) }, 400 end ActionCable.server.broadcast("messages", { topic: :tcp_debug, status: status, message: message}) render json: message.to_json, status: status end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thecore_tcp_debug-3.0.6 | lib/root_actions/tcp_debug.rb |
thecore_tcp_debug-3.0.5 | lib/root_actions/tcp_debug.rb |