Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature monitor the resource over proxy #840

Merged

Conversation

ugurerkan
Copy link
Contributor

@ugurerkan ugurerkan commented Oct 30, 2021

Description

Added new proxy feature based on http and https proxy agents. Proxy feature works like notifications, there is many proxy could be related one proxy entry.

Supported features

  • Proxies can activate and disable in bulk
  • Proxies auto enabled by default for new monitors
  • Proxies could be applied in bulk to current monitors
  • Both authenticated and anonymous proxies supported
  • Export and import support for proxies
  • HTTP, HTTPS, SOCKS, SOCKS v5 SOCKS v4 protocols are supported

Reviews are welcome 🤩

Fixes #470

Type of change

  • User Interface
  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and test it
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

Screenshots

Proxy Dialog 2021-10-30 at 21 36 20
Proxy Dialog Protocol List 2021-11-04 at 14 33 48
Settings Page 2021-11-30 at 10 13 15
Monitor Page 2021-10-30 at 21 35 47

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 8471ce9 to f13bf6b Compare October 30, 2021 18:57
server/model/monitor.js Outdated Show resolved Hide resolved
server/model/monitor.js Outdated Show resolved Hide resolved
server/model/monitor.js Outdated Show resolved Hide resolved
src/components/ProxyDialog.vue Outdated Show resolved Hide resolved
src/pages/Settings.vue Outdated Show resolved Hide resolved
src/pages/EditMonitor.vue Outdated Show resolved Hide resolved
src/languages/en.js Show resolved Hide resolved
@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch 2 times, most recently from b5a6114 to 3b99517 Compare October 30, 2021 19:08
@ugurerkan
Copy link
Contributor Author

@Saibamen Thank you for your quick reviews, I have updated them.

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch 2 times, most recently from d21faa1 to 5515d64 Compare October 30, 2021 19:38
@louislam louislam added this to the 1.11.0 milestone Oct 31, 2021
@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 5515d64 to 39804d1 Compare October 31, 2021 11:27
src/pages/EditMonitor.vue Outdated Show resolved Hide resolved
@deefdragon
Copy link
Contributor

Looking good. As a note, I think the switches should be "Enabled" and "Set As Default" instead of "Activated" and "Default Enabled".

@louislam
Copy link
Owner

louislam commented Nov 3, 2021

Screen Shot 2021-10-30 at 21 35 47

Wondering why it looks like that it is allowed to select multiple proxies for a monitor.

If it is single selection, dropdown (select-option) would be better.

@Saibamen
Copy link
Contributor

Saibamen commented Nov 3, 2021

Or radio button

Radio button is also better for Edit URL and Default label

@ugurerkan
Copy link
Contributor Author

ugurerkan commented Nov 3, 2021

Wondering why it looks like that it is allowed to select multiple proxies for a monitor.

If it is single selection, dropdown (select-option) would be better.

@louislam I have used them as radio buttons and multiple proxy can not selected. I prefer radios over dropdown because look more fancy but dropdown also considerable.

Screen.Recording.2021-11-03.at.12.08.28.mp4

Or radio button

Radio button is also better for Edit URL and Default label

@Saibamen I did not understand this, could you please clarify? 🤔
edit url triggers modal to edit proxy configuration and the default label is just indicator does not have interaction.

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 39804d1 to 2b061ce Compare November 3, 2021 09:02
@ugurerkan
Copy link
Contributor Author

ugurerkan commented Nov 3, 2021

Looking good. As a note, I think the switches should be "Enabled" and "Set As Default" instead of "Activated" and "Default Enabled".

@deefdragon Thank you for your advice, agree on this and updated accordingly. Now, it is more expressive.

@Saibamen
Copy link
Contributor

Saibamen commented Nov 3, 2021

@ugurerkan

I did not understand this, could you please clarify? 🤔

It is OK. I just wanted to say in my previous comment, that you can't implement working Edit or Default label in dropdown ;)

@thomasleveil
Copy link
Contributor

@ugurerkan nice work, there are a few monitors I cannot yet create because I need to go through a proxy. Would this feature work with sock5 type proxies ?

@ugurerkan
Copy link
Contributor Author

ugurerkan commented Nov 3, 2021

@thomasleveil thank you very much.

