From 633602949938ab44129b71ddb330b7cdf48bb5f1 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Fri, 17 May 2013 11:57:48 +0200 Subject: [PATCH] Added the ability to specify an optional host address for the built-in HTTP server to bind to. [#19] --- Changes | 4 +++- lib/Monitorix.pm | 6 +++++- man/man5/monitorix.conf.5 | 9 ++++++++- monitorix.conf | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 9044f3b..403a94a 100644 --- a/Changes +++ b/Changes @@ -4,8 +4,10 @@ graph. Now the values shown are more real and accurate. - Added user/password authentication option in the built-in HTTP server. [#14] - Added the script 'htpasswd.pl' to be able to encrypt passwords. [#14] +- Added the ability to specify an optional host address for the built-in HTTP + server to bind to. [#19] - Fixed a bug that prevented seeing the Core temperatures in the 'lmsens' graph. - (thanks to Bryan Guidroz, bryanguidroz AT hotmail.com for pointing this out) + (thanks to Bryan Guidroz, bryanguidroz AT hotmail.com) 3.2.0 - 13-May-2013 diff --git a/lib/Monitorix.pm b/lib/Monitorix.pm index 952ae72..b6c4365 100644 --- a/lib/Monitorix.pm +++ b/lib/Monitorix.pm @@ -24,6 +24,7 @@ use strict; use warnings; use Exporter 'import'; use POSIX qw(setuid setgid setsid); +use Socket; our @EXPORT = qw(logger trim min max celsius_to httpd_setup get_nvidia_data get_ati_data flush_accounting_rules); sub logger { @@ -76,6 +77,7 @@ sub httpd_setup { my (undef, undef, $uid) = getpwnam($config->{httpd_builtin}->{user}); my (undef, undef, $gid) = getgrnam($config->{httpd_builtin}->{group}); + my $host = $config->{httpd_builtin}->{host}; my $port = $config->{httpd_builtin}->{port}; if(!defined($uid)) { @@ -115,7 +117,9 @@ sub httpd_setup { } } - my $server = HTTPServer->new($port); + my $server = HTTPServer->new(); + $server->host($host); + $server->port($port); $server->run(); exit(0); } diff --git a/man/man5/monitorix.conf.5 b/man/man5/monitorix.conf.5 index c44110a..4e443eb 100644 --- a/man/man5/monitorix.conf.5 +++ b/man/man5/monitorix.conf.5 @@ -32,7 +32,7 @@ Default value: \fIPlace a Title Here\fP .RS The name of the host. .P -Default value: none +Default value: .RE .P .BI theme_color @@ -159,6 +159,13 @@ This enables or disables the HTTP server that Monitorix has built-in. This is sp Default value: \fIy\fP .RE .P +.BI host +.RS +This option takes an optional host address for this server to bind to. If none is specified (default) it will bind to all interfaces. +.P +Default value: +.RE +.P .BI port .RS This is the network port from where the HTTP server will listen on. diff --git a/monitorix.conf b/monitorix.conf index 86200cd..add2b6a 100644 --- a/monitorix.conf +++ b/monitorix.conf @@ -20,6 +20,7 @@ base_cgi = /monitorix-cgi enabled = y + host = port = 8080 user = nobody group = nobody