diff --git a/README.md b/README.md index 98cf98a..2ef2e1a 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,9 @@ inside of the gnome-shell panel (this could not be developed). Things I plan to add at some point or another: - * Buttons to operate on services à la nagstamon (recheck, connect via SSH, etc.) + * Buttons to operate on services à la nagstamon (connect via SSH, etc.) * Filters to hide services (handled, scheduled downtime, host down, ...) * Support for other free (as in free speech) monitoring servers - * Choose which columns are shown in services result Things I will be unlikely to add unless a patch is provided: diff --git a/prefs.js b/prefs.js index b9f033f..1365dbf 100644 --- a/prefs.js +++ b/prefs.js @@ -67,6 +67,7 @@ const prefs = [ { type: Gtk.Entry, category: 'Settings', label: _('Password'), key: 'password' }, { type: Gtk.Entry, category: 'Settings', label: _('Web URL'), key: 'url' }, { type: Gtk.Entry, category: 'Settings', label: _('CGI / API URL'), key: 'urlcgi' }, + { type: Gtk.Entry, category: 'Settings', label: _('Proxy URL'), key: 'proxy' }, { type: Gtk.Switch, category: 'Settings', label: _('Check SSL certificate'), key: 'strict-ssl', align: Gtk.Align.START }, { type: Gtk.ColorButton, category: 'Colors', label: _('OK background color'), key: 'ok-color', align: Gtk.Align.START }, { type: Gtk.ColorButton, category: 'Colors', label: _('Warning background color'), key: 'warning-color', align: Gtk.Align.START }, diff --git a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml index 24ef178..caee328 100644 --- a/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml +++ b/schemas/org.gnome.shell.extensions.monito@drieu.org.gschema.xml @@ -89,6 +89,10 @@ '' + + '' + + true diff --git a/servers/genericserver.js b/servers/genericserver.js index 8e52ccf..69830c9 100644 --- a/servers/genericserver.js +++ b/servers/genericserver.js @@ -20,7 +20,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -const { Soup } = imports.gi; +const { Soup, Gio } = imports.gi; const ExtensionUtils = imports.misc.extensionUtils; const Lang = imports.lang; @@ -62,7 +62,8 @@ var GenericServer = class { this.strict_ssl != this._settings.get_boolean ( "strict-ssl" ) || this.name != this._settings.get_string ( "name" ) || this.password != this._settings.get_string ( "password" ) || - this.urlcgi != this._settings.get_string ( "urlcgi" ) ) + this.urlcgi != this._settings.get_string ( "urlcgi" ) || + this.proxy != this._settings.get_string ( "proxy" ) ) { this.type = this._settings.get_string ( "type" ); this.username = this._settings.get_string ( "username" ); @@ -70,6 +71,7 @@ var GenericServer = class { this.name = this._settings.get_string ( "name" ); this.password = this._settings.get_string ( "password" ); this.urlcgi = this._settings.get_string ( "urlcgi" ); + this.proxy = this._settings.get_string ( "proxy" ); this._httpSession = null; this.monitoLog ( 'Refreshing URL parameters' ); } @@ -86,7 +88,15 @@ var GenericServer = class { { if ( this._httpSession == null ) { this.monitoLog ( 'Preparing new HTTP with strict SSL ' + this.strict_ssl ); - this._httpSession = new Soup.Session(); + this._httpSession = new Soup.SessionSync(); + this._httpSession.timeout = 5; + if ( this.proxy ) + { + this.monitoLog ( 'monito Proxy ' + this.proxy + ' for ' + this.name ); + let proxy = new Gio.SimpleProxyResolver ( { default_proxy: 'socks://127.0.0.1:3128' } ); + this._httpSession.proxy_resolver = proxy; + } +// Soup.Session.prototype.add_feature.call(this._httpSession, new Soup.SimpleProxyResolver()); this._httpSession.ssl_strict = this.strict_ssl; this._httpSession.user_agent = Me.metadata.uuid; } @@ -112,9 +122,9 @@ var GenericServer = class { // this.monitoLog ( message.status_code ); // this.monitoLog ( message.response_body ); - message.response_headers.foreach ((name, val) => { - this.monitoLog (name, val); - }); +// message.response_headers.foreach ((name, val) => { +// this.monitoLog (name, val); +// }); // this.monitoLog ( message.response_body.data ); if ( message.status_code != Soup.Status.OK )