Currently, the feature supports only HTTP and HTTPS protocols. But, the base proxy agent library is supporting SOCKS and PAC proxy as well. So, this could be easily integrated. I will take a look and try to improve accordingly. SOCKS proxies have common usage, it looks like this feature should have it at least.

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 57bc880 to d36373e Compare November 4, 2021 11:36
@ugurerkan
Copy link
Contributor Author

SOCKS proxy agent library and protocol support added.

Screen Shot 2021-11-04 at 14 33 48

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from d36373e to 6e2963f Compare November 4, 2021 11:39
@ugurerkan ugurerkan changed the title Feature monitor the resource over HTTP(s) proxy Feature monitor the resource over proxy Nov 4, 2021
@thomasleveil
Copy link
Contributor

thomasleveil commented Nov 5, 2021

@ugurerkan may I suggest using {{ proxy.host }}:{{ proxy.port }} ({{ proxy.protocol }}) to describe a proxy
image

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 6e2963f to 461105d Compare November 5, 2021 10:35
@ugurerkan
Copy link
Contributor Author

@thomasleveil good point, thank you.
Proxies was able to be mistaken by other protocols and ports with same host, updated accordingly.

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch 3 times, most recently from e4c5b0b to 1a7da29 Compare November 10, 2021 16:03
@ugurerkan
Copy link
Contributor Author

ugurerkan commented Nov 16, 2021

There are couple straightforward solutions like below;

Socks Proxy

HTTP/S Proxy

I suggest tinyproxy for HTTP proxy and dante or ssh for SOCKS proxies.

@ugurerkan
Copy link
Contributor Author

ugurerkan commented Nov 30, 2021

I have sync the branch with new settings page.
BTW, functional and neat design, congrats @chakflying @louislam 🚀

Screen Shot 2021-11-30 at 10 13 15

@louislam
Copy link
Owner

I have sync the branch with new settings page. BTW, functional and neat design, congrats @chakflying @louislam 🚀

Screen Shot 2021-11-30 at 10 13 15

All credit goes to @chakflying!

@ugurerkan
Copy link
Contributor Author

Hey @louislam, it is possible to relate and support proxy for notifications there is a couple of feature request for this #616 #915

I think it is better to implement this with an axios wrapper notification client. The notification client is going to provide support of proxy to HTTP/S requests of notification providers. The wrapper approach is will reduce copy code to implement the proxy option to each notification provider.

If it is suited well to uptime kuma goals, I can contribute to the implementation of this feature after the proxy feature is merged. 🤔

@ufo56
Copy link

ufo56 commented Mar 1, 2022

Any plan to merge this feature ?

@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 6160665 to 97acf08 Compare March 1, 2022 09:47
@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 97acf08 to 8527f6c Compare March 3, 2022 16:59
Added new proxy feature based on http and https proxy agents.
Proxy feature works like notifications, there is many proxy
could be related one proxy entry.

Supported features
- Proxies can activate and disable in bulk
- Proxies auto enabled by default for new monitors
- Proxies could be applied in bulk to current monitors
- Both authenticated and anonymous proxies supported
- Export and import support for proxies
- Socks proxy support implemented.
- Monitor proxy agent create flow refactored
  and moved under proxy class.

Thanks for suggestion @thomasleveil
@ugurerkan ugurerkan force-pushed the feature/request-with-http-proxy branch from 8527f6c to 8078d06 Compare March 6, 2022 16:34
@chakflying chakflying mentioned this pull request Mar 13, 2022
1 task
@louislam louislam modified the milestones: 1.11.0, Pending Mar 16, 2022
@gaby
Copy link
Contributor

gaby commented Mar 20, 2022

@ugurerkan Does this support Proxies using self-signed certificates ? It would be ideal if there was a field to paste a custom CA.

@louislam louislam modified the milestones: Pending, 1.14.0 Mar 22, 2022

<div v-if="proxy.auth" class="mb-3">
<label for="proxy-password" class="form-label">{{ $t("Password") }}</label>
<input id="proxy-password" v-model="proxy.password" type="text" class="form-control" required>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just finished testing, it is a solid update and feature!

Just found this should be type="password". I will update it my branch, because I don't have a write permission of this pr.

Thank you so much for the big feature.

Copy link
Contributor Author

@ugurerkan ugurerkan Apr 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your test and review. It is good to help and contribute.

