diff --git a/.gitignore b/.gitignore index 3dd4ab41..890251e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +1 *~ /docs/ /dev/ diff --git a/README.md b/README.md index f0afa575..520963b0 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ - add redis patch - add proxy patch - sig helper reconnect patch +- uptime status patch (mooleshacat) - token monitor patch (mooleshacat) **User features** @@ -168,6 +169,11 @@ This branch has the token monitor patch from myself (mooleshacat) which will che This patch is a temporary workaround until inv_sig_helper itself can get the tokens for us. unixfox (invidious dev) raised this idea to techmetx11 (inv_sig_helper dev) and they are working on an implementation that will eventually make this patch useless. This is OK, as it is only a patch and that setup would be better performance wise than my current implementations. You can read about it here https://github.com/iv-org/inv_sig_helper/issues/10 +## uptime status patch + +This fork has the uptime patch made by myself (mooleshacat) which if enabled in the config, will show the uptime on the page. Please note, if everyone can see your uptime, so could a theoretical attacker. This may or may not be a good idea, you be the judge. + + ## Documentation The full documentation can be accessed online at https://docs.invidious.io/ diff --git a/config/config.example.yml b/config/config.example.yml index 759b81e0..a9ef777a 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -238,6 +238,14 @@ http_proxy: # Features # ----------------------------- +## +## Enable/Disable showing the uptime on the main page. +## +## Accepted values: true, false +## Default: false +## +#uptime_enabled: true + ## ## Enable/Disable the "Popular" tab on the main page. ## diff --git a/src/invidious.cr b/src/invidious.cr index f7155f44..39510ec6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -16,6 +16,7 @@ require "digest/md5" require "file_utils" +require "process" # Require kemal, kilt, then our own overrides require "kemal" diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 45efc3ff..a5fc0aca 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -102,6 +102,7 @@ class Config # Subscribe to channels using PubSubHubbub (requires domain, hmac_key) property use_pubsub_feeds : Bool | Int32 = false property popular_enabled : Bool = true + property uptime_enabled : Bool = false property captcha_enabled : Bool = true property login_enabled : Bool = true property registration_enabled : Bool = true diff --git a/src/invidious/helpers/uptime.cr b/src/invidious/helpers/uptime.cr new file mode 100644 index 00000000..f406cc48 --- /dev/null +++ b/src/invidious/helpers/uptime.cr @@ -0,0 +1,23 @@ +class Invidious::Uptime + + def self.get_uptime + + str_uptime = "error" + + if CONFIG.uptime_enabled + + # get the uptime + uptime_cmd = "/usr/bin/uptime" + uptime_args = "-p" + process = Process.new(uptime_cmd, [uptime_args], output: Process::Redirect::Pipe) + str_uptime = process.output.gets_to_end + + else + str_uptime = "" + end + + return str_uptime + + end + +end \ No newline at end of file diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 11193a1b..45f78a43 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -1,6 +1,7 @@ <% locale = env.get("preferences").as(Preferences).locale dark_mode = env.get("preferences").as(Preferences).dark_mode + uptime_enabled = CONFIG.uptime_enabled %> @@ -33,6 +34,10 @@ <% if navbar_search %>
😸Invidious🐈catspeed💨 + <% if uptime_enabled %> +
+         server <%= Invidious::Uptime.get_uptime %> + <% end %>