@louislam louislam merged commit 04e3394 into louislam:master Apr 2, 2022
@ugurerkan
Copy link
Contributor Author

@ugurerkan Does this support Proxies using self-signed certificates ? It would be ideal if there was a field to paste a custom CA.

@gaby Tested with Squid Proxy, there is couple solution for this;

  • Users could export a self-signed certificate for Node and the certificate will be trusted

    # to enable environment wide or runtime
    export NODE_EXTRA_CA_CERTS=[CA certificate file path]
      
    # also enabling over npm is supported
    npm config set cafile [CA certificate file path]
  • Users could execute node with use of the system certificate store and system trusted certificates are became trusted

     # to enable runtime
     node --use-openssl-ca
       
     # to enable environment wide
     export NODE_OPTIONS=--use-openssl-ca
  • Users could create a trusted self-signed certificate with mkcert tool. It will help to produce trusted self-signed certificates.
    https://github.com/FiloSottile/mkcert

  • We could add systemwide-cas package and allow adding certificates like your advice
    https://github.com/fujifish/syswide-cas

I think, solving this above uptime kuma level would be better and more flexible for users and we can keep our interface simple.

References;

@gaby
Copy link
Contributor

gaby commented Apr 2, 2022

@ugurerkan Does this support Proxies using self-signed certificates ? It would be ideal if there was a field to paste a custom CA.

@gaby Tested with Squid Proxy, there is couple solution for this;

  • Users could export a self-signed certificate for Node and the certificate will be trusted
    # to enable environment wide or runtime
    export NODE_EXTRA_CA_CERTS=[CA certificate file path]
      
    # also enabling over npm is supported
    npm config set cafile [CA certificate file path]
  • Users could execute node with use of the system certificate store and system trusted certificates are became trusted
     # to enable runtime
     node --use-openssl-ca
       
     # to enable environment wide
     export NODE_OPTIONS=--use-openssl-ca
  • Users could create a trusted self-signed certificate with mkcert tool. It will help to produce trusted self-signed certificates.
    https://github.com/FiloSottile/mkcert
  • We could add systemwide-cas package and allow adding certificates like your advice
    https://github.com/fujifish/syswide-cas

I think, solving this above uptime kuma level would be better and more flexible for users and we can keep our interface simple.

References;

Something like syswide-cas is what I was thinking. Use case would be if multiple monitors use different CA's which could be a case in corporate/mixed environments.

Excellent work, i'm looking forward to using this recently merged feature!

await sendProxyList(socket);

if (proxy.applyExisting) {
await restartMonitors(socket.userID);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking source code, may found some potential issues.

Should only restart monitors which belong to this proxy.
Even better, the proxy config of monitors should be updated without restarting.

@@ -222,6 +222,32 @@
{{ $t("Setup Notification") }}
</button>

<!-- Proxies -->
<h2 class="mt-5 mb-2">{{ $t("Proxies") }}</h2>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxies section should be available for http(s) monitor type only?

Copy link
Contributor Author

@ugurerkan ugurerkan Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it is better to show only v-if="monitor.type === 'http' || monitor.type === 'keyword'"

@@ -1490,6 +1562,19 @@ async function restartMonitor(userID, monitorID) {
return await startMonitor(userID, monitorID);
}

async function restartMonitors(userID) {
Copy link
Owner

@louislam louislam Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function creates another set of monitors unexpectedly, because it does not stop current monitors.

But as the proxy config of monitors should be updated without restarting, this function is not needed anyway in my opinion.


await Proxy.delete(proxyID, socket.userID);
await sendProxyList(socket);
await restartMonitors(socket.userID);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only restart monitors which belong to this proxy.
Even better, the proxy config of monitors should be updated without restarting.

@ugurerkan
Copy link
Contributor Author

@louislam thank you in detail evaluation, I'll check update proxy configuration without restart monitor and create fix. It is going work better without restart all monitors and side effect you are detected.

@louislam louislam mentioned this pull request Apr 7, 2022
@louislam
Copy link
Owner

louislam commented Apr 7, 2022

@louislam thank you in detail evaluation, I'll check update proxy configuration without restart monitor and create fix. It is going work better without restart all monitors and side effect you are detected.

Thanks, I just created a pr for related issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitor the resource over HTTP(s) proxy
8 